From 90eefa6e5ad74354a2bbe7bf7dd79193e16dc3ba Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Thu, 12 Jun 2014 14:58:47 +1000 Subject: [PATCH] glmixer: send the stream-start event and the caps event after. https://bugzilla.gnome.org/show_bug.cgi?id=730944 --- gst-libs/gst/gl/gstglmixer.c | 35 ++++++++++++++++++++++++++++++++--- gst-libs/gst/gl/gstglmixer.h | 3 +++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/gst-libs/gst/gl/gstglmixer.c b/gst-libs/gst/gl/gstglmixer.c index c12fc218ea..14c56c21cb 100644 --- a/gst-libs/gst/gl/gstglmixer.c +++ b/gst-libs/gst/gl/gstglmixer.c @@ -1347,12 +1347,16 @@ gst_gl_mixer_src_setcaps (GstPad * pad, GstGLMixer * mix, GstCaps * caps) mix->out_info = info; + if (mix->current_caps == NULL || + gst_caps_is_equal (caps, mix->current_caps) == FALSE) { + gst_caps_replace (&mix->current_caps, caps); + mix->send_caps = TRUE; + } + GST_GL_MIXER_UNLOCK (mix); - ret = gst_pad_set_caps (mix->srcpad, caps); + ret = gst_gl_mixer_do_bufferpool (mix, caps); - if (ret) - ret = gst_gl_mixer_do_bufferpool (mix, caps); done: priv->negotiated = ret; @@ -1847,6 +1851,28 @@ gst_gl_mixer_collected (GstCollectPads * pads, GstGLMixer * mix) gst_pad_push_event (mix->srcpad, gst_event_new_flush_stop (TRUE)); } + if (mix->send_stream_start) { + gchar s_id[32]; + + /* stream-start (FIXME: create id based on input ids) */ + g_snprintf (s_id, sizeof (s_id), "mix-%08x", g_random_int ()); + if (!gst_pad_push_event (mix->srcpad, gst_event_new_stream_start (s_id))) { + GST_WARNING_OBJECT (mix->srcpad, "Sending stream start event failed"); + } + mix->send_stream_start = FALSE; + } + + if (gst_pad_check_reconfigure (mix->srcpad)) + gst_gl_mixer_update_src_caps (mix); + + if (mix->send_caps) { + if (!gst_pad_push_event (mix->srcpad, + gst_event_new_caps (mix->current_caps))) { + GST_WARNING_OBJECT (mix->srcpad, "Sending caps event failed"); + } + mix->send_caps = FALSE; + } + GST_GL_MIXER_LOCK (mix); if (mix->newseg_pending) { @@ -2292,6 +2318,9 @@ gst_gl_mixer_change_state (GstElement * element, GstStateChange transition) switch (transition) { case GST_STATE_CHANGE_READY_TO_PAUSED: { + mix->send_stream_start = TRUE; + mix->send_caps = TRUE; + gst_caps_replace (&mix->current_caps, NULL); GST_LOG_OBJECT (mix, "starting collectpads"); gst_collect_pads_start (mix->collect); break; diff --git a/gst-libs/gst/gl/gstglmixer.h b/gst-libs/gst/gl/gstglmixer.h index 41dd48202e..87d2bfa012 100644 --- a/gst-libs/gst/gl/gstglmixer.h +++ b/gst-libs/gst/gl/gstglmixer.h @@ -76,12 +76,15 @@ struct _GstGLMixer GPtrArray *array_buffers; GPtrArray *frames; + GstCaps *current_caps; GstVideoInfo out_info; GLuint out_tex_id; GstGLDownload *download; gboolean newseg_pending; gboolean flush_stop_pending; + gboolean send_stream_start; + gboolean send_caps; GstSegment segment; GstClockTime ts_offset;