Disable webrtc.webrtc_cases.
[chromium-blink-merge.git] / media / renderers / default_renderer_factory.cc
bloba2a91d5b16491407ab11c48507c4d7c834f9c9ca
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 VideoRendererSink* video_renderer_sink) {
43 DCHECK(audio_renderer_sink);
45 // Create our audio decoders and renderer.
46 ScopedVector<AudioDecoder> audio_decoders;
48 #if !defined(MEDIA_DISABLE_FFMPEG)
49 audio_decoders.push_back(new FFmpegAudioDecoder(
50 media_task_runner, base::Bind(&MediaLog::AddLogEvent, media_log_)));
51 #endif
53 audio_decoders.push_back(new OpusAudioDecoder(media_task_runner));
55 scoped_ptr<AudioRenderer> audio_renderer(new AudioRendererImpl(
56 media_task_runner, audio_renderer_sink, audio_decoders.Pass(),
57 audio_hardware_config_, media_log_));
59 // Create our video decoders and renderer.
60 ScopedVector<VideoDecoder> video_decoders;
62 // |gpu_factories_| requires that its entry points be called on its
63 // |GetTaskRunner()|. Since |pipeline_| will own decoders created from the
64 // factories, require that their message loops are identical.
65 DCHECK(!gpu_factories_.get() ||
66 (gpu_factories_->GetTaskRunner() == media_task_runner.get()));
68 if (gpu_factories_.get())
69 video_decoders.push_back(new GpuVideoDecoder(gpu_factories_));
71 #if !defined(MEDIA_DISABLE_LIBVPX)
72 video_decoders.push_back(new VpxVideoDecoder(media_task_runner));
73 #endif
75 #if !defined(MEDIA_DISABLE_FFMPEG)
76 video_decoders.push_back(new FFmpegVideoDecoder(media_task_runner));
77 #endif
79 scoped_ptr<VideoRenderer> video_renderer(new VideoRendererImpl(
80 media_task_runner, video_renderer_sink, video_decoders.Pass(), true,
81 gpu_factories_, media_log_));
83 // Create renderer.
84 return scoped_ptr<Renderer>(new RendererImpl(
85 media_task_runner, audio_renderer.Pass(), video_renderer.Pass()));
88 } // namespace media