Drive: Add BatchableRequest subclass.
[chromium-blink-merge.git] / media / renderers / default_renderer_factory.cc
blob81162d35e2a1956cb4e2aece8fde4b58cbd034d0
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"
7 #include "base/bind.h"
8 #include "base/single_thread_task_runner.h"
9 #if !defined(MEDIA_DISABLE_FFMPEG)
10 #include "media/base/media_log.h"
11 #include "media/filters/ffmpeg_audio_decoder.h"
12 #include "media/filters/ffmpeg_video_decoder.h"
13 #endif
14 #include "media/filters/gpu_video_decoder.h"
15 #include "media/filters/opus_audio_decoder.h"
16 #include "media/renderers/audio_renderer_impl.h"
17 #include "media/renderers/gpu_video_accelerator_factories.h"
18 #include "media/renderers/renderer_impl.h"
19 #include "media/renderers/video_renderer_impl.h"
20 #if !defined(MEDIA_DISABLE_LIBVPX)
21 #include "media/filters/vpx_video_decoder.h"
22 #endif
24 namespace media {
26 DefaultRendererFactory::DefaultRendererFactory(
27 const scoped_refptr<MediaLog>& media_log,
28 const scoped_refptr<GpuVideoAcceleratorFactories>& gpu_factories,
29 const AudioHardwareConfig& audio_hardware_config)
30 : media_log_(media_log),
31 gpu_factories_(gpu_factories),
32 audio_hardware_config_(audio_hardware_config) {
35 DefaultRendererFactory::~DefaultRendererFactory() {
38 // TODO(xhwang): Use RendererConfig to customize what decoders we use.
39 scoped_ptr<Renderer> DefaultRendererFactory::CreateRenderer(
40 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner,
41 AudioRendererSink* audio_renderer_sink) {
42 DCHECK(audio_renderer_sink);
44 // Create our audio decoders and renderer.
45 ScopedVector<AudioDecoder> audio_decoders;
47 #if !defined(MEDIA_DISABLE_FFMPEG)
48 audio_decoders.push_back(new FFmpegAudioDecoder(
49 media_task_runner, base::Bind(&MediaLog::AddLogEvent, media_log_)));
50 #endif
52 audio_decoders.push_back(new OpusAudioDecoder(media_task_runner));
54 scoped_ptr<AudioRenderer> audio_renderer(new AudioRendererImpl(
55 media_task_runner, audio_renderer_sink, audio_decoders.Pass(),
56 audio_hardware_config_, media_log_));
58 // Create our video decoders and renderer.
59 ScopedVector<VideoDecoder> video_decoders;
61 // |gpu_factories_| requires that its entry points be called on its
62 // |GetTaskRunner()|. Since |pipeline_| will own decoders created from the
63 // factories, require that their message loops are identical.
64 DCHECK(!gpu_factories_.get() ||
65 (gpu_factories_->GetTaskRunner() == media_task_runner.get()));
67 if (gpu_factories_.get())
68 video_decoders.push_back(new GpuVideoDecoder(gpu_factories_));
70 #if !defined(MEDIA_DISABLE_LIBVPX)
71 video_decoders.push_back(new VpxVideoDecoder(media_task_runner));
72 #endif
74 #if !defined(MEDIA_DISABLE_FFMPEG)
75 video_decoders.push_back(new FFmpegVideoDecoder(media_task_runner));
76 #endif
78 scoped_ptr<VideoRenderer> video_renderer(new VideoRendererImpl(
79 media_task_runner, video_decoders.Pass(), true, media_log_));
81 // Create renderer.
82 return scoped_ptr<Renderer>(new RendererImpl(
83 media_task_runner, audio_renderer.Pass(), video_renderer.Pass()));
86 } // namespace media