mimic: Ensure segment is sent before caps and buffer

https://bugzilla.gnome.org/show_bug.cgi?id=700420
This commit is contained in:
Nicolas Dufresne 2013-05-15 19:23:08 -04:00 committed by Olivier Crête
parent 2b25ef8564
commit 4c4fc14afc
3 changed files with 13 additions and 5 deletions

View file

@ -353,7 +353,6 @@ gst_mim_dec_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
case GST_EVENT_STREAM_START: case GST_EVENT_STREAM_START:
case GST_EVENT_FLUSH_STOP: case GST_EVENT_FLUSH_STOP:
case GST_EVENT_EOS: case GST_EVENT_EOS:
mimdec->need_segment = FALSE;
gst_adapter_clear (mimdec->adapter); gst_adapter_clear (mimdec->adapter);
break; break;
default: default:

View file

@ -209,6 +209,7 @@ gst_mim_enc_reset_locked (GstMimEnc * mimenc)
mimenc->width = 0; mimenc->width = 0;
mimenc->height = 0; mimenc->height = 0;
} }
gst_event_replace (&mimenc->pending_segment, NULL);
} }
static void static void
@ -296,7 +297,6 @@ gst_mim_enc_chain (GstPad * pad, GstObject * parent, GstBuffer * in)
GST_OBJECT_LOCK (mimenc); GST_OBJECT_LOCK (mimenc);
gst_buffer_map (in, &in_map, GST_MAP_READ); gst_buffer_map (in, &in_map, GST_MAP_READ);
out = gst_buffer_new_and_alloc (mimenc->buffer_size + TCP_HEADER_SIZE); out = gst_buffer_new_and_alloc (mimenc->buffer_size + TCP_HEADER_SIZE);
@ -335,6 +335,11 @@ gst_mim_enc_chain (GstPad * pad, GstObject * parent, GstBuffer * in)
gst_buffer_unmap (out, &out_map); gst_buffer_unmap (out, &out_map);
gst_buffer_resize (out, 0, buffer_size + TCP_HEADER_SIZE); gst_buffer_resize (out, 0, buffer_size + TCP_HEADER_SIZE);
if (G_UNLIKELY (mimenc->pending_segment)) {
gst_pad_push_event (mimenc->srcpad, mimenc->pending_segment);
mimenc->pending_segment = FALSE;
}
GST_OBJECT_UNLOCK (mimenc); GST_OBJECT_UNLOCK (mimenc);
res = gst_pad_push (mimenc->srcpad, out); res = gst_pad_push (mimenc->srcpad, out);
@ -375,6 +380,10 @@ gst_mim_enc_event (GstPad * pad, GstObject * parent, GstEvent * event)
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH_STOP:
gst_segment_init (&mimenc->segment, GST_FORMAT_UNDEFINED);
gst_event_replace (&mimenc->pending_segment, NULL);
break;
case GST_EVENT_EOS: case GST_EVENT_EOS:
gst_mim_enc_reset (mimenc); gst_mim_enc_reset (mimenc);
break; break;
@ -396,6 +405,7 @@ gst_mim_enc_event (GstPad * pad, GstObject * parent, GstEvent * event)
if (mimenc->segment.format != GST_FORMAT_TIME) if (mimenc->segment.format != GST_FORMAT_TIME)
goto newseg_wrong_format; goto newseg_wrong_format;
gst_event_replace (&mimenc->pending_segment, event);
forward = FALSE; forward = FALSE;
break; break;
@ -513,12 +523,10 @@ gst_mim_enc_change_state (GstElement * element, GstStateChange transition)
gboolean paused_mode; gboolean paused_mode;
switch (transition) { switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
case GST_STATE_CHANGE_READY_TO_PAUSED: case GST_STATE_CHANGE_READY_TO_PAUSED:
GST_OBJECT_LOCK (mimenc); GST_OBJECT_LOCK (mimenc);
gst_segment_init (&mimenc->segment, GST_FORMAT_UNDEFINED); gst_segment_init (&mimenc->segment, GST_FORMAT_UNDEFINED);
gst_event_replace (&mimenc->pending_segment, NULL);
mimenc->last_buffer = GST_CLOCK_TIME_NONE; mimenc->last_buffer = GST_CLOCK_TIME_NONE;
GST_OBJECT_UNLOCK (mimenc); GST_OBJECT_UNLOCK (mimenc);
break; break;

View file

@ -57,6 +57,7 @@ struct _GstMimEnc
gboolean paused_mode; gboolean paused_mode;
GstSegment segment; GstSegment segment;
GstEvent *pending_segment;
GstClockTime last_buffer; GstClockTime last_buffer;
GstClockID clock_id; GstClockID clock_id;
gboolean stop_paused_mode; gboolean stop_paused_mode;