X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/dae87f93abd93555095575886b8b1ef126f0a0da..4fce94faca2f653e522ed2a6352dff16a5a4eeb0:/src/unix/mediactrl.cpp diff --git a/src/unix/mediactrl.cpp b/src/unix/mediactrl.cpp index 1fd4298a0a..cf20c15e2e 100644 --- a/src/unix/mediactrl.cpp +++ b/src/unix/mediactrl.cpp @@ -65,12 +65,15 @@ #include //strstr #include "wx/log.h" -#include "wx/msgdlg.h" #ifdef __WXGTK__ //for /related for GDK_WINDOW_XWINDOW # include "wx/gtk/win_gtk.h" # include +# if wxUSE_DYNLIB_CLASS +# include "wx/dynlib.h" +# endif +//# include //gstreamer gnome interface - needs deps #endif @@ -124,8 +127,6 @@ public: #endif GstElement* m_player; //GStreamer media element -// GstElement* m_audiosink; - GstElement* m_videosink; wxSize m_videoSize; wxControl* m_ctrl; @@ -203,9 +204,14 @@ gint wxGStreamerMediaBackend::OnGTKRealize(GtkWidget* theWidget, GdkWindow *window = GTK_PIZZA(theWidget)->bin_window; wxASSERT(window); - gst_x_overlay_set_xwindow_id( GST_X_OVERLAY(be->m_videosink), - GDK_WINDOW_XWINDOW( window ) - ); + GstElement* videosink; + g_object_get (G_OBJECT (be->m_player), "video-sink", &videosink, NULL); + + GstElement* overlay = gst_bin_get_by_interface (GST_BIN (videosink), + GST_TYPE_X_OVERLAY); + gst_x_overlay_set_xwindow_id( GST_X_OVERLAY(overlay), + GDK_WINDOW_XWINDOW( window ) + ); return 0; } @@ -217,8 +223,6 @@ gint wxGStreamerMediaBackend::OnGTKRealize(GtkWidget* theWidget, // wxGStreamerMediaBackend::Cleanup // // Frees the gstreamer interfaces if there were any created -//TODO: Do we need to free the video interface? I'm getting segfaults -//if I do... //--------------------------------------------------------------------------- void wxGStreamerMediaBackend::Cleanup() { @@ -226,11 +230,6 @@ void wxGStreamerMediaBackend::Cleanup() { gst_element_set_state (m_player, GST_STATE_NULL); gst_object_unref (GST_OBJECT (m_player)); - - //if(GST_IS_OBJECT(m_videosink)) - // gst_object_unref (GST_OBJECT (m_videosink)); - //if(GST_IS_OBJECT(m_audiosink)) - // gst_object_unref (GST_OBJECT (m_audiosink)); } } @@ -354,7 +353,13 @@ void wxGStreamerMediaBackend::OnError(GstElement *play, gchar *debug, gpointer data) { - wxMessageBox(wxString::Format(wxT("Error in wxMediaCtrl!\nError Message:%s"), wxString(err->message, wxConvLocal).c_str())); + wxLogSysError( + wxString::Format( + wxT("Error in wxMediaCtrl!\nError Message:%s\nDebug:%s\n"), + (const wxChar*)wxConvUTF8.cMB2WX(err->message), + (const wxChar*)wxConvUTF8.cMB2WX(debug) + ) + ); } @@ -386,14 +391,13 @@ void wxGStreamerMediaBackend::OnVideoCapsReady(GstPad* pad, GParamSpec* pspec, g // wxGStreamerMediaBackend::Load (URI version) // // 1) Stops/Cleanups the previous instance if there is any -// 2) Creates the gstreamer interfaces - playbin and xvimagesink for video -// 3) If there is no playbin or video sink it bails out -// 4) Sets the playbin to have our video sink so we can set the window later -// 5) Set up the error and end-of-stream callbacks for our player -// 6) Make sure our video sink can support the x overlay interface -// 7) Make sure the passed URI is valid and tell playbin to load it -// 8) Use the xoverlay extension to tell gstreamer to play in our window -// 9) Get the video size - pause required to set the stream in action +// 2) Creates the gstreamer playbin +// 3) If there is no playbin bail out +// 4) Set up the error and end-of-stream callbacks for our player +// 5) Make our video sink and make sure it supports the x overlay interface +// 6) Make sure the passed URI is valid and tell playbin to load it +// 7) Use the xoverlay extension to tell gstreamer to play in our window +// 8) Get the video size - pause required to set the stream in action //--------------------------------------------------------------------------- bool wxGStreamerMediaBackend::Load(const wxURI& location) { @@ -402,46 +406,72 @@ bool wxGStreamerMediaBackend::Load(const wxURI& location) //2 m_player = gst_element_factory_make ("playbin", "play"); -// m_audiosink = gst_element_factory_make ("alsasink", "audiosink"); - m_videosink = gst_element_factory_make ("xvimagesink", "videosink"); //3 - //no playbin -- outta here :) - if (!m_player || !GST_IS_OBJECT(m_videosink)) + if (!m_player) return false; -// //have alsa? -// if (GST_IS_OBJECT(m_audiosink) == false) -// { -// //nope, try OSS -// m_audiosink = gst_element_factory_make ("osssink", "audiosink"); -// wxASSERT_MSG(GST_IS_OBJECT(m_audiosink), wxT("WARNING: Alsa and OSS drivers for gstreamer not found - audio will be unavailable for wxMediaCtrl")); -// } - + //4 + g_signal_connect (m_player, "eos", G_CALLBACK (OnFinish), this); + g_signal_connect (m_player, "error", G_CALLBACK (OnError), this); + + //5 + GstElement* overlay = NULL; + GstElement* videosink; + +#if defined(__WXGTK__) && wxUSE_DYNLIB_CLASS + + //use gnome-specific gstreamer extensions + //if synthisis (?) file not found, it + //spits out a warning and uses ximagesink + wxDynamicLibrary gstgconf; + if(gstgconf.Load(gstgconf.CanonicalizeName(wxT("gstgconf-0.8")))) + { + typedef GstElement* (*LPgst_gconf_get_default_video_sink) (void); + LPgst_gconf_get_default_video_sink pGst_gconf_get_default_video_sink = + (LPgst_gconf_get_default_video_sink) + gstgconf.GetSymbol(wxT("gst_gconf_get_default_video_sink")); + + if (pGst_gconf_get_default_video_sink) + { + videosink = (*pGst_gconf_get_default_video_sink) (); + wxASSERT( GST_IS_BIN(videosink) ); + overlay = gst_bin_get_by_interface (GST_BIN (videosink), + GST_TYPE_X_OVERLAY); + } + + gstgconf.Detach(); + } + + if ( ! GST_IS_X_OVERLAY(overlay) ) + { +#endif + videosink = gst_element_factory_make ("xvimagesink", "videosink"); + if ( !GST_IS_OBJECT(videosink) ) + videosink = gst_element_factory_make ("ximagesink", "videosink"); + + overlay = videosink; + + wxASSERT( GST_IS_X_OVERLAY(overlay) ); + if ( ! GST_IS_X_OVERLAY(overlay) ) + return false; +#if defined(__WXGTK__) && wxUSE_DYNLIB_CLASS + } +#endif - //4 g_object_set (G_OBJECT (m_player), - "video-sink", m_videosink, + "video-sink", videosink, // "audio-sink", m_audiosink, - NULL); - - //5 - g_signal_connect (m_player, "eos", G_CALLBACK (OnError), this); - g_signal_connect (m_player, "error", G_CALLBACK (OnFinish), this); + NULL); //6 - wxASSERT( GST_IS_X_OVERLAY(m_videosink) ); - if ( ! GST_IS_X_OVERLAY(m_videosink) ) - return false; - - //7 wxString locstring = location.BuildUnescapedURI(); wxASSERT(gst_uri_protocol_is_valid("file")); wxASSERT(gst_uri_is_valid(locstring.mb_str())); g_object_set (G_OBJECT (m_player), "uri", (const char*)locstring.mb_str(), NULL); - - //8 + + //7 #ifdef __WXGTK__ if(!GTK_WIDGET_REALIZED(m_ctrl->m_wxwindow)) { @@ -459,7 +489,7 @@ bool wxGStreamerMediaBackend::Load(const wxURI& location) #endif - gst_x_overlay_set_xwindow_id( GST_X_OVERLAY(m_videosink), + gst_x_overlay_set_xwindow_id( GST_X_OVERLAY(overlay), #ifdef __WXGTK__ GDK_WINDOW_XWINDOW( window ) #else @@ -470,11 +500,12 @@ bool wxGStreamerMediaBackend::Load(const wxURI& location) #ifdef __WXGTK__ } //end else block #endif - - //9 - wxASSERT(gst_element_set_state (m_player, - GST_STATE_PAUSED) == GST_STATE_SUCCESS); + //8 + + wxASSERT(gst_element_set_state (m_player, + GST_STATE_PAUSED) == GST_STATE_SUCCESS); + const GList *list = NULL; g_object_get (G_OBJECT (m_player), "stream-info", &list, NULL);