This sets up API to release OutputSurface from LTHClient.
[chromium-blink-merge.git] / media / mojo / services / mojo_media_client.h
blobf5e5ca2db850252e8edaaf103908f8a2e16153d6
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_MOJO_MEDIA_CLIENT_H_
6 #define MEDIA_MOJO_SERVICES_MOJO_MEDIA_CLIENT_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/cdm_factory.h"
15 #include "media/base/media_log.h"
16 #include "media/base/renderer_factory.h"
17 #include "media/base/video_decoder.h"
18 #include "media/base/video_renderer_sink.h"
20 namespace media {
22 // Interface class which clients will extend to override (at compile time) the
23 // default configurations for mojo media services.
24 class PlatformMojoMediaClient {
25 public:
26 virtual ~PlatformMojoMediaClient() {};
28 // Returns the RendererFactory to be used by MojoRendererService. If returns
29 // null, a RendererImpl will be used with audio/video decoders provided in
30 // CreateAudioDecoders() and CreateVideoDecoders().
31 virtual scoped_ptr<RendererFactory> CreateRendererFactory(
32 const scoped_refptr<MediaLog>& media_log) = 0;
34 // The list of audio or video decoders for use with RendererImpl when
35 // CreateRendererFactory() returns null. Ownership of the decoders is passed
36 // to the caller. The methods on each decoder will only be called on
37 // |media_task_runner|. |media_log| should be used to log errors or important
38 // status information.
39 virtual ScopedVector<AudioDecoder> CreateAudioDecoders(
40 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner,
41 const scoped_refptr<MediaLog>& media_log) = 0;
42 virtual ScopedVector<VideoDecoder> CreateVideoDecoders(
43 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner,
44 const scoped_refptr<MediaLog>& media_log) = 0;
46 // The output sink used for rendering audio or video respectively.
47 virtual scoped_refptr<AudioRendererSink> CreateAudioRendererSink() = 0;
48 virtual scoped_ptr<VideoRendererSink> CreateVideoRendererSink(
49 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) = 0;
51 // The platform's audio hardware configuration. Note, this must remain
52 // constant for the lifetime of the PlatformMojoMediaClient.
53 virtual const AudioHardwareConfig& GetAudioHardwareConfig() = 0;
55 // Returns the CdmFactory to be used by MojoCdmService.
56 virtual scoped_ptr<CdmFactory> CreateCdmFactory() = 0;
59 class MojoMediaClient {
60 public:
61 // Returns an instance of the MojoMediaClient object. Only one instance will
62 // exist per process.
63 static MojoMediaClient* Get();
65 // Copy of the PlatformMojoMediaClient interface.
66 scoped_ptr<RendererFactory> CreateRendererFactory(
67 const scoped_refptr<MediaLog>& media_log);
68 ScopedVector<AudioDecoder> CreateAudioDecoders(
69 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner,
70 const scoped_refptr<MediaLog>& media_log);
71 ScopedVector<VideoDecoder> CreateVideoDecoders(
72 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner,
73 const scoped_refptr<MediaLog>& media_log);
74 scoped_refptr<AudioRendererSink> CreateAudioRendererSink();
75 scoped_ptr<VideoRendererSink> CreateVideoRendererSink(
76 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
77 const AudioHardwareConfig& GetAudioHardwareConfig();
78 scoped_ptr<CdmFactory> CreateCdmFactory();
80 private:
81 friend struct base::DefaultLazyInstanceTraits<MojoMediaClient>;
83 MojoMediaClient();
84 ~MojoMediaClient();
86 scoped_ptr<PlatformMojoMediaClient> mojo_media_client_;
88 DISALLOW_COPY_AND_ASSIGN(MojoMediaClient);
91 } // namespace media
93 #endif // MEDIA_MOJO_SERVICES_MOJO_MEDIA_CLIENT_H_