imagefreeze: Handle seqnums

https://bugzilla.gnome.org/show_bug.cgi?id=739366
This commit is contained in:
Thibault Saunier 2014-10-29 18:44:43 +01:00
parent 63e0b29291
commit 99bbc2bbe4
2 changed files with 23 additions and 2 deletions

View file

@ -158,6 +158,7 @@ gst_image_freeze_reset (GstImageFreeze * self)
self->fps_n = self->fps_d = 0;
self->offset = 0;
self->seqnum = 0;
g_mutex_unlock (&self->lock);
g_atomic_int_set (&self->seeking, 0);
@ -570,6 +571,7 @@ gst_image_freeze_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
gint64 last_stop;
gboolean start_task;
gboolean flush;
guint32 seqnum;
gst_event_parse_seek (event, &rate, &format, &flags, &start_type, &start,
&stop_type, &stop);
@ -598,11 +600,13 @@ gst_image_freeze_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
}
}
seqnum = gst_event_get_seqnum (event);
if (flush) {
GstEvent *e;
g_atomic_int_set (&self->seeking, 1);
e = gst_event_new_flush_start ();
gst_event_set_seqnum (e, seqnum);
gst_pad_push_event (self->srcpad, e);
} else {
gst_pad_pause_task (self->srcpad);
@ -624,6 +628,7 @@ gst_image_freeze_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
GstEvent *e;
e = gst_event_new_flush_stop (TRUE);
gst_event_set_seqnum (e, seqnum);
gst_pad_push_event (self->srcpad, e);
g_atomic_int_set (&self->seeking, 0);
}
@ -636,6 +641,7 @@ gst_image_freeze_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
gst_element_post_message (GST_ELEMENT (self), m);
}
self->seqnum = seqnum;
GST_PAD_STREAM_UNLOCK (self->srcpad);
GST_DEBUG_OBJECT (pad, "Seek successful");
@ -717,6 +723,9 @@ gst_image_freeze_src_loop (GstPad * pad)
&self->segment);
e = gst_event_new_segment (&self->segment);
if (self->seqnum)
gst_event_set_seqnum (e, self->seqnum);
g_mutex_lock (&self->lock);
if (self->segment.rate >= 0) {
self->offset =
@ -823,14 +832,25 @@ pause_task:
gst_element_post_message (GST_ELEMENT_CAST (self), m);
gst_pad_push_event (self->srcpad, e);
} else {
GstEvent *e = gst_event_new_eos ();
GST_DEBUG_OBJECT (pad, "Sending EOS at end of segment");
gst_pad_push_event (self->srcpad, gst_event_new_eos ());
if (self->seqnum)
gst_event_set_seqnum (e, self->seqnum);
gst_pad_push_event (self->srcpad, e);
}
} else if (flow_ret == GST_FLOW_NOT_LINKED || flow_ret < GST_FLOW_EOS) {
GstEvent *e = gst_event_new_eos ();
GST_ELEMENT_ERROR (self, STREAM, FAILED,
("Internal data stream error."),
("stream stopped, reason %s", reason));
gst_pad_push_event (self->srcpad, gst_event_new_eos ());
if (self->seqnum)
gst_event_set_seqnum (e, self->seqnum);
gst_pad_push_event (self->srcpad, e);
}
return;
}

View file

@ -53,6 +53,7 @@ struct _GstImageFreeze
GstSegment segment;
gboolean need_segment;
guint seqnum;
guint64 offset;