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

Side by Side Diff: media/gpu/android_video_decode_accelerator.cc

Issue 2058113002: Add 'cbcs' encryption scheme support in Android media. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/gpu/android_video_decode_accelerator.h" 5 #include "media/gpu/android_video_decode_accelerator.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 config_ = config; 435 config_ = config;
436 codec_config_ = new CodecConfig(); 436 codec_config_ = new CodecConfig();
437 codec_config_->codec_ = VideoCodecProfileToVideoCodec(config.profile); 437 codec_config_->codec_ = VideoCodecProfileToVideoCodec(config.profile);
438 codec_config_->initial_expected_coded_size_ = 438 codec_config_->initial_expected_coded_size_ =
439 config.initial_expected_coded_size; 439 config.initial_expected_coded_size;
440 440
441 // We signalled that we support deferred initialization, so see if the client 441 // We signalled that we support deferred initialization, so see if the client
442 // does also. 442 // does also.
443 deferred_initialization_pending_ = config.is_deferred_initialization_allowed; 443 deferred_initialization_pending_ = config.is_deferred_initialization_allowed;
444 444
445 if (config_.is_encrypted && !deferred_initialization_pending_) { 445 if (config_.is_encrypted() && !deferred_initialization_pending_) {
446 DLOG(ERROR) << "Deferred initialization must be used for encrypted streams"; 446 DLOG(ERROR) << "Deferred initialization must be used for encrypted streams";
447 return false; 447 return false;
448 } 448 }
449 449
450 if (codec_config_->codec_ != media::kCodecVP8 && 450 if (codec_config_->codec_ != media::kCodecVP8 &&
451 codec_config_->codec_ != media::kCodecVP9 && 451 codec_config_->codec_ != media::kCodecVP9 &&
452 codec_config_->codec_ != media::kCodecH264) { 452 codec_config_->codec_ != media::kCodecH264) {
453 LOG(ERROR) << "Unsupported profile: " << config.profile; 453 LOG(ERROR) << "Unsupported profile: " << config.profile;
454 return false; 454 return false;
455 } 455 }
456 456
457 // Only use MediaCodec for VP8/9 if it's likely backed by hardware 457 // Only use MediaCodec for VP8/9 if it's likely backed by hardware
458 // or if the stream is encrypted. 458 // or if the stream is encrypted.
459 if ((codec_config_->codec_ == media::kCodecVP8 || 459 if ((codec_config_->codec_ == media::kCodecVP8 ||
460 codec_config_->codec_ == media::kCodecVP9) && 460 codec_config_->codec_ == media::kCodecVP9) &&
461 !config_.is_encrypted && 461 !config_.is_encrypted() &&
462 media::VideoCodecBridge::IsKnownUnaccelerated( 462 media::VideoCodecBridge::IsKnownUnaccelerated(
463 codec_config_->codec_, media::MEDIA_CODEC_DECODER)) { 463 codec_config_->codec_, media::MEDIA_CODEC_DECODER)) {
464 DVLOG(1) << "Initialization failed: " 464 DVLOG(1) << "Initialization failed: "
465 << (codec_config_->codec_ == media::kCodecVP8 ? "vp8" : "vp9") 465 << (codec_config_->codec_ == media::kCodecVP8 ? "vp8" : "vp9")
466 << " is not hardware accelerated"; 466 << " is not hardware accelerated";
467 return false; 467 return false;
468 } 468 }
469 469
470 auto gles_decoder = get_gles2_decoder_cb_.Run(); 470 auto gles_decoder = get_gles2_decoder_cb_.Run();
471 if (!gles_decoder) { 471 if (!gles_decoder) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 } 534 }
535 535
536 // Start the thread for async configuration, even if we don't need it now. 536 // Start the thread for async configuration, even if we don't need it now.
537 // ResetCodecState might rebuild the codec later, for example. 537 // ResetCodecState might rebuild the codec later, for example.
538 if (!g_avda_timer.Pointer()->StartThread(this)) { 538 if (!g_avda_timer.Pointer()->StartThread(this)) {
539 LOG(ERROR) << "Failed to start AVDA thread"; 539 LOG(ERROR) << "Failed to start AVDA thread";
540 return false; 540 return false;
541 } 541 }
542 542
543 // If we are encrypted, then we aren't able to create the codec yet. 543 // If we are encrypted, then we aren't able to create the codec yet.
544 if (config_.is_encrypted) { 544 if (config_.is_encrypted()) {
545 InitializeCdm(); 545 InitializeCdm();
546 return true; 546 return true;
547 } 547 }
548 548
549 if (deferred_initialization_pending_) { 549 if (deferred_initialization_pending_) {
550 ConfigureMediaCodecAsynchronously(); 550 ConfigureMediaCodecAsynchronously();
551 return true; 551 return true;
552 } 552 }
553 553
554 // If the client doesn't support deferred initialization (WebRTC), then we 554 // If the client doesn't support deferred initialization (WebRTC), then we
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 bitstream_buffer.subsamples(); 664 bitstream_buffer.subsamples();
665 665
666 media::MediaCodecStatus status; 666 media::MediaCodecStatus status;
667 if (key_id.empty() || iv.empty()) { 667 if (key_id.empty() || iv.empty()) {
668 status = media_codec_->QueueInputBuffer(input_buf_index, memory, 668 status = media_codec_->QueueInputBuffer(input_buf_index, memory,
669 bitstream_buffer.size(), 669 bitstream_buffer.size(),
670 presentation_timestamp); 670 presentation_timestamp);
671 } else { 671 } else {
672 status = media_codec_->QueueSecureInputBuffer( 672 status = media_codec_->QueueSecureInputBuffer(
673 input_buf_index, memory, bitstream_buffer.size(), key_id, iv, 673 input_buf_index, memory, bitstream_buffer.size(), key_id, iv,
674 subsamples, presentation_timestamp); 674 subsamples, config_.encryption_scheme, presentation_timestamp);
675 } 675 }
676 676
677 DVLOG(2) << __FUNCTION__ 677 DVLOG(2) << __FUNCTION__
678 << ": Queue(Secure)InputBuffer: pts:" << presentation_timestamp 678 << ": Queue(Secure)InputBuffer: pts:" << presentation_timestamp
679 << " status:" << status; 679 << " status:" << status;
680 680
681 if (status == media::MEDIA_CODEC_NO_KEY) { 681 if (status == media::MEDIA_CODEC_NO_KEY) {
682 // Keep trying to enqueue the same input buffer. 682 // Keep trying to enqueue the same input buffer.
683 // The buffer is owned by us (not the MediaCodec) and is filled with data. 683 // The buffer is owned by us (not the MediaCodec) and is filled with data.
684 DVLOG(1) << "QueueSecureInputBuffer failed: NO_KEY"; 684 DVLOG(1) << "QueueSecureInputBuffer failed: NO_KEY";
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 if (media::MediaCodecUtil::IsSurfaceViewOutputSupported()) { 1628 if (media::MediaCodecUtil::IsSurfaceViewOutputSupported()) {
1629 capabilities.flags |= media::VideoDecodeAccelerator::Capabilities:: 1629 capabilities.flags |= media::VideoDecodeAccelerator::Capabilities::
1630 SUPPORTS_EXTERNAL_OUTPUT_SURFACE; 1630 SUPPORTS_EXTERNAL_OUTPUT_SURFACE;
1631 } 1631 }
1632 } 1632 }
1633 1633
1634 return capabilities; 1634 return capabilities;
1635 } 1635 }
1636 1636
1637 } // namespace media 1637 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698