7165N/AThis fix is included in wxWidgets 3.1.0
7165N/A===================================================================
7165N/A@@ -7543,43 +7543,22 @@ if test "$wxUSE_MEDIACTRL" = "yes" -o "$
7165N/A dnl -------------------------------------------------------------------
7165N/A- dnl Test for at least 0.8 gstreamer module from pkg-config
7165N/A- dnl Even totem doesn't accept 0.9 evidently.
7165N/A- dnl So, we first check to see if 0.10 if available - if not we
7165N/A- dnl try the older 0.8 version
7165N/A+ dnl Test for at least gstreamer 1.0 module from pkg-config
7165N/A dnl -------------------------------------------------------------------
7165N/A GST_VERSION=$GST_VERSION_MAJOR.$GST_VERSION_MINOR
7165N/A- if test "$wxUSE_GSTREAMER8" = "no"; then
7165N/A- [gstreamer-$GST_VERSION gstreamer-plugins-base-$GST_VERSION],
7165N/A- GST_LIBS="$GST_LIBS -lgstinterfaces-$GST_VERSION"
7165N/A- AC_MSG_WARN([GStreamer 0.10 not available, falling back to 0.8])
7165N/A- if test $GST_VERSION_MINOR = "8"; then
7165N/A- GST_VERSION=$GST_VERSION_MAJOR.$GST_VERSION_MINOR
7165N/A- [gstreamer-$GST_VERSION gstreamer-interfaces-$GST_VERSION gstreamer-gconf-$GST_VERSION],
7165N/A- AC_MSG_WARN([GStreamer 0.8/0.10 not available.])
7165N/A+ [gstreamer-$GST_VERSION gstreamer-plugins-base-$GST_VERSION],
7165N/A+ GST_LIBS="$GST_LIBS -lgstvideo-$GST_VERSION"
7165N/A+ AC_MSG_WARN([GStreamer 1.0 not available])
7165N/A if test "$wxUSE_GSTREAMER" = "yes"; then
7165N/A CPPFLAGS="$GST_CFLAGS $CPPFLAGS"
7165N/A===================================================================
7165N/A-#if GST_VERSION_MAJOR > 0 || GST_VERSION_MINOR >= 10
7165N/A //-----------------------------------------------------------------------------
7165N/A- This is the GStreamer backend for unix. Currently we require 0.8 or
7165N/A- 0.10. Here we use the "playbin" GstElement for ease of use.
7165N/A+ This is the GStreamer backend for unix. Currently we require 1.0.
7165N/A+ Here we use the "playbin" GstElement for ease of use.
7165N/A- Note that now we compare state change functions to GST_STATE_FAILURE
7165N/A- now rather than GST_STATE_SUCCESS as newer gstreamer versions return
7165N/A+ Note that now we compare state change functions to GST_STATE_CHANGE_FAILURE
7165N/A+ now rather than GST_STATE_CHANGE_SUCCESS as newer gstreamer versions return
7165N/A non-success values for returns that are otherwise successful but not
7165N/A moment but with a tad bit of work it could theorectically work in
7165N/A- in erratic video playback (GStreamer-based bug, happens in totem as well)
7165N/A- - this is better in 0.10, however. One thing that might make it worse
7165N/A- here is that we don't preserve the aspect ratio of the video and stretch
7165N/A+ One last note is that we don't preserve the aspect ratio of the video and
7165N/A+ stretch it to the whole window.
7165N/A Note that there are some things used here that could be undocumented -
7165N/A for reference see the media player Kiss and Totem as well as some
7165N/A that attempted thread-safety...
7165N/A Then there is the issue of m_asynclock. This serves several purposes:
7165N/A- 1) It prevents the C callbacks from sending wx state change events
7165N/A- so that we don't get duplicate ones in 0.8
7165N/A- 2) It makes the sync and async handlers in 0.10 not drop any
7165N/A+ 1) It makes the sync and async handlers not drop any
7165N/A messages so that while we are polling it we get the messages in
7165N/A SyncStateChange instead of the queue.
7165N/A- 3) Keeps the pausing in Stop() synchronous
7165N/A+ 2) Keeps the pausing in Stop() synchronous
7165N/A RN: Note that I've tried to follow the wxGTK conventions here as close
7165N/A as possible. In the implementation the C Callbacks come first, then
7165N/A //=============================================================================
7165N/A //-----------------------------------------------------------------------------
7165N/A-// GStreamer (most version compatibility) macros
7165N/A //-----------------------------------------------------------------------------
7165N/A-// In 0.9 there was a HUGE change to GstQuery and the
7165N/A-// gst_element_query function changed dramatically and split off
7165N/A-#if GST_VERSION_MAJOR == 0 && GST_VERSION_MINOR <= 8
7165N/A-# define wxGst_element_query_duration(e, f, p) \
7165N/A- gst_element_query(e, GST_QUERY_TOTAL, f, p)
7165N/A-# define wxGst_element_query_position(e, f, p) \
7165N/A- gst_element_query(e, GST_QUERY_POSITION, f, p)
7165N/A-#elif GST_VERSION_MAJOR == 0 && GST_VERSION_MINOR == 9
7165N/A-// However, the actual 0.9 version has a slightly different definition
7165N/A-// and instead of gst_element_query_duration it has two parameters to
7165N/A-// gst_element_query_position instead
7165N/A-# define wxGst_element_query_duration(e, f, p) \
7165N/A- gst_element_query_position(e, f, 0, p)
7165N/A-# define wxGst_element_query_position(e, f, p) \
7165N/A- gst_element_query_position(e, f, p, 0)
7165N/A-# define wxGst_element_query_duration \
7165N/A- gst_element_query_duration
7165N/A-# define wxGst_element_query_position \
7165N/A- gst_element_query_position
7165N/A-#if GST_VERSION_MAJOR > 0 || GST_VERSION_MINOR >= 10
7165N/A-# define GST_STATE_FAILURE GST_STATE_CHANGE_FAILURE
7165N/A-# define GST_STATE_SUCCESS GST_STATE_CHANGE_SUCCESS
7165N/A-# define GstElementState GstState
7165N/A-# define gst_gconf_get_default_video_sink() \
7165N/A- gst_element_factory_make ("gconfvideosink", "video-sink");
7165N/A-# define gst_gconf_get_default_audio_sink() \
7165N/A- gst_element_factory_make ("gconfaudiosink", "audio-sink");
7165N/A // Max wait time for element state waiting - GST_CLOCK_TIME_NONE for inf
7165N/A #define wxGSTREAMER_TIMEOUT (100 * GST_MSECOND) // Max 100 milliseconds
7165N/A@@ -189,11 +144,11 @@ public:
7165N/A bool DoLoad(const wxString& locstring);
7165N/A wxMediaCtrl* GetControl() { return m_ctrl; } // for C Callbacks
7165N/A- void HandleStateChange(GstElementState oldstate, GstElementState newstate);
7165N/A+ void HandleStateChange(GstState oldstate, GstState newstate);
7165N/A bool QueryVideoSizeFromElement(GstElement* element);
7165N/A bool QueryVideoSizeFromPad(GstPad* caps);
7165N/A- bool SyncStateChange(GstElement* element, GstElementState state,
7165N/A+ bool SyncStateChange(GstElement* element, GstState state,
7165N/A gint64 llTimeout = wxGSTREAMER_TIMEOUT);
7165N/A bool TryAudioSink(GstElement* audiosink);
7165N/A bool TryVideoSink(GstElement* videosink);
7165N/A double m_dRate; // Current playback rate -
7165N/A // see GetPlaybackRate for notes
7165N/A wxLongLong m_llPausedPos; // Paused position - see Pause()
7165N/A- GstXOverlay* m_xoverlay; // X Overlay that contains the GST video
7165N/A+ GstVideoOverlay* m_videooverlay; // Video Overlay that contains the GST video
7165N/A wxMutex m_asynclock; // See "discussion of internals"
7165N/A class wxGStreamerMediaEventHandler* m_eventHandler; // see below
7165N/A@@ -284,7 +239,7 @@ expose_event(GtkWidget* widget, GdkEvent
7165N/A // I've seen this recommended somewhere...
7165N/A // TODO: Is this needed? Maybe it is just cruft...
7165N/A- // gst_x_overlay_set_xwindow_id( GST_X_OVERLAY(be->m_xoverlay),
7165N/A+ // gst_video_overlay_set_window_handle( GST_VIDEO_OVERLAY(be->m_videooverlay),
7165N/A // GDK_WINDOW_XWINDOW( window ) );
7165N/A // If we have actual video.....
7165N/A@@ -294,7 +249,7 @@ expose_event(GtkWidget* widget, GdkEvent
7165N/A // GST Doesn't redraw automatically while paused
7165N/A // Plus, the video sometimes doesn't redraw when it looses focus
7165N/A // or is painted over so we just tell it to redraw...
7165N/A- gst_x_overlay_expose(be->m_xoverlay);
7165N/A+ gst_video_overlay_expose(be->m_videooverlay);
7165N/A@@ -334,7 +289,7 @@ static gint gtk_window_realize_callback(
7165N/A GdkWindow* window = gtk_widget_get_window(widget);
7165N/A- gst_x_overlay_set_xwindow_id( GST_X_OVERLAY(be->m_xoverlay),
7165N/A+ gst_video_overlay_set_window_handle( GST_VIDEO_OVERLAY(be->m_videooverlay),
7165N/A GtkWidget* w = be->GetControl()->m_wxwindow;
7165N/A@@ -349,30 +304,6 @@ static gint gtk_window_realize_callback(
7165N/A //-----------------------------------------------------------------------------
7165N/A-// Called by gstreamer when the state changes - here we
7165N/A-// send the appropriate corresponding wx event.
7165N/A-// 0.8 only as HandleStateChange does this in both versions
7165N/A-//-----------------------------------------------------------------------------
7165N/A-#if GST_VERSION_MAJOR == 0 && GST_VERSION_MINOR < 10
7165N/A-static void gst_state_change_callback(GstElement *play,
7165N/A- wxGStreamerMediaBackend* be)
7165N/A- be->HandleStateChange(oldstate, newstate);
7165N/A-//-----------------------------------------------------------------------------
7165N/A // Called by gstreamer when the media is done playing ("end of stream")
7165N/A@@ -425,69 +356,17 @@ static void gst_notify_caps_callback(Gst
7165N/A //-----------------------------------------------------------------------------
7165N/A-// "notify::stream-info" from m_playbin
7165N/A-// Run through the stuff in "stream-info" of m_playbin for a valid
7165N/A-// video pad, and then attempt to query the video size from it - if not
7165N/A-// set up an event to do so when ready.
7165N/A-// Currently unused - now we just query it directly using
7165N/A-// QueryVideoSizeFromElement.
7165N/A-//-----------------------------------------------------------------------------
7165N/A-#if GST_VERSION_MAJOR > 0 || GST_VERSION_MINOR >= 10
7165N/A-static void gst_notify_stream_info_callback(GstElement* WXUNUSED(element),
7165N/A- GParamSpec* WXUNUSED(pspec),
7165N/A- wxGStreamerMediaBackend* be)
7165N/A- wxLogTrace(wxTRACE_GStreamer, wxT("gst_notify_stream_info_callback"));
7165N/A- be->QueryVideoSizeFromElement(be->m_playbin);
7165N/A-//-----------------------------------------------------------------------------
7165N/A-// "desired-size-changed" from m_xoverlay
7165N/A-// 0.8-specific this provides us with the video size when it changes -
7165N/A-// even though we get the caps as well this seems to come before the
7165N/A-// caps notification does...
7165N/A-// Note it will return 16,16 for an early-bird value or for audio
7165N/A-//-----------------------------------------------------------------------------
7165N/A-#if GST_VERSION_MAJOR == 0 && GST_VERSION_MINOR < 10
7165N/A-static void gst_desired_size_changed_callback(GstElement * play,
7165N/A- guint width, guint height,
7165N/A- wxGStreamerMediaBackend* be)
7165N/A- if(!(width == 16 && height == 16))
7165N/A- be->QueryVideoSizeFromElement(be->m_playbin);
7165N/A-//-----------------------------------------------------------------------------
7165N/A // gst_bus_async_callback [static]
7165N/A // gst_bus_sync_callback [static]
7165N/A-// Called by m_playbin for notifications such as end-of-stream in 0.10 -
7165N/A-// in previous versions g_signal notifications were used. Because everything
7165N/A+// Called by m_playbin for notifications such as end-of-stream. Because everything
7165N/A // in centered in one switch statement though it reminds one of old WinAPI
7165N/A // gst_bus_sync_callback is that sync version that is called on the main GUI
7165N/A // thread before the async version that we use to set the xwindow id of the
7165N/A-// XOverlay (NB: This isn't currently used - see CreateControl()).
7165N/A+// VideoOverlay (NB: This isn't currently used - see CreateControl()).
7165N/A //-----------------------------------------------------------------------------
7165N/A-#if GST_VERSION_MAJOR > 0 || GST_VERSION_MINOR >= 10
7165N/A static gboolean gst_bus_async_callback(GstBus* WXUNUSED(bus),
7165N/A@@ -537,8 +416,7 @@ static GstBusSyncReply gst_bus_sync_call
7165N/A // Pass a non-xwindowid-setting event on to the async handler where it
7165N/A- if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT ||
7165N/A- !gst_structure_has_name (message->structure, "prepare-xwindow-id"))
7165N/A+ if (!gst_is_video_overlay_prepare_window_handle_message (message))
7165N/A // NB: Unfortunately, the async callback can be quite
7165N/A@@ -552,12 +430,11 @@ static GstBusSyncReply gst_bus_sync_call
7165N/A- wxLogTrace(wxTRACE_GStreamer, wxT("Got prepare-xwindow-id"));
7165N/A+ wxLogTrace(wxTRACE_GStreamer, wxT("Got prepare-window-handle"));
7165N/A return GST_BUS_DROP; // We handled this message - drop from the queue
7165N/A //-----------------------------------------------------------------------------
7165N/A@@ -569,11 +446,11 @@ static GstBusSyncReply gst_bus_sync_call
7165N/A // wxGStreamerMediaBackend::HandleStateChange
7165N/A // Handles a state change event from our C Callback for "state-change" or
7165N/A-// the async queue in 0.10. (Mostly this is here to avoid locking the
7165N/A+// the async queue . (Mostly this is here to avoid locking the
7165N/A //-----------------------------------------------------------------------------
7165N/A-void wxGStreamerMediaBackend::HandleStateChange(GstElementState oldstate,
7165N/A+void wxGStreamerMediaBackend::HandleStateChange(GstState oldstate,
7165N/A@@ -604,83 +481,13 @@ void wxGStreamerMediaBackend::HandleStat
7165N/A //-----------------------------------------------------------------------------
7165N/A-// wxGStreamerMediaBackend::QueryVideoSizeFromElement
7165N/A-// Run through the stuff in "stream-info" of element for a valid
7165N/A-// video pad, and then attempt to query the video size from it - if not
7165N/A-// set up an event to do so when ready. Return true
7165N/A-// if we got a valid video pad.
7165N/A-//-----------------------------------------------------------------------------
7165N/A-bool wxGStreamerMediaBackend::QueryVideoSizeFromElement(GstElement* element)
7165N/A- g_object_get (G_OBJECT (element), "stream-info", &list, NULL);
7165N/A- for ( ; list != NULL; list = list->next)
7165N/A- GObject *info = (GObject *) list->data;
7165N/A- g_object_get (info, "type", &type, NULL);
7165N/A- pspec = g_object_class_find_property (
7165N/A- G_OBJECT_GET_CLASS (info), "type");
7165N/A- val = g_enum_get_value (G_PARAM_SPEC_ENUM (pspec)->enum_class, type);
7165N/A- if (!strncasecmp(val->value_name, "video", 5) ||
7165N/A- !strncmp(val->value_name, "GST_STREAM_TYPE_VIDEO", 21))
7165N/A- // Newer gstreamer 0.8+ plugins are SUPPOSED to have "object"...
7165N/A- // but a lot of old plugins still use "pad" :)
7165N/A- pspec = g_object_class_find_property (
7165N/A- G_OBJECT_GET_CLASS (info), "object");
7165N/A- g_object_get (info, "pad", &pad, NULL);
7165N/A- g_object_get (info, "object", &pad, NULL);
7165N/A-#if GST_VERSION_MAJOR == 0 && GST_VERSION_MINOR <= 8
7165N/A- // Killed in 0.9, presumely because events and such
7165N/A- // should be pushed on pads regardless of whether they
7165N/A- pad = (GstPad *) GST_PAD_REALIZE (pad);
7165N/A- if(!QueryVideoSizeFromPad(pad))
7165N/A- // wait for those caps to get ready
7165N/A- G_CALLBACK(gst_notify_caps_callback),
7165N/A- }// end searching through info list
7165N/A- // no video (or extremely delayed stream-info)
7165N/A- m_videoSize = wxSize(0,0);
7165N/A-//-----------------------------------------------------------------------------
7165N/A // wxGStreamerMediaBackend::QueryVideoSizeFromPad
7165N/A // Gets the size of our video (in wxSize) from a GstPad
7165N/A //-----------------------------------------------------------------------------
7165N/A bool wxGStreamerMediaBackend::QueryVideoSizeFromPad(GstPad* pad)
7165N/A- const GstCaps* caps = GST_PAD_CAPS(pad);
7165N/A+ GstCaps* caps = gst_pad_get_current_caps(pad);
7165N/A const GstStructure *s = gst_caps_get_structure (caps, 0);
7165N/A@@ -706,23 +513,26 @@ bool wxGStreamerMediaBackend::QueryVideo
7165N/A- wxLogTrace(wxTRACE_GStreamer, wxT("Adjusted video size: [%i,%i]"),
7165N/A+ wxLogTrace(wxTRACE_GStreamer, wxT("Adjusted video size: [%i,%i]"),
7165N/A+ m_videoSize = wxSize(0,0);
7165N/A //-----------------------------------------------------------------------------
7165N/A-// wxGStreamerMediaBackend::SetupXOverlay
7165N/A+// wxGStreamerMediaBackend::SetupVideoOverlay
7165N/A-// Attempts to set the XWindow id of our GstXOverlay to tell it which
7165N/A+// Attempts to set the XWindow id of our GstVideoOverlay to tell it which
7165N/A // window to play video in.
7165N/A //-----------------------------------------------------------------------------
7165N/A-void wxGStreamerMediaBackend::SetupXOverlay()
7165N/A+void wxGStreamerMediaBackend::SetupVideoOverlay()
7165N/A- // Use the xoverlay extension to tell gstreamer to play in our window
7165N/A+ // Use the videooverlay extension to tell gstreamer to play in our window
7165N/A if (!gtk_widget_get_realized(m_ctrl->m_wxwindow))
7165N/A@@ -739,7 +549,7 @@ void wxGStreamerMediaBackend::SetupXOver
7165N/A GdkWindow* window = gtk_widget_get_window(m_ctrl->m_wxwindow);
7165N/A- gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(m_xoverlay),
7165N/A+ gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(m_videooverlay),
7165N/A@@ -769,9 +579,8 @@ void wxGStreamerMediaBackend::SetupXOver
7165N/A // PRECONDITION: Assumes m_asynclock is Lock()ed
7165N/A //-----------------------------------------------------------------------------
7165N/A-#if GST_VERSION_MAJOR > 0 || GST_VERSION_MINOR >= 10
7165N/A bool wxGStreamerMediaBackend::SyncStateChange(GstElement* element,
7165N/A- GstElementState desiredstate,
7165N/A GstBus* bus = gst_element_get_bus(element);
7165N/A@@ -844,23 +653,6 @@ bool wxGStreamerMediaBackend::SyncStateC
7165N/A-#else // 0.8 implementation
7165N/A-bool wxGStreamerMediaBackend::SyncStateChange(GstElement* element,
7165N/A- GstElementState desiredstate,
7165N/A- while(GST_STATE(element) != desiredstate)
7165N/A- if(llTimeWaited >= llTimeout)
7165N/A- llTimeWaited += 10*GST_MSECOND;
7165N/A- return llTimeWaited != llTimeout;
7165N/A //-----------------------------------------------------------------------------
7165N/A // wxGStreamerMediaBackend::TryAudioSink
7165N/A@@ -884,25 +676,25 @@ bool wxGStreamerMediaBackend::TryAudioSi
7165N/A bool wxGStreamerMediaBackend::TryVideoSink(GstElement* videosink)
7165N/A- // Check if the video sink either is an xoverlay or might contain one...
7165N/A- if( !GST_IS_BIN(videosink) && !GST_IS_X_OVERLAY(videosink) )
7165N/A+ // Check if the video sink either is an videooverlay or might contain one...
7165N/A+ if( !GST_IS_BIN(videosink) && !GST_IS_VIDEO_OVERLAY(videosink) )
7165N/A- // Make our video sink and make sure it supports the x overlay interface
7165N/A- // the x overlay enables us to put the video in our control window
7165N/A+ // Make our video sink and make sure it supports the video overlay interface
7165N/A+ // the video overlay enables us to put the video in our control window
7165N/A // (
i.e. we NEED it!) - also connect to the natural video size change event
7165N/A if( GST_IS_BIN(videosink) )
7165N/A- m_xoverlay = (GstXOverlay*)
7165N/A+ m_videooverlay = (GstVideoOverlay*)
7165N/A gst_bin_get_by_interface (GST_BIN (videosink),
7165N/A- m_xoverlay = (GstXOverlay*) videosink;
7165N/A+ m_videooverlay = (GstVideoOverlay*) videosink;
7165N/A- if ( !GST_IS_X_OVERLAY(m_xoverlay) )
7165N/A+ if ( !GST_IS_VIDEO_OVERLAY(m_videooverlay) )
7165N/A@@ -1046,11 +838,7 @@ bool wxGStreamerMediaBackend::CreateCont
7165N/A-#if GST_VERSION_MAJOR > 0 || GST_VERSION_MINOR >= 10
7165N/A bInited = gst_init_check(&argcGST, &argvGST, &error);
7165N/A- bInited = gst_init_check(&argcGST, &argvGST);
7165N/A // Cleanup arguments for unicode case
7165N/A@@ -1117,78 +905,52 @@ bool wxGStreamerMediaBackend::CreateCont
7165N/A-#if GST_VERSION_MAJOR == 0 && GST_VERSION_MINOR < 10
7165N/A- g_signal_connect(m_playbin, "eos",
7165N/A- G_CALLBACK(gst_finish_callback), this);
7165N/A- g_signal_connect(m_playbin, "error",
7165N/A- G_CALLBACK(gst_error_callback), this);
7165N/A- g_signal_connect(m_playbin, "state-change",
7165N/A- G_CALLBACK(gst_state_change_callback), this);
7165N/A- // GStreamer 0.10+ uses GstBus for this now, connect to the sync
7165N/A- // handler as well so we can set the X window id of our xoverlay
7165N/A+ // GStreamer uses GstBus for this now, connect to the sync
7165N/A+ // handler as well so we can set the video window id of our videooverlay
7165N/A gst_bus_add_watch (gst_element_get_bus(m_playbin),
7165N/A (GstBusFunc) gst_bus_async_callback, this);
7165N/A gst_bus_set_sync_handler(gst_element_get_bus(m_playbin),
7165N/A- (GstBusSyncHandler) gst_bus_sync_callback, this);
7165N/A- g_signal_connect(m_playbin, "notify::stream-info",
7165N/A- G_CALLBACK(gst_notify_stream_info_callback), this);
7165N/A+ (GstBusSyncHandler) gst_bus_sync_callback, this, NULL);
7165N/A- GstElement* audiosink = gst_gconf_get_default_audio_sink();
7165N/A+ // Use autodetection, then alsa, then oss as a stopgap
7165N/A+ GstElement* audiosink = gst_element_factory_make ("autoaudiosink", "audio-sink");
7165N/A if( !TryAudioSink(audiosink) )
7165N/A- // fallback to autodetection, then alsa, then oss as a stopgap
7165N/A- audiosink = gst_element_factory_make ("autoaudiosink", "audio-sink");
7165N/A+ audiosink = gst_element_factory_make ("alsasink", "alsa-output");
7165N/A if( !TryAudioSink(audiosink) )
7165N/A- audiosink = gst_element_factory_make ("alsasink", "alsa-output");
7165N/A+ audiosink = gst_element_factory_make ("osssink", "play_audio");
7165N/A if( !TryAudioSink(audiosink) )
7165N/A- audiosink = gst_element_factory_make ("osssink", "play_audio");
7165N/A- if( !TryAudioSink(audiosink) )
7165N/A- wxLogSysError(wxT("Could not find a valid audiosink"));
7165N/A+ wxLogSysError(wxT("Could not find a valid audiosink"));
7165N/A // Setup video sink - first try gconf, then auto, then xvimage and
7165N/A // then finally plain ximage
7165N/A- GstElement* videosink = gst_gconf_get_default_video_sink();
7165N/A+ GstElement* videosink = gst_element_factory_make ("autovideosink", "video-sink");
7165N/A if( !TryVideoSink(videosink) )
7165N/A- videosink = gst_element_factory_make ("autovideosink", "video-sink");
7165N/A+ videosink = gst_element_factory_make ("xvimagesink", "video-sink");
7165N/A if( !TryVideoSink(videosink) )
7165N/A- videosink = gst_element_factory_make ("xvimagesink", "video-sink");
7165N/A+ // finally, do a final fallback to ximagesink
7165N/A+ gst_element_factory_make ("ximagesink", "video-sink");
7165N/A if( !TryVideoSink(videosink) )
7165N/A- // finally, do a final fallback to ximagesink
7165N/A- gst_element_factory_make ("ximagesink", "video-sink");
7165N/A- if( !TryVideoSink(videosink) )
7165N/A- g_object_unref(audiosink);
7165N/A- wxLogSysError(wxT("Could not find a suitable video sink"));
7165N/A+ g_object_unref(audiosink);
7165N/A+ wxLogSysError(wxT("Could not find a suitable video sink"));
7165N/A-#if GST_VERSION_MAJOR == 0 && GST_VERSION_MINOR < 10
7165N/A- // Not on 0.10... called when video size changes
7165N/A- g_signal_connect(m_xoverlay, "desired-size-changed",
7165N/A- G_CALLBACK(gst_desired_size_changed_callback), this);
7165N/A- // Tell GStreamer which window to draw to in 0.8 - 0.10
7165N/A- // sometimes needs this too...
7165N/A+ // Tell GStreamer which window to draw to
7165N/A // Now that we know (or, rather think) our video and audio sink
7165N/A // are valid set our playbin to use them
7165N/A@@ -1197,6 +959,10 @@ bool wxGStreamerMediaBackend::CreateCont
7165N/A+ GstPad *video_sinkpad = gst_element_get_static_pad (videosink, "sink");
7165N/A+ g_signal_connect (video_sinkpad, "notify::caps", G_CALLBACK (gst_notify_caps_callback), this);
7165N/A+ gst_object_unref (video_sinkpad);
7165N/A m_eventHandler = new wxGStreamerMediaEventHandler(this);
7165N/A@@ -1213,26 +979,10 @@ bool wxGStreamerMediaBackend::Load(const
7165N/A //-----------------------------------------------------------------------------
7165N/A // wxGStreamerMediaBackend::Load (URI version)
7165N/A-// In the case of a file URI passes it unencoded -
7165N/A-// also, as of 0.10.3 and earlier GstURI (the uri parser for gstreamer)
7165N/A-// is sort of broken and only accepts uris with at least two slashes
7165N/A-// after the scheme (
i.e. file: == not ok, file:// == ok)
7165N/A //-----------------------------------------------------------------------------
7165N/A bool wxGStreamerMediaBackend::Load(const wxURI& location)
7165N/A- //Workaround GstURI leading "//" problem and make sure it leads
7165N/A- return DoLoad(wxString(wxT("file://")) +
7165N/A //-----------------------------------------------------------------------------
7165N/A@@ -1258,7 +1008,7 @@ bool wxGStreamerMediaBackend::DoLoad(con
7165N/A // Set playbin to ready to stop the current media...
7165N/A if( gst_element_set_state (m_playbin,
7165N/A- GST_STATE_READY) == GST_STATE_FAILURE ||
7165N/A+ GST_STATE_READY) == GST_STATE_CHANGE_FAILURE ||
7165N/A !SyncStateChange(m_playbin, GST_STATE_READY))
7165N/A@@ -1281,7 +1031,7 @@ bool wxGStreamerMediaBackend::DoLoad(con
7165N/A // Try to pause media as gstreamer won't let us query attributes
7165N/A // such as video size unless it is paused or playing
7165N/A if( gst_element_set_state (m_playbin,
7165N/A- GST_STATE_PAUSED) == GST_STATE_FAILURE ||
7165N/A+ GST_STATE_PAUSED) == GST_STATE_CHANGE_FAILURE ||
7165N/A !SyncStateChange(m_playbin, GST_STATE_PAUSED))
7165N/A@@ -1307,12 +1057,11 @@ bool wxGStreamerMediaBackend::DoLoad(con
7165N/A // Sets the stream to a playing state
7165N/A-// THREAD-UNSAFE in 0.8, maybe in 0.10 as well
7165N/A //-----------------------------------------------------------------------------
7165N/A bool wxGStreamerMediaBackend::Play()
7165N/A if (gst_element_set_state (m_playbin,
7165N/A- GST_STATE_PLAYING) == GST_STATE_FAILURE)
7165N/A+ GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
7165N/A@@ -1326,13 +1075,12 @@ bool wxGStreamerMediaBackend::Play()
7165N/A // Marks where we paused and pauses the stream
7165N/A-// THREAD-UNSAFE in 0.8, maybe in 0.10 as well
7165N/A //-----------------------------------------------------------------------------
7165N/A bool wxGStreamerMediaBackend::Pause()
7165N/A m_llPausedPos = wxGStreamerMediaBackend::GetPosition();
7165N/A if (gst_element_set_state (m_playbin,
7165N/A- GST_STATE_PAUSED) == GST_STATE_FAILURE)
7165N/A+ GST_STATE_PAUSED) == GST_STATE_CHANGE_FAILURE)
7165N/A@@ -1353,7 +1101,7 @@ bool wxGStreamerMediaBackend::Stop()
7165N/A wxMutexLocker lock(m_asynclock);
7165N/A if(gst_element_set_state (m_playbin,
7165N/A- GST_STATE_PAUSED) == GST_STATE_FAILURE ||
7165N/A+ GST_STATE_PAUSED) == GST_STATE_CHANGE_FAILURE ||
7165N/A !SyncStateChange(m_playbin, GST_STATE_PAUSED))
7165N/A@@ -1417,10 +1165,8 @@ wxLongLong wxGStreamerMediaBackend::GetP
7165N/A- GstFormat fmtTime = GST_FORMAT_TIME;
7165N/A- if (!wxGst_element_query_position(m_playbin, &fmtTime, &pos) ||
7165N/A- fmtTime != GST_FORMAT_TIME || pos == -1)
7165N/A+ if (!gst_element_query_position(m_playbin, GST_FORMAT_TIME, &pos) || pos == -1)
7165N/A@@ -1438,44 +1184,21 @@ wxLongLong wxGStreamerMediaBackend::GetP
7165N/A // This is also an exceedingly ugly function due to the three implementations
7165N/A // (or, rather two plus one implementation without a seek function).
7165N/A-// This is asynchronous and thread-safe on both 0.8 and 0.10.
7165N/A // NB: This fires both a stop and play event if the media was previously
7165N/A // playing... which in some ways makes sense. And yes, this makes the video
7165N/A // go all haywire at times - a gstreamer bug...
7165N/A //-----------------------------------------------------------------------------
7165N/A bool wxGStreamerMediaBackend::SetPosition(wxLongLong where)
7165N/A-#if GST_VERSION_MAJOR == 0 && GST_VERSION_MINOR == 8 \
7165N/A- // 0.8.0 has no gst_element_seek according to official docs!!!
7165N/A- wxLogSysError(wxT("GStreamer 0.8.0 does not have gst_element_seek")
7165N/A- wxT(" according to official docs"));
7165N/A-# if GST_VERSION_MAJOR > 0 || GST_VERSION_MINOR >= 10
7165N/A- gst_element_seek (m_playbin, m_dRate, GST_FORMAT_TIME,
7165N/A+ if ( gst_element_seek (m_playbin, m_dRate, GST_FORMAT_TIME,
7165N/A (GstSeekFlags)(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT),
7165N/A- GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE );
7165N/A- // NB: Some gstreamer versions return false basically all the time
7165N/A- // here - even totem doesn't bother to check the return value here
7165N/A- // so I guess we'll just assume it worked -
7165N/A- // TODO: maybe check the gst error callback???
7165N/A- gst_element_seek (m_playbin, (GstSeekType) (GST_SEEK_METHOD_SET |
7165N/A- GST_FORMAT_TIME | GST_SEEK_FLAG_FLUSH),
7165N/A-# endif // GST_VERSION_MAJOR > 0 || GST_VERSION_MINOR >= 10
7165N/A+ GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE ) )
7165N/A //-----------------------------------------------------------------------------
7165N/A@@ -1487,10 +1210,8 @@ bool wxGStreamerMediaBackend::SetPositio
7165N/A wxLongLong wxGStreamerMediaBackend::GetDuration()
7165N/A- GstFormat fmtTime = GST_FORMAT_TIME;
7165N/A- if(!wxGst_element_query_duration(m_playbin, &fmtTime, &length) ||
7165N/A- fmtTime != GST_FORMAT_TIME || length == -1)
7165N/A+ if(!gst_element_query_duration(m_playbin, GST_FORMAT_TIME, &length) || length == -1)
7165N/A return length / GST_MSECOND ;
7165N/A@@ -1512,7 +1233,7 @@ void wxGStreamerMediaBackend::Move(int W
7165N/A // wxGStreamerMediaBackend::GetVideoSize
7165N/A-// gst_x_overlay_get_desired_size also does this in 0.8...
7165N/A+// gst_video_overlay_get_desired_size also does this in 0.8...
7165N/A //-----------------------------------------------------------------------------
7165N/A wxSize wxGStreamerMediaBackend::GetVideoSize() const
7165N/A@@ -1539,9 +1260,8 @@ wxSize wxGStreamerMediaBackend::GetVideo
7165N/A-// In 0.10 GStreamer has new gst_element_seek API that might
7165N/A-// support this - and I've got an attempt to do so but it is untested
7165N/A-// but it would appear to work...
7165N/A+// In has new gst_element_seek API that supports this - and I've got an attempt
7165N/A+// to do so but it is untested but it would appear to work...
7165N/A //-----------------------------------------------------------------------------
7165N/A double wxGStreamerMediaBackend::GetPlaybackRate()
7165N/A@@ -1552,7 +1272,6 @@ double wxGStreamerMediaBackend::GetPlayb
7165N/A bool wxGStreamerMediaBackend::SetPlaybackRate(double dRate)
7165N/A-#if GST_VERSION_MAJOR > 0 || GST_VERSION_MINOR >= 10
7165N/A if( gst_element_seek (m_playbin, dRate, GST_FORMAT_TIME,
7165N/A (GstSeekFlags)(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT),
7165N/A@@ -1565,7 +1284,6 @@ bool wxGStreamerMediaBackend::SetPlaybac
7165N/A@@ -1593,10 +1311,8 @@ wxLongLong wxGStreamerMediaBackend::GetD
7165N/A wxLongLong wxGStreamerMediaBackend::GetDownloadTotal()
7165N/A- GstFormat fmtBytes = GST_FORMAT_BYTES;
7165N/A- if (!wxGst_element_query_duration(m_playbin, &fmtBytes, &length) ||
7165N/A- fmtBytes != GST_FORMAT_BYTES || length == -1)
7165N/A+ if (!gst_element_query_duration(m_playbin, GST_FORMAT_BYTES, &length) || length == -1)