1 // Copyright 2016 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "media/mojo/services/media_service_factory.h"
9 #include "base/notreached.h"
10 #include "base/task/single_thread_task_runner.h"
11 #include "build/build_config.h"
12 #include "media/mojo/buildflags.h"
13 #include "media/mojo/services/gpu_mojo_media_client.h"
14 #include "media/mojo/services/media_service.h"
15 #include "media/mojo/services/test_mojo_media_client.h"
17 #if BUILDFLAG(IS_ANDROID)
18 #include "media/mojo/services/android_mojo_media_client.h" // nogncheck
22 #include "media/mojo/services/media_foundation_mojo_media_client.h"
27 std::unique_ptr<MediaService> CreateMediaService(
28 mojo::PendingReceiver<mojom::MediaService> receiver) {
29 #if BUILDFLAG(IS_ANDROID)
30 return std::make_unique<MediaService>(
31 std::make_unique<AndroidMojoMediaClient>(), std::move(receiver));
32 #elif BUILDFLAG(IS_WIN)
33 return std::make_unique<MediaService>(
34 std::make_unique<MediaFoundationMojoMediaClient>(), std::move(receiver));
36 NOTREACHED() << "No MediaService implementation available.";
41 std::unique_ptr<MediaService> CreateGpuMediaService(
42 mojo::PendingReceiver<mojom::MediaService> receiver,
43 const gpu::GpuPreferences& gpu_preferences,
44 const gpu::GpuDriverBugWorkarounds& gpu_workarounds,
45 const gpu::GpuFeatureInfo& gpu_feature_info,
46 const gpu::GPUInfo& gpu_info,
47 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
48 base::WeakPtr<MediaGpuChannelManager> media_gpu_channel_manager,
49 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory,
50 AndroidOverlayMojoFactoryCB android_overlay_factory_cb) {
51 return std::make_unique<MediaService>(
52 std::make_unique<GpuMojoMediaClient>(
53 gpu_preferences, gpu_workarounds, gpu_feature_info, gpu_info,
54 task_runner, media_gpu_channel_manager, gpu_memory_buffer_factory,
55 std::move(android_overlay_factory_cb)),
59 std::unique_ptr<MediaService> CreateMediaServiceForTesting(
60 mojo::PendingReceiver<mojom::MediaService> receiver) {
61 return std::make_unique<MediaService>(std::make_unique<TestMojoMediaClient>(),