+ }
+
+#if GST_VERSION_MAJOR == 0 && GST_VERSION_MINOR < 10
+ // Not on 0.10... called when video size changes
+ g_signal_connect(m_xoverlay, "desired-size-changed",
+ G_CALLBACK(gst_desired_size_changed_callback), this);
+#endif
+ // Tell GStreamer which window to draw to in 0.8 - 0.10
+ // sometimes needs this too...
+ SetupXOverlay();
+
+ // Now that we know (or, rather think) our video and audio sink
+ // are valid set our playbin to use them
+ g_object_set (G_OBJECT (m_playbin),
+ "video-sink", videosink,
+ "audio-sink", audiosink,
+ NULL);
+
+ m_eventHandler = new wxGStreamerMediaEventHandler(this);
+ return true;
+}
+
+//-----------------------------------------------------------------------------
+// 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);