+//-----------------------------------------------------------------------------
+// wxGStreamerMediaBackend::Load (File version)
+//
+// Just calls DoLoad() with a prepended file scheme
+//-----------------------------------------------------------------------------
+bool wxGStreamerMediaBackend::Load(const wxString& fileName)
+{
+ return DoLoad(wxString( wxT("file://") ) + fileName);
+}
+
+//-----------------------------------------------------------------------------
+// wxGStreamerMediaBackend::Load (URI version)
+//
+// In the case of a file URI passes it unencoded -
+// also, as of 0.10.3 and earlier GstURI (the uri parser for gstreamer)
+// is sort of broken and only accepts uris with at least two slashes
+// after the scheme (i.e. file: == not ok, file:// == ok)
+//-----------------------------------------------------------------------------
+bool wxGStreamerMediaBackend::Load(const wxURI& location)
+{
+ if(location.GetScheme().CmpNoCase(wxT("file")) == 0)
+ {
+ wxString uristring = location.BuildUnescapedURI();
+
+ //Workaround GstURI leading "//" problem and make sure it leads
+ //with that
+ return DoLoad(wxString(wxT("file://")) +
+ uristring.Right(uristring.length() - 5)
+ );
+ }
+ else
+ return DoLoad(location.BuildURI());
+}
+
+//-----------------------------------------------------------------------------
+// wxGStreamerMediaBackend::DoLoad
+//
+// Loads the media
+// 1) Reset member variables and set playbin back to ready state
+// 2) Check URI for validity and then tell the playbin to load it
+// 3) Set the playbin to the pause state
+//
+// NB: Even after this function is over with we probably don't have the
+// video size or duration - no amount of clever hacking is going to get
+// around that, unfortunately.
+//-----------------------------------------------------------------------------
+bool wxGStreamerMediaBackend::DoLoad(const wxString& locstring)
+{
+ wxMutexLocker lock(m_asynclock); // lock state events and async callbacks
+
+ // Reset positions & rate
+ m_llPausedPos = 0;
+ m_dRate = 1.0;
+ m_videoSize = wxSize(0,0);
+
+ // Set playbin to ready to stop the current media...
+ if( gst_element_set_state (m_playbin,
+ GST_STATE_READY) == GST_STATE_FAILURE ||
+ !SyncStateChange(m_playbin, GST_STATE_READY))
+ {
+ wxLogSysError(wxT("wxGStreamerMediaBackend::Load - ")
+ wxT("Could not set initial state to ready"));
+ return false;
+ }
+
+ // free current media resources
+ gst_element_set_state (m_playbin, GST_STATE_NULL);
+
+ // Make sure the passed URI is valid and tell playbin to load it
+ // non-file uris are encoded
+ wxASSERT(gst_uri_protocol_is_valid("file"));
+ wxASSERT(gst_uri_is_valid(locstring.mb_str()));
+
+ g_object_set (G_OBJECT (m_playbin), "uri",
+ (const char*)locstring.mb_str(), NULL);
+
+ // Try to pause media as gstreamer won't let us query attributes
+ // such as video size unless it is paused or playing
+ if( gst_element_set_state (m_playbin,
+ GST_STATE_PAUSED) == GST_STATE_FAILURE ||
+ !SyncStateChange(m_playbin, GST_STATE_PAUSED))
+ {
+ return false; // no real error message needed here as this is
+ // generic failure 99% of the time (i.e. no
+ // source etc.) and has an error message
+ }
+
+
+ NotifyMovieLoaded(); // Notify the user - all we can do for now
+ return true;
+}
+
+
+//-----------------------------------------------------------------------------
+// wxGStreamerMediaBackend::Play
+//
+// Sets the stream to a playing state
+//
+// THREAD-UNSAFE in 0.8, maybe in 0.10 as well
+//-----------------------------------------------------------------------------