Implements a media.mozGetMetadata() method returning a new javascript object whose properties are key value pairs respresenting metadata tags from the media resource. This data is available after readystate enters METADATA_LOADED.
Currently this is only implemented for Ogg Vorbis streams.
Media format metadata is parsed out by the media decoders. In the nsCodecStateMachine::ReadMetadata subclasses we fill in an nsDataHashtable pointer using the format-specifc api.
The hash pointer is passed up to the media element as part of the MetadataLoaded event.
The hash is deleted if the load is aborted. The audio metadata is also reset to zero (as in the constructor), resolving a todo comment.
nsOggReader::RangeEndTime() relied on CRC values from valid ogg
pages to keep track of already-searched data when looking for a
end timestamp. This caused quadratic behaviour searching in a
section of a file with no valid pages.
Instead, remember where we last looked, and backoff immediately
if we go more than the maximum length of a page into previously
scanned data. This avoids searching data we've eliminated as
containing valid Ogg pages and lets us search backward with O(N)
instead.
We trim the initial few samples out of the opus decoder,
to give the output time to converge, and to correct for
the encoding delay. Encoders store the delay in the preskip
field of the Ogg encapsulation header.
The previous code to do this was a hack based on the granulepos
values and could fail on some inputs. Instead, keep a count
of how many samples we want to trip, and remove packet data
until that value matches the preskip value from the header.
The value is set to the preskip value from the header when
the decoder is initialized. We also need to do this after
seek. To do this we add a specialized nsOggReader::ResetDecode
method which takes a boolean argument, set to true when
we are seeking to the start of the stream. In that case,
the method resets the skip count.
There is still an issue after general seeks. The spec recommends
trimming a full 80 ms (3840 frames) to allow the decoder to fully
settle from the previous state. It's tricky to do this inside
nsOpusState because it doesn't know where it is in the stream.
Also add some debug output to track the decode behaviour.
Parse and decode Opus streams embedded in the Ogg
container. Based on the draft specification from
https://wiki.xiph.org/OggOpus
Support is conditional on the runtime preference
setting media.opus.enabled, which is false by
default until we're confident the spec is stable
and useful.
This patch doesn't support the gain header or
multichannel files.
The LEUint*() functions from the skeleton parser
are used to read the multi-byte header fields.
This requires moving them to earlier in the file.
Mappings for the .opus filename extension are also
added to facilitate testing with local files.