From: Victor Toso <[email protected]>

Odd minor versions are for development version, which means that
checks on 1.9.x should be considered for development while normal
environments should be running the stable.

Some timeline of stable releases:

1.14.4: Tue Oct  2 22:53:01 2018 +0100
1.14.0: Mon Mar 19 20:09:51 2018 +0000
1.12.0: Thu May  4 15:36:55 2017 +0300
1.10.0: Tue Nov  1 17:50:24 2016 +0200

This patch reduces a bit the code paths in channel-display-gst.c

CentOS 7.6         : 1.10.4
Fedora 27          : 1.12.5
Fedora 28-30       : 1.14.x
Debian 9 (Stretch) : 1.10.4

Signed-off-by: Victor Toso <[email protected]>
---
 configure.ac              |  9 +++++----
 meson.build               |  4 +++-
 src/channel-display-gst.c | 36 ------------------------------------
 3 files changed, 8 insertions(+), 41 deletions(-)

diff --git a/configure.ac b/configure.ac
index 2f63422..7dab0be 100644
--- a/configure.ac
+++ b/configure.ac
@@ -215,8 +215,9 @@ AS_IF([test "x$enable_pulse" != "xno"],
 ])
 AM_CONDITIONAL([HAVE_PULSE], [test "x$enable_pulse" = "xyes"])
 
