OLD | NEW |
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/timestamp_constants.h" | 10 #include "media/base/timestamp_constants.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 if (codec_id == kWebMCodecDescriptions) | 23 if (codec_id == kWebMCodecDescriptions) |
24 return kTextDescriptions; | 24 return kTextDescriptions; |
25 | 25 |
26 if (codec_id == kWebMCodecMetadata) | 26 if (codec_id == kWebMCodecMetadata) |
27 return kTextMetadata; | 27 return kTextMetadata; |
28 | 28 |
29 return kTextNone; | 29 return kTextNone; |
30 } | 30 } |
31 | 31 |
32 static base::TimeDelta PrecisionCappedDefaultDuration( | 32 static base::TimeDelta PrecisionCappedDefaultDuration( |
33 const double timecode_scale_in_us, const int64 duration_in_ns) { | 33 const double timecode_scale_in_us, |
| 34 const int64_t duration_in_ns) { |
34 if (duration_in_ns <= 0) | 35 if (duration_in_ns <= 0) |
35 return kNoTimestamp(); | 36 return kNoTimestamp(); |
36 | 37 |
37 int64 mult = duration_in_ns / 1000; | 38 int64_t mult = duration_in_ns / 1000; |
38 mult /= timecode_scale_in_us; | 39 mult /= timecode_scale_in_us; |
39 if (mult == 0) | 40 if (mult == 0) |
40 return kNoTimestamp(); | 41 return kNoTimestamp(); |
41 | 42 |
42 mult = static_cast<double>(mult) * timecode_scale_in_us; | 43 mult = static_cast<double>(mult) * timecode_scale_in_us; |
43 return base::TimeDelta::FromMicroseconds(mult); | 44 return base::TimeDelta::FromMicroseconds(mult); |
44 } | 45 } |
45 | 46 |
46 WebMTracksParser::WebMTracksParser(const scoped_refptr<MediaLog>& media_log, | 47 WebMTracksParser::WebMTracksParser(const scoped_refptr<MediaLog>& media_log, |
47 bool ignore_text_tracks) | 48 bool ignore_text_tracks) |
48 : track_type_(-1), | 49 : track_type_(-1), |
49 track_num_(-1), | 50 track_num_(-1), |
50 seek_preroll_(-1), | 51 seek_preroll_(-1), |
51 codec_delay_(-1), | 52 codec_delay_(-1), |
52 default_duration_(-1), | 53 default_duration_(-1), |
53 audio_track_num_(-1), | 54 audio_track_num_(-1), |
54 audio_default_duration_(-1), | 55 audio_default_duration_(-1), |
55 video_track_num_(-1), | 56 video_track_num_(-1), |
56 video_default_duration_(-1), | 57 video_default_duration_(-1), |
57 ignore_text_tracks_(ignore_text_tracks), | 58 ignore_text_tracks_(ignore_text_tracks), |
58 media_log_(media_log), | 59 media_log_(media_log), |
59 audio_client_(media_log), | 60 audio_client_(media_log), |
60 video_client_(media_log) { | 61 video_client_(media_log) { |
61 } | 62 } |
62 | 63 |
63 WebMTracksParser::~WebMTracksParser() {} | 64 WebMTracksParser::~WebMTracksParser() {} |
64 | 65 |
65 int WebMTracksParser::Parse(const uint8* buf, int size) { | 66 int WebMTracksParser::Parse(const uint8_t* buf, int size) { |
66 track_type_ =-1; | 67 track_type_ =-1; |
67 track_num_ = -1; | 68 track_num_ = -1; |
68 default_duration_ = -1; | 69 default_duration_ = -1; |
69 track_name_.clear(); | 70 track_name_.clear(); |
70 track_language_.clear(); | 71 track_language_.clear(); |
71 audio_track_num_ = -1; | 72 audio_track_num_ = -1; |
72 audio_default_duration_ = -1; | 73 audio_default_duration_ = -1; |
73 audio_decoder_config_ = AudioDecoderConfig(); | 74 audio_decoder_config_ = AudioDecoderConfig(); |
74 video_track_num_ = -1; | 75 video_track_num_ = -1; |
75 video_default_duration_ = -1; | 76 video_default_duration_ = -1; |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 track_content_encodings_client_.reset(); | 261 track_content_encodings_client_.reset(); |
261 | 262 |
262 audio_client_.Reset(); | 263 audio_client_.Reset(); |
263 video_client_.Reset(); | 264 video_client_.Reset(); |
264 return true; | 265 return true; |
265 } | 266 } |
266 | 267 |
267 return true; | 268 return true; |
268 } | 269 } |
269 | 270 |
270 bool WebMTracksParser::OnUInt(int id, int64 val) { | 271 bool WebMTracksParser::OnUInt(int id, int64_t val) { |
271 int64* dst = NULL; | 272 int64_t* dst = NULL; |
272 | 273 |
273 switch (id) { | 274 switch (id) { |
274 case kWebMIdTrackNumber: | 275 case kWebMIdTrackNumber: |
275 dst = &track_num_; | 276 dst = &track_num_; |
276 break; | 277 break; |
277 case kWebMIdTrackType: | 278 case kWebMIdTrackType: |
278 dst = &track_type_; | 279 dst = &track_type_; |
279 break; | 280 break; |
280 case kWebMIdSeekPreRoll: | 281 case kWebMIdSeekPreRoll: |
281 dst = &seek_preroll_; | 282 dst = &seek_preroll_; |
(...skipping 15 matching lines...) Expand all Loading... |
297 } | 298 } |
298 | 299 |
299 *dst = val; | 300 *dst = val; |
300 return true; | 301 return true; |
301 } | 302 } |
302 | 303 |
303 bool WebMTracksParser::OnFloat(int id, double val) { | 304 bool WebMTracksParser::OnFloat(int id, double val) { |
304 return true; | 305 return true; |
305 } | 306 } |
306 | 307 |
307 bool WebMTracksParser::OnBinary(int id, const uint8* data, int size) { | 308 bool WebMTracksParser::OnBinary(int id, const uint8_t* data, int size) { |
308 if (id == kWebMIdCodecPrivate) { | 309 if (id == kWebMIdCodecPrivate) { |
309 if (!codec_private_.empty()) { | 310 if (!codec_private_.empty()) { |
310 MEDIA_LOG(ERROR, media_log_) | 311 MEDIA_LOG(ERROR, media_log_) |
311 << "Multiple CodecPrivate fields in a track."; | 312 << "Multiple CodecPrivate fields in a track."; |
312 return false; | 313 return false; |
313 } | 314 } |
314 codec_private_.assign(data, data + size); | 315 codec_private_.assign(data, data + size); |
315 return true; | 316 return true; |
316 } | 317 } |
317 return true; | 318 return true; |
(...skipping 17 matching lines...) Expand all Loading... |
335 | 336 |
336 if (id == kWebMIdLanguage) { | 337 if (id == kWebMIdLanguage) { |
337 track_language_ = str; | 338 track_language_ = str; |
338 return true; | 339 return true; |
339 } | 340 } |
340 | 341 |
341 return true; | 342 return true; |
342 } | 343 } |
343 | 344 |
344 } // namespace media | 345 } // namespace media |
OLD | NEW |