Chromium Code Reviews| 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 19 matching lines...) Expand all Loading... | |
| 30 #include "media/base/android/media_codec_util.h" | 30 #include "media/base/android/media_codec_util.h" |
| 31 #include "media/base/bind_to_current_loop.h" | 31 #include "media/base/bind_to_current_loop.h" |
| 32 #include "media/base/bitstream_buffer.h" | 32 #include "media/base/bitstream_buffer.h" |
| 33 #include "media/base/limits.h" | 33 #include "media/base/limits.h" |
| 34 #include "media/base/media.h" | 34 #include "media/base/media.h" |
| 35 #include "media/base/timestamp_constants.h" | 35 #include "media/base/timestamp_constants.h" |
| 36 #include "media/base/video_decoder_config.h" | 36 #include "media/base/video_decoder_config.h" |
| 37 #include "media/gpu/android_video_surface_chooser_impl.h" | 37 #include "media/gpu/android_video_surface_chooser_impl.h" |
| 38 #include "media/gpu/avda_picture_buffer_manager.h" | 38 #include "media/gpu/avda_picture_buffer_manager.h" |
| 39 #include "media/gpu/content_video_view_overlay.h" | 39 #include "media/gpu/content_video_view_overlay.h" |
| 40 #include "media/gpu/content_video_view_overlay_factory.h" | |
| 41 #include "media/gpu/shared_memory_region.h" | 40 #include "media/gpu/shared_memory_region.h" |
| 42 #include "media/video/picture.h" | 41 #include "media/video/picture.h" |
| 43 #include "ui/gl/android/scoped_java_surface.h" | 42 #include "ui/gl/android/scoped_java_surface.h" |
| 44 #include "ui/gl/android/surface_texture.h" | 43 #include "ui/gl/android/surface_texture.h" |
| 45 #include "ui/gl/gl_bindings.h" | 44 #include "ui/gl/gl_bindings.h" |
| 46 | 45 |
| 47 #if defined(ENABLE_MOJO_MEDIA_IN_GPU_PROCESS) | 46 #if defined(ENABLE_MOJO_MEDIA_IN_GPU_PROCESS) |
| 48 #include "media/mojo/services/mojo_cdm_service.h" // nogncheck | 47 #include "media/mojo/services/mojo_cdm_service.h" // nogncheck |
| 49 #endif | 48 #endif |
| 50 | 49 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 AVDACodecAllocator* codec_allocator, | 114 AVDACodecAllocator* codec_allocator, |
| 116 int surface_id, | 115 int surface_id, |
| 117 VideoCodec codec, | 116 VideoCodec codec, |
| 118 const AndroidVideoDecodeAccelerator::PlatformConfig& platform_config) { | 117 const AndroidVideoDecodeAccelerator::PlatformConfig& platform_config) { |
| 119 return platform_config.force_deferred_surface_creation || | 118 return platform_config.force_deferred_surface_creation || |
| 120 (surface_id == SurfaceManager::kNoSurfaceID && codec == kCodecH264 && | 119 (surface_id == SurfaceManager::kNoSurfaceID && codec == kCodecH264 && |
| 121 codec_allocator->IsAnyRegisteredAVDA() && | 120 codec_allocator->IsAnyRegisteredAVDA() && |
| 122 platform_config.sdk_int <= 18); | 121 platform_config.sdk_int <= 18); |
| 123 } | 122 } |
| 124 | 123 |
| 124 std::unique_ptr<AndroidOverlay> CreateContentVideoViewOverlay( | |
| 125 int32_t surface_id, | |
| 126 AndroidOverlayConfig config) { | |
| 127 return base::MakeUnique<ContentVideoViewOverlay>(surface_id, | |
| 128 std::move(config)); | |
| 129 } | |
| 130 | |
| 125 } // namespace | 131 } // namespace |
| 126 | 132 |
| 127 // AVDAManager manages a RepeatingTimer so that AVDAs can get a regular callback | 133 // AVDAManager manages a RepeatingTimer so that AVDAs can get a regular callback |
| 128 // to DoIOTask(). | 134 // to DoIOTask(). |
| 129 class AVDAManager { | 135 class AVDAManager { |
| 130 public: | 136 public: |
| 131 AVDAManager() {} | 137 AVDAManager() {} |
| 132 | 138 |
| 133 // Request periodic callback of |avda|->DoIOTask(). Does nothing if the | 139 // Request periodic callback of |avda|->DoIOTask(). Does nothing if the |
| 134 // instance is already registered and the timer started. The first request | 140 // instance is already registered and the timer started. The first request |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 395 // resolved synchronously. The only exception will be if we need to defer | 401 // resolved synchronously. The only exception will be if we need to defer |
| 396 // surface creation for other reasons, in which case the sync path with just | 402 // surface creation for other reasons, in which case the sync path with just |
| 397 // signal success optimistically. | 403 // signal success optimistically. |
| 398 if (during_initialize_ && !deferred_initialization_pending_) { | 404 if (during_initialize_ && !deferred_initialization_pending_) { |
| 399 DCHECK_EQ(config_.surface_id, SurfaceManager::kNoSurfaceID); | 405 DCHECK_EQ(config_.surface_id, SurfaceManager::kNoSurfaceID); |
| 400 OnSurfaceTransition(nullptr); | 406 OnSurfaceTransition(nullptr); |
| 401 return; | 407 return; |
| 402 } | 408 } |
| 403 | 409 |
| 404 // If we have a surface, then notify |surface_chooser_| about it. | 410 // If we have a surface, then notify |surface_chooser_| about it. |
| 405 std::unique_ptr<AndroidOverlayFactory> factory; | 411 AndroidOverlayFactoryCB factory; |
| 406 if (config_.surface_id != SurfaceManager::kNoSurfaceID) { | 412 if (config_.surface_id != SurfaceManager::kNoSurfaceID) { |
| 407 factory = | 413 factory = base::Bind(&CreateContentVideoViewOverlay, config_.surface_id); |
|
tguilbert
2017/05/04 21:52:04
NIT: Remove brackets for single line if
liberato (no reviews please)
2017/05/05 16:50:23
Done.
| |
| 408 base::MakeUnique<ContentVideoViewOverlayFactory>(config_.surface_id); | |
| 409 } | 414 } |
| 410 | 415 |
| 411 // Notify |surface_chooser_| that we've started. This guarantees that we'll | 416 // Notify |surface_chooser_| that we've started. This guarantees that we'll |
| 412 // get a callback. It might not be a synchronous callback, but we're not in | 417 // get a callback. It might not be a synchronous callback, but we're not in |
| 413 // the synchronous case. It will be soon, though. For pre-M, we rely on the | 418 // the synchronous case. It will be soon, though. For pre-M, we rely on the |
| 414 // fact that |surface_chooser_| won't tell us to use a SurfaceTexture while | 419 // fact that |surface_chooser_| won't tell us to use a SurfaceTexture while |
| 415 // waiting for an overlay to become ready, for example. | 420 // waiting for an overlay to become ready, for example. |
| 416 surface_chooser_->Initialize( | 421 surface_chooser_->Initialize( |
| 417 base::Bind(&AndroidVideoDecodeAccelerator::OnSurfaceTransition, | 422 base::Bind(&AndroidVideoDecodeAccelerator::OnSurfaceTransition, |
| 418 weak_this_factory_.GetWeakPtr()), | 423 weak_this_factory_.GetWeakPtr()), |
| (...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1267 | 1272 |
| 1268 // It's possible that we'll receive a SetSurface before initializing the | 1273 // It's possible that we'll receive a SetSurface before initializing the |
| 1269 // surface chooser. For example, if we defer surface creation, then we'll | 1274 // surface chooser. For example, if we defer surface creation, then we'll |
| 1270 // signal success to WMPI before initializing it. WMPI is free to change the | 1275 // signal success to WMPI before initializing it. WMPI is free to change the |
| 1271 // surface. In this case, just pretend that |surface_id| is the initial one. | 1276 // surface. In this case, just pretend that |surface_id| is the initial one. |
| 1272 if (state_ == BEFORE_OVERLAY_INIT) { | 1277 if (state_ == BEFORE_OVERLAY_INIT) { |
| 1273 config_.surface_id = surface_id; | 1278 config_.surface_id = surface_id; |
| 1274 return; | 1279 return; |
| 1275 } | 1280 } |
| 1276 | 1281 |
| 1277 std::unique_ptr<AndroidOverlayFactory> factory; | 1282 AndroidOverlayFactoryCB factory; |
| 1278 if (surface_id != SurfaceManager::kNoSurfaceID) | 1283 if (surface_id != SurfaceManager::kNoSurfaceID) |
| 1279 factory = base::MakeUnique<ContentVideoViewOverlayFactory>(surface_id); | 1284 factory = base::Bind(&CreateContentVideoViewOverlay, surface_id); |
| 1280 | 1285 |
| 1281 surface_chooser_->ReplaceOverlayFactory(std::move(factory)); | 1286 surface_chooser_->ReplaceOverlayFactory(std::move(factory)); |
| 1282 } | 1287 } |
| 1283 | 1288 |
| 1284 void AndroidVideoDecodeAccelerator::Destroy() { | 1289 void AndroidVideoDecodeAccelerator::Destroy() { |
| 1285 DVLOG(1) << __func__; | 1290 DVLOG(1) << __func__; |
| 1286 DCHECK(thread_checker_.CalledOnValidThread()); | 1291 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1287 | 1292 |
| 1288 picture_buffer_manager_.Destroy(output_picture_buffers_); | 1293 picture_buffer_manager_.Destroy(output_picture_buffers_); |
| 1289 client_ = nullptr; | 1294 client_ = nullptr; |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1694 codec_config_->task_type, | 1699 codec_config_->task_type, |
| 1695 codec_config_->surface_bundle); | 1700 codec_config_->surface_bundle); |
| 1696 } | 1701 } |
| 1697 | 1702 |
| 1698 void AndroidVideoDecodeAccelerator::ReleaseCodecAndBundle() { | 1703 void AndroidVideoDecodeAccelerator::ReleaseCodecAndBundle() { |
| 1699 ReleaseCodec(); | 1704 ReleaseCodec(); |
| 1700 codec_config_->surface_bundle = nullptr; | 1705 codec_config_->surface_bundle = nullptr; |
| 1701 } | 1706 } |
| 1702 | 1707 |
| 1703 } // namespace media | 1708 } // namespace media |
| OLD | NEW |