diff options
Diffstat (limited to 'media/formats/webm/webm_tracks_parser.cc')
-rw-r--r-- | media/formats/webm/webm_tracks_parser.cc | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/media/formats/webm/webm_tracks_parser.cc b/media/formats/webm/webm_tracks_parser.cc index 86bb0a7..0c2cd8e 100644 --- a/media/formats/webm/webm_tracks_parser.cc +++ b/media/formats/webm/webm_tracks_parser.cc @@ -43,7 +43,8 @@ static base::TimeDelta PrecisionCappedDefaultDuration( return base::TimeDelta::FromMicroseconds(mult); } -WebMTracksParser::WebMTracksParser(const LogCB& log_cb, bool ignore_text_tracks) +WebMTracksParser::WebMTracksParser(const scoped_refptr<MediaLog>& media_log, + bool ignore_text_tracks) : track_type_(-1), track_num_(-1), seek_preroll_(-1), @@ -54,9 +55,9 @@ WebMTracksParser::WebMTracksParser(const LogCB& log_cb, bool ignore_text_tracks) video_track_num_(-1), video_default_duration_(-1), ignore_text_tracks_(ignore_text_tracks), - log_cb_(log_cb), - audio_client_(log_cb), - video_client_(log_cb) { + media_log_(media_log), + audio_client_(media_log), + video_client_(media_log) { } WebMTracksParser::~WebMTracksParser() {} @@ -102,7 +103,7 @@ WebMParserClient* WebMTracksParser::OnListStart(int id) { if (id == kWebMIdContentEncodings) { DCHECK(!track_content_encodings_client_.get()); track_content_encodings_client_.reset( - new WebMContentEncodingsClient(log_cb_)); + new WebMContentEncodingsClient(media_log_)); return track_content_encodings_client_->OnListStart(id); } @@ -136,9 +137,9 @@ bool WebMTracksParser::OnListEnd(int id) { if (id == kWebMIdTrackEntry) { if (track_type_ == -1 || track_num_ == -1) { - MEDIA_LOG(ERROR, log_cb_) << "Missing TrackEntry data for " - << " TrackType " << track_type_ << " TrackNum " - << track_num_; + MEDIA_LOG(ERROR, media_log_) << "Missing TrackEntry data for " + << " TrackType " << track_type_ + << " TrackNum " << track_num_; return false; } @@ -146,7 +147,7 @@ bool WebMTracksParser::OnListEnd(int id) { track_type_ != kWebMTrackTypeVideo && track_type_ != kWebMTrackTypeSubtitlesOrCaptions && track_type_ != kWebMTrackTypeDescriptionsOrMetadata) { - MEDIA_LOG(ERROR, log_cb_) << "Unexpected TrackType " << track_type_; + MEDIA_LOG(ERROR, media_log_) << "Unexpected TrackType " << track_type_; return false; } @@ -154,29 +155,29 @@ bool WebMTracksParser::OnListEnd(int id) { if (track_type_ == kWebMTrackTypeSubtitlesOrCaptions) { text_track_kind = CodecIdToTextKind(codec_id_); if (text_track_kind == kTextNone) { - MEDIA_LOG(ERROR, log_cb_) << "Missing TrackEntry CodecID" - << " TrackNum " << track_num_; + MEDIA_LOG(ERROR, media_log_) << "Missing TrackEntry CodecID" + << " TrackNum " << track_num_; return false; } if (text_track_kind != kTextSubtitles && text_track_kind != kTextCaptions) { - MEDIA_LOG(ERROR, log_cb_) << "Wrong TrackEntry CodecID" - << " TrackNum " << track_num_; + MEDIA_LOG(ERROR, media_log_) << "Wrong TrackEntry CodecID" + << " TrackNum " << track_num_; return false; } } else if (track_type_ == kWebMTrackTypeDescriptionsOrMetadata) { text_track_kind = CodecIdToTextKind(codec_id_); if (text_track_kind == kTextNone) { - MEDIA_LOG(ERROR, log_cb_) << "Missing TrackEntry CodecID" - << " TrackNum " << track_num_; + MEDIA_LOG(ERROR, media_log_) << "Missing TrackEntry CodecID" + << " TrackNum " << track_num_; return false; } if (text_track_kind != kTextDescriptions && text_track_kind != kTextMetadata) { - MEDIA_LOG(ERROR, log_cb_) << "Wrong TrackEntry CodecID" - << " TrackNum " << track_num_; + MEDIA_LOG(ERROR, media_log_) << "Wrong TrackEntry CodecID" + << " TrackNum " << track_num_; return false; } } @@ -196,8 +197,8 @@ bool WebMTracksParser::OnListEnd(int id) { audio_encryption_key_id_ = encryption_key_id; if (default_duration_ == 0) { - MEDIA_LOG(ERROR, log_cb_) << "Illegal 0ns audio TrackEntry " - "DefaultDuration"; + MEDIA_LOG(ERROR, media_log_) << "Illegal 0ns audio TrackEntry " + "DefaultDuration"; return false; } audio_default_duration_ = default_duration_; @@ -209,7 +210,7 @@ bool WebMTracksParser::OnListEnd(int id) { return false; } } else { - MEDIA_LOG(DEBUG, log_cb_) << "Ignoring audio track " << track_num_; + MEDIA_LOG(DEBUG, media_log_) << "Ignoring audio track " << track_num_; ignored_tracks_.insert(track_num_); } } else if (track_type_ == kWebMTrackTypeVideo) { @@ -218,8 +219,8 @@ bool WebMTracksParser::OnListEnd(int id) { video_encryption_key_id_ = encryption_key_id; if (default_duration_ == 0) { - MEDIA_LOG(ERROR, log_cb_) << "Illegal 0ns video TrackEntry " - "DefaultDuration"; + MEDIA_LOG(ERROR, media_log_) << "Illegal 0ns video TrackEntry " + "DefaultDuration"; return false; } video_default_duration_ = default_duration_; @@ -231,13 +232,13 @@ bool WebMTracksParser::OnListEnd(int id) { return false; } } else { - MEDIA_LOG(DEBUG, log_cb_) << "Ignoring video track " << track_num_; + MEDIA_LOG(DEBUG, media_log_) << "Ignoring video track " << track_num_; ignored_tracks_.insert(track_num_); } } else if (track_type_ == kWebMTrackTypeSubtitlesOrCaptions || track_type_ == kWebMTrackTypeDescriptionsOrMetadata) { if (ignore_text_tracks_) { - MEDIA_LOG(DEBUG, log_cb_) << "Ignoring text track " << track_num_; + MEDIA_LOG(DEBUG, media_log_) << "Ignoring text track " << track_num_; ignored_tracks_.insert(track_num_); } else { std::string track_num = base::Int64ToString(track_num_); @@ -245,7 +246,7 @@ bool WebMTracksParser::OnListEnd(int id) { text_track_kind, track_name_, track_language_, track_num); } } else { - MEDIA_LOG(ERROR, log_cb_) << "Unexpected TrackType " << track_type_; + MEDIA_LOG(ERROR, media_log_) << "Unexpected TrackType " << track_type_; return false; } @@ -290,8 +291,8 @@ bool WebMTracksParser::OnUInt(int id, int64 val) { } if (*dst != -1) { - MEDIA_LOG(ERROR, log_cb_) << "Multiple values for id " << std::hex << id - << " specified"; + MEDIA_LOG(ERROR, media_log_) << "Multiple values for id " << std::hex << id + << " specified"; return false; } @@ -306,7 +307,8 @@ bool WebMTracksParser::OnFloat(int id, double val) { bool WebMTracksParser::OnBinary(int id, const uint8* data, int size) { if (id == kWebMIdCodecPrivate) { if (!codec_private_.empty()) { - MEDIA_LOG(ERROR, log_cb_) << "Multiple CodecPrivate fields in a track."; + MEDIA_LOG(ERROR, media_log_) + << "Multiple CodecPrivate fields in a track."; return false; } codec_private_.assign(data, data + size); @@ -318,7 +320,7 @@ bool WebMTracksParser::OnBinary(int id, const uint8* data, int size) { bool WebMTracksParser::OnString(int id, const std::string& str) { if (id == kWebMIdCodecID) { if (!codec_id_.empty()) { - MEDIA_LOG(ERROR, log_cb_) << "Multiple CodecID fields in a track"; + MEDIA_LOG(ERROR, media_log_) << "Multiple CodecID fields in a track"; return false; } |