Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(601)

Unified Diff: media/formats/webm/webm_tracks_parser.cc

Issue 1735003004: Implement reading of media track info from WebM and MP4 containers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@demuxer-tracks2
Patch Set: rebase Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/formats/webm/webm_tracks_parser.h ('k') | media/media.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/formats/webm/webm_tracks_parser.cc
diff --git a/media/formats/webm/webm_tracks_parser.cc b/media/formats/webm/webm_tracks_parser.cc
index 464a77ff1e66eab49ff8a43358508f76e509bad9..5ffa0aac66ad4b4fb6ad13dc7f4745a8dfa73d76 100644
--- a/media/formats/webm/webm_tracks_parser.cc
+++ b/media/formats/webm/webm_tracks_parser.cc
@@ -77,6 +77,7 @@ int WebMTracksParser::Parse(const uint8_t* buf, int size) {
video_decoder_config_ = VideoDecoderConfig();
text_tracks_.clear();
ignored_tracks_.clear();
+ media_tracks_.reset(new MediaTracks());
WebMListParser parser(kWebMIdTracks, this);
int result = parser.Parse(buf, size);
@@ -210,6 +211,9 @@ bool WebMTracksParser::OnListEnd(int id) {
!audio_encryption_key_id_.empty(), &audio_decoder_config_)) {
return false;
}
+ media_tracks_->AddAudioTrack(audio_decoder_config_,
+ base::Uint64ToString(track_num_), "main",
+ track_name_, track_language_);
} else {
MEDIA_LOG(DEBUG, media_log_) << "Ignoring audio track " << track_num_;
ignored_tracks_.insert(track_num_);
@@ -232,6 +236,9 @@ bool WebMTracksParser::OnListEnd(int id) {
&video_decoder_config_)) {
return false;
}
+ media_tracks_->AddVideoTrack(video_decoder_config_,
+ base::Uint64ToString(track_num_), "main",
+ track_name_, track_language_);
} else {
MEDIA_LOG(DEBUG, media_log_) << "Ignoring video track " << track_num_;
ignored_tracks_.insert(track_num_);
@@ -335,7 +342,15 @@ bool WebMTracksParser::OnString(int id, const std::string& str) {
}
if (id == kWebMIdLanguage) {
- track_language_ = str;
+ // Check that the language string is in ISO 639-2 format (3 letter code of a
+ // language, all lower-case letters).
+ if (str.size() != 3 || str[0] < 'a' || str[0] > 'z' || str[1] < 'a' ||
+ str[1] > 'z' || str[2] < 'a' || str[2] > 'z') {
+ VLOG(2) << "Ignoring kWebMIdLanguage (not ISO 639-2 compliant): " << str;
+ track_language_ = "und";
+ } else {
+ track_language_ = str;
+ }
return true;
}
« no previous file with comments | « media/formats/webm/webm_tracks_parser.h ('k') | media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698