[Spice-devel] [PATCH v6 24/26] spice-gtk: Allow disabling support for the builtin MJPEG video decoder

Francois Gouget fgouget at codeweavers.com
Wed Oct 14 08:34:36 PDT 2015


This makes it possible to test the GStreamer video decoder with MJPEG
streams.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
 configure.ac               | 11 +++++++++++
 src/Makefile.am            |  7 ++++++-
 src/channel-display-priv.h |  2 ++
 src/channel-display.c      |  5 +++++
 4 files changed, 24 insertions(+), 1 deletion(-)


Changes since the previous version:
 * Have configure warn if we have neither the builtin MJPEG decoder, 
   nor the GStreamer-based one. Note that this is a warning and not an 
   error because it should just mean that videos will go through the 
   regular mechanisms.
 * Added #ifdef checks.



diff --git a/configure.ac b/configure.ac
index 60a43f6..254d902 100644
--- a/configure.ac
+++ b/configure.ac
@@ -357,6 +357,14 @@ AM_CONDITIONAL([HAVE_GSTVIDEO], [test "x$have_gst_video" = "xyes"])]
 AC_SUBST(GSTVIDEO_CFLAGS)
 AC_SUBST(GSTVIDEO_LIBS)
 
+AC_ARG_ENABLE([builtin-mjpeg],
+  AS_HELP_STRING([--enable-builtin-mjpeg], [Enable the builtin mjpeg video decoder @<:@default=yes@:>@]),
+  [],
+  enable_builtin_mjpeg="yes")
+AS_IF([test "x$enable_builtin_mjpeg" = "xyes"],
+      [AC_DEFINE([HAVE_BUILTIN_MJPEG], 1, [Use the builtin mjpeg decoder?])])
+AM_CONDITIONAL(WITH_BUILTIN_MJPEG, [test "x$enable_builtin_mjpeg" != "xno"])
+
 AC_CHECK_LIB(jpeg, jpeg_destroy_decompress,
     AC_MSG_CHECKING([for jpeglib.h])
     AC_TRY_CPP(
@@ -779,3 +787,6 @@ AC_MSG_NOTICE([
 if test "x$have_dbus" = "xno"; then
   AC_MSG_WARN([No D-Bus support, desktop integration and USB redirection may not work properly])
 fi
+if test "x$enable_builtin_mjpeg" = "xno" && test "x$have_gst_video" != "xyes"; then
+  AC_MSG_WARN([No builtin MJPEG or GStreamer decoder, video not be streamed])
+fi
diff --git a/src/Makefile.am b/src/Makefile.am
index ae43b13..bd69679 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -258,7 +258,6 @@ libspice_client_glib_2_0_la_SOURCES =			\
 	channel-cursor.c				\
 	channel-display.c				\
 	channel-display-priv.h				\
-	channel-display-mjpeg.c				\
 	channel-inputs.c				\
 	channel-main.c					\
 	channel-playback.c				\
@@ -346,6 +345,12 @@ libspice_client_glib_2_0_la_SOURCES +=	\
 	$(NULL)
 endif
 
+if WITH_BUILTIN_MJPEG
+libspice_client_glib_2_0_la_SOURCES +=	\
+	channel-display-mjpeg.c		\
+	$(NULL)
+endif
+
 if HAVE_GSTVIDEO
 libspice_client_glib_2_0_la_SOURCES +=	\
 	channel-display-gst.c		\
diff --git a/src/channel-display-priv.h b/src/channel-display-priv.h
index d8a03e9..2c64eb4 100644
--- a/src/channel-display-priv.h
+++ b/src/channel-display-priv.h
@@ -65,7 +65,9 @@ struct VideoDecoder {
  * @stream:     The associated video stream.
  * @return:     A pointer to a structure implementing the VideoDecoder methods.
  */
+#ifdef HAVE_BUILTIN_MJPEG
 VideoDecoder* create_mjpeg_decoder(int codec_type, display_stream *stream);
+#endif
 #ifdef HAVE_GSTVIDEO
 VideoDecoder* create_gstreamer_decoder(int codec_type, display_stream *stream);
 gboolean gstvideo_init(void);
diff --git a/src/channel-display.c b/src/channel-display.c
index 86d8869..1762f3e 100644
--- a/src/channel-display.c
+++ b/src/channel-display.c
@@ -597,8 +597,11 @@ static void spice_display_channel_reset_capabilities(SpiceChannel *channel)
         spice_channel_set_capability(SPICE_CHANNEL(channel), SPICE_DISPLAY_CAP_STREAM_REPORT);
     }
     spice_channel_set_capability(SPICE_CHANNEL(channel), SPICE_DISPLAY_CAP_MULTI_CODEC);
+#ifdef HAVE_BUILTIN_MJPEG
     spice_channel_set_capability(SPICE_CHANNEL(channel), SPICE_DISPLAY_CAP_CODEC_MJPEG);
+#endif
     if (gstvideo_init()) {
+        spice_channel_set_capability(SPICE_CHANNEL(channel), SPICE_DISPLAY_CAP_CODEC_MJPEG);
         spice_channel_set_capability(SPICE_CHANNEL(channel), SPICE_DISPLAY_CAP_CODEC_VP8);
         spice_channel_set_capability(SPICE_CHANNEL(channel), SPICE_DISPLAY_CAP_CODEC_H264);
     }
@@ -1011,9 +1014,11 @@ static void display_handle_stream_create(SpiceChannel *channel, SpiceMsgIn *in)
     display_update_stream_region(st);
 
     switch (op->codec_type) {
+#ifdef HAVE_BUILTIN_MJPEG
     case SPICE_VIDEO_CODEC_TYPE_MJPEG:
         st->video_decoder = create_mjpeg_decoder(op->codec_type, st);
         break;
+#endif
     default:
 #ifdef HAVE_GSTVIDEO
         st->video_decoder = create_gstreamer_decoder(op->codec_type, st);
-- 
2.6.1



More information about the Spice-devel mailing list