[Spice-devel] [PATCH spice-server v3 5/5] Compatibility for GStreamer 0.10 for test utility
Frediano Ziglio
fziglio at redhat.com
Wed Nov 9 10:19:14 UTC 2016
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
server/tests/gst-test.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 59 insertions(+), 2 deletions(-)
Changes since v2:
- use a gst_buffer_new_wrapped_full replacement;
- use 1.0 style for gst_bus_set_sync_handler.
(all comments by Christophe).
diff --git a/server/tests/gst-test.c b/server/tests/gst-test.c
index 62f1f1c..bee1f22 100644
--- a/server/tests/gst-test.c
+++ b/server/tests/gst-test.c
@@ -69,6 +69,57 @@ typedef struct {
SpiceBitmap *bitmap;
} TestFrame;
+#ifdef HAVE_GSTREAMER_0_10
+
+#define VIDEOCONVERT "ffmpegcolorspace"
+#define BGRx_CAPS "caps=video/x-raw-rgb,bpp=32,depth=24,blue_mask=-16777216,green_mask=16711680,red_mask=65280"
+
+typedef GstBuffer GstSample;
+#define gst_sample_get_buffer(s) (s)
+#define gst_sample_get_caps(s) GST_BUFFER_CAPS(s)
+#define gst_sample_unref(s) gst_buffer_unref(s)
+#define gst_app_sink_pull_sample(s) gst_app_sink_pull_buffer(s)
+typedef struct {
+ uint8_t *data;
+} GstMapInfo;
+#define GST_MAP_READ 1
+static inline void
+gst_buffer_unmap(GstBuffer *buffer, GstMapInfo *mapinfo)
+{ }
+
+static inline gboolean
+gst_buffer_map(GstBuffer *buffer, GstMapInfo *mapinfo, int flags)
+{
+ mapinfo->data = GST_BUFFER_DATA(buffer);
+ return mapinfo->data != NULL;
+}
+
+static GstBuffer*
+gst_buffer_new_wrapped_full(int flags SPICE_GNUC_UNUSED, gpointer data, gsize maxsize,
+ gsize offset, gsize size,
+ gpointer user_data, GDestroyNotify notify)
+{
+ GstBuffer *buffer = gst_buffer_new();
+
+ buffer->malloc_data = user_data;
+ GST_BUFFER_FREE_FUNC(buffer) = notify;
+ GST_BUFFER_DATA(buffer) = (uint8_t *) data + offset;
+ GST_BUFFER_SIZE(buffer) = size;
+
+ return buffer;
+}
+
+#define GST_MEMORY_FLAG_PHYSICALLY_CONTIGUOUS 0
+
+#define gst_bus_set_sync_handler(bus, proc, param, destroy) G_STMT_START {\
+ verify(destroy == NULL); \
+ gst_bus_set_sync_handler(bus, proc, param); \
+} G_STMT_END
+#else
+#define VIDEOCONVERT "videoconvert"
+#define BGRx_CAPS "caps=video/x-raw,format=BGRx"
+#endif
+
typedef void (*SampleProc)(GstSample *sample, void *param);
typedef struct {
@@ -230,7 +281,11 @@ static const EncoderInfo encoder_infos[] = {
{ "gstreamer:vp8", gstreamer_encoder_new, SPICE_VIDEO_CODEC_TYPE_VP8,
"caps=video/x-vp8", "vp8dec" },
{ "gstreamer:h264", gstreamer_encoder_new, SPICE_VIDEO_CODEC_TYPE_H264,
+#ifdef HAVE_GSTREAMER_0_10
+ "", "h264parse ! ffdec_h264" },
+#else
"", "h264parse ! avdec_h264" },
+#endif
{ NULL, NULL }
};
@@ -526,7 +581,7 @@ create_output_pipeline(const EncoderInfo *encoder, SampleProc sample_proc, void
{
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"
+ "%s ! %s ! " VIDEOCONVERT " ! appsink name=sink " BGRx_CAPS
" sync=false drop=false", encoder->caps, encoder->decoder);
TestPipeline *pipeline = create_pipeline(desc, sample_proc, param);
@@ -543,7 +598,7 @@ static void
create_input_pipeline(const char *input_pipeline_desc, SampleProc sample_proc, void *param)
{
gchar *desc =
- g_strdup_printf("%s ! appsink name=sink caps=video/x-raw,format=BGRx"
+ g_strdup_printf("%s ! appsink name=sink " BGRx_CAPS
" sync=false drop=false", input_pipeline_desc);
TestPipeline *pipeline = create_pipeline(desc, sample_proc, param);
@@ -573,7 +628,9 @@ pipeline_send_raw_data(TestPipeline *pipeline, VideoBuffer *video_buffer)
video_buffer, (void (*)(void*)) video_buffer_release);
GST_BUFFER_DURATION(buffer) = GST_CLOCK_TIME_NONE;
+#ifndef HAVE_GSTREAMER_0_10
GST_BUFFER_DTS(buffer) = GST_CLOCK_TIME_NONE;
+#endif
if (gst_app_src_push_buffer(pipeline->appsrc, buffer) != GST_FLOW_OK) {
g_printerr("GStreamer error: unable to push frame of size %u\n", video_buffer->size);
--
2.7.4
More information about the Spice-devel
mailing list