The correct basis for (Xing, VBRI) seek table calculations is the
byte size and duration provided by that metadata, rather than some
other (possibly even estimated) one. This also prevents an infinite
conversion loop in (unlikely) case where a TOC is provided without
such corresponding (duration) metdata.
Use the same strategy as accurate seeks to store
pending non-accurate seeks to avoid overwriting non-definite
stop times. When doing non-accurate seeks our position
reporting might drift off by some secs and the stream can
end up before it should.
Fixes#603695
Fixes#598761
This removes a good 50% of processing time for parsing a buffer.
We do this by simply... getting the nicks that we already have handy
instead of going through the expensive glib system.
Previously, we could get false sync relatively easily - it sometimes happened
on real files. This cleans the code up a fair bit, and makes it require more
confirmation that we've found valid sync before continuing.
Metadata provided seek tables are consistent with metadata's view of
total size, which typically matches real size, but need not do so
(e.g. a truncated file). Fixes seeking and position reporting
in such truncated files (although duration based on metadata may then
still be incorrect).
Let's not put every single mp3 frame in our index, a few frames per
second should be more than enough. For now use an index interval
of 100ms-500ms depending on the upstream size, to keep the index at
a reasonable size. Factor out the code that adds the index entry
into a separate function for better code readability.
While technically upstream may be seekable even if it doesn't know
the exact size, I can't think of a use case where this distincation
is relevant in practice, so for now just assume we're not seekable
if upstream doesn't provide us with a size. Makes sure we don't
build a seek index when streaming internet radio with sources that
pretend to be seekable until you try to actually seek.
Some Xing headers apparently start the TOC at byte 1 instead of 0. Don't
reject them because of it, just subtract the initial offset when reading
the table.
Be more lenient about what we accept as changing bits in a header - basically,
only require that the mp3 sync marker is present, for the mpeg version,
layer and samplerate.
Fixes: #581464
Some mp3 streams have an offset in timestamps, requiring us to push the
frame *AFTER* segment.stop in order for the decoder to be able to push
all data up to the segment.stop position.
Don't introduce glitches in the output by a) relaxing the threshold for
taking upstream timestamps in preference to our calculated timestamps and
b) only set the discont flag on outgoing buffers in response to an incoming
discont buffer.
Fixes: #575046
Don't allow a change in sample rate/channels/layer/version unless we can
see another frame at the correct offset. Prevents accidently flipping
due to simple single-bit corruption.
Since SEEK event handling might perform some conversion
from TIME to BYTES, do not let upstream fool application
into (TIME) seeking not being possible.
Integer underflow made accurate seeks to near zero fail and seek to
completely the wrong place. Fix by clamping to zero, since we can't seek
to negative times anyway.
Original commit message from CVS:
* gst/mpegaudioparse/gstmpegaudioparse.c: (channel_mode_class),
(GST_TYPE_MP3_CHANNEL_MODE), (mp3_type_frame_length_from_header),
(gst_mp3parse_emit_frame), (mp3parse_get_query_types):
* gst/mpegaudioparse/gstmpegaudioparse.h:
Do an initial class_ref on an internal enum type from within the
class_init function so that there aren't any issues when multiple
mp3parse elements are started in separate threads at the same
time. (Why we use an enum type here if the tag is registered as
a string type, I don't know). Also remove custom UNUSED macro
and use GLib's instead.
Original commit message from CVS:
* gst/mpegaudioparse/gstmpegaudioparse.c:
Calculate samples per frame correctly for "MPEG 2.5" layer 3.
Fixes skipping on these files.
Original commit message from CVS:
* gst/mpegaudioparse/gstmpegaudioparse.c:
(gst_mp3parse_sink_event):
Post a GST_ELEMENT_ERROR if we get EOS before seeing any valid
frames. Partially fixes bug #552237.
Original commit message from CVS:
* gst/mpegaudioparse/gstmpegaudioparse.c:
(gst_mp3parse_sink_event), (gst_mp3parse_emit_frame),
(mp3parse_total_time), (mp3parse_bytepos_to_time):
Don't recurse from mp3parse_bytepos_to_time() to mp3parse_total_time()
if we're called from there already. Otherwise we end up in a endless
recursion and crash with a stack overflow.
This can happen when a Xing or VBRI header with TOC exists but it
doesn't contain the total time. Fixes bug #545370.
Original commit message from CVS:
* ext/lame/gstlame.c: (gst_lame_sink_setcaps):
* gst/mpegaudioparse/gstmpegaudioparse.c:
(mp3_type_frame_length_from_header), (mp3_caps_create),
(gst_mp3parse_chain):
Put the MPEG audio version into the caps as "mpegaudioversion".
This is different from "mpegversion".
Original commit message from CVS:
* docs/plugins/gst-plugins-ugly-plugins-docs.sgml:
* docs/plugins/gst-plugins-ugly-plugins-sections.txt:
* ext/a52dec/gsta52dec.c:
* ext/amrnb/amrnbdec.c:
* ext/amrnb/amrnbenc.c:
* ext/amrnb/amrnbparse.c:
* ext/lame/gstlame.c:
* ext/mad/gstmad.c:
* ext/sidplay/gstsiddec.cc:
* gst/asfdemux/gstrtspwms.c:
* gst/mpegaudioparse/gstxingmux.c:
* gst/realmedia/rademux.c:
* gst/realmedia/rdtmanager.c:
* gst/realmedia/rtspreal.c:
* gst/synaesthesia/gstsynaesthesia.c:
Add missing elements to docs. Restore alphabetical order in section
file. Document mad (it was included in docs already).
Fix doc-markup: use convinience syntax for examples
(produces valid docbook), add several refsec2 when we have several
titles. Fix some types.
Original commit message from CVS:
* ext/lame/gstlame.c:
* ext/sidplay/gstsiddec.cc:
* gst/mpegaudioparse/gstxingmux.c:
Do not use short_description in section docs for elements. We extract
them from element details and there will be warnings if they differ.
Original commit message from CVS:
* gst/mpegaudioparse/gstmpegaudioparse.c: (head_check):
Don't mark MPEG headers with emphasis == 0x2 as invalid. This
emphasis value is reserved but unfortunately files with that
value exist and the information is not important for the decoder
anyway. Fixes bug #537235.
Original commit message from CVS:
* gst/mpegaudioparse/gstxingmux.c: (generate_xing_header):
Fix alignment issues that caused SIGBUS on some architectures.