diff options
author | rouslan@chromium.org <rouslan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-15 18:36:58 +0000 |
---|---|---|
committer | rouslan@chromium.org <rouslan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-15 18:36:58 +0000 |
commit | 2b3bcfd5fcc68872386631a88053f9fd8153a631 (patch) | |
tree | 5bf4723428e7a21b2ed9b38a5318cfd735bab587 /media | |
parent | eecd1253ee681af7d91346a03b09901ef653e688 (diff) | |
download | chromium_src-2b3bcfd5fcc68872386631a88053f9fd8153a631.zip chromium_src-2b3bcfd5fcc68872386631a88053f9fd8153a631.tar.gz chromium_src-2b3bcfd5fcc68872386631a88053f9fd8153a631.tar.bz2 |
Revert 200308 "Parse WebM track name and language"
> Parse WebM track name and language
>
> The Track header of a WebM file contains (among other items)
> a track name and track language. We do not currently use
> this information. However, it is needed to contruct WebVTT
> inband text tracks. The WebM tracks parser has been
> modified to provide this information to its clients.
>
> BUG=230708
>
> Review URL: https://chromiumcodereview.appspot.com/14977006
TBR=matthewjheaney@chromium.org
Review URL: https://codereview.chromium.org/14959015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200323 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/media.gyp | 4 | ||||
-rw-r--r-- | media/webm/tracks_builder.cc | 212 | ||||
-rw-r--r-- | media/webm/tracks_builder.h | 56 | ||||
-rw-r--r-- | media/webm/webm_cluster_parser.cc | 6 | ||||
-rw-r--r-- | media/webm/webm_cluster_parser.h | 3 | ||||
-rw-r--r-- | media/webm/webm_cluster_parser_unittest.cc | 42 | ||||
-rw-r--r-- | media/webm/webm_constants.cc | 14 | ||||
-rw-r--r-- | media/webm/webm_constants.h | 14 | ||||
-rw-r--r-- | media/webm/webm_tracks_parser.cc | 40 | ||||
-rw-r--r-- | media/webm/webm_tracks_parser.h | 17 | ||||
-rw-r--r-- | media/webm/webm_tracks_parser_unittest.cc | 93 |
11 files changed, 33 insertions, 468 deletions
diff --git a/media/media.gyp b/media/media.gyp index 7369c08a..089778c 100644 --- a/media/media.gyp +++ b/media/media.gyp @@ -429,7 +429,6 @@ 'webm/webm_audio_client.h', 'webm/webm_cluster_parser.cc', 'webm/webm_cluster_parser.h', - 'webm/webm_constants.cc', 'webm/webm_constants.h', 'webm/webm_content_encodings.cc', 'webm/webm_content_encodings.h', @@ -996,12 +995,9 @@ 'video/capture/video_capture_device_unittest.cc', 'webm/cluster_builder.cc', 'webm/cluster_builder.h', - 'webm/tracks_builder.cc', - 'webm/tracks_builder.h', 'webm/webm_cluster_parser_unittest.cc', 'webm/webm_content_encodings_client_unittest.cc', 'webm/webm_parser_unittest.cc', - 'webm/webm_tracks_parser_unittest.cc', ], 'conditions': [ ['arm_neon == 1', { diff --git a/media/webm/tracks_builder.cc b/media/webm/tracks_builder.cc deleted file mode 100644 index c5b3e74..0000000 --- a/media/webm/tracks_builder.cc +++ /dev/null @@ -1,212 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "media/webm/tracks_builder.h" - -#include "media/webm/webm_constants.h" - -namespace media { - -// Returns size of an integer, formatted using Matroska serialization. -static int GetUIntMkvSize(uint64 value) { - if (value < 0x07F) - return 1; - if (value < 0x03FFF) - return 2; - if (value < 0x01FFFFF) - return 3; - if (value < 0x0FFFFFFF) - return 4; - if (value < 0x07FFFFFFFF) - return 5; - if (value < 0x03FFFFFFFFFF) - return 6; - if (value < 0x01FFFFFFFFFFFF) - return 7; - return 8; -} - -// Returns the minimium size required to serialize an integer value. -static int GetUIntSize(uint64 value) { - if (value < 0x0100) - return 1; - if (value < 0x010000) - return 2; - if (value < 0x01000000) - return 3; - if (value < 0x0100000000) - return 4; - if (value < 0x010000000000) - return 5; - if (value < 0x01000000000000) - return 6; - if (value < 0x0100000000000000) - return 7; - return 8; -} - -static int MasterElementSize(int element_id, int payload_size) { - return GetUIntSize(element_id) + GetUIntMkvSize(payload_size) + payload_size; -} - -static int IntElementSize(int element_id, int value) { - return GetUIntSize(element_id) + 1 + GetUIntSize(value); -} - -static int StringElementSize(int element_id, const std::string& value) { - return GetUIntSize(element_id) + - GetUIntMkvSize(value.length()) + - value.length(); -} - -static void SerializeInt(uint8** buf_ptr, int* buf_size_ptr, - int64 value, int size) { - uint8*& buf = *buf_ptr; - int& buf_size = *buf_size_ptr; - - for (int idx = 1; idx <= size; ++idx) { - *buf++ = static_cast<uint8>(value >> ((size - idx) * 8)); - --buf_size; - } -} - -static void WriteElementId(uint8** buf, int* buf_size, int element_id) { - SerializeInt(buf, buf_size, element_id, GetUIntSize(element_id)); -} - -static void WriteUInt(uint8** buf, int* buf_size, uint64 value) { - const int size = GetUIntMkvSize(value); - value |= (1ULL << (size * 7)); // Matroska formatting - SerializeInt(buf, buf_size, value, size); -} - -static void WriteMasterElement(uint8** buf, int* buf_size, - int element_id, int payload_size) { - WriteElementId(buf, buf_size, element_id); - WriteUInt(buf, buf_size, payload_size); -} - -static void WriteIntElement(uint8** buf, int* buf_size, - int element_id, int value) { - WriteElementId(buf, buf_size, element_id); - - const int size = GetUIntSize(value); - WriteUInt(buf, buf_size, size); - - SerializeInt(buf, buf_size, value, size); -} - -static void WriteStringElement(uint8** buf_ptr, int* buf_size_ptr, - int element_id, const std::string& value) { - uint8*& buf = *buf_ptr; - int& buf_size = *buf_size_ptr; - - WriteElementId(&buf, &buf_size, element_id); - - const uint64 size = value.length(); - WriteUInt(&buf, &buf_size, size); - - memcpy(buf, value.data(), size); - buf += size; - buf_size -= size; -} - -TracksBuilder::TracksBuilder() {} -TracksBuilder::~TracksBuilder() {} - -void TracksBuilder::AddTrack( - int track_num, - int track_type, - const std::string& codec_id, - const std::string& name, - const std::string& language) { - tracks_.push_back(Track(track_num, track_type, codec_id, name, language)); -} - -std::vector<uint8> TracksBuilder::Finish() { - // Allocate the storage - std::vector<uint8> buffer; - buffer.resize(GetTracksSize()); - - // Populate the storage with a tracks header - WriteTracks(&buffer[0], buffer.size()); - - return buffer; -} - -int TracksBuilder::GetTracksSize() const { - return MasterElementSize(kWebMIdTracks, GetTracksPayloadSize()); -} - -int TracksBuilder::GetTracksPayloadSize() const { - int payload_size = 0; - - for (TrackList::const_iterator itr = tracks_.begin(); - itr != tracks_.end(); ++itr) { - payload_size += itr->GetSize(); - } - - return payload_size; -} - -void TracksBuilder::WriteTracks(uint8* buf, int buf_size) const { - WriteMasterElement(&buf, &buf_size, kWebMIdTracks, GetTracksPayloadSize()); - - for (TrackList::const_iterator itr = tracks_.begin(); - itr != tracks_.end(); ++itr) { - itr->Write(&buf, &buf_size); - } -} - -TracksBuilder::Track::Track(int track_num, int track_type, - const std::string& codec_id, - const std::string& name, - const std::string& language) - : track_num_(track_num), - track_type_(track_type), - codec_id_(codec_id), - name_(name), - language_(language) { -} - -int TracksBuilder::Track::GetSize() const { - return MasterElementSize(kWebMIdTrackEntry, GetPayloadSize()); -} - -int TracksBuilder::Track::GetPayloadSize() const { - int size = 0; - - size += IntElementSize(kWebMIdTrackNumber, track_num_); - size += IntElementSize(kWebMIdTrackType, track_type_); - - if (!codec_id_.empty()) - size += StringElementSize(kWebMIdCodecID, codec_id_); - - if (!name_.empty()) - size += StringElementSize(kWebMIdName, name_); - - if (!language_.empty()) - size += StringElementSize(kWebMIdLanguage, language_); - - return size; -} - -void TracksBuilder::Track::Write(uint8** buf, int* buf_size) const { - WriteMasterElement(buf, buf_size, kWebMIdTrackEntry, GetPayloadSize()); - - WriteIntElement(buf, buf_size, kWebMIdTrackNumber, track_num_); - WriteIntElement(buf, buf_size, kWebMIdTrackType, track_type_); - - if (!codec_id_.empty()) - WriteStringElement(buf, buf_size, kWebMIdCodecID, codec_id_); - - if (!name_.empty()) - WriteStringElement(buf, buf_size, kWebMIdName, name_); - - if (!language_.empty()) - WriteStringElement(buf, buf_size, kWebMIdLanguage, language_); -} - -} // namespace media - diff --git a/media/webm/tracks_builder.h b/media/webm/tracks_builder.h deleted file mode 100644 index 87ceaed..0000000 --- a/media/webm/tracks_builder.h +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef MEDIA_WEBM_TRACKS_BUILDER_H_ -#define MEDIA_WEBM_TRACKS_BUILDER_H_ - -#include <list> -#include <string> -#include <vector> - -#include "base/basictypes.h" - -namespace media { - -class TracksBuilder { - public: - TracksBuilder(); - ~TracksBuilder(); - - void AddTrack(int track_num, int track_type, const std::string& codec_id, - const std::string& name, const std::string& language); - - std::vector<uint8> Finish(); - - private: - int GetTracksSize() const; - int GetTracksPayloadSize() const; - void WriteTracks(uint8* buffer, int buffer_size) const; - - class Track { - public: - Track(int track_num, int track_type, const std::string& codec_id, - const std::string& name, const std::string& language); - - int GetSize() const; - void Write(uint8** buf, int* buf_size) const; - private: - int GetPayloadSize() const; - - int track_num_; - int track_type_; - std::string codec_id_; - std::string name_; - std::string language_; - }; - - typedef std::list<Track> TrackList; - TrackList tracks_; - - DISALLOW_COPY_AND_ASSIGN(TracksBuilder); -}; - -} // namespace media - -#endif // MEDIA_WEBM_TRACKS_BUILDER_H_ diff --git a/media/webm/webm_cluster_parser.cc b/media/webm/webm_cluster_parser.cc index ec89b67..1d47720 100644 --- a/media/webm/webm_cluster_parser.cc +++ b/media/webm/webm_cluster_parser.cc @@ -48,7 +48,7 @@ bool WebMClusterParser::TextTrackIterator::operator()( WebMClusterParser::WebMClusterParser( int64 timecode_scale, int audio_track_num, int video_track_num, - const WebMTracksParser::TextTracks& text_tracks, + const std::set<int>& text_tracks, const std::set<int64>& ignored_tracks, const std::string& audio_encryption_key_id, const std::string& video_encryption_key_id, @@ -67,10 +67,10 @@ WebMClusterParser::WebMClusterParser( audio_(audio_track_num, false), video_(video_track_num, true), log_cb_(log_cb) { - for (WebMTracksParser::TextTracks::const_iterator it = text_tracks.begin(); + for (std::set<int>::const_iterator it = text_tracks.begin(); it != text_tracks.end(); ++it) { - text_track_map_.insert(std::make_pair(it->first, Track(it->first, false))); + text_track_map_.insert(std::make_pair(*it, Track(*it, false))); } } diff --git a/media/webm/webm_cluster_parser.h b/media/webm/webm_cluster_parser.h index 63d8626..62cbde1 100644 --- a/media/webm/webm_cluster_parser.h +++ b/media/webm/webm_cluster_parser.h @@ -15,7 +15,6 @@ #include "media/base/media_log.h" #include "media/base/stream_parser_buffer.h" #include "media/webm/webm_parser.h" -#include "media/webm/webm_tracks_parser.h" namespace media { @@ -75,7 +74,7 @@ class MEDIA_EXPORT WebMClusterParser : public WebMParserClient { WebMClusterParser(int64 timecode_scale, int audio_track_num, int video_track_num, - const WebMTracksParser::TextTracks& text_tracks, + const std::set<int>& text_tracks, const std::set<int64>& ignored_tracks, const std::string& audio_encryption_key_id, const std::string& video_encryption_key_id, diff --git a/media/webm/webm_cluster_parser_unittest.cc b/media/webm/webm_cluster_parser_unittest.cc index cea97e5..baa35f2 100644 --- a/media/webm/webm_cluster_parser_unittest.cc +++ b/media/webm/webm_cluster_parser_unittest.cc @@ -206,7 +206,7 @@ class WebMClusterParserTest : public testing::Test { : parser_(new WebMClusterParser(kTimecodeScale, kAudioTrackNum, kVideoTrackNum, - WebMTracksParser::TextTracks(), + std::set<int>(), std::set<int64>(), std::string(), std::string(), @@ -338,7 +338,7 @@ TEST_F(WebMClusterParserTest, IgnoredTracks) { parser_.reset(new WebMClusterParser(kTimecodeScale, kAudioTrackNum, kVideoTrackNum, - WebMTracksParser::TextTracks(), + std::set<int>(), ignored_tracks, std::string(), std::string(), @@ -372,13 +372,8 @@ TEST_F(WebMClusterParserTest, IgnoredTracks) { } TEST_F(WebMClusterParserTest, ParseTextTracks) { - typedef WebMTracksParser::TextTracks TextTracks; - TextTracks text_tracks; - WebMTracksParser::TextTrackInfo text_track_info; - - text_track_info.kind = kTextSubtitles; - text_tracks.insert(std::make_pair(TextTracks::key_type(kTextTrackNum), - text_track_info)); + std::set<int> text_tracks; + text_tracks.insert(kTextTrackNum); parser_.reset(new WebMClusterParser(kTimecodeScale, kAudioTrackNum, @@ -409,13 +404,8 @@ TEST_F(WebMClusterParserTest, ParseTextTracks) { } TEST_F(WebMClusterParserTest, TextTracksSimpleBlock) { - typedef WebMTracksParser::TextTracks TextTracks; - TextTracks text_tracks; - WebMTracksParser::TextTrackInfo text_track_info; - - text_track_info.kind = kTextSubtitles; - text_tracks.insert(std::make_pair(TextTracks::key_type(kTextTrackNum), - text_track_info)); + std::set<int> text_tracks; + text_tracks.insert(kTextTrackNum); parser_.reset(new WebMClusterParser(kTimecodeScale, kAudioTrackNum, @@ -439,20 +429,14 @@ TEST_F(WebMClusterParserTest, TextTracksSimpleBlock) { } TEST_F(WebMClusterParserTest, ParseMultipleTextTracks) { - typedef WebMTracksParser::TextTracks TextTracks; - TextTracks text_tracks; - WebMTracksParser::TextTrackInfo text_track_info; + typedef std::set<int> TextTrackSet; + TextTrackSet text_tracks; const int kSubtitleTextTrackNum = kTextTrackNum; const int kCaptionTextTrackNum = kTextTrackNum + 1; - text_track_info.kind = kTextSubtitles; - text_tracks.insert(std::make_pair(TextTracks::key_type(kSubtitleTextTrackNum), - text_track_info)); - - text_track_info.kind = kTextCaptions; - text_tracks.insert(std::make_pair(TextTracks::key_type(kCaptionTextTrackNum), - text_track_info)); + text_tracks.insert(kSubtitleTextTrackNum); + text_tracks.insert(kCaptionTextTrackNum); parser_.reset(new WebMClusterParser(kTimecodeScale, kAudioTrackNum, @@ -488,7 +472,7 @@ TEST_F(WebMClusterParserTest, ParseMultipleTextTracks) { const WebMClusterParser::BufferQueue* text_buffers; while (text_it(&text_track_num, &text_buffers)) { - const WebMTracksParser::TextTracks::const_iterator find_result = + const TextTrackSet::const_iterator find_result = text_tracks.find(text_track_num); ASSERT_TRUE(find_result != text_tracks.end()); ASSERT_TRUE(VerifyTextBuffers(parser_, kInputBlockInfo, input_block_count, @@ -502,7 +486,7 @@ TEST_F(WebMClusterParserTest, ParseEncryptedBlock) { parser_.reset(new WebMClusterParser(kTimecodeScale, kAudioTrackNum, kVideoTrackNum, - WebMTracksParser::TextTracks(), + std::set<int>(), std::set<int64>(), std::string(), "video_key_id", @@ -521,7 +505,7 @@ TEST_F(WebMClusterParserTest, ParseBadEncryptedBlock) { parser_.reset(new WebMClusterParser(kTimecodeScale, kAudioTrackNum, kVideoTrackNum, - WebMTracksParser::TextTracks(), + std::set<int>(), std::set<int64>(), std::string(), "video_key_id", diff --git a/media/webm/webm_constants.cc b/media/webm/webm_constants.cc deleted file mode 100644 index 13ae086..0000000 --- a/media/webm/webm_constants.cc +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "media/webm/webm_constants.h" - -namespace media { - -const char kWebMCodecSubtitles[] = "D_WEBVTT/SUBTITLES"; -const char kWebMCodecCaptions[] = "D_WEBVTT/CAPTIONS"; -const char kWebMCodecDescriptions[] = "D_WEBVTT/DESCRIPTIONS"; -const char kWebMCodecMetadata[] = "D_WEBVTT/METADATA"; - -} // namespace media diff --git a/media/webm/webm_constants.h b/media/webm/webm_constants.h index 5cfd5e6..7e5e3b1 100644 --- a/media/webm/webm_constants.h +++ b/media/webm/webm_constants.h @@ -6,7 +6,6 @@ #define MEDIA_WEBM_WEBM_CONSTANTS_H_ #include "base/basictypes.h" -#include "media/base/media_export.h" namespace media { @@ -206,19 +205,6 @@ const uint8 kWebMFlagEncryptedFrame = 0x1; const int kWebMIvSize = 8; const int kWebMSignalByteSize = 1; -// Current specification for WebVTT embedded in WebM -// http://wiki.webmproject.org/webm-metadata/temporal-metadata/webvtt-in-webm - -const int kWebMTrackTypeVideo = 1; -const int kWebMTrackTypeAudio = 2; -const int kWebMTrackTypeSubtitlesOrCaptions = 0x11; -const int kWebMTrackTypeDescriptionsOrMetadata = 0x21; - -MEDIA_EXPORT extern const char kWebMCodecSubtitles[]; -MEDIA_EXPORT extern const char kWebMCodecCaptions[]; -MEDIA_EXPORT extern const char kWebMCodecDescriptions[]; -MEDIA_EXPORT extern const char kWebMCodecMetadata[]; - } // namespace media #endif // MEDIA_WEBM_WEBM_CONSTANTS_H_ diff --git a/media/webm/webm_tracks_parser.cc b/media/webm/webm_tracks_parser.cc index 4cf6f4a..7d11f69 100644 --- a/media/webm/webm_tracks_parser.cc +++ b/media/webm/webm_tracks_parser.cc @@ -12,17 +12,23 @@ namespace media { +// Values for TrackType element. +static const int kWebMTrackTypeVideo = 1; +static const int kWebMTrackTypeAudio = 2; +static const int kWebMTrackTypeSubtitlesOrCaptions = 0x11; +static const int kWebMTrackTypeDescriptionsOrMetadata = 0x21; + static TextKind CodecIdToTextKind(const std::string& codec_id) { - if (codec_id == kWebMCodecSubtitles) + if (codec_id == "D_WEBVTT/SUBTITLES") return kTextSubtitles; - if (codec_id == kWebMCodecCaptions) + if (codec_id == "D_WEBVTT/CAPTIONS") return kTextCaptions; - if (codec_id == kWebMCodecDescriptions) + if (codec_id == "D_WEBVTT/DESCRIPTIONS") return kTextDescriptions; - if (codec_id == kWebMCodecMetadata) + if (codec_id == "D_WEBVTT/METADATA") return kTextMetadata; return kTextNone; @@ -43,8 +49,6 @@ WebMTracksParser::~WebMTracksParser() {} int WebMTracksParser::Parse(const uint8* buf, int size) { track_type_ =-1; track_num_ = -1; - track_name_.clear(); - track_language_.clear(); audio_track_num_ = -1; audio_decoder_config_ = AudioDecoderConfig(); video_track_num_ = -1; @@ -73,8 +77,6 @@ WebMParserClient* WebMTracksParser::OnListStart(int id) { if (id == kWebMIdTrackEntry) { track_type_ = -1; track_num_ = -1; - track_name_.clear(); - track_language_.clear(); codec_id_ = ""; codec_private_.clear(); audio_client_.Reset(); @@ -113,9 +115,8 @@ bool WebMTracksParser::OnListEnd(int id) { return false; } - TextKind text_track_kind = kTextNone; if (track_type_ == kWebMTrackTypeSubtitlesOrCaptions) { - text_track_kind = CodecIdToTextKind(codec_id_); + TextKind text_track_kind = CodecIdToTextKind(codec_id_); if (text_track_kind == kTextNone) { MEDIA_LOG(log_cb_) << "Missing TrackEntry CodecID" << " TrackNum " << track_num_; @@ -129,7 +130,7 @@ bool WebMTracksParser::OnListEnd(int id) { return false; } } else if (track_type_ == kWebMTrackTypeDescriptionsOrMetadata) { - text_track_kind = CodecIdToTextKind(codec_id_); + TextKind text_track_kind = CodecIdToTextKind(codec_id_); if (text_track_kind == kTextNone) { MEDIA_LOG(log_cb_) << "Missing TrackEntry CodecID" << " TrackNum " << track_num_; @@ -185,10 +186,7 @@ bool WebMTracksParser::OnListEnd(int id) { } } else if (track_type_ == kWebMTrackTypeSubtitlesOrCaptions || track_type_ == kWebMTrackTypeDescriptionsOrMetadata) { - TextTrackInfo& text_track_info = text_tracks_[track_num_]; - text_track_info.kind = text_track_kind; - text_track_info.name = track_name_; - text_track_info.language = track_language_; + text_tracks_.insert(track_num_); } else { MEDIA_LOG(log_cb_) << "Unexpected TrackType " << track_type_; return false; @@ -196,8 +194,6 @@ bool WebMTracksParser::OnListEnd(int id) { track_type_ = -1; track_num_ = -1; - track_name_.clear(); - track_language_.clear(); codec_id_ = ""; codec_private_.clear(); track_content_encodings_client_.reset(); @@ -262,16 +258,6 @@ bool WebMTracksParser::OnString(int id, const std::string& str) { return true; } - if (id == kWebMIdName) { - track_name_ = str; - return true; - } - - if (id == kWebMIdLanguage) { - track_language_ = str; - return true; - } - return true; } diff --git a/media/webm/webm_tracks_parser.h b/media/webm/webm_tracks_parser.h index d5be6ce..79d8888 100644 --- a/media/webm/webm_tracks_parser.h +++ b/media/webm/webm_tracks_parser.h @@ -5,7 +5,6 @@ #ifndef MEDIA_WEBM_WEBM_TRACKS_PARSER_H_ #define MEDIA_WEBM_WEBM_TRACKS_PARSER_H_ -#include <map> #include <set> #include <string> #include <vector> @@ -23,7 +22,7 @@ namespace media { // Parser for WebM Tracks element. -class MEDIA_EXPORT WebMTracksParser : public WebMParserClient { +class WebMTracksParser : public WebMParserClient { public: explicit WebMTracksParser(const LogCB& log_cb); virtual ~WebMTracksParser(); @@ -55,15 +54,7 @@ class MEDIA_EXPORT WebMTracksParser : public WebMParserClient { return video_decoder_config_; } - struct TextTrackInfo { - TextKind kind; - std::string name; - std::string language; - }; - - typedef std::map<int64, TextTrackInfo> TextTracks; - - const TextTracks& text_tracks() const { + const std::set<int>& text_tracks() const { return text_tracks_; } @@ -78,15 +69,13 @@ class MEDIA_EXPORT WebMTracksParser : public WebMParserClient { int64 track_type_; int64 track_num_; - std::string track_name_; - std::string track_language_; std::string codec_id_; std::vector<uint8> codec_private_; scoped_ptr<WebMContentEncodingsClient> track_content_encodings_client_; int64 audio_track_num_; int64 video_track_num_; - TextTracks text_tracks_; + std::set<int> text_tracks_; std::set<int64> ignored_tracks_; std::string audio_encryption_key_id_; std::string video_encryption_key_id_; diff --git a/media/webm/webm_tracks_parser_unittest.cc b/media/webm/webm_tracks_parser_unittest.cc deleted file mode 100644 index 6d23669..0000000 --- a/media/webm/webm_tracks_parser_unittest.cc +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/logging.h" -#include "media/webm/tracks_builder.h" -#include "media/webm/webm_constants.h" -#include "media/webm/webm_tracks_parser.h" -#include "testing/gmock/include/gmock/gmock.h" -#include "testing/gtest/include/gtest/gtest.h" - -using ::testing::InSequence; -using ::testing::Return; -using ::testing::_; - -namespace media { - -static const int kTypeSubtitlesOrCaptions = 0x11; -static const int kTypeDescriptionsOrMetadata = 0x21; - -class WebMTracksParserTest : public testing::Test { - public: - WebMTracksParserTest() {} -}; - -static void VerifyTextTrackInfo(const uint8* buffer, - int buffer_size, - TextKind text_kind, - const std::string& name, - const std::string& language) { - scoped_ptr<WebMTracksParser> parser(new WebMTracksParser(LogCB())); - - int result = parser->Parse(buffer, buffer_size); - EXPECT_GT(result, 0); - EXPECT_EQ(result, buffer_size); - - const WebMTracksParser::TextTracks& text_tracks = parser->text_tracks(); - EXPECT_EQ(text_tracks.size(), WebMTracksParser::TextTracks::size_type(1)); - - const WebMTracksParser::TextTracks::const_iterator itr = text_tracks.begin(); - EXPECT_EQ(itr->first, 1); // track num - - const WebMTracksParser::TextTrackInfo& info = itr->second; - EXPECT_EQ(info.kind, text_kind); - EXPECT_TRUE(info.name == name); - EXPECT_TRUE(info.language == language); -} - -TEST_F(WebMTracksParserTest, TestSubtitleNoNameNoLang) { - InSequence s; - - TracksBuilder tb; - tb.AddTrack(1, kWebMTrackTypeSubtitlesOrCaptions, - kWebMCodecSubtitles, "", ""); - - const std::vector<uint8> buf = tb.Finish(); - VerifyTextTrackInfo(&buf[0], buf.size(), kTextSubtitles, "", ""); -} - -TEST_F(WebMTracksParserTest, TestSubtitleYesNameNoLang) { - InSequence s; - - TracksBuilder tb; - tb.AddTrack(1, kWebMTrackTypeSubtitlesOrCaptions, - kWebMCodecSubtitles, "Spock", ""); - - const std::vector<uint8> buf = tb.Finish(); - VerifyTextTrackInfo(&buf[0], buf.size(), kTextSubtitles, "Spock", ""); -} - -TEST_F(WebMTracksParserTest, TestSubtitleNoNameYesLang) { - InSequence s; - - TracksBuilder tb; - tb.AddTrack(1, kWebMTrackTypeSubtitlesOrCaptions, - kWebMCodecSubtitles, "", "eng"); - - const std::vector<uint8> buf = tb.Finish(); - VerifyTextTrackInfo(&buf[0], buf.size(), kTextSubtitles, "", "eng"); -} - -TEST_F(WebMTracksParserTest, TestSubtitleYesNameYesLang) { - InSequence s; - - TracksBuilder tb; - tb.AddTrack(1, kWebMTrackTypeSubtitlesOrCaptions, - kWebMCodecSubtitles, "Picard", "fre"); - - const std::vector<uint8> buf = tb.Finish(); - VerifyTextTrackInfo(&buf[0], buf.size(), kTextSubtitles, "Picard", "fre"); -} - -} // namespace media |