| 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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 // We should never be here if a SurfaceView is required. | 326 // We should never be here if a SurfaceView is required. |
| 327 DCHECK_EQ(config_.surface_id, SurfaceManager::kNoSurfaceID); | 327 DCHECK_EQ(config_.surface_id, SurfaceManager::kNoSurfaceID); |
| 328 defer_surface_creation_ = true; | 328 defer_surface_creation_ = true; |
| 329 NotifyInitializationComplete(true); | 329 NotifyInitializationComplete(true); |
| 330 return true; | 330 return true; |
| 331 } | 331 } |
| 332 | 332 |
| 333 // We signaled that we support deferred initialization, so see if the client | 333 // We signaled that we support deferred initialization, so see if the client |
| 334 // does also. | 334 // does also. |
| 335 deferred_initialization_pending_ = config.is_deferred_initialization_allowed; | 335 deferred_initialization_pending_ = config.is_deferred_initialization_allowed; |
| 336 if (config_.is_encrypted && !deferred_initialization_pending_) { | 336 if (config_.is_encrypted() && !deferred_initialization_pending_) { |
| 337 DLOG(ERROR) << "Deferred initialization must be used for encrypted streams"; | 337 DLOG(ERROR) << "Deferred initialization must be used for encrypted streams"; |
| 338 return false; | 338 return false; |
| 339 } | 339 } |
| 340 | 340 |
| 341 if (AVDACodecAllocator::Instance()->AllocateSurface(this, | 341 if (AVDACodecAllocator::Instance()->AllocateSurface(this, |
| 342 config_.surface_id)) { | 342 config_.surface_id)) { |
| 343 // We now own the surface, so finish initialization. | 343 // We now own the surface, so finish initialization. |
| 344 return InitializePictureBufferManager(); | 344 return InitializePictureBufferManager(); |
| 345 } | 345 } |
| 346 | 346 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 367 | 367 |
| 368 codec_config_->surface = | 368 codec_config_->surface = |
| 369 picture_buffer_manager_.Initialize(config_.surface_id); | 369 picture_buffer_manager_.Initialize(config_.surface_id); |
| 370 if (codec_config_->surface.IsEmpty()) | 370 if (codec_config_->surface.IsEmpty()) |
| 371 return false; | 371 return false; |
| 372 | 372 |
| 373 if (!AVDACodecAllocator::Instance()->StartThread(this)) | 373 if (!AVDACodecAllocator::Instance()->StartThread(this)) |
| 374 return false; | 374 return false; |
| 375 | 375 |
| 376 // If we are encrypted, then we aren't able to create the codec yet. | 376 // If we are encrypted, then we aren't able to create the codec yet. |
| 377 if (config_.is_encrypted) { | 377 if (config_.is_encrypted()) { |
| 378 InitializeCdm(); | 378 InitializeCdm(); |
| 379 return true; | 379 return true; |
| 380 } | 380 } |
| 381 | 381 |
| 382 if (deferred_initialization_pending_ || defer_surface_creation_) { | 382 if (deferred_initialization_pending_ || defer_surface_creation_) { |
| 383 defer_surface_creation_ = false; | 383 defer_surface_creation_ = false; |
| 384 ConfigureMediaCodecAsynchronously(); | 384 ConfigureMediaCodecAsynchronously(); |
| 385 return true; | 385 return true; |
| 386 } | 386 } |
| 387 | 387 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 const std::vector<SubsampleEntry>& subsamples = bitstream_buffer.subsamples(); | 497 const std::vector<SubsampleEntry>& subsamples = bitstream_buffer.subsamples(); |
| 498 | 498 |
| 499 MediaCodecStatus status; | 499 MediaCodecStatus status; |
| 500 if (key_id.empty() || iv.empty()) { | 500 if (key_id.empty() || iv.empty()) { |
| 501 status = media_codec_->QueueInputBuffer(input_buf_index, memory, | 501 status = media_codec_->QueueInputBuffer(input_buf_index, memory, |
| 502 bitstream_buffer.size(), | 502 bitstream_buffer.size(), |
| 503 presentation_timestamp); | 503 presentation_timestamp); |
| 504 } else { | 504 } else { |
| 505 status = media_codec_->QueueSecureInputBuffer( | 505 status = media_codec_->QueueSecureInputBuffer( |
| 506 input_buf_index, memory, bitstream_buffer.size(), key_id, iv, | 506 input_buf_index, memory, bitstream_buffer.size(), key_id, iv, |
| 507 subsamples, presentation_timestamp); | 507 subsamples, config_.encryption_scheme, presentation_timestamp); |
| 508 } | 508 } |
| 509 | 509 |
| 510 DVLOG(2) << __func__ | 510 DVLOG(2) << __func__ |
| 511 << ": Queue(Secure)InputBuffer: pts:" << presentation_timestamp | 511 << ": Queue(Secure)InputBuffer: pts:" << presentation_timestamp |
| 512 << " status:" << status; | 512 << " status:" << status; |
| 513 | 513 |
| 514 if (status == MEDIA_CODEC_NO_KEY) { | 514 if (status == MEDIA_CODEC_NO_KEY) { |
| 515 // Keep trying to enqueue the same input buffer. | 515 // Keep trying to enqueue the same input buffer. |
| 516 // The buffer is owned by us (not the MediaCodec) and is filled with data. | 516 // The buffer is owned by us (not the MediaCodec) and is filled with data. |
| 517 DVLOG(1) << "QueueSecureInputBuffer failed: NO_KEY"; | 517 DVLOG(1) << "QueueSecureInputBuffer failed: NO_KEY"; |
| (...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1445 } | 1445 } |
| 1446 #endif | 1446 #endif |
| 1447 | 1447 |
| 1448 return capabilities; | 1448 return capabilities; |
| 1449 } | 1449 } |
| 1450 | 1450 |
| 1451 bool AndroidVideoDecodeAccelerator::IsMediaCodecSoftwareDecodingForbidden() | 1451 bool AndroidVideoDecodeAccelerator::IsMediaCodecSoftwareDecodingForbidden() |
| 1452 const { | 1452 const { |
| 1453 // Prevent MediaCodec from using its internal software decoders when we have | 1453 // Prevent MediaCodec from using its internal software decoders when we have |
| 1454 // more secure and up to date versions in the renderer process. | 1454 // more secure and up to date versions in the renderer process. |
| 1455 return !config_.is_encrypted && (codec_config_->codec == kCodecVP8 || | 1455 return !config_.is_encrypted() && (codec_config_->codec == kCodecVP8 || |
| 1456 codec_config_->codec == kCodecVP9); | 1456 codec_config_->codec == kCodecVP9); |
| 1457 } | 1457 } |
| 1458 | 1458 |
| 1459 bool AndroidVideoDecodeAccelerator::UpdateSurface() { | 1459 bool AndroidVideoDecodeAccelerator::UpdateSurface() { |
| 1460 DCHECK(pending_surface_id_); | 1460 DCHECK(pending_surface_id_); |
| 1461 DCHECK_NE(config_.surface_id, pending_surface_id_.value()); | 1461 DCHECK_NE(config_.surface_id, pending_surface_id_.value()); |
| 1462 DCHECK(config_.surface_id == SurfaceManager::kNoSurfaceID || | 1462 DCHECK(config_.surface_id == SurfaceManager::kNoSurfaceID || |
| 1463 pending_surface_id_.value() == SurfaceManager::kNoSurfaceID); | 1463 pending_surface_id_.value() == SurfaceManager::kNoSurfaceID); |
| 1464 | 1464 |
| 1465 const int previous_surface_id = config_.surface_id; | 1465 const int previous_surface_id = config_.surface_id; |
| 1466 const int new_surface_id = pending_surface_id_.value(); | 1466 const int new_surface_id = pending_surface_id_.value(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1510 AVDACodecAllocator::Instance()->DeallocateSurface(this, new_surface_id); | 1510 AVDACodecAllocator::Instance()->DeallocateSurface(this, new_surface_id); |
| 1511 } | 1511 } |
| 1512 | 1512 |
| 1513 // Regardless of whether we succeeded, we no longer own the previous surface. | 1513 // Regardless of whether we succeeded, we no longer own the previous surface. |
| 1514 AVDACodecAllocator::Instance()->DeallocateSurface(this, previous_surface_id); | 1514 AVDACodecAllocator::Instance()->DeallocateSurface(this, previous_surface_id); |
| 1515 | 1515 |
| 1516 return success; | 1516 return success; |
| 1517 } | 1517 } |
| 1518 | 1518 |
| 1519 } // namespace media | 1519 } // namespace media |
| OLD | NEW |