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

Side by Side Diff: media/webm/webm_stream_parser.cc

Issue 10910293: Add is_encrypted() in VideoDecoderConfig. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Resolve comments. Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
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
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 // TODO(xhwang): Support decryption of audio (see http://crbug.com/123421).
356 config_helper.video_config())) { 355 bool is_video_encrypted = !tracks_parser.video_encryption_key_id().empty();
356
357 VideoDecoderConfig video_config;
358 if (is_video_encrypted) {
359 const VideoDecoderConfig& original_video_config =
360 config_helper.video_config();
361 video_config.Initialize(original_video_config.codec(),
362 original_video_config.profile(),
363 original_video_config.format(),
364 original_video_config.coded_size(),
365 original_video_config.visible_rect(),
366 original_video_config.natural_size(),
367 original_video_config.extra_data(),
368 original_video_config.extra_data_size(),
369 is_video_encrypted, false);
370
371 // Fire needkey event.
372 std::string key_id = tracks_parser.video_encryption_key_id();
373 int key_id_size = key_id.size();
374 DCHECK_GT(key_id_size, 0);
375 scoped_array<uint8> key_id_array(new uint8[key_id_size]);
376 memcpy(key_id_array.get(), key_id.data(), key_id_size);
377 need_key_cb_.Run(key_id_array.Pass(), key_id_size);
378 } else {
379 video_config.CopyFrom(config_helper.video_config());
380 }
381
382 if (!config_cb_.Run(config_helper.audio_config(), video_config)) {
357 DVLOG(1) << "New config data isn't allowed."; 383 DVLOG(1) << "New config data isn't allowed.";
358 return -1; 384 return -1;
359 } 385 }
360 386
361 // TODO(xhwang): Support decryption of audio (see http://crbug.com/123421).
362 if (!tracks_parser.video_encryption_key_id().empty()) {
363 std::string key_id = tracks_parser.video_encryption_key_id();
364 int key_id_size = key_id.size();
365 CHECK_GT(key_id_size, 0);
366 CHECK_LT(key_id_size, 2048);
367 scoped_array<uint8> key_id_array(new uint8[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);
370 }
371
372 cluster_parser_.reset(new WebMClusterParser( 387 cluster_parser_.reset(new WebMClusterParser(
373 info_parser.timecode_scale(), 388 info_parser.timecode_scale(),
374 tracks_parser.audio_track_num(), 389 tracks_parser.audio_track_num(),
375 tracks_parser.video_track_num(), 390 tracks_parser.video_track_num(),
376 tracks_parser.video_encryption_key_id())); 391 tracks_parser.video_encryption_key_id()));
377 392
378 ChangeState(kParsingClusters); 393 ChangeState(kParsingClusters);
379 394
380 if (!init_cb_.is_null()) { 395 if (!init_cb_.is_null()) {
381 init_cb_.Run(true, duration); 396 init_cb_.Run(true, duration);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 if (!video_buffers.empty() && !video_cb_.Run(video_buffers)) 449 if (!video_buffers.empty() && !video_cb_.Run(video_buffers))
435 return -1; 450 return -1;
436 451
437 if (cluster_ended) 452 if (cluster_ended)
438 end_of_segment_cb_.Run(); 453 end_of_segment_cb_.Run();
439 454
440 return bytes_parsed; 455 return bytes_parsed;
441 } 456 }
442 457
443 } // namespace media 458 } // namespace media
OLDNEW
« media/filters/ffmpeg_video_decoder_unittest.cc ('K') | « media/mp4/mp4_stream_parser_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698