mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 09:10:36 +00:00
gst/wavparse/gstwavparse.c: Return FALSE if we can't handle a query instead of changing the format. Ignore fact when ...
Original commit message from CVS: * gst/wavparse/gstwavparse.c: Return FALSE if we can't handle a query instead of changing the format. Ignore fact when dealing with mpeg audio.
This commit is contained in:
parent
f75f427ec1
commit
55fe83f022
2 changed files with 40 additions and 33 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2007-11-08 Stefan Kost <ensonic@users.sf.net>
|
||||||
|
|
||||||
|
* gst/wavparse/gstwavparse.c:
|
||||||
|
Return FALSE if we can't handle a query instead of changing the
|
||||||
|
format. Ignore fact when dealing with mpeg audio.
|
||||||
|
|
||||||
2007-11-02 Tim-Philipp Müller <tim at centricular dot net>
|
2007-11-02 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
Patch by: Ole André Vadla Ravnås <ole.andre.ravnas@tandberg.com>
|
Patch by: Ole André Vadla Ravnås <ole.andre.ravnas@tandberg.com>
|
||||||
|
|
|
@ -1031,7 +1031,7 @@ gst_wavparse_peek_chunk (GstWavParse * wav, guint32 * tag, guint32 * size)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* gst_wavparse_calculate_duration:
|
* gst_wavparse_calculate_duration:
|
||||||
* @wav Wavparse object
|
* @wav: wavparse object
|
||||||
*
|
*
|
||||||
* Calculate duration on demand and store in @wav. Prefer bps, but use fact as a
|
* Calculate duration on demand and store in @wav. Prefer bps, but use fact as a
|
||||||
* fallback.
|
* fallback.
|
||||||
|
@ -1259,31 +1259,34 @@ gst_wavparse_stream_headers (GstWavParse * wav)
|
||||||
GST_DEBUG_OBJECT (wav, "datasize = %d", size);
|
GST_DEBUG_OBJECT (wav, "datasize = %d", size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GST_RIFF_TAG_fact:{
|
case GST_RIFF_TAG_fact:
|
||||||
/* number of samples (for compressed formats) */
|
if (wav->format != GST_RIFF_WAVE_FORMAT_MPEGL12 &&
|
||||||
if (wav->streaming) {
|
wav->format != GST_RIFF_WAVE_FORMAT_MPEGL3) {
|
||||||
const guint8 *data = NULL;
|
/* number of samples (for compressed formats) */
|
||||||
|
if (wav->streaming) {
|
||||||
|
const guint8 *data = NULL;
|
||||||
|
|
||||||
if (gst_adapter_available (wav->adapter) < 8 + 4) {
|
if (gst_adapter_available (wav->adapter) < 8 + 4) {
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
}
|
||||||
|
gst_adapter_flush (wav->adapter, 8);
|
||||||
|
data = gst_adapter_peek (wav->adapter, 4);
|
||||||
|
wav->fact = GST_READ_UINT32_LE (data);
|
||||||
|
gst_adapter_flush (wav->adapter, 4);
|
||||||
|
} else {
|
||||||
|
gst_buffer_unref (buf);
|
||||||
|
if ((res =
|
||||||
|
gst_pad_pull_range (wav->sinkpad, wav->offset + 8, 4,
|
||||||
|
&buf)) != GST_FLOW_OK)
|
||||||
|
goto header_read_error;
|
||||||
|
wav->fact = GST_READ_UINT32_LE (GST_BUFFER_DATA (buf));
|
||||||
|
gst_buffer_unref (buf);
|
||||||
}
|
}
|
||||||
gst_adapter_flush (wav->adapter, 8);
|
GST_DEBUG_OBJECT (wav, "have fact %u", wav->fact);
|
||||||
data = gst_adapter_peek (wav->adapter, 4);
|
wav->offset += 8 + 4;
|
||||||
wav->fact = GST_READ_UINT32_LE (data);
|
break;
|
||||||
gst_adapter_flush (wav->adapter, 4);
|
|
||||||
} else {
|
|
||||||
gst_buffer_unref (buf);
|
|
||||||
if ((res =
|
|
||||||
gst_pad_pull_range (wav->sinkpad, wav->offset + 8, 4,
|
|
||||||
&buf)) != GST_FLOW_OK)
|
|
||||||
goto header_read_error;
|
|
||||||
wav->fact = GST_READ_UINT32_LE (GST_BUFFER_DATA (buf));
|
|
||||||
gst_buffer_unref (buf);
|
|
||||||
}
|
}
|
||||||
GST_DEBUG_OBJECT (wav, "have fact %u", wav->fact);
|
/* fall-through */
|
||||||
wav->offset += 8 + 4;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
if (wav->streaming) {
|
if (wav->streaming) {
|
||||||
if (!gst_wavparse_peek_chunk (wav, &tag, &size))
|
if (!gst_wavparse_peek_chunk (wav, &tag, &size))
|
||||||
|
@ -1875,14 +1878,15 @@ gst_wavparse_pad_convert (GstPad * pad,
|
||||||
"src=%" G_GINT64_FORMAT ", offset=%" G_GINT64_FORMAT, src_value,
|
"src=%" G_GINT64_FORMAT ", offset=%" G_GINT64_FORMAT, src_value,
|
||||||
wavparse->offset);
|
wavparse->offset);
|
||||||
if (wavparse->bps > 0)
|
if (wavparse->bps > 0)
|
||||||
*dest_value = gst_util_uint64_scale (src_value, GST_SECOND,
|
*dest_value = uint64_ceiling_scale (src_value, GST_SECOND,
|
||||||
(guint64) wavparse->bps);
|
(guint64) wavparse->bps);
|
||||||
else {
|
else if (wavparse->fact) {
|
||||||
guint64 bps = gst_util_uint64_scale_int (wavparse->datasize,
|
guint64 bps = uint64_ceiling_scale_int (wavparse->datasize,
|
||||||
wavparse->rate, wavparse->fact);
|
wavparse->rate, wavparse->fact);
|
||||||
|
|
||||||
*dest_value =
|
*dest_value = uint64_ceiling_scale_int (src_value, GST_SECOND, bps);
|
||||||
gst_util_uint64_scale_int (src_value, GST_SECOND, bps);
|
} else {
|
||||||
|
res = FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -2003,18 +2007,15 @@ gst_wavparse_pad_query (GstPad * pad, GstQuery * query)
|
||||||
}
|
}
|
||||||
case GST_QUERY_DURATION:
|
case GST_QUERY_DURATION:
|
||||||
{
|
{
|
||||||
gint64 duration;
|
gint64 duration = 0;
|
||||||
GstFormat format;
|
GstFormat format;
|
||||||
|
|
||||||
gst_query_parse_duration (query, &format, NULL);
|
gst_query_parse_duration (query, &format, NULL);
|
||||||
|
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case GST_FORMAT_TIME:{
|
case GST_FORMAT_TIME:{
|
||||||
if (gst_wavparse_calculate_duration (wav)) {
|
if ((res = gst_wavparse_calculate_duration (wav))) {
|
||||||
duration = wav->duration;
|
duration = wav->duration;
|
||||||
} else {
|
|
||||||
format = GST_FORMAT_BYTES;
|
|
||||||
duration = wav->datasize;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue