| OLD | NEW |
| 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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 DCHECK(g_avda_manager.Get().AllocateSurface(config_.surface_id, this)); | 412 DCHECK(g_avda_manager.Get().AllocateSurface(config_.surface_id, this)); |
| 413 | 413 |
| 414 defer_surface_creation_ = true; | 414 defer_surface_creation_ = true; |
| 415 NotifyInitializationComplete(true); | 415 NotifyInitializationComplete(true); |
| 416 return true; | 416 return true; |
| 417 } | 417 } |
| 418 | 418 |
| 419 // We signaled that we support deferred initialization, so see if the client | 419 // We signaled that we support deferred initialization, so see if the client |
| 420 // does also. | 420 // does also. |
| 421 deferred_initialization_pending_ = config.is_deferred_initialization_allowed; | 421 deferred_initialization_pending_ = config.is_deferred_initialization_allowed; |
| 422 if (config_.is_encrypted && !deferred_initialization_pending_) { | 422 if (config_.is_encrypted() && !deferred_initialization_pending_) { |
| 423 DLOG(ERROR) << "Deferred initialization must be used for encrypted streams"; | 423 DLOG(ERROR) << "Deferred initialization must be used for encrypted streams"; |
| 424 return false; | 424 return false; |
| 425 } | 425 } |
| 426 | 426 |
| 427 if (g_avda_manager.Get().AllocateSurface(config_.surface_id, this)) { | 427 if (g_avda_manager.Get().AllocateSurface(config_.surface_id, this)) { |
| 428 // We have successfully owned the surface, so finish initialization now. | 428 // We have successfully owned the surface, so finish initialization now. |
| 429 return InitializePictureBufferManager(); | 429 return InitializePictureBufferManager(); |
| 430 } | 430 } |
| 431 | 431 |
| 432 // We have to wait for some other AVDA instance to free up the surface. | 432 // We have to wait for some other AVDA instance to free up the surface. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 458 on_destroying_surface_cb_ = | 458 on_destroying_surface_cb_ = |
| 459 base::Bind(&AndroidVideoDecodeAccelerator::OnDestroyingSurface, | 459 base::Bind(&AndroidVideoDecodeAccelerator::OnDestroyingSurface, |
| 460 weak_this_factory_.GetWeakPtr()); | 460 weak_this_factory_.GetWeakPtr()); |
| 461 AVDASurfaceTracker::GetInstance()->RegisterOnDestroyingSurfaceCallback( | 461 AVDASurfaceTracker::GetInstance()->RegisterOnDestroyingSurfaceCallback( |
| 462 on_destroying_surface_cb_); | 462 on_destroying_surface_cb_); |
| 463 | 463 |
| 464 if (!g_avda_codec_allocator.Get().StartThread(this)) | 464 if (!g_avda_codec_allocator.Get().StartThread(this)) |
| 465 return false; | 465 return false; |
| 466 | 466 |
| 467 // If we are encrypted, then we aren't able to create the codec yet. | 467 // If we are encrypted, then we aren't able to create the codec yet. |
| 468 if (config_.is_encrypted) { | 468 if (config_.is_encrypted()) { |
| 469 InitializeCdm(); | 469 InitializeCdm(); |
| 470 return true; | 470 return true; |
| 471 } | 471 } |
| 472 | 472 |
| 473 if (deferred_initialization_pending_ || defer_surface_creation_) { | 473 if (deferred_initialization_pending_ || defer_surface_creation_) { |
| 474 defer_surface_creation_ = false; | 474 defer_surface_creation_ = false; |
| 475 ConfigureMediaCodecAsynchronously(); | 475 ConfigureMediaCodecAsynchronously(); |
| 476 return true; | 476 return true; |
| 477 } | 477 } |
| 478 | 478 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 const std::vector<SubsampleEntry>& subsamples = bitstream_buffer.subsamples(); | 589 const std::vector<SubsampleEntry>& subsamples = bitstream_buffer.subsamples(); |
| 590 | 590 |
| 591 MediaCodecStatus status; | 591 MediaCodecStatus status; |
| 592 if (key_id.empty() || iv.empty()) { | 592 if (key_id.empty() || iv.empty()) { |
| 593 status = media_codec_->QueueInputBuffer(input_buf_index, memory, | 593 status = media_codec_->QueueInputBuffer(input_buf_index, memory, |
| 594 bitstream_buffer.size(), | 594 bitstream_buffer.size(), |
| 595 presentation_timestamp); | 595 presentation_timestamp); |
| 596 } else { | 596 } else { |
| 597 status = media_codec_->QueueSecureInputBuffer( | 597 status = media_codec_->QueueSecureInputBuffer( |
| 598 input_buf_index, memory, bitstream_buffer.size(), key_id, iv, | 598 input_buf_index, memory, bitstream_buffer.size(), key_id, iv, |
| 599 subsamples, presentation_timestamp); | 599 subsamples, config_.encryption_scheme, presentation_timestamp); |
| 600 } | 600 } |
| 601 | 601 |
| 602 DVLOG(2) << __FUNCTION__ | 602 DVLOG(2) << __FUNCTION__ |
| 603 << ": Queue(Secure)InputBuffer: pts:" << presentation_timestamp | 603 << ": Queue(Secure)InputBuffer: pts:" << presentation_timestamp |
| 604 << " status:" << status; | 604 << " status:" << status; |
| 605 | 605 |
| 606 if (status == MEDIA_CODEC_NO_KEY) { | 606 if (status == MEDIA_CODEC_NO_KEY) { |
| 607 // Keep trying to enqueue the same input buffer. | 607 // Keep trying to enqueue the same input buffer. |
| 608 // The buffer is owned by us (not the MediaCodec) and is filled with data. | 608 // The buffer is owned by us (not the MediaCodec) and is filled with data. |
| 609 DVLOG(1) << "QueueSecureInputBuffer failed: NO_KEY"; | 609 DVLOG(1) << "QueueSecureInputBuffer failed: NO_KEY"; |
| (...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1583 } | 1583 } |
| 1584 #endif | 1584 #endif |
| 1585 | 1585 |
| 1586 return capabilities; | 1586 return capabilities; |
| 1587 } | 1587 } |
| 1588 | 1588 |
| 1589 bool AndroidVideoDecodeAccelerator::IsMediaCodecSoftwareDecodingForbidden() | 1589 bool AndroidVideoDecodeAccelerator::IsMediaCodecSoftwareDecodingForbidden() |
| 1590 const { | 1590 const { |
| 1591 // Prevent MediaCodec from using its internal software decoders when we have | 1591 // Prevent MediaCodec from using its internal software decoders when we have |
| 1592 // more secure and up to date versions in the renderer process. | 1592 // more secure and up to date versions in the renderer process. |
| 1593 return !config_.is_encrypted && (codec_config_->codec_ == kCodecVP8 || | 1593 return !config_.is_encrypted() && (codec_config_->codec_ == kCodecVP8 || |
| 1594 codec_config_->codec_ == kCodecVP9); | 1594 codec_config_->codec_ == kCodecVP9); |
| 1595 } | 1595 } |
| 1596 | 1596 |
| 1597 } // namespace media | 1597 } // namespace media |
| OLD | NEW |