Bug 831224: Remove trailing whitespaces, r=padenot
Bug 831224: Added MP3 frame parser, r=padenot

MP3 streams consist of small frames, with each frame containing the
audio data of a few hundred milliseconds. The actual duration of the
encoded audio can among frames.

Each frame consists of a 4-byte frame header, some optional extra
information, and the audio data. The MP3 frame parser walks over the
content of an MP3 stream, computes the duration of each frame from
the frame header, and sums them up to the streams complete duration.

The MP3 frame parser does not decode the actual audio data.
Bug 831224: Allow update of the media duration, r=padenot

With MP3 streams, the media duration might change after we received
new data. This patch adds infrastructure to signal the new duration
to the media decoder and state machine. It will also fire an event
of type 'durationchange' to the DOM.
Bug 831224: Parse MP3 frame headers in OmxDecoder, r=padenot

On FirefoxOS, the Android libraries estimate the duration of MP3 streams
by examining the first MP3 frame header. This only works for streams with
constant bit rate. For streams with variable bit rate, a too short or too
long duration is computed.

This patch adds support for parsing MP3 frame headers. The decoder handles
file streams by reading them at once at the beginning and parsing them
immediately. Network streams are updated when a new fragment arrives.
Bug 831224: Use multi-threaded I/O for reading and processing MP3 frames, r=padenot

Reading large MP3 files from a slow medium, such as an SD card, takes
several seconds. This is too long for interactive applications like the
music app.

With this patch, the OmxDecoder reads large MP3 file in smaller chunks
and hands over each chunk individually to the MP3 parser. Reading the
file is done in the I/O thread, which is allowed to block, parsing is
done on the main thread.

The current chunk size is 8 MiB, which is small enough to not cause any
delay.
Bug 831224: Added mochitest for variable-bitrate MP3s, r=padenot

The test checks the duration of an MP3 file with variable bitrate. The
MP3 file only contains silence. It uses a high bit-rate encoding for its
first half, a low bit-rate encoding for its second half. The correct
duration is 10 seconds, but an incorrect implementation will return a
much shorter value.