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 #ifndef MEDIA_MOJO_SERVICES_RENDERER_CONFIG_H_
6 #define MEDIA_MOJO_SERVICES_RENDERER_CONFIG_H_
8 #include "base/lazy_instance.h"
9 #include "base/memory/scoped_vector.h"
10 #include "base/single_thread_task_runner.h"
11 #include "media/base/audio_decoder.h"
12 #include "media/base/audio_hardware_config.h"
13 #include "media/base/audio_renderer_sink.h"
14 #include "media/base/media_log.h"
15 #include "media/base/video_decoder.h"
16 #include "media/base/video_renderer_sink.h"
20 // Interface class which clients will extend to override (at compile time) the
21 // default audio or video rendering configurations for MojoRendererService.
22 class PlatformRendererConfig
{
24 virtual ~PlatformRendererConfig() {};
26 // The list of audio or video decoders for use with the AudioRenderer or
27 // VideoRenderer respectively. Ownership of the decoders is passed to the
28 // caller. The methods on each decoder will only be called on
29 // |media_task_runner|. |media_log_cb| should be used to log errors or
30 // important status information.
31 virtual ScopedVector
<AudioDecoder
> GetAudioDecoders(
32 const scoped_refptr
<base::SingleThreadTaskRunner
>& media_task_runner
,
33 const LogCB
& media_log_cb
) = 0;
34 virtual ScopedVector
<VideoDecoder
> GetVideoDecoders(
35 const scoped_refptr
<base::SingleThreadTaskRunner
>& media_task_runner
,
36 const LogCB
& media_log_cb
) = 0;
38 // The output sink used for rendering audio or video respectively.
39 virtual scoped_refptr
<AudioRendererSink
> GetAudioRendererSink() = 0;
40 virtual scoped_ptr
<VideoRendererSink
> GetVideoRendererSink() = 0;
42 // The platform's audio hardware configuration. Note, this must remain
43 // constant for the lifetime of the PlatformRendererConfig.
44 virtual const AudioHardwareConfig
& GetAudioHardwareConfig() = 0;
47 class RendererConfig
{
49 // Returns an instance of the RenderConfig object. Only one instance will
51 static RendererConfig
* Get();
53 // Copy of the PlatformRendererConfig interface.
54 ScopedVector
<AudioDecoder
> GetAudioDecoders(
55 const scoped_refptr
<base::SingleThreadTaskRunner
>& media_task_runner
,
56 const LogCB
& media_log_cb
);
57 ScopedVector
<VideoDecoder
> GetVideoDecoders(
58 const scoped_refptr
<base::SingleThreadTaskRunner
>& media_task_runner
,
59 const LogCB
& media_log_cb
);
60 scoped_refptr
<AudioRendererSink
> GetAudioRendererSink();
61 scoped_ptr
<VideoRendererSink
> GetVideoRendererSink();
62 const AudioHardwareConfig
& GetAudioHardwareConfig();
65 friend struct base::DefaultLazyInstanceTraits
<RendererConfig
>;
70 scoped_ptr
<PlatformRendererConfig
> renderer_config_
;
72 DISALLOW_COPY_AND_ASSIGN(RendererConfig
);
77 #endif // MEDIA_MOJO_SERVICES_RENDERER_CONFIG_H_