Chromium Code Reviews| Index: media/formats/webm/webm_cluster_parser.h |
| diff --git a/media/formats/webm/webm_cluster_parser.h b/media/formats/webm/webm_cluster_parser.h |
| index 2af102eaa0ce58b28909a6aa15fffd1bdbe4ed00..f3d5541ec516da8e2eeba89d4d3b2c5f1d5ff0b6 100644 |
| --- a/media/formats/webm/webm_cluster_parser.h |
| +++ b/media/formats/webm/webm_cluster_parser.h |
| @@ -11,6 +11,7 @@ |
| #include <string> |
| #include "base/memory/scoped_ptr.h" |
| +#include "media/base/audio_decoder_config.h" |
| #include "media/base/media_export.h" |
| #include "media/base/media_log.h" |
| #include "media/base/stream_parser.h" |
| @@ -35,6 +36,17 @@ class MEDIA_EXPORT WebMClusterParser : public WebMParserClient { |
| kDefaultVideoBufferDurationInMs = 42 // Low 24fps to reduce stalls |
| }; |
| + // Opus packets encode the duration and other parameters in the 5 most |
|
wolenetz
2015/01/30 01:48:08
move to impl. drop last ','
chcunningham
2015/02/03 20:34:43
Done.
|
| + // significant bits of the first byte. The index in this array corresponds |
| + // to the duration of each frame of the packet in microseconds. See |
| + // http://goo.gl/2RmoxA |
| + const uint16 kOpusFrameDurationsMu[32] = { |
| + 10000, 20000, 40000, 60000, 10000, 20000, 40000, 60000, |
| + 10000, 20000, 40000, 60000, 10000, 20000, 10000, 20000, |
| + 2500, 5000, 10000, 20000, 2500, 5000, 10000, 20000, |
| + 2500, 5000, 10000, 20000, 2500, 5000, 10000, 20000, |
| + }; |
| + |
| private: |
| // Helper class that manages per-track state. |
| class Track { |
| @@ -143,6 +155,7 @@ class MEDIA_EXPORT WebMClusterParser : public WebMParserClient { |
| const std::set<int64>& ignored_tracks, |
| const std::string& audio_encryption_key_id, |
| const std::string& video_encryption_key_id, |
| + const AudioDecoderConfig& audio_config, |
| const LogCB& log_cb); |
| ~WebMClusterParser() override; |
| @@ -227,11 +240,24 @@ class MEDIA_EXPORT WebMClusterParser : public WebMParserClient { |
| // if that track num is not a text track. |
| Track* FindTextTrack(int track_num); |
| + // Attempts to read the duration from the encoded audio data, storing output |
| + // in |duration| in microseconds. This obviously violates layering rules, but |
| + // is useful for MSE to know duration in cases where it isn't explicitly given |
| + // and cannot be calculated when for Blocks at the end of a Cluster (The next |
|
wolenetz
2015/01/30 01:48:08
nits: grammar (when for), un-cap (The
chcunningham
2015/02/03 20:34:43
Done.
|
| + // Cluster in playback-order may not be the next Cluster we parse, so we can't |
| + // simply use the delta of the first Block in the next Cluster). Avoid calling |
| + // if encrypted; may produce unexpected output. See implementation for |
| + // supported codecs. |
| + bool TryGetEncodedAudioDuration(const uint8* data, int size, int64* duration); |
|
wolenetz
2015/01/30 01:48:08
What is bool retval?
chcunningham
2015/02/03 20:34:43
Now base::TimeDelta
|
| + // Reads Opus packet header to determine packet duration. |
|
wolenetz
2015/01/30 01:48:08
nit: insert blank link prior.
chcunningham
2015/02/03 20:34:43
Done.
|
| + bool ReadOpusDuration(const uint8* data, int size, int64* duration); |
| + |
| double timecode_multiplier_; // Multiplier used to convert timecodes into |
| // microseconds. |
| std::set<int64> ignored_tracks_; |
| std::string audio_encryption_key_id_; |
| std::string video_encryption_key_id_; |
| + const AudioDecoderConfig& audio_config_; |
|
wolenetz
2015/01/30 01:48:08
Do we need the whole config? Or just some specific
chcunningham
2015/02/03 20:34:43
Done. Now just taking in the codec.
|
| WebMListParser parser_; |