cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / media / renderers / default_renderer_factory.cc
blobadd6e15c9c8179efc8a2f64ae52e9477e941a49a
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 "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"
21 #endif
22 #endif
24 #if !defined(OS_ANDROID) || defined(ENABLE_MEDIA_PIPELINE_ON_ANDROID)
25 #include "media/filters/opus_audio_decoder.h"
26 #endif
28 #if !defined(MEDIA_DISABLE_LIBVPX)
29 #include "media/filters/vpx_video_decoder.h"
30 #endif
32 namespace media {
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 const scoped_refptr<base::TaskRunner>& worker_task_runner,
49 AudioRendererSink* audio_renderer_sink,
50 VideoRendererSink* video_renderer_sink) {
51 DCHECK(audio_renderer_sink);
53 // Create our audio decoders and renderer.
54 ScopedVector<AudioDecoder> audio_decoders;
56 #if !defined(MEDIA_DISABLE_FFMPEG)
57 audio_decoders.push_back(
58 new FFmpegAudioDecoder(media_task_runner, media_log_));
59 #endif
61 #if !defined(OS_ANDROID) || defined(ENABLE_MEDIA_PIPELINE_ON_ANDROID)
62 audio_decoders.push_back(new OpusAudioDecoder(media_task_runner));
63 #endif
65 scoped_ptr<AudioRenderer> audio_renderer(new AudioRendererImpl(
66 media_task_runner, audio_renderer_sink, audio_decoders.Pass(),
67 audio_hardware_config_, media_log_));
69 // Create our video decoders and renderer.
70 ScopedVector<VideoDecoder> video_decoders;
72 // |gpu_factories_| requires that its entry points be called on its
73 // |GetTaskRunner()|. Since |pipeline_| will own decoders created from the
74 // factories, require that their message loops are identical.
75 DCHECK(!gpu_factories_.get() ||
76 (gpu_factories_->GetTaskRunner() == media_task_runner.get()));
78 if (gpu_factories_.get())
79 video_decoders.push_back(new GpuVideoDecoder(gpu_factories_));
81 #if !defined(MEDIA_DISABLE_LIBVPX)
82 video_decoders.push_back(new VpxVideoDecoder(media_task_runner));
83 #endif
85 #if !defined(MEDIA_DISABLE_FFMPEG) && !defined(DISABLE_FFMPEG_VIDEO_DECODERS)
86 video_decoders.push_back(new FFmpegVideoDecoder(media_task_runner));
87 #endif
89 scoped_ptr<VideoRenderer> video_renderer(new VideoRendererImpl(
90 media_task_runner, worker_task_runner, video_renderer_sink,
91 video_decoders.Pass(), true, gpu_factories_, media_log_));
93 // Create renderer.
94 return scoped_ptr<Renderer>(new RendererImpl(
95 media_task_runner, audio_renderer.Pass(), video_renderer.Pass()));
98 } // namespace media