diff options
author | Slávek Banko <slavek.banko@axis.cz> | 2016-03-11 02:21:44 +0100 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2016-03-11 02:21:44 +0100 |
commit | da6d8b0b34a10f7510d2054dbb059570a9194ab3 (patch) | |
tree | 27259804092408a8e936d8ba3f86bdc7cc3259e0 /src | |
parent | 4da999bdb1b535994fd3fa18772921da41b0b65e (diff) | |
download | kmplayer-da6d8b0b34a10f7510d2054dbb059570a9194ab3.tar.gz kmplayer-da6d8b0b34a10f7510d2054dbb059570a9194ab3.zip |
Add GStreamer 1.0 support
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/gstplayer.cpp | 91 |
2 files changed, 85 insertions, 8 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 6db915f..6278004 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -53,7 +53,7 @@ kxvplayer_LDADD= libkmplayerbackend.la -lDCOP -lXv kxvplayer_LDFLAGS= $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor kxvplayer_SOURCES= xvplayer.cpp -kgstplayer_LDADD= libkmplayerbackend.la $(LIB_GST) $(LIB_GST_PLUGINS) -lgstinterfaces-0.10 -lDCOP +kgstplayer_LDADD= libkmplayerbackend.la $(LIB_GST) $(LIB_GST_PLUGINS) $(LIB_GST_OVERLAY) -lDCOP kgstplayer_LDFLAGS= $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor kgstplayer_SOURCES= gstplayer.cpp diff --git a/src/gstplayer.cpp b/src/gstplayer.cpp index 0585ac9..74bcee0 100644 --- a/src/gstplayer.cpp +++ b/src/gstplayer.cpp @@ -39,8 +39,13 @@ #include <X11/keysym.h> #include <X11/Xatom.h> #include <gst/gst.h> +#if GST_CHECK_VERSION(1,0,0) +#include <gst/video/videooverlay.h> +#include <gst/video/colorbalance.h> +#else #include <gst/interfaces/xoverlay.h> #include <gst/interfaces/colorbalance.h> +#endif static char configfile[2048]; @@ -76,7 +81,11 @@ static const char *vcd_device; static GstElement *gst_elm_play; static GstBus *gst_bus; static unsigned int /*GstMessageType*/ ignore_messages_mask; +#if GST_CHECK_VERSION(1,0,0) +static GstVideoOverlay *xoverlay; +#else static GstXOverlay *xoverlay; +#endif static GstColorBalance *color_balance; static gulong gst_bus_sync; static gulong gst_bus_async; @@ -121,7 +130,11 @@ gstCapsSet (GstPad *pad, GParamSpec * /*pspec*/, gpointer /*data*/) { +#if GST_CHECK_VERSION(1,0,0) + GstCaps *caps = gst_pad_get_current_caps (pad); +#else GstCaps *caps = gst_pad_get_negotiated_caps (pad); +#endif if (!caps) return; TQApplication::postEvent (gstapp, new TQEvent ((TQEvent::Type) event_video)); @@ -200,7 +213,13 @@ static void gstSource (GObject *, GParamSpec *, gpointer /*data*/) { static void gstGetDuration () { GstFormat fmt = GST_FORMAT_TIME; gint64 len = -1; // usec - if (gst_element_query_duration (gst_elm_play, &fmt, &len)) + if (gst_element_query_duration (gst_elm_play, +#if GST_CHECK_VERSION(1,0,0) + fmt, +#else + &fmt, +#endif + &len)) if (movie_length != len / (GST_MSECOND * 100)) { movie_length = len / (GST_MSECOND * 100); fprintf (stderr, "new length %d\n", movie_length); @@ -245,13 +264,23 @@ static void gstBusMessage (GstBus *, GstMessage * message, gpointer) { break; case GST_MESSAGE_BUFFERING: { gint percent = 0; - gst_structure_get_int (message->structure, "buffer-percent", &percent); + gst_structure_get_int ( +#if GST_CHECK_VERSION(1,0,0) + gst_message_get_structure(message), +#else + message->structure, +#endif + "buffer-percent", &percent); TQApplication::postEvent (gstapp, new GstProgressEvent (percent)); //fprintf (stderr, "Buffering message (%u%%)\n", percent); break; } case GST_MESSAGE_APPLICATION: { +#if GST_CHECK_VERSION(1,0,0) + const char * msg = gst_structure_get_name (gst_message_get_structure(message)); +#else const char * msg = gst_structure_get_name (message->structure); +#endif fprintf (stderr, "app msg %s\n", msg ? msg : "<unknown>"); //gst_structure_foreach (message->structure, gstStructure, 0L); break; @@ -297,10 +326,21 @@ static void gstBusMessage (GstBus *, GstMessage * message, gpointer) { } static void gstMessageElement (GstBus *, GstMessage *msg, gpointer /*data*/) { - if (gst_structure_has_name (msg->structure, "prepare-xwindow-id")) { + if (gst_structure_has_name ( +#if GST_CHECK_VERSION(1,0,0) + gst_message_get_structure(msg), +#else + msg->structure, +#endif + "prepare-xwindow-id")) { fprintf (stderr, "prepare-xwindow-id\n"); - if (xoverlay) + if (xoverlay) { +#if GST_CHECK_VERSION(1,0,0) + gst_video_overlay_set_window_handle (xoverlay, wid); +#else gst_x_overlay_set_xwindow_id (xoverlay, wid); +#endif + } } } @@ -598,13 +638,25 @@ void KGStreamerPlayer::play (int repeat) { goto fail; if (GST_IS_BIN (videosink)) element = gst_bin_get_by_interface (GST_BIN (videosink), - GST_TYPE_X_OVERLAY); +#if GST_CHECK_VERSION(1,0,0) + GST_TYPE_VIDEO_OVERLAY +#else + GST_TYPE_X_OVERLAY +#endif + ); else element = videosink; +#if GST_CHECK_VERSION(1,0,0) + if (GST_IS_VIDEO_OVERLAY (element)) { + xoverlay = GST_VIDEO_OVERLAY (element); + gst_video_overlay_set_window_handle (xoverlay, wid); + } +#else if (GST_IS_X_OVERLAY (element)) { xoverlay = GST_X_OVERLAY (element); gst_x_overlay_set_xwindow_id (xoverlay, wid); } +#endif gst_element_set_bus (videosink, gst_bus); gst_element_set_state (videosink, GST_STATE_READY); success = gstPollForStateChange (videosink, GST_STATE_READY); @@ -621,7 +673,11 @@ void KGStreamerPlayer::play (int repeat) { "video-sink", videosink, "audio-sink", audiosink, NULL); +#if GST_CHECK_VERSION(1,0,0) + gst_bus_set_sync_handler (gst_bus, gst_bus_sync_signal_handler, 0L, 0L); +#else gst_bus_set_sync_handler (gst_bus, gst_bus_sync_signal_handler, 0L); +#endif gst_bus_sync = g_signal_connect (gst_bus, "sync-message::element", G_CALLBACK (gstMessageElement), 0L); g_signal_connect (gst_elm_play, "notify::source", @@ -766,7 +822,13 @@ void KGStreamerPlayer::updatePosition () { if (gst_elm_play && callback) { GstFormat fmt = GST_FORMAT_TIME; gint64 val = 0; // usec - if (gst_element_query_position (gst_elm_play, &fmt, &val)) + if (gst_element_query_position (gst_elm_play, +#if GST_CHECK_VERSION(1,0,0) + fmt, +#else + &fmt, +#endif + &val)) callback->moviePosition (int (val / (GST_MSECOND * 100))); } mutex.unlock (); @@ -888,11 +950,19 @@ protected: if (gst_elm_play) { GstElement *videosink; g_object_get (gst_elm_play, "video-sink", &videosink, NULL); +#if GST_CHECK_VERSION(1,0,0) + if (videosink && GST_IS_VIDEO_OVERLAY (videosink)) { + gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (videosink), wid); + gst_video_overlay_expose (GST_VIDEO_OVERLAY (videosink)); + gst_object_unref (videosink); + } +#else if (videosink && GST_IS_X_OVERLAY (videosink)) { gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (videosink), wid); gst_x_overlay_expose (GST_X_OVERLAY (videosink)); gst_object_unref (videosink); } +#endif } mutex.unlock (); } @@ -900,8 +970,15 @@ protected: case ConfigureNotify: mutex.lock (); - if (xoverlay && GST_IS_X_OVERLAY (xoverlay)) +#if GST_CHECK_VERSION(1,0,0) + if (xoverlay && GST_IS_VIDEO_OVERLAY (xoverlay)) { + gst_video_overlay_expose (xoverlay); + } +#else + if (xoverlay && GST_IS_X_OVERLAY (xoverlay)) { gst_x_overlay_expose (xoverlay); + } +#endif mutex.unlock (); break; case ButtonPress: { |