baseparse: use _set_duration to configure duration update interval

... as it logically belongs there as one or the other; either subclass
can provide a duration, or an estimate must be made (reguarly updated).
This commit is contained in:
Mark Nauwelaerts 2010-09-22 14:13:17 +02:00
parent eb9ba9e115
commit 13f85c8f11
6 changed files with 22 additions and 19 deletions

View file

@ -465,7 +465,7 @@ gst_aacparse_detect_stream (GstAacParse * aacparse,
aacparse->channels = ((data[2] & 0x01) << 2) | ((data[3] & 0xc0) >> 6);
gst_base_parse_set_frame_props (GST_BASE_PARSE (aacparse),
aacparse->sample_rate, 1024, 50);
aacparse->sample_rate, 1024);
GST_DEBUG ("ADTS: samplerate %d, channels %d, objtype %d",
aacparse->sample_rate, aacparse->channels, aacparse->object_type);

View file

@ -465,7 +465,7 @@ gst_ac3_parse_parse_frame (GstBaseParse * parse, GstBuffer * buf)
ac3parse->sample_rate = rate;
ac3parse->channels = chans;
gst_base_parse_set_frame_props (parse, rate, 256 * blocks, 50);
gst_base_parse_set_frame_props (parse, rate, 256 * blocks);
}
return GST_FLOW_OK;

View file

@ -237,7 +237,7 @@ gst_amrparse_sink_setcaps (GstBaseParse * parse, GstCaps * caps)
}
amrparse->need_header = FALSE;
gst_base_parse_set_frame_props (GST_BASE_PARSE (amrparse), 50, 1, 50);
gst_base_parse_set_frame_props (GST_BASE_PARSE (amrparse), 50, 1);
gst_amrparse_set_src_caps (amrparse);
return TRUE;
}
@ -306,7 +306,7 @@ gst_amrparse_check_valid_frame (GstBaseParse * parse,
if (dsize >= AMR_MIME_HEADER_SIZE &&
gst_amrparse_parse_header (amrparse, data, skipsize)) {
amrparse->need_header = FALSE;
gst_base_parse_set_frame_props (GST_BASE_PARSE (amrparse), 50, 1, 50);
gst_base_parse_set_frame_props (GST_BASE_PARSE (amrparse), 50, 1);
} else {
GST_WARNING ("media doesn't look like a AMR format");
}

View file

@ -2106,11 +2106,13 @@ gst_base_parse_sink_activate_pull (GstPad * sinkpad, gboolean active)
* @duration: duration value.
*
* Sets the duration of the currently playing media. Subclass can use this
* when it notices a change in the media duration.
*/
* when it is able to determine duration and/or notices a change in the media
* duration. Alternatively, if @interval is non-zero (default), then stream
* duration is determined based on estimated bitrate, and updated every @interval
* frames. */
void
gst_base_parse_set_duration (GstBaseParse * parse,
GstFormat fmt, gint64 duration)
GstFormat fmt, gint64 duration, gint interval)
{
g_return_if_fail (parse != NULL);
@ -2126,6 +2128,14 @@ gst_base_parse_set_duration (GstBaseParse * parse,
parse->priv->duration = duration;
parse->priv->duration_fmt = fmt;
GST_DEBUG_OBJECT (parse, "set duration: %" G_GINT64_FORMAT, duration);
if (fmt == GST_FORMAT_TIME && GST_CLOCK_TIME_IS_VALID (duration)) {
if (interval != 0) {
GST_DEBUG_OBJECT (parse, "valid duration provided, disabling estimate");
interval = 0;
}
}
GST_DEBUG_OBJECT (parse, "set update interval: %d", interval);
parse->priv->update_interval = interval;
GST_BASE_PARSE_UNLOCK (parse);
}
@ -2195,28 +2205,23 @@ gst_base_parse_set_passthrough (GstBaseParse * parse, gboolean passthrough)
* @parse: the #GstBaseParse to set
* @fps_num: frames per second (numerator).
* @fps_den: frames per second (denominator).
* @interval: duration update interval in frames.
*
* If frames per second is configured, parser can take care of buffer duration
* and timestamping. If #interval is non-zero (default), then stream duration
* is determined based on frame and byte counts, and updated every #interval
* frames.
* and timestamping.
*/
void
gst_base_parse_set_frame_props (GstBaseParse * parse, guint fps_num,
guint fps_den, gint interval)
guint fps_den)
{
g_return_if_fail (parse != NULL);
GST_BASE_PARSE_LOCK (parse);
parse->priv->fps_num = fps_num;
parse->priv->fps_den = fps_den;
parse->priv->update_interval = interval;
if (!fps_num || !fps_den) {
GST_DEBUG_OBJECT (parse, "invalid fps (%d/%d), ignoring parameters",
fps_num, fps_den);
fps_num = fps_den = 0;
interval = 0;
parse->priv->frame_duration = GST_CLOCK_TIME_NONE;
} else {
parse->priv->frame_duration =
@ -2225,7 +2230,6 @@ gst_base_parse_set_frame_props (GstBaseParse * parse, guint fps_num,
}
GST_LOG_OBJECT (parse, "set fps: %d/%d => duration: %" G_GINT64_FORMAT " ms",
fps_num, fps_den, parse->priv->frame_duration / GST_MSECOND);
GST_LOG_OBJECT (parse, "set update interval: %d", interval);
GST_BASE_PARSE_UNLOCK (parse);
}

View file

@ -284,8 +284,7 @@ GstFlowReturn gst_base_parse_push_buffer (GstBaseParse *parse,
GstBuffer *buffer);
void gst_base_parse_set_duration (GstBaseParse *parse,
GstFormat fmt,
gint64 duration);
GstFormat fmt, gint64 duration, gint interval);
void gst_base_parse_set_seek (GstBaseParse * parse,
GstBaseParseSeekable seek, guint bitrate);
@ -295,7 +294,7 @@ void gst_base_parse_set_min_frame_size (GstBaseParse *parse,
void gst_base_parse_set_passthrough (GstBaseParse * parse, gboolean passthrough);
void gst_base_parse_set_frame_props (GstBaseParse * parse, guint fps_num,
guint fps_den, gint interval);
guint fps_den);
gboolean gst_base_parse_get_sync (GstBaseParse * parse);

View file

@ -995,7 +995,7 @@ gst_flac_parse_handle_streaminfo (GstFlacParse * flacparse, GstBuffer * buffer)
if (flacparse->total_samples)
gst_base_parse_set_duration (GST_BASE_PARSE (flacparse), GST_FORMAT_TIME,
GST_FRAMES_TO_CLOCK_TIME (flacparse->total_samples,
flacparse->samplerate));
flacparse->samplerate), 0);
GST_DEBUG_OBJECT (flacparse, "STREAMINFO:\n"
"\tmin/max blocksize: %u/%u,\n"