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