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

Side by Side Diff: media/formats/webm/webm_tracks_parser.cc

Issue 1041353002: media-internals: Differentiate error, info, and debug log messages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address reviewer comments Created 5 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/formats/webm/webm_tracks_parser.h" 5 #include "media/formats/webm/webm_tracks_parser.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "media/base/buffers.h" 10 #include "media/base/buffers.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 129 }
130 130
131 bool WebMTracksParser::OnListEnd(int id) { 131 bool WebMTracksParser::OnListEnd(int id) {
132 if (id == kWebMIdContentEncodings) { 132 if (id == kWebMIdContentEncodings) {
133 DCHECK(track_content_encodings_client_.get()); 133 DCHECK(track_content_encodings_client_.get());
134 return track_content_encodings_client_->OnListEnd(id); 134 return track_content_encodings_client_->OnListEnd(id);
135 } 135 }
136 136
137 if (id == kWebMIdTrackEntry) { 137 if (id == kWebMIdTrackEntry) {
138 if (track_type_ == -1 || track_num_ == -1) { 138 if (track_type_ == -1 || track_num_ == -1) {
139 MEDIA_LOG(log_cb_) << "Missing TrackEntry data for " 139 MEDIA_LOG(ERROR, log_cb_) << "Missing TrackEntry data for "
140 << " TrackType " << track_type_ 140 << " TrackType " << track_type_ << " TrackNum "
141 << " TrackNum " << track_num_; 141 << track_num_;
142 return false; 142 return false;
143 } 143 }
144 144
145 if (track_type_ != kWebMTrackTypeAudio && 145 if (track_type_ != kWebMTrackTypeAudio &&
146 track_type_ != kWebMTrackTypeVideo && 146 track_type_ != kWebMTrackTypeVideo &&
147 track_type_ != kWebMTrackTypeSubtitlesOrCaptions && 147 track_type_ != kWebMTrackTypeSubtitlesOrCaptions &&
148 track_type_ != kWebMTrackTypeDescriptionsOrMetadata) { 148 track_type_ != kWebMTrackTypeDescriptionsOrMetadata) {
149 MEDIA_LOG(log_cb_) << "Unexpected TrackType " << track_type_; 149 MEDIA_LOG(ERROR, log_cb_) << "Unexpected TrackType " << track_type_;
150 return false; 150 return false;
151 } 151 }
152 152
153 TextKind text_track_kind = kTextNone; 153 TextKind text_track_kind = kTextNone;
154 if (track_type_ == kWebMTrackTypeSubtitlesOrCaptions) { 154 if (track_type_ == kWebMTrackTypeSubtitlesOrCaptions) {
155 text_track_kind = CodecIdToTextKind(codec_id_); 155 text_track_kind = CodecIdToTextKind(codec_id_);
156 if (text_track_kind == kTextNone) { 156 if (text_track_kind == kTextNone) {
157 MEDIA_LOG(log_cb_) << "Missing TrackEntry CodecID" 157 MEDIA_LOG(ERROR, log_cb_) << "Missing TrackEntry CodecID"
158 << " TrackNum " << track_num_; 158 << " TrackNum " << track_num_;
159 return false; 159 return false;
160 } 160 }
161 161
162 if (text_track_kind != kTextSubtitles && 162 if (text_track_kind != kTextSubtitles &&
163 text_track_kind != kTextCaptions) { 163 text_track_kind != kTextCaptions) {
164 MEDIA_LOG(log_cb_) << "Wrong TrackEntry CodecID" 164 MEDIA_LOG(ERROR, log_cb_) << "Wrong TrackEntry CodecID"
165 << " TrackNum " << track_num_; 165 << " TrackNum " << track_num_;
166 return false; 166 return false;
167 } 167 }
168 } else if (track_type_ == kWebMTrackTypeDescriptionsOrMetadata) { 168 } else if (track_type_ == kWebMTrackTypeDescriptionsOrMetadata) {
169 text_track_kind = CodecIdToTextKind(codec_id_); 169 text_track_kind = CodecIdToTextKind(codec_id_);
170 if (text_track_kind == kTextNone) { 170 if (text_track_kind == kTextNone) {
171 MEDIA_LOG(log_cb_) << "Missing TrackEntry CodecID" 171 MEDIA_LOG(ERROR, log_cb_) << "Missing TrackEntry CodecID"
172 << " TrackNum " << track_num_; 172 << " TrackNum " << track_num_;
173 return false; 173 return false;
174 } 174 }
175 175
176 if (text_track_kind != kTextDescriptions && 176 if (text_track_kind != kTextDescriptions &&
177 text_track_kind != kTextMetadata) { 177 text_track_kind != kTextMetadata) {
178 MEDIA_LOG(log_cb_) << "Wrong TrackEntry CodecID" 178 MEDIA_LOG(ERROR, log_cb_) << "Wrong TrackEntry CodecID"
179 << " TrackNum " << track_num_; 179 << " TrackNum " << track_num_;
180 return false; 180 return false;
181 } 181 }
182 } 182 }
183 183
184 std::string encryption_key_id; 184 std::string encryption_key_id;
185 if (track_content_encodings_client_) { 185 if (track_content_encodings_client_) {
186 DCHECK(!track_content_encodings_client_->content_encodings().empty()); 186 DCHECK(!track_content_encodings_client_->content_encodings().empty());
187 // If we have multiple ContentEncoding in one track. Always choose the 187 // If we have multiple ContentEncoding in one track. Always choose the
188 // key id in the first ContentEncoding as the key id of the track. 188 // key id in the first ContentEncoding as the key id of the track.
189 encryption_key_id = track_content_encodings_client_-> 189 encryption_key_id = track_content_encodings_client_->
190 content_encodings()[0]->encryption_key_id(); 190 content_encodings()[0]->encryption_key_id();
191 } 191 }
192 192
193 if (track_type_ == kWebMTrackTypeAudio) { 193 if (track_type_ == kWebMTrackTypeAudio) {
194 if (audio_track_num_ == -1) { 194 if (audio_track_num_ == -1) {
195 audio_track_num_ = track_num_; 195 audio_track_num_ = track_num_;
196 audio_encryption_key_id_ = encryption_key_id; 196 audio_encryption_key_id_ = encryption_key_id;
197 197
198 if (default_duration_ == 0) { 198 if (default_duration_ == 0) {
199 MEDIA_LOG(log_cb_) << "Illegal 0ns audio TrackEntry DefaultDuration"; 199 MEDIA_LOG(ERROR, log_cb_) << "Illegal 0ns audio TrackEntry "
200 "DefaultDuration";
200 return false; 201 return false;
201 } 202 }
202 audio_default_duration_ = default_duration_; 203 audio_default_duration_ = default_duration_;
203 204
204 DCHECK(!audio_decoder_config_.IsValidConfig()); 205 DCHECK(!audio_decoder_config_.IsValidConfig());
205 if (!audio_client_.InitializeConfig( 206 if (!audio_client_.InitializeConfig(
206 codec_id_, codec_private_, seek_preroll_, codec_delay_, 207 codec_id_, codec_private_, seek_preroll_, codec_delay_,
207 !audio_encryption_key_id_.empty(), &audio_decoder_config_)) { 208 !audio_encryption_key_id_.empty(), &audio_decoder_config_)) {
208 return false; 209 return false;
209 } 210 }
210 } else { 211 } else {
211 MEDIA_LOG(log_cb_) << "Ignoring audio track " << track_num_; 212 MEDIA_LOG(DEBUG, log_cb_) << "Ignoring audio track " << track_num_;
212 ignored_tracks_.insert(track_num_); 213 ignored_tracks_.insert(track_num_);
213 } 214 }
214 } else if (track_type_ == kWebMTrackTypeVideo) { 215 } else if (track_type_ == kWebMTrackTypeVideo) {
215 if (video_track_num_ == -1) { 216 if (video_track_num_ == -1) {
216 video_track_num_ = track_num_; 217 video_track_num_ = track_num_;
217 video_encryption_key_id_ = encryption_key_id; 218 video_encryption_key_id_ = encryption_key_id;
218 219
219 if (default_duration_ == 0) { 220 if (default_duration_ == 0) {
220 MEDIA_LOG(log_cb_) << "Illegal 0ns video TrackEntry DefaultDuration"; 221 MEDIA_LOG(ERROR, log_cb_) << "Illegal 0ns video TrackEntry "
222 "DefaultDuration";
221 return false; 223 return false;
222 } 224 }
223 video_default_duration_ = default_duration_; 225 video_default_duration_ = default_duration_;
224 226
225 DCHECK(!video_decoder_config_.IsValidConfig()); 227 DCHECK(!video_decoder_config_.IsValidConfig());
226 if (!video_client_.InitializeConfig( 228 if (!video_client_.InitializeConfig(
227 codec_id_, codec_private_, !video_encryption_key_id_.empty(), 229 codec_id_, codec_private_, !video_encryption_key_id_.empty(),
228 &video_decoder_config_)) { 230 &video_decoder_config_)) {
229 return false; 231 return false;
230 } 232 }
231 } else { 233 } else {
232 MEDIA_LOG(log_cb_) << "Ignoring video track " << track_num_; 234 MEDIA_LOG(DEBUG, log_cb_) << "Ignoring video track " << track_num_;
233 ignored_tracks_.insert(track_num_); 235 ignored_tracks_.insert(track_num_);
234 } 236 }
235 } else if (track_type_ == kWebMTrackTypeSubtitlesOrCaptions || 237 } else if (track_type_ == kWebMTrackTypeSubtitlesOrCaptions ||
236 track_type_ == kWebMTrackTypeDescriptionsOrMetadata) { 238 track_type_ == kWebMTrackTypeDescriptionsOrMetadata) {
237 if (ignore_text_tracks_) { 239 if (ignore_text_tracks_) {
238 MEDIA_LOG(log_cb_) << "Ignoring text track " << track_num_; 240 MEDIA_LOG(DEBUG, log_cb_) << "Ignoring text track " << track_num_;
239 ignored_tracks_.insert(track_num_); 241 ignored_tracks_.insert(track_num_);
240 } else { 242 } else {
241 std::string track_num = base::Int64ToString(track_num_); 243 std::string track_num = base::Int64ToString(track_num_);
242 text_tracks_[track_num_] = TextTrackConfig( 244 text_tracks_[track_num_] = TextTrackConfig(
243 text_track_kind, track_name_, track_language_, track_num); 245 text_track_kind, track_name_, track_language_, track_num);
244 } 246 }
245 } else { 247 } else {
246 MEDIA_LOG(log_cb_) << "Unexpected TrackType " << track_type_; 248 MEDIA_LOG(ERROR, log_cb_) << "Unexpected TrackType " << track_type_;
247 return false; 249 return false;
248 } 250 }
249 251
250 track_type_ = -1; 252 track_type_ = -1;
251 track_num_ = -1; 253 track_num_ = -1;
252 default_duration_ = -1; 254 default_duration_ = -1;
253 track_name_.clear(); 255 track_name_.clear();
254 track_language_.clear(); 256 track_language_.clear();
255 codec_id_ = ""; 257 codec_id_ = "";
256 codec_private_.clear(); 258 codec_private_.clear();
(...skipping 24 matching lines...) Expand all
281 dst = &codec_delay_; 283 dst = &codec_delay_;
282 break; 284 break;
283 case kWebMIdDefaultDuration: 285 case kWebMIdDefaultDuration:
284 dst = &default_duration_; 286 dst = &default_duration_;
285 break; 287 break;
286 default: 288 default:
287 return true; 289 return true;
288 } 290 }
289 291
290 if (*dst != -1) { 292 if (*dst != -1) {
291 MEDIA_LOG(log_cb_) << "Multiple values for id " << std::hex << id 293 MEDIA_LOG(ERROR, log_cb_) << "Multiple values for id " << std::hex << id
292 << " specified"; 294 << " specified";
293 return false; 295 return false;
294 } 296 }
295 297
296 *dst = val; 298 *dst = val;
297 return true; 299 return true;
298 } 300 }
299 301
300 bool WebMTracksParser::OnFloat(int id, double val) { 302 bool WebMTracksParser::OnFloat(int id, double val) {
301 return true; 303 return true;
302 } 304 }
303 305
304 bool WebMTracksParser::OnBinary(int id, const uint8* data, int size) { 306 bool WebMTracksParser::OnBinary(int id, const uint8* data, int size) {
305 if (id == kWebMIdCodecPrivate) { 307 if (id == kWebMIdCodecPrivate) {
306 if (!codec_private_.empty()) { 308 if (!codec_private_.empty()) {
307 MEDIA_LOG(log_cb_) << "Multiple CodecPrivate fields in a track."; 309 MEDIA_LOG(ERROR, log_cb_) << "Multiple CodecPrivate fields in a track.";
308 return false; 310 return false;
309 } 311 }
310 codec_private_.assign(data, data + size); 312 codec_private_.assign(data, data + size);
311 return true; 313 return true;
312 } 314 }
313 return true; 315 return true;
314 } 316 }
315 317
316 bool WebMTracksParser::OnString(int id, const std::string& str) { 318 bool WebMTracksParser::OnString(int id, const std::string& str) {
317 if (id == kWebMIdCodecID) { 319 if (id == kWebMIdCodecID) {
318 if (!codec_id_.empty()) { 320 if (!codec_id_.empty()) {
319 MEDIA_LOG(log_cb_) << "Multiple CodecID fields in a track"; 321 MEDIA_LOG(ERROR, log_cb_) << "Multiple CodecID fields in a track";
320 return false; 322 return false;
321 } 323 }
322 324
323 codec_id_ = str; 325 codec_id_ = str;
324 return true; 326 return true;
325 } 327 }
326 328
327 if (id == kWebMIdName) { 329 if (id == kWebMIdName) {
328 track_name_ = str; 330 track_name_ = str;
329 return true; 331 return true;
330 } 332 }
331 333
332 if (id == kWebMIdLanguage) { 334 if (id == kWebMIdLanguage) {
333 track_language_ = str; 335 track_language_ = str;
334 return true; 336 return true;
335 } 337 }
336 338
337 return true; 339 return true;
338 } 340 }
339 341
340 } // namespace media 342 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698