From d0e4331648a4609d7a623166d151f44560836e82 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Sun, 1 Nov 2009 23:16:18 +0100 Subject: [PATCH] resindvd: Add gst_base_src_new_seamless_segment() to GstBaseSrc copy Add a new function to the internal copy of GstBaseSrc for starting a new seamless segment. --- ext/resindvd/rsnbasesrc.c | 63 +++++++++++++++++++++++++++++++++++++++ ext/resindvd/rsnbasesrc.h | 1 + 2 files changed, 64 insertions(+) diff --git a/ext/resindvd/rsnbasesrc.c b/ext/resindvd/rsnbasesrc.c index 92760c0bcd..b1e8a44d41 100644 --- a/ext/resindvd/rsnbasesrc.c +++ b/ext/resindvd/rsnbasesrc.c @@ -569,6 +569,69 @@ gst_base_src_get_do_timestamp (RsnBaseSrc * src) return res; } +/** + * gst_base_src_new_seamless_segment: + * @src: The source + * @start: The new start value for the segment + * @stop: Stop value for the new segment + * @position: The position value for the new segent + * + * Prepare a new seamless segment for emission downstream. This function must + * only be called by derived sub-classes, and only from the create() function, + * as the stream-lock needs to be held. + * + * The format for the new segment will be the current format of the source, as + * configured with gst_base_src_set_format() + * + * Returns: %TRUE if preparation of the seamless segment succeeded. + * + * Since: 0.10.26 + */ +gboolean +gst_base_src_new_seamless_segment (RsnBaseSrc * src, gint64 start, gint64 stop, + gint64 position) +{ + gboolean res = TRUE; + + GST_DEBUG_OBJECT (src, + "Starting new seamless segment. Start %" GST_TIME_FORMAT " stop %" + GST_TIME_FORMAT " position %" GST_TIME_FORMAT, GST_TIME_ARGS (start), + GST_TIME_ARGS (stop), GST_TIME_ARGS (position)); + + if (src->data.ABI.running) { + if (src->priv->close_segment) + gst_event_unref (src->priv->close_segment); + src->priv->close_segment = + gst_event_new_new_segment_full (TRUE, + src->segment.rate, src->segment.applied_rate, src->segment.format, + src->segment.start, src->segment.last_stop, src->segment.time); + } + + gst_segment_set_newsegment_full (&src->segment, FALSE, src->segment.rate, + src->segment.applied_rate, src->segment.format, start, stop, position); + + if (src->priv->start_segment) + gst_event_unref (src->priv->start_segment); + if (src->segment.rate >= 0.0) { + /* forward, we send data from last_stop to stop */ + src->priv->start_segment = + gst_event_new_new_segment_full (FALSE, + src->segment.rate, src->segment.applied_rate, src->segment.format, + src->segment.last_stop, stop, src->segment.time); + } else { + /* reverse, we send data from last_stop to start */ + src->priv->start_segment = + gst_event_new_new_segment_full (FALSE, + src->segment.rate, src->segment.applied_rate, src->segment.format, + src->segment.start, src->segment.last_stop, src->segment.time); + } + + src->priv->discont = TRUE; + src->data.ABI.running = TRUE; + + return res; +} + static gboolean gst_base_src_setcaps (GstPad * pad, GstCaps * caps) { diff --git a/ext/resindvd/rsnbasesrc.h b/ext/resindvd/rsnbasesrc.h index 1dd9f7f5a4..e7bd3fa56e 100644 --- a/ext/resindvd/rsnbasesrc.h +++ b/ext/resindvd/rsnbasesrc.h @@ -254,6 +254,7 @@ gulong gst_base_src_get_blocksize (RsnBaseSrc *src); void gst_base_src_set_do_timestamp (RsnBaseSrc *src, gboolean timestamp); gboolean gst_base_src_get_do_timestamp (RsnBaseSrc *src); +gboolean gst_base_src_new_seamless_segment (RsnBaseSrc *src, gint64 start, gint64 stop, gint64 position); G_END_DECLS #endif /* __RSN_BASE_SRC_H__ */