+GST_REQ="1.10"
 SPICE_CHECK_GSTREAMER(GSTAUDIO, 1.0,
-    [gstreamer-1.0 gstreamer-base-1.0 gstreamer-app-1.0 gstreamer-audio-1.0],
+    [gstreamer-1.0 >= $GST_REQ gstreamer-base-1.0 >= $GST_REQ 
gstreamer-app-1.0 >= $GST_REQ gstreamer-audio-1.0 >= $GST_REQ],
     [SPICE_CHECK_GSTREAMER_ELEMENTS($GST_INSPECT_1_0,
          [gst-plugins-base 1.0], [audioconvert audioresample appsink])
      SPICE_CHECK_GSTREAMER_ELEMENTS($GST_INSPECT_1_0,
@@ -224,10 +225,10 @@ SPICE_CHECK_GSTREAMER(GSTAUDIO, 1.0,
      AS_IF([test x"$missing_gstreamer_elements" = "xyes"],
          SPICE_WARNING([The GStreamer 1.0 audio backend can be built but may 
not work.]))
     ],
-    [AC_MSG_ERROR([Required GStreamer packages missing])])
+    [AC_MSG_ERROR([Required GStreamer packages missing or system version is 
below $GST_REQ])])
 
 SPICE_CHECK_GSTREAMER(GSTVIDEO, 1.0,
-    [gstreamer-1.0 gstreamer-base-1.0 gstreamer-app-1.0 gstreamer-video-1.0],
+    [gstreamer-1.0 >= $GST_REQ gstreamer-base-1.0 >= $GST_REQ 
gstreamer-app-1.0 >= $GST_REQ gstreamer-video-1.0 >= $GST_REQ],
     [missing_gstreamer_elements=""
      SPICE_CHECK_GSTREAMER_ELEMENTS($GST_INSPECT_1_0,
          [gst-plugins-base 1.0], [appsrc videoconvert appsink])
@@ -240,7 +241,7 @@ SPICE_CHECK_GSTREAMER(GSTVIDEO, 1.0,
      AS_IF([test x"$missing_gstreamer_elements" = "xyes"],
          SPICE_WARNING([The GStreamer video decoder can be built but may not 
work.]))
     ],
-    [AC_MSG_ERROR([Required GStreamer packages missing])])
+    [AC_MSG_ERROR([Required GStreamer packages missing or system version is 
below $GST_REQ])])
 
 AC_ARG_ENABLE([builtin-mjpeg],
   AS_HELP_STRING([--enable-builtin-mjpeg], [Enable the builtin mjpeg video 
decoder @<:@default=yes@:>@]),
diff --git a/meson.build b/meson.build
index 70dd318..5f39ff4 100644
--- a/meson.build
+++ b/meson.build
@@ -166,9 +166,11 @@ if d.found()
   spice_gtk_has_pulse = true
 endif
 
+gstreamer_version = '1.10'
+gstreamer_version_info = '>= @0@'.format(gstreamer_version)
 deps = ['gstreamer-1.0', 'gstreamer-base-1.0', 'gstreamer-app-1.0', 
'gstreamer-audio-1.0', 'gstreamer-video-1.0']
 foreach dep : deps
-  spice_glib_deps += dependency(dep)
+  spice_glib_deps += dependency(dep, version: gstreamer_version_info)
 endforeach
 
 # builtin-mjpeg
diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c
index 2b42053..5483755 100644
--- a/src/channel-display-gst.c
+++ b/src/channel-display-gst.c
@@ -352,9 +352,7 @@ static gboolean handle_pipeline_message(GstBus *bus, 
GstMessage *msg, gpointer v
                                           
gst_opts[decoder->base.codec_type].name);
         GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(decoder->pipeline),
                                   GST_DEBUG_GRAPH_SHOW_ALL
-#if GST_CHECK_VERSION(1,5,1)
                                     | GST_DEBUG_GRAPH_SHOW_FULL_PARAMS
-#endif
                                     | GST_DEBUG_GRAPH_SHOW_STATES,
                                     filename);
         g_free(filename);
@@ -367,7 +365,6 @@ static gboolean handle_pipeline_message(GstBus *bus, 
GstMessage *msg, gpointer v
     return TRUE;
 }
 
-#if GST_CHECK_VERSION(1,9,0)
 static void app_source_setup(GstElement *pipeline G_GNUC_UNUSED,
                              GstElement *source,
                              SpiceGstDecoder *decoder)
@@ -392,12 +389,10 @@ static void app_source_setup(GstElement *pipeline 
G_GNUC_UNUSED,
     gst_caps_unref(caps);
     decoder->appsrc = GST_APP_SRC(gst_object_ref(source));
 }
-#endif
 
 static gboolean create_pipeline(SpiceGstDecoder *decoder)
 {
     GstBus *bus;
-#if GST_CHECK_VERSION(1,9,0)
     GstElement *playbin, *sink;
     SpiceGstPlayFlags flags;
     GstCaps *caps;
@@ -469,35 +464,6 @@ static gboolean create_pipeline(SpiceGstDecoder *decoder)
 
     g_warn_if_fail(decoder->appsrc == NULL);
     decoder->pipeline = playbin;
-#else
-    gchar *desc;
-    GError *err = NULL;
-
-    /* - We schedule the frame display ourselves so set sync=false on appsink
-     *   so the pipeline decodes them as fast as possible. This will also
-     *   minimize the risk of frames getting lost when we rebuild the
-     *   pipeline.
-     * - Set max-bytes=0 on appsrc so it does not drop frames that may be
-     *   needed by those that follow.
-     */
-    desc = g_strdup_printf("appsrc name=src is-live=true format=time 
max-bytes=0 block=true "
-                           "caps=%s ! %s ! videoconvert ! appsink name=sink "
-                           "caps=video/x-raw,format=BGRx sync=false 
drop=false",
-                           gst_opts[decoder->base.codec_type].dec_caps,
-                           gst_opts[decoder->base.codec_type].dec_name);
-    SPICE_DEBUG("GStreamer pipeline: %s", desc);
-
-    decoder->pipeline = gst_parse_launch_full(desc, NULL, 
GST_PARSE_FLAG_FATAL_ERRORS, &err);
-    g_free(desc);
-    if (!decoder->pipeline) {
-        spice_warning("GStreamer error: %s", err->message);
-        g_clear_error(&err);
-        return FALSE;
-    }
-
-    decoder->appsrc = 
GST_APP_SRC(gst_bin_get_by_name(GST_BIN(decoder->pipeline), "src"));
-    decoder->appsink = 
GST_APP_SINK(gst_bin_get_by_name(GST_BIN(decoder->pipeline), "sink"));
-#endif
 
     if (decoder->appsink) {
         GstAppSinkCallbacks appsink_cbs = { NULL };
@@ -643,14 +609,12 @@ static gboolean 
spice_gst_decoder_queue_frame(VideoDecoder *video_decoder,
         return FALSE;
     }
 
-#if GST_CHECK_VERSION(1,9,0)
     if (decoder->appsrc == NULL) {
         spice_warning("Error: Playbin has not yet initialized the Appsrc 
element");
         stream_dropped_frame_on_playback(decoder->base.stream);
         spice_frame_free(frame);
         return TRUE;
     }
-#endif
 
     /* frame ownership is moved to the buffer */
     GstBuffer *buffer = 
gst_buffer_new_wrapped_full(GST_MEMORY_FLAG_PHYSICALLY_CONTIGUOUS,
-- 
2.20.1

_______________________________________________
Spice-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/spice-devel

Reply via email to