Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / media / mojo / services / renderer_config_default.cc
blob7cee1a7ac6c35531d6c88d583970f96b2c872888
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
3 // found in the LICENSE file.
5 #include "media/mojo/services/renderer_config.h"
7 #include "base/files/file_path.h"
8 #include "base/path_service.h"
9 #include "media/audio/audio_manager_base.h"
10 #include "media/audio/audio_output_stream_sink.h"
11 #include "media/audio/fake_audio_log_factory.h"
12 #include "media/base/media.h"
13 #include "media/filters/opus_audio_decoder.h"
15 #if !defined(MEDIA_DISABLE_FFMPEG)
16 #include "media/filters/ffmpeg_audio_decoder.h"
17 #include "media/filters/ffmpeg_video_decoder.h"
18 #endif
20 #if !defined(MEDIA_DISABLE_LIBVPX)
21 #include "media/filters/vpx_video_decoder.h"
22 #endif
24 namespace media {
25 namespace internal {
27 class DummyVideoRendererSink : public VideoRendererSink {
28 public:
29 DummyVideoRendererSink() {}
30 ~DummyVideoRendererSink() override {}
32 void Start(RenderCallback* callback) override {}
33 void Stop() override {}
34 void PaintFrameUsingOldRenderingPath(
35 const scoped_refptr<VideoFrame>& frame) override {}
37 private:
38 DISALLOW_COPY_AND_ASSIGN(DummyVideoRendererSink);
41 class DefaultRendererConfig : public PlatformRendererConfig {
42 public:
43 DefaultRendererConfig() {
44 // TODO(dalecurtis): This will not work if the process is sandboxed...
45 if (!media::IsMediaLibraryInitialized()) {
46 base::FilePath module_dir;
47 CHECK(PathService::Get(base::DIR_EXE, &module_dir));
48 CHECK(media::InitializeMediaLibrary(module_dir));
51 // TODO(dalecurtis): We should find a single owner per process for the audio
52 // manager or make it a lazy instance. It's not safe to call Get()/Create()
53 // across multiple threads...
55 // TODO(dalecurtis): Eventually we'll want something other than a fake audio
56 // log factory here too. We should probably at least DVLOG() such info.
57 AudioManager* audio_manager = AudioManager::Get();
58 if (!audio_manager)
59 audio_manager = media::AudioManager::Create(&fake_audio_log_factory_);
61 audio_hardware_config_.reset(new AudioHardwareConfig(
62 audio_manager->GetInputStreamParameters(
63 AudioManagerBase::kDefaultDeviceId),
64 audio_manager->GetDefaultOutputStreamParameters()));
67 ScopedVector<AudioDecoder> GetAudioDecoders(
68 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner,
69 const LogCB& media_log_cb) override {
70 ScopedVector<AudioDecoder> audio_decoders;
72 #if !defined(MEDIA_DISABLE_FFMPEG)
73 audio_decoders.push_back(
74 new FFmpegAudioDecoder(media_task_runner, media_log_cb));
75 audio_decoders.push_back(new OpusAudioDecoder(media_task_runner));
76 #endif
78 return audio_decoders.Pass();
81 ScopedVector<VideoDecoder> GetVideoDecoders(
82 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner,
83 const LogCB& media_log_cb) override {
84 ScopedVector<VideoDecoder> video_decoders;
86 // TODO(dalecurtis): If we ever need GPU video decoders, we'll need to
87 // figure out how to retrieve the GpuVideoAcceleratorFactories...
89 #if !defined(MEDIA_DISABLE_LIBVPX)
90 video_decoders.push_back(new VpxVideoDecoder(media_task_runner));
91 #endif
93 #if !defined(MEDIA_DISABLE_FFMPEG)
94 video_decoders.push_back(new FFmpegVideoDecoder(media_task_runner));
95 #endif
97 return video_decoders.Pass();
100 scoped_refptr<AudioRendererSink> GetAudioRendererSink() override {
101 return new AudioOutputStreamSink();
104 scoped_ptr<VideoRendererSink> GetVideoRendererSink() override {
105 return make_scoped_ptr(new DummyVideoRendererSink());
108 const AudioHardwareConfig& GetAudioHardwareConfig() override {
109 return *audio_hardware_config_;
112 private:
113 FakeAudioLogFactory fake_audio_log_factory_;
114 scoped_ptr<AudioHardwareConfig> audio_hardware_config_;
116 DISALLOW_COPY_AND_ASSIGN(DefaultRendererConfig);
119 scoped_ptr<PlatformRendererConfig> CreatePlatformRendererConfig() {
120 return make_scoped_ptr(new DefaultRendererConfig());
123 } // namespace internal
124 } // namespace media