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

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

Issue 2864603002: Provide callback to create mojo AndroidOverlays to AVDA. (Closed)
Patch Set: fixed deps 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/gpu_video_decode_accelerator_factory.h" 5 #include "media/gpu/gpu_video_decode_accelerator_factory.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "gpu/command_buffer/service/gpu_preferences.h" 8 #include "gpu/command_buffer/service/gpu_preferences.h"
9 #include "media/base/media_switches.h" 9 #include "media/base/media_switches.h"
10 #include "media/gpu/gpu_video_accelerator_util.h" 10 #include "media/gpu/gpu_video_accelerator_util.h"
(...skipping 13 matching lines...) Expand all
24 #include "ui/gl/gl_surface_egl.h" 24 #include "ui/gl/gl_surface_egl.h"
25 #endif 25 #endif
26 #if defined(ARCH_CPU_X86_FAMILY) 26 #if defined(ARCH_CPU_X86_FAMILY)
27 #include "media/gpu/vaapi_video_decode_accelerator.h" 27 #include "media/gpu/vaapi_video_decode_accelerator.h"
28 #include "ui/gl/gl_implementation.h" 28 #include "ui/gl/gl_implementation.h"
29 #endif 29 #endif
30 #elif defined(OS_ANDROID) 30 #elif defined(OS_ANDROID)
31 #include "media/gpu/android_video_decode_accelerator.h" 31 #include "media/gpu/android_video_decode_accelerator.h"
32 #include "media/gpu/android_video_surface_chooser_impl.h" 32 #include "media/gpu/android_video_surface_chooser_impl.h"
33 #include "media/gpu/avda_codec_allocator.h" 33 #include "media/gpu/avda_codec_allocator.h"
34 #include "media/mojo/clients/mojo_android_overlay.h"
35 #include "services/service_manager/public/cpp/connector.h"
34 #endif 36 #endif
35 37
36 namespace media { 38 namespace media {
37 39
38 // static 40 // static
39 MEDIA_GPU_EXPORT std::unique_ptr<GpuVideoDecodeAcceleratorFactory> 41 MEDIA_GPU_EXPORT std::unique_ptr<GpuVideoDecodeAcceleratorFactory>
40 GpuVideoDecodeAcceleratorFactory::Create( 42 GpuVideoDecodeAcceleratorFactory::Create(
41 const GetGLContextCallback& get_gl_context_cb, 43 const GetGLContextCallback& get_gl_context_cb,
42 const MakeGLContextCurrentCallback& make_context_current_cb, 44 const MakeGLContextCurrentCallback& make_context_current_cb,
43 const BindGLImageCallback& bind_image_cb) { 45 const BindGLImageCallback& bind_image_cb) {
44 return base::WrapUnique(new GpuVideoDecodeAcceleratorFactory( 46 return base::WrapUnique(new GpuVideoDecodeAcceleratorFactory(
45 get_gl_context_cb, make_context_current_cb, bind_image_cb, 47 get_gl_context_cb, make_context_current_cb, bind_image_cb,
46 GetGLES2DecoderCallback())); 48 GetGLES2DecoderCallback(), nullptr, nullptr));
47 } 49 }
48 50
49 // static 51 // static
50 MEDIA_GPU_EXPORT std::unique_ptr<GpuVideoDecodeAcceleratorFactory> 52 MEDIA_GPU_EXPORT std::unique_ptr<GpuVideoDecodeAcceleratorFactory>
51 GpuVideoDecodeAcceleratorFactory::CreateWithGLES2Decoder( 53 GpuVideoDecodeAcceleratorFactory::CreateWithGLES2Decoder(
52 const GetGLContextCallback& get_gl_context_cb, 54 const GetGLContextCallback& get_gl_context_cb,
53 const MakeGLContextCurrentCallback& make_context_current_cb, 55 const MakeGLContextCurrentCallback& make_context_current_cb,
54 const BindGLImageCallback& bind_image_cb, 56 const BindGLImageCallback& bind_image_cb,
55 const GetGLES2DecoderCallback& get_gles2_decoder_cb) { 57 const GetGLES2DecoderCallback& get_gles2_decoder_cb,
58 service_manager::Connector* connector,
59 const char* browser_service_name) {
56 return base::WrapUnique(new GpuVideoDecodeAcceleratorFactory( 60 return base::WrapUnique(new GpuVideoDecodeAcceleratorFactory(
57 get_gl_context_cb, make_context_current_cb, bind_image_cb, 61 get_gl_context_cb, make_context_current_cb, bind_image_cb,
58 get_gles2_decoder_cb)); 62 get_gles2_decoder_cb, connector, browser_service_name));
59 } 63 }
60 64
61 // static 65 // static
62 MEDIA_GPU_EXPORT std::unique_ptr<GpuVideoDecodeAcceleratorFactory> 66 MEDIA_GPU_EXPORT std::unique_ptr<GpuVideoDecodeAcceleratorFactory>
63 GpuVideoDecodeAcceleratorFactory::CreateWithNoGL() { 67 GpuVideoDecodeAcceleratorFactory::CreateWithNoGL() {
64 return Create(GetGLContextCallback(), MakeGLContextCurrentCallback(), 68 return Create(GetGLContextCallback(), MakeGLContextCurrentCallback(),
65 BindGLImageCallback()); 69 BindGLImageCallback());
66 } 70 }
67 71
68 // static 72 // static
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 return decoder; 248 return decoder;
245 } 249 }
246 #endif 250 #endif
247 251
248 #if defined(OS_ANDROID) 252 #if defined(OS_ANDROID)
249 std::unique_ptr<VideoDecodeAccelerator> 253 std::unique_ptr<VideoDecodeAccelerator>
250 GpuVideoDecodeAcceleratorFactory::CreateAndroidVDA( 254 GpuVideoDecodeAcceleratorFactory::CreateAndroidVDA(
251 const gpu::GpuDriverBugWorkarounds& workarounds, 255 const gpu::GpuDriverBugWorkarounds& workarounds,
252 const gpu::GpuPreferences& gpu_preferences) const { 256 const gpu::GpuPreferences& gpu_preferences) const {
253 std::unique_ptr<VideoDecodeAccelerator> decoder; 257 std::unique_ptr<VideoDecodeAccelerator> decoder;
258
259 // To make unit-testing easier, convert the connector into a callback.
260 AndroidOverlayMojoFactoryCB overlay_cb;
261 #if defined(OS_ANDROID)
262 if (connector_ && browser_service_name_)
263 overlay_cb =
264 base::Bind(&GpuVideoDecodeAcceleratorFactory::CreateAndroidOverlay,
265 connector_, browser_service_name_);
266 #endif
267
254 decoder.reset(new AndroidVideoDecodeAccelerator( 268 decoder.reset(new AndroidVideoDecodeAccelerator(
255 AVDACodecAllocator::GetInstance(), 269 AVDACodecAllocator::GetInstance(),
256 base::MakeUnique<AndroidVideoSurfaceChooserImpl>(), 270 base::MakeUnique<AndroidVideoSurfaceChooserImpl>(),
257 make_context_current_cb_, get_gles2_decoder_cb_, 271 make_context_current_cb_, get_gles2_decoder_cb_, std::move(overlay_cb),
258 AndroidVideoDecodeAccelerator::PlatformConfig::CreateDefault())); 272 AndroidVideoDecodeAccelerator::PlatformConfig::CreateDefault()));
259 return decoder; 273 return decoder;
260 } 274 }
275
276 std::unique_ptr<media::AndroidOverlay>
277 GpuVideoDecodeAcceleratorFactory::CreateAndroidOverlay(
278 service_manager::Connector* connector,
279 const char* browser_service_name,
280 const base::UnguessableToken& routing_token,
281 media::AndroidOverlayConfig config) {
282 media::mojom::AndroidOverlayProviderPtr provider_ptr;
283 if (!connector || !browser_service_name)
284 return nullptr;
285
286 connector->BindInterface(browser_service_name, &provider_ptr);
287 return base::MakeUnique<media::MojoAndroidOverlay>(
288 std::move(provider_ptr), std::move(config), routing_token);
289 }
261 #endif 290 #endif
262 291
263 GpuVideoDecodeAcceleratorFactory::GpuVideoDecodeAcceleratorFactory( 292 GpuVideoDecodeAcceleratorFactory::GpuVideoDecodeAcceleratorFactory(
264 const GetGLContextCallback& get_gl_context_cb, 293 const GetGLContextCallback& get_gl_context_cb,
265 const MakeGLContextCurrentCallback& make_context_current_cb, 294 const MakeGLContextCurrentCallback& make_context_current_cb,
266 const BindGLImageCallback& bind_image_cb, 295 const BindGLImageCallback& bind_image_cb,
267 const GetGLES2DecoderCallback& get_gles2_decoder_cb) 296 const GetGLES2DecoderCallback& get_gles2_decoder_cb,
297 service_manager::Connector* connector,
298 const char* browser_service_name)
268 : get_gl_context_cb_(get_gl_context_cb), 299 : get_gl_context_cb_(get_gl_context_cb),
269 make_context_current_cb_(make_context_current_cb), 300 make_context_current_cb_(make_context_current_cb),
270 bind_image_cb_(bind_image_cb), 301 bind_image_cb_(bind_image_cb),
271 get_gles2_decoder_cb_(get_gles2_decoder_cb) {} 302 get_gles2_decoder_cb_(get_gles2_decoder_cb),
303 connector_(connector),
304 browser_service_name_(browser_service_name) {}
272 305
273 GpuVideoDecodeAcceleratorFactory::~GpuVideoDecodeAcceleratorFactory() {} 306 GpuVideoDecodeAcceleratorFactory::~GpuVideoDecodeAcceleratorFactory() {}
274 307
275 } // namespace media 308 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698