/**
* gst_event_new_flush_stop:
+ * @reset_time: if time should be reset
*
* Allocate a new flush stop event. The flush stop event can be sent
* upstream and downstream and travels serialized with the dataflow.
* Returns: (transfer full): a new flush stop event.
*/
GstEvent *
-gst_event_new_flush_stop (void)
+gst_event_new_flush_stop (gboolean reset_time)
{
- return gst_event_new (GST_EVENT_FLUSH_STOP);
+ GstEvent *event;
+
+ GST_CAT_INFO (GST_CAT_EVENT, "creating flush stop %d", reset_time);
+
+ event = gst_event_new_custom (GST_EVENT_FLUSH_STOP,
+ gst_structure_id_new (GST_QUARK (EVENT_FLUSH_STOP),
+ GST_QUARK (RESET_TIME), G_TYPE_BOOLEAN, reset_time, NULL));
+
+ return event;
+}
+
+/**
+ * gst_event_parse_flush_stop:
+ * @event: The event to parse
+ * @reset_time: (out): if time should be reset
+ *
+ * Parse the FLUSH_STOP event and retrieve the @reset_time member.
+ */
+void
+gst_event_parse_flush_stop (GstEvent * event, gboolean * reset_time)
+{
+ GstStructure *structure;
+
+ g_return_if_fail (GST_IS_EVENT (event));
+ g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_FLUSH_STOP);
+
+ structure = GST_EVENT_STRUCTURE (event);
+ if (G_LIKELY (reset_time))
+ *reset_time =
+ g_value_get_boolean (gst_structure_id_get_value (structure,
+ GST_QUARK (RESET_TIME)));
}
/**
/* flush events */
GstEvent * gst_event_new_flush_start (void);
-GstEvent * gst_event_new_flush_stop (void);
+
+GstEvent * gst_event_new_flush_stop (gboolean reset_time);
+void gst_event_parse_flush_stop (GstEvent *event, gboolean *reset_time);
/* EOS event */
GstEvent * gst_event_new_eos (void);
"min-buffers", "max-buffers", "prefix", "postfix", "align", "time",
"GstQueryAllocation", "need-pool", "meta", "pool", "GstEventCaps",
"GstEventReconfigure", "segment", "GstQueryScheduling", "pull-mode",
- "random-access", "sequential", "allocator"
+ "random-access", "sequential", "allocator", "GstEventFlushStop"
};
GQuark _priv_gst_quark_table[GST_QUARK_MAX];
GST_QUARK_RANDOM_ACCESS = 124,
GST_QUARK_SEQUENTIAL = 125,
GST_QUARK_ALLOCATOR = 126,
+ GST_QUARK_EVENT_FLUSH_STOP = 127,
- GST_QUARK_MAX = 127
+ GST_QUARK_MAX = 128
} GstQuarkId;
extern GQuark _priv_gst_quark_table[GST_QUARK_MAX];
/* prepare for streaming again */
if (flush) {
GST_DEBUG_OBJECT (parse, "sending flush stop");
- gst_pad_push_event (parse->srcpad, gst_event_new_flush_stop ());
- gst_pad_push_event (parse->sinkpad, gst_event_new_flush_stop ());
+ gst_pad_push_event (parse->srcpad, gst_event_new_flush_stop (TRUE));
+ gst_pad_push_event (parse->sinkpad, gst_event_new_flush_stop (TRUE));
gst_base_parse_clear_queues (parse);
} else {
/* keep track of our position */
/* FIXME: Casting to GstClockEntry only works because the types
* are the same */
if (G_LIKELY (sink->priv->cached_clock_id != NULL
- && GST_CLOCK_ENTRY_CLOCK ((GstClockEntry *) sink->
- priv->cached_clock_id) == clock)) {
+ && GST_CLOCK_ENTRY_CLOCK ((GstClockEntry *) sink->priv->
+ cached_clock_id) == clock)) {
if (!gst_clock_single_shot_id_reinit (clock, sink->priv->cached_clock_id,
time)) {
gst_clock_id_unref (sink->priv->cached_clock_id);
* prerolled buffer */
basesink->playing_async = TRUE;
if (basesink->priv->async_enabled) {
- basesink->priv->reset_time = TRUE;
gst_element_lost_state (GST_ELEMENT_CAST (basesink));
} else {
basesink->priv->have_latency = TRUE;
}
static void
-gst_base_sink_flush_stop (GstBaseSink * basesink, GstPad * pad)
+gst_base_sink_flush_stop (GstBaseSink * basesink, GstPad * pad,
+ gboolean reset_time)
{
/* unset flushing so we can accept new data, this also flushes out any EOS
* event. */
if (basesink->pad_mode == GST_ACTIVATE_PUSH) {
/* we need new segment info after the flush. */
basesink->have_newsegment = FALSE;
- gst_segment_init (&basesink->segment, GST_FORMAT_UNDEFINED);
- gst_segment_init (&basesink->clip_segment, GST_FORMAT_UNDEFINED);
+ if (reset_time) {
+ gst_segment_init (&basesink->segment, GST_FORMAT_UNDEFINED);
+ gst_segment_init (&basesink->clip_segment, GST_FORMAT_UNDEFINED);
+ }
}
+ basesink->priv->reset_time = reset_time;
GST_OBJECT_UNLOCK (basesink);
}
gst_event_unref (event);
break;
case GST_EVENT_FLUSH_STOP:
+ {
+ gboolean reset_time;
+
if (bclass->event)
bclass->event (basesink, event);
- GST_DEBUG_OBJECT (basesink, "flush-stop %p", event);
+ gst_event_parse_flush_stop (event, &reset_time);
+ GST_DEBUG_OBJECT (basesink, "flush-stop %p, reset_time: %d", event,
+ reset_time);
- gst_base_sink_flush_stop (basesink, pad);
+ gst_base_sink_flush_stop (basesink, pad, reset_time);
gst_event_unref (event);
break;
+ }
default:
/* other events are sent to queue or subclass depending on if they
* are serialized. */
if (flush) {
GST_DEBUG_OBJECT (sink, "stop flushing upstream");
- gst_pad_push_event (pad, gst_event_new_flush_stop ());
- gst_base_sink_flush_stop (sink, pad);
+ gst_pad_push_event (pad, gst_event_new_flush_stop (TRUE));
+ gst_base_sink_flush_stop (sink, pad, TRUE);
} else if (res && sink->running) {
/* we are running the current segment and doing a non-flushing seek,
* close the segment first based on the position. */
/* and prepare to continue streaming */
if (flush) {
- tevent = gst_event_new_flush_stop ();
+ tevent = gst_event_new_flush_stop (TRUE);
gst_event_set_seqnum (tevent, seqnum);
/* send flush stop, peer will accept data and events again. We
* are not yet providing data as we still have the STREAM_LOCK. */
fail_unless (eret == TRUE);
GST_DEBUG ("sending FLUSH_STOP");
- event = gst_event_new_flush_stop ();
+ event = gst_event_new_flush_stop (TRUE);
eret = gst_pad_send_event (sinkpad, event);
fail_unless (eret == TRUE);
}
/* stop flushing, timing is affected now */
{
GST_DEBUG ("sending flush_stop");
- event = gst_event_new_flush_stop ();
+ event = gst_event_new_flush_stop (TRUE);
eret = gst_pad_send_event (sinkpad, event);
fail_if (eret == FALSE);
{
GST_DEBUG ("sending flush_stop");
- event = gst_event_new_flush_stop ();
+ event = gst_event_new_flush_stop (TRUE);
eret = gst_pad_send_event (sinkpad, event);
fail_if (eret == FALSE);
}
/* FLUSH_STOP */
{
- event = gst_event_new_flush_stop ();
+ gboolean reset_time;
+
+ event = gst_event_new_flush_stop (TRUE);
fail_if (event == NULL);
fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_FLUSH_STOP);
fail_unless (GST_EVENT_IS_UPSTREAM (event));
fail_unless (GST_EVENT_IS_DOWNSTREAM (event));
fail_unless (GST_EVENT_IS_SERIALIZED (event));
+
+ gst_event_parse_flush_stop (event, &reset_time);
+ fail_unless (reset_time == TRUE);
gst_event_unref (event);
}
/* EOS */
/* block_async_full_cb sets state to 1 and then flushes to unblock temporarily
*/
fail_unless (state == 1);
- gst_pad_push_event (pad, gst_event_new_flush_stop ());
+ gst_pad_push_event (pad, gst_event_new_flush_stop (TRUE));
/* unblock callback is called */
gst_pad_remove_probe (pad, id);
/* block_async_full_cb sets state to 1 and then flushes to unblock temporarily
*/
fail_unless_equals_int (state, 1);
- gst_pad_push_event (pad, gst_event_new_flush_stop ());
+ gst_pad_push_event (pad, gst_event_new_flush_stop (TRUE));
/* gst_BLOCK calls the destroy_notify function if necessary */
gst_object_unref (pad);