[Spice-commits] 2 commits - src/channel-display-gst.c
Victor Toso de Carvalho
victortoso at kemper.freedesktop.org
Thu Oct 20 14:30:47 UTC 2016
src/channel-display-gst.c | 89 ++++++++++++++++++++++++++--------------------
1 file changed, 52 insertions(+), 37 deletions(-)
New commits:
commit b023c3caa097743222c9ad4cf94950ecc1aed2bf
Author: Victor Toso <me at victortoso.com>
Date: Wed Oct 5 17:49:03 2016 +0200
channel-display-gst: use a static array for gst options
Signed-off-by: Victor Toso <victortoso at redhat.com>
Acked-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c
index efadb1e..f52299f 100644
--- a/src/channel-display-gst.c
+++ b/src/channel-display-gst.c
@@ -50,6 +50,39 @@ typedef struct SpiceGstDecoder {
guint timer_id;
} SpiceGstDecoder;
+static struct {
+ const gchar *dec_name;
+ const gchar *dec_caps;
+} gst_opts[] = {
+ /* decodebin will use vaapi if installed, which for a time could
+ * intentionally crash the application. So only use decodebin as a
+ * fallback or when SPICE_GSTVIDEO_AUTO is set.
+ * See: https://bugs.freedesktop.org/show_bug.cgi?id=90884
+ */
+ { "decodebin", "" },
+
+ /* SPICE_VIDEO_CODEC_TYPE_MJPEG */
+ { "jpegdec", "caps=image/jpeg" },
+
+ /* SPICE_VIDEO_CODEC_TYPE_VP8
+ *
+ * typefind is unable to identify VP8 streams by design.
+ * See: https://bugzilla.gnome.org/show_bug.cgi?id=756457
+ */
+ { "vp8dec", "caps=video/x-vp8" },
+
+ /* SPICE_VIDEO_CODEC_TYPE_H264
+ * h264 streams detection works fine and setting an incomplete cap
+ * causes errors. So let typefind do all the work.
+ */
+ { "h264parse ! avdec_h264", "" },
+
+};
+
+G_STATIC_ASSERT(G_N_ELEMENTS(gst_opts) == SPICE_VIDEO_CODEC_TYPE_ENUM_END);
+
+#define VALID_VIDEO_CODEC_TYPE(codec) \
+ (codec > 0 && codec < SPICE_VIDEO_CODEC_TYPE_ENUM_END)
/* ---------- SpiceFrame ---------- */
@@ -249,45 +282,20 @@ static void free_pipeline(SpiceGstDecoder *decoder)
static gboolean create_pipeline(SpiceGstDecoder *decoder)
{
- const gchar *src_caps, *gstdec_name;
gchar *desc;
+ gboolean auto_enabled;
+ guint opt;
GstAppSinkCallbacks appsink_cbs = { NULL };
GError *err = NULL;
- switch (decoder->base.codec_type) {
- case SPICE_VIDEO_CODEC_TYPE_MJPEG:
- src_caps = "caps=image/jpeg";
- gstdec_name = "jpegdec";
- break;
- case SPICE_VIDEO_CODEC_TYPE_VP8:
- /* typefind is unable to identify VP8 streams by design.
- * See: https://bugzilla.gnome.org/show_bug.cgi?id=756457
- */
- src_caps = "caps=video/x-vp8";
- gstdec_name = "vp8dec";
- break;
- case SPICE_VIDEO_CODEC_TYPE_H264:
- /* h264 streams detection works fine and setting an incomplete cap
- * causes errors. So let typefind do all the work.
- */
- src_caps = "";
- gstdec_name = "h264parse ! avdec_h264";
- break;
- default:
- SPICE_DEBUG("Unknown codec type %d. Trying decodebin.",
- decoder->base.codec_type);
- src_caps = "";
- gstdec_name = NULL;
- break;
- }
-
- /* decodebin will use vaapi if installed, which for a time could
- * intentionally crash the application. So only use decodebin as a
- * fallback or when SPICE_GSTVIDEO_AUTO is set.
- * See: https://bugs.freedesktop.org/show_bug.cgi?id=90884
- */
- if (gstdec_name == NULL || g_getenv("SPICE_GSTVIDEO_AUTO") != NULL) {
- gstdec_name = "decodebin";
+ auto_enabled = (g_getenv("SPICE_GSTVIDEO_AUTO") != NULL);
+ if (auto_enabled || !VALID_VIDEO_CODEC_TYPE(decoder->base.codec_type)) {
+ SPICE_DEBUG("Trying %s for codec type %d %s",
+ gst_opts[0].dec_name, decoder->base.codec_type,
+ (auto_enabled) ? "(SPICE_GSTVIDEO_AUTO is set)" : "");
+ opt = 0;
+ } else {
+ opt = decoder->base.codec_type;
}
/* - We schedule the frame display ourselves so set sync=false on appsink
@@ -300,7 +308,7 @@ static gboolean create_pipeline(SpiceGstDecoder *decoder)
desc = g_strdup_printf("appsrc name=src is-live=true format=time max-bytes=0 block=true "
"%s ! %s ! videoconvert ! appsink name=sink "
"caps=video/x-raw,format=BGRx sync=false drop=false",
- src_caps, gstdec_name);
+ gst_opts[opt].dec_caps, gst_opts[opt].dec_name);
SPICE_DEBUG("GStreamer pipeline: %s", desc);
decoder->pipeline = gst_parse_launch_full(desc, NULL, GST_PARSE_FLAG_FATAL_ERRORS, &err);
commit bd319608facf7b32c97b3d55701822da6868048b
Author: Victor Toso <me at victortoso.com>
Date: Tue Oct 4 15:22:23 2016 +0200
channel-display-gst: style changes in create_pipeline
Move declaration of variable to top and break big g_strdup_printf
line.
Signed-off-by: Victor Toso <victortoso at redhat.com>
Acked-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c
index 430bb95..efadb1e 100644
--- a/src/channel-display-gst.c
+++ b/src/channel-display-gst.c
@@ -250,6 +250,10 @@ static void free_pipeline(SpiceGstDecoder *decoder)
static gboolean create_pipeline(SpiceGstDecoder *decoder)
{
const gchar *src_caps, *gstdec_name;
+ gchar *desc;
+ GstAppSinkCallbacks appsink_cbs = { NULL };
+ GError *err = NULL;
+
switch (decoder->base.codec_type) {
case SPICE_VIDEO_CODEC_TYPE_MJPEG:
src_caps = "caps=image/jpeg";
@@ -293,10 +297,12 @@ static gboolean create_pipeline(SpiceGstDecoder *decoder)
* - Set max-bytes=0 on appsrc so it does not drop frames that may be
* needed by those that follow.
*/
- gchar *desc = g_strdup_printf("appsrc name=src is-live=true format=time max-bytes=0 block=true %s ! %s ! videoconvert ! appsink name=sink caps=video/x-raw,format=BGRx sync=false drop=false", src_caps, gstdec_name);
+ desc = g_strdup_printf("appsrc name=src is-live=true format=time max-bytes=0 block=true "
+ "%s ! %s ! videoconvert ! appsink name=sink "
+ "caps=video/x-raw,format=BGRx sync=false drop=false",
+ src_caps, gstdec_name);
SPICE_DEBUG("GStreamer pipeline: %s", desc);
- GError *err = NULL;
decoder->pipeline = gst_parse_launch_full(desc, NULL, GST_PARSE_FLAG_FATAL_ERRORS, &err);
g_free(desc);
if (!decoder->pipeline) {
@@ -307,7 +313,8 @@ static gboolean create_pipeline(SpiceGstDecoder *decoder)
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"));
- GstAppSinkCallbacks appsink_cbs = {NULL, NULL, &new_sample, {NULL}};
+
+ appsink_cbs.new_sample = new_sample;
gst_app_sink_set_callbacks(decoder->appsink, &appsink_cbs, decoder, NULL);
decoder->clock = gst_pipeline_get_clock(GST_PIPELINE(decoder->pipeline));
More information about the Spice-commits
mailing list