gstreamer: basesrc: Send an update NEWSEGMENT event downstream if the duration changes

Mark Nauwelaerts mark.nauwelaerts at gmail.com
Wed Jun 8 09:57:04 PDT 2011


Sebastian_Dr=F6ge wrote:
> Module: gstreamer
> Branch: master
> Commit: 934faf163caf10ed3d54d81fd7b793069913dffd
> URL:    http://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=934faf163caf10ed3d54d81fd7b793069913dffd
>
> Author: Sebastian Dröge<sebastian.droege at collabora.co.uk>
> Date:   Fri May 27 09:05:46 2011 +0200
>
> basesrc: Send an update NEWSEGMENT event downstream if the duration changes
>
> This allows streaming the complete file for files that have grown since
> streaming started.
>
> Fixes bug #647940.
>

Has this commit been tested in some way (?), because it looks like a lot of 
elements (e.g. avidemux, baseparse) are going to be really surprised (and mess 
up their state in push mode, maybe pull mode) if they receive some (BYTE) 
newsegment event that is not the result of some upstream seek they performed.

Moreover, it would send a newsegment event even when downstream operates in pull 
mode, so downstream is then receiving an update to an initial newsegment it 
never received.

I also seem to be missing how it fixes the original problem, since afaik e.g. 
avidemux would simply carry on reading beyond whatever was the previous size 
(either pull or push mode).

Mark.

> ---
>
>   libs/gst/base/gstbasesrc.c |   24 ++++++++++++++++++++++++
>   1 files changed, 24 insertions(+), 0 deletions(-)
>
> diff --git a/libs/gst/base/gstbasesrc.c b/libs/gst/base/gstbasesrc.c
> index 59319e2..a8098e7 100644
> --- a/libs/gst/base/gstbasesrc.c
> +++ b/libs/gst/base/gstbasesrc.c
> @@ -2028,6 +2028,7 @@ gst_base_src_update_length (GstBaseSrc * src, guint64 offset, guint * length)
>     GstBaseSrcClass *bclass;
>     GstFormat format;
>     gint64 stop;
> +  gboolean updated = FALSE;
>
>     bclass = GST_BASE_SRC_GET_CLASS (src);
>
> @@ -2083,10 +2084,33 @@ gst_base_src_update_length (GstBaseSrc * src, guint64 offset, guint * length)
>     /* keep track of current position and update duration.
>      * segment is in bytes, we checked that above. */
>     GST_OBJECT_LOCK (src);
> +  updated = (src->segment.duration != size);
>     gst_segment_set_duration (&src->segment, GST_FORMAT_BYTES, size);
>     gst_segment_set_last_stop (&src->segment, GST_FORMAT_BYTES, offset);
>     GST_OBJECT_UNLOCK (src);
>
> +  /* If we updated the duration and doing forward playback, we
> +   * have to update the downstream segments to update the stop
> +   * position */
> +  if (updated&&  src->segment.rate>= 0.0) {
> +    gint64 stop;
> +    GstEvent *event;
> +
> +    /* for deriving a stop position for the playback segment from the seek
> +     * segment, we must take the duration when the stop is not set */
> +    if ((stop = src->segment.stop) == -1)
> +      stop = src->segment.duration;
> +
> +    GST_DEBUG_OBJECT (src, "Sending update newsegment from %" G_GINT64_FORMAT
> +        " to %" G_GINT64_FORMAT, src->segment.start, stop);
> +
> +    event =
> +        gst_event_new_new_segment_full (TRUE,
> +        src->segment.rate, src->segment.applied_rate, src->segment.format,
> +        src->segment.start, stop, src->segment.time);
> +    gst_pad_push_event (src->srcpad, event);
> +  }
> +
>     return TRUE;
>
>     /* ERRORS */
>
>
>
>
> _______________________________________________
> gstreamer-commits mailing list
> gstreamer-commits at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-commits



More information about the gstreamer-devel mailing list