Remember parsed comments from the OpusTags header in
an array member variable. Add a method to generate
the nsHTMLMediaElement::MetadataTags hash table from
those entries, performing the same validatation we
do for Vorbis.
This feature is tested by adding the existing opus
test file to gMetadataTests.
IsValidVorbisTagName is moved to a static method
on nsOggCodecState so it can be shared among the
subclasses and easily called externally.
MetadataTags generation for Vorbis streams is moved
to the same method name on nsVorbisState to allow
sharing of the parsing and validation code as much
as possible, since both formats use the same scheme.
It's arguable whether contrustuction better belongs to
nsOggReader or to the nsCodecState subclasses, since in
theory the various multiplexed streams interact in
determining the canonical tag list, but it is the
per-codec streams which contain the metadata in Ogg.
Return PL_DHASH_STOP if JS_SetProperty fails, and check
the return code of the enumerator to propagate the failure
back to javascript through the return value of mozGetMetadata.
In addition, use JS_DefineProperty in mozGetMetadata so
web content can't intercept and alter our creation calls.
JS_SetProperty() will define a new property if it doesn't
exist, but it will also call any existing setters, in
particular those on Object.prototype. This is confusing
for an object that created by a platform object method
from internal data.
Bug 748144 switched our opus decoding to use the
opus_multistream api so we could handle surround
audio files. The version of opus in our tree at
the time didn't include extern "C" {} protection
in the corresponding header, so we had to provide
our own.
With the update to the opus 1.0.0 source release
in bug 790381, this oversight is corrected and
we can remove our work-around.
Add a new test file with some invalid comments and verify
they are filtered out of the mozGetMetadata() output.
The new file includes the following valid edge cases:
- empty tag name
- empty tag value
- punctuation in the tag name
and the following invalid cases:
- non-ascii tag name
- invalid characters in tag name
- non-utf-8 tag value
- no tag=value separator
Also updates the mochitest messages to be less confusing.
Verify that tag names are ASCII within the valid character
ranges and that values are UTF-8, skipping comments where
these checks fail.
As written, the check in IsValidVorbisTagName() for the
separator character isn't necessary, because we've already
split on the first occurance. However, it's better to run
the extra check in case the function is reused elsewhere.