Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/webm/webm_stream_parser.h" | 5 #include "media/webm/webm_stream_parser.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 | 339 |
| 340 base::TimeDelta duration = kInfiniteDuration(); | 340 base::TimeDelta duration = kInfiniteDuration(); |
| 341 | 341 |
| 342 if (info_parser.duration() > 0) { | 342 if (info_parser.duration() > 0) { |
| 343 double mult = info_parser.timecode_scale() / 1000.0; | 343 double mult = info_parser.timecode_scale() / 1000.0; |
| 344 int64 duration_in_us = info_parser.duration() * mult; | 344 int64 duration_in_us = info_parser.duration() * mult; |
| 345 duration = base::TimeDelta::FromMicroseconds(duration_in_us); | 345 duration = base::TimeDelta::FromMicroseconds(duration_in_us); |
| 346 } | 346 } |
| 347 | 347 |
| 348 FFmpegConfigHelper config_helper; | 348 FFmpegConfigHelper config_helper; |
| 349 | |
| 350 if (!config_helper.Parse(data, bytes_parsed)) { | 349 if (!config_helper.Parse(data, bytes_parsed)) { |
| 351 DVLOG(1) << "Failed to parse config data."; | 350 DVLOG(1) << "Failed to parse config data."; |
| 352 return -1; | 351 return -1; |
| 353 } | 352 } |
| 354 | 353 |
| 355 if (!config_cb_.Run(config_helper.audio_config(), | 354 VideoDecoderConfig video_config; |
| 356 config_helper.video_config())) { | 355 video_config.CopyFrom(config_helper.video_config()); |
| 357 DVLOG(1) << "New config data isn't allowed."; | |
| 358 return -1; | |
| 359 } | |
| 360 | 356 |
| 361 // TODO(xhwang): Support decryption of audio (see http://crbug.com/123421). | 357 // TODO(xhwang): Support decryption of audio (see http://crbug.com/123421). |
| 362 if (!tracks_parser.video_encryption_key_id().empty()) { | 358 bool is_video_encrypted = !tracks_parser.video_encryption_key_id().empty(); |
| 359 if (is_video_encrypted) { | |
| 360 video_config.set_is_encrypted(true); | |
|
acolwell GONE FROM CHROMIUM
2012/09/17 17:41:17
Use Initialize() here and CopyFrom() in an else so
xhwang
2012/09/17 19:42:25
Done.
| |
| 361 | |
| 362 // Fire needkey event. | |
| 363 std::string key_id = tracks_parser.video_encryption_key_id(); | 363 std::string key_id = tracks_parser.video_encryption_key_id(); |
| 364 int key_id_size = key_id.size(); | 364 int key_id_size = key_id.size(); |
| 365 CHECK_GT(key_id_size, 0); | 365 CHECK_GT(key_id_size, 0); |
| 366 CHECK_LT(key_id_size, 2048); | 366 CHECK_LT(key_id_size, 2048); |
|
acolwell GONE FROM CHROMIUM
2012/09/17 17:41:17
This should not be a CHECK since it means an "Aw S
xhwang
2012/09/17 19:42:25
Hmm, good catch. According to Frank, 2048bytes is
| |
| 367 scoped_array<uint8> key_id_array(new uint8[key_id_size]); | 367 scoped_array<uint8> key_id_array(new uint8[key_id_size]); |
| 368 memcpy(key_id_array.get(), key_id.data(), key_id_size); | 368 memcpy(key_id_array.get(), key_id.data(), key_id_size); |
| 369 need_key_cb_.Run(key_id_array.Pass(), key_id_size); | 369 need_key_cb_.Run(key_id_array.Pass(), key_id_size); |
| 370 } | 370 } |
| 371 | 371 |
| 372 if (!config_cb_.Run(config_helper.audio_config(), video_config)) { | |
| 373 DVLOG(1) << "New config data isn't allowed."; | |
| 374 return -1; | |
| 375 } | |
| 376 | |
| 372 cluster_parser_.reset(new WebMClusterParser( | 377 cluster_parser_.reset(new WebMClusterParser( |
| 373 info_parser.timecode_scale(), | 378 info_parser.timecode_scale(), |
| 374 tracks_parser.audio_track_num(), | 379 tracks_parser.audio_track_num(), |
| 375 tracks_parser.video_track_num(), | 380 tracks_parser.video_track_num(), |
| 376 tracks_parser.video_encryption_key_id())); | 381 tracks_parser.video_encryption_key_id())); |
| 377 | 382 |
| 378 ChangeState(kParsingClusters); | 383 ChangeState(kParsingClusters); |
| 379 | 384 |
| 380 if (!init_cb_.is_null()) { | 385 if (!init_cb_.is_null()) { |
| 381 init_cb_.Run(true, duration); | 386 init_cb_.Run(true, duration); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 434 if (!video_buffers.empty() && !video_cb_.Run(video_buffers)) | 439 if (!video_buffers.empty() && !video_cb_.Run(video_buffers)) |
| 435 return -1; | 440 return -1; |
| 436 | 441 |
| 437 if (cluster_ended) | 442 if (cluster_ended) |
| 438 end_of_segment_cb_.Run(); | 443 end_of_segment_cb_.Run(); |
| 439 | 444 |
| 440 return bytes_parsed; | 445 return bytes_parsed; |
| 441 } | 446 } |
| 442 | 447 |
| 443 } // namespace media | 448 } // namespace media |
| OLD | NEW |