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

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

Issue 2856253004: removed AndroidOverlayFactory (Closed)
Patch Set: cl feedvback Created 3 years, 7 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 19 matching lines...) Expand all
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
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
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);
408 base::MakeUnique<ContentVideoViewOverlayFactory>(config_.surface_id);
409 }
410 414
411 // Notify |surface_chooser_| that we've started. This guarantees that we'll 415 // 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 416 // 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 417 // 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 418 // fact that |surface_chooser_| won't tell us to use a SurfaceTexture while
415 // waiting for an overlay to become ready, for example. 419 // waiting for an overlay to become ready, for example.
416 surface_chooser_->Initialize( 420 surface_chooser_->Initialize(
417 base::Bind(&AndroidVideoDecodeAccelerator::OnSurfaceTransition, 421 base::Bind(&AndroidVideoDecodeAccelerator::OnSurfaceTransition,
418 weak_this_factory_.GetWeakPtr()), 422 weak_this_factory_.GetWeakPtr()),
419 base::Bind(&AndroidVideoDecodeAccelerator::OnSurfaceTransition, 423 base::Bind(&AndroidVideoDecodeAccelerator::OnSurfaceTransition,
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 1271
1268 // It's possible that we'll receive a SetSurface before initializing the 1272 // 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 1273 // 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 1274 // 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. 1275 // surface. In this case, just pretend that |surface_id| is the initial one.
1272 if (state_ == BEFORE_OVERLAY_INIT) { 1276 if (state_ == BEFORE_OVERLAY_INIT) {
1273 config_.surface_id = surface_id; 1277 config_.surface_id = surface_id;
1274 return; 1278 return;
1275 } 1279 }
1276 1280
1277 std::unique_ptr<AndroidOverlayFactory> factory; 1281 AndroidOverlayFactoryCB factory;
1278 if (surface_id != SurfaceManager::kNoSurfaceID) 1282 if (surface_id != SurfaceManager::kNoSurfaceID)
1279 factory = base::MakeUnique<ContentVideoViewOverlayFactory>(surface_id); 1283 factory = base::Bind(&CreateContentVideoViewOverlay, surface_id);
1280 1284
1281 surface_chooser_->ReplaceOverlayFactory(std::move(factory)); 1285 surface_chooser_->ReplaceOverlayFactory(std::move(factory));
1282 } 1286 }
1283 1287
1284 void AndroidVideoDecodeAccelerator::Destroy() { 1288 void AndroidVideoDecodeAccelerator::Destroy() {
1285 DVLOG(1) << __func__; 1289 DVLOG(1) << __func__;
1286 DCHECK(thread_checker_.CalledOnValidThread()); 1290 DCHECK(thread_checker_.CalledOnValidThread());
1287 1291
1288 picture_buffer_manager_.Destroy(output_picture_buffers_); 1292 picture_buffer_manager_.Destroy(output_picture_buffers_);
1289 client_ = nullptr; 1293 client_ = nullptr;
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1694 codec_config_->task_type, 1698 codec_config_->task_type,
1695 codec_config_->surface_bundle); 1699 codec_config_->surface_bundle);
1696 } 1700 }
1697 1701
1698 void AndroidVideoDecodeAccelerator::ReleaseCodecAndBundle() { 1702 void AndroidVideoDecodeAccelerator::ReleaseCodecAndBundle() {
1699 ReleaseCodec(); 1703 ReleaseCodec();
1700 codec_config_->surface_bundle = nullptr; 1704 codec_config_->surface_bundle = nullptr;
1701 } 1705 }
1702 1706
1703 } // namespace media 1707 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698