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/renderers/default_renderer_factory.h"
8 #include "build/build_config.h"
9 #include "base/single_thread_task_runner.h"
10 #include "media/base/media_log.h"
11 #include "media/filters/gpu_video_decoder.h"
12 #include "media/renderers/audio_renderer_impl.h"
13 #include "media/renderers/gpu_video_accelerator_factories.h"
14 #include "media/renderers/renderer_impl.h"
15 #include "media/renderers/video_renderer_impl.h"
17 #if !defined(MEDIA_DISABLE_FFMPEG)
18 #include "media/filters/ffmpeg_audio_decoder.h"
19 #if !defined(DISABLE_FFMPEG_VIDEO_DECODERS)
20 #include "media/filters/ffmpeg_video_decoder.h"
24 #if !defined(OS_ANDROID) || defined(ENABLE_MEDIA_PIPELINE_ON_ANDROID)
25 #include "media/filters/opus_audio_decoder.h"
28 #if !defined(MEDIA_DISABLE_LIBVPX)
29 #include "media/filters/vpx_video_decoder.h"
34 DefaultRendererFactory::DefaultRendererFactory(
35 const scoped_refptr
<MediaLog
>& media_log
,
36 const scoped_refptr
<GpuVideoAcceleratorFactories
>& gpu_factories
,
37 const AudioHardwareConfig
& audio_hardware_config
)
38 : media_log_(media_log
),
39 gpu_factories_(gpu_factories
),
40 audio_hardware_config_(audio_hardware_config
) {
43 DefaultRendererFactory::~DefaultRendererFactory() {
46 scoped_ptr
<Renderer
> DefaultRendererFactory::CreateRenderer(
47 const scoped_refptr
<base::SingleThreadTaskRunner
>& media_task_runner
,
48 AudioRendererSink
* audio_renderer_sink
,
49 VideoRendererSink
* video_renderer_sink
) {
50 DCHECK(audio_renderer_sink
);
52 // Create our audio decoders and renderer.
53 ScopedVector
<AudioDecoder
> audio_decoders
;
55 #if !defined(MEDIA_DISABLE_FFMPEG)
56 audio_decoders
.push_back(
57 new FFmpegAudioDecoder(media_task_runner
, media_log_
));
60 #if !defined(OS_ANDROID) || defined(ENABLE_MEDIA_PIPELINE_ON_ANDROID)
61 audio_decoders
.push_back(new OpusAudioDecoder(media_task_runner
));
64 scoped_ptr
<AudioRenderer
> audio_renderer(new AudioRendererImpl(
65 media_task_runner
, audio_renderer_sink
, audio_decoders
.Pass(),
66 audio_hardware_config_
, media_log_
));
68 // Create our video decoders and renderer.
69 ScopedVector
<VideoDecoder
> video_decoders
;
71 // |gpu_factories_| requires that its entry points be called on its
72 // |GetTaskRunner()|. Since |pipeline_| will own decoders created from the
73 // factories, require that their message loops are identical.
74 DCHECK(!gpu_factories_
.get() ||
75 (gpu_factories_
->GetTaskRunner() == media_task_runner
.get()));
77 if (gpu_factories_
.get())
78 video_decoders
.push_back(new GpuVideoDecoder(gpu_factories_
));
80 #if !defined(MEDIA_DISABLE_LIBVPX)
81 video_decoders
.push_back(new VpxVideoDecoder(media_task_runner
));
84 #if !defined(MEDIA_DISABLE_FFMPEG) && !defined(DISABLE_FFMPEG_VIDEO_DECODERS)
85 video_decoders
.push_back(new FFmpegVideoDecoder(media_task_runner
));
88 scoped_ptr
<VideoRenderer
> video_renderer(new VideoRendererImpl(
89 media_task_runner
, video_renderer_sink
, video_decoders
.Pass(), true,
90 gpu_factories_
, media_log_
));
93 return scoped_ptr
<Renderer
>(new RendererImpl(
94 media_task_runner
, audio_renderer
.Pass(), video_renderer
.Pass()));