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

Side by Side Diff: mojo/services/html_viewer/webmediaplayer_factory.cc

Issue 795193003: Introduce MojoRendererFactory::ServiceProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 6 years 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
« no previous file with comments | « media/mojo/services/mojo_renderer_factory.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "mojo/services/html_viewer/webmediaplayer_factory.h" 5 #include "mojo/services/html_viewer/webmediaplayer_factory.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
11 #include "media/audio/audio_manager.h" 11 #include "media/audio/audio_manager.h"
12 #include "media/audio/audio_manager_base.h" 12 #include "media/audio/audio_manager_base.h"
13 #include "media/audio/audio_output_stream_sink.h" 13 #include "media/audio/audio_output_stream_sink.h"
14 #include "media/base/audio_hardware_config.h" 14 #include "media/base/audio_hardware_config.h"
15 #include "media/base/media.h" 15 #include "media/base/media.h"
16 #include "media/base/media_log.h" 16 #include "media/base/media_log.h"
17 #include "media/blink/webmediaplayer_impl.h" 17 #include "media/blink/webmediaplayer_impl.h"
18 #include "media/blink/webmediaplayer_params.h" 18 #include "media/blink/webmediaplayer_params.h"
19 #include "media/filters/default_renderer_factory.h" 19 #include "media/filters/default_renderer_factory.h"
20 #include "media/filters/gpu_video_accelerator_factories.h" 20 #include "media/filters/gpu_video_accelerator_factories.h"
21 #include "media/mojo/interfaces/media_renderer.mojom.h" 21 #include "media/mojo/interfaces/media_renderer.mojom.h"
22 #include "media/mojo/services/mojo_renderer_factory.h" 22 #include "media/mojo/services/mojo_renderer_factory.h"
23 #include "mojo/public/cpp/application/connect.h" 23 #include "mojo/public/cpp/application/connect.h"
24 #include "mojo/public/interfaces/application/shell.mojom.h" 24 #include "mojo/public/interfaces/application/shell.mojom.h"
25 25
26 namespace mojo { 26 namespace mojo {
27 27
28 #if !defined(OS_ANDROID)
29 namespace {
30
31 class RendererServiceProvider
32 : public media::MojoRendererFactory::ServiceProvider {
33 public:
34 explicit RendererServiceProvider(ServiceProviderPtr service_provider_ptr)
35 : service_provider_ptr_(service_provider_ptr.Pass()) {}
36 ~RendererServiceProvider() final {}
37
38 void ConnectToService(InterfacePtr<MediaRenderer>* media_renderer_ptr) final {
39 mojo::ConnectToService(service_provider_ptr_.get(), media_renderer_ptr);
40 }
41
42 private:
43 ServiceProviderPtr service_provider_ptr_;
44
45 DISALLOW_COPY_AND_ASSIGN(RendererServiceProvider);
46 };
47
48 } // namespace
49 #endif
50
28 WebMediaPlayerFactory::WebMediaPlayerFactory( 51 WebMediaPlayerFactory::WebMediaPlayerFactory(
29 const scoped_refptr<base::SingleThreadTaskRunner>& compositor_task_runner, 52 const scoped_refptr<base::SingleThreadTaskRunner>& compositor_task_runner,
30 bool enable_mojo_media_renderer) 53 bool enable_mojo_media_renderer)
31 : compositor_task_runner_(compositor_task_runner), 54 : compositor_task_runner_(compositor_task_runner),
32 enable_mojo_media_renderer_(enable_mojo_media_renderer), 55 enable_mojo_media_renderer_(enable_mojo_media_renderer),
33 media_thread_("Media"), 56 media_thread_("Media"),
34 audio_manager_(media::AudioManager::Create(&fake_audio_log_factory_)), 57 audio_manager_(media::AudioManager::Create(&fake_audio_log_factory_)),
35 audio_hardware_config_( 58 audio_hardware_config_(
36 audio_manager_->GetInputStreamParameters( 59 audio_manager_->GetInputStreamParameters(
37 media::AudioManagerBase::kDefaultDeviceId), 60 media::AudioManagerBase::kDefaultDeviceId),
(...skipping 17 matching lines...) Expand all
55 #if defined(OS_ANDROID) 78 #if defined(OS_ANDROID)
56 return nullptr; 79 return nullptr;
57 #else 80 #else
58 scoped_refptr<media::MediaLog> media_log(new media::MediaLog()); 81 scoped_refptr<media::MediaLog> media_log(new media::MediaLog());
59 scoped_ptr<media::RendererFactory> media_renderer_factory; 82 scoped_ptr<media::RendererFactory> media_renderer_factory;
60 83
61 if (enable_mojo_media_renderer_) { 84 if (enable_mojo_media_renderer_) {
62 ServiceProviderPtr media_renderer_service_provider; 85 ServiceProviderPtr media_renderer_service_provider;
63 shell->ConnectToApplication("mojo:media", 86 shell->ConnectToApplication("mojo:media",
64 GetProxy(&media_renderer_service_provider)); 87 GetProxy(&media_renderer_service_provider));
65 media_renderer_factory.reset( 88 media_renderer_factory.reset(new media::MojoRendererFactory(make_scoped_ptr(
66 new media::MojoRendererFactory(media_renderer_service_provider.Pass())); 89 new RendererServiceProvider(media_renderer_service_provider.Pass()))));
67 } else { 90 } else {
68 media_renderer_factory.reset( 91 media_renderer_factory.reset(
69 new media::DefaultRendererFactory(media_log, 92 new media::DefaultRendererFactory(media_log,
70 nullptr, // No GPU factory. 93 nullptr, // No GPU factory.
71 GetAudioHardwareConfig())); 94 GetAudioHardwareConfig()));
72 } 95 }
73 96
74 media::WebMediaPlayerParams params( 97 media::WebMediaPlayerParams params(
75 media::WebMediaPlayerParams::DeferLoadCB(), CreateAudioRendererSink(), 98 media::WebMediaPlayerParams::DeferLoadCB(), CreateAudioRendererSink(),
76 media_log, GetMediaThreadTaskRunner(), compositor_task_runner_, nullptr); 99 media_log, GetMediaThreadTaskRunner(), compositor_task_runner_, nullptr);
(...skipping 19 matching lines...) Expand all
96 119
97 scoped_refptr<base::SingleThreadTaskRunner> 120 scoped_refptr<base::SingleThreadTaskRunner>
98 WebMediaPlayerFactory::GetMediaThreadTaskRunner() { 121 WebMediaPlayerFactory::GetMediaThreadTaskRunner() {
99 if (!media_thread_.IsRunning()) 122 if (!media_thread_.IsRunning())
100 media_thread_.Start(); 123 media_thread_.Start();
101 124
102 return media_thread_.message_loop_proxy(); 125 return media_thread_.message_loop_proxy();
103 } 126 }
104 127
105 } // namespace mojo 128 } // namespace mojo
OLDNEW
« no previous file with comments | « media/mojo/services/mojo_renderer_factory.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698