OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_MOJO_SERVICES_MOJO_RENDERER_IMPL_H_ | 5 #ifndef MEDIA_MOJO_SERVICES_MOJO_RENDERER_IMPL_H_ |
6 #define MEDIA_MOJO_SERVICES_MOJO_RENDERER_IMPL_H_ | 6 #define MEDIA_MOJO_SERVICES_MOJO_RENDERER_IMPL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "media/base/renderer.h" | 11 #include "media/base/renderer.h" |
12 #include "media/mojo/interfaces/renderer.mojom.h" | 12 #include "media/mojo/interfaces/renderer.mojom.h" |
13 #include "mojo/public/cpp/bindings/binding.h" | 13 #include "mojo/public/cpp/bindings/binding.h" |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 class SingleThreadTaskRunner; | 16 class SingleThreadTaskRunner; |
17 } | 17 } |
18 | 18 |
19 namespace media { | 19 namespace media { |
20 | 20 |
21 class DemuxerStreamProvider; | 21 class DemuxerStreamProvider; |
| 22 class VideoOverlayFactory; |
| 23 class VideoRendererSink; |
22 | 24 |
23 // A media::Renderer that proxies to a mojom::Renderer. That | 25 // A media::Renderer that proxies to a mojom::Renderer. That |
24 // mojom::Renderer proxies back to the MojoRendererImpl via the | 26 // mojom::Renderer proxies back to the MojoRendererImpl via the |
25 // mojom::RendererClient interface. | 27 // mojom::RendererClient interface. |
26 // | 28 // |
27 // This class can be created on any thread, where the |remote_renderer| is | 29 // This class can be created on any thread, where the |remote_renderer| is |
28 // connected and passed in the constructor. Then Initialize() will be called on | 30 // connected and passed in the constructor. Then Initialize() will be called on |
29 // the |task_runner| and starting from that point this class is bound to the | 31 // the |task_runner| and starting from that point this class is bound to the |
30 // |task_runner|*. That means all Renderer and RendererClient methods will be | 32 // |task_runner|*. That means all Renderer and RendererClient methods will be |
31 // called/dispached on the |task_runner|. The only exception is GetMediaTime(), | 33 // called/dispached on the |task_runner|. The only exception is GetMediaTime(), |
32 // which can be called on any thread. | 34 // which can be called on any thread. |
33 class MojoRendererImpl : public Renderer, public mojom::RendererClient { | 35 class MojoRendererImpl : public Renderer, public mojom::RendererClient { |
34 public: | 36 public: |
35 MojoRendererImpl( | 37 MojoRendererImpl( |
36 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 38 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| 39 std::unique_ptr<VideoOverlayFactory> video_overlay_factory, |
| 40 VideoRendererSink* video_renderer_sink, |
37 mojom::RendererPtr remote_renderer); | 41 mojom::RendererPtr remote_renderer); |
38 ~MojoRendererImpl() override; | 42 ~MojoRendererImpl() override; |
39 | 43 |
40 // Renderer implementation. | 44 // Renderer implementation. |
41 void Initialize(DemuxerStreamProvider* demuxer_stream_provider, | 45 void Initialize(DemuxerStreamProvider* demuxer_stream_provider, |
42 media::RendererClient* client, | 46 media::RendererClient* client, |
43 const PipelineStatusCB& init_cb) override; | 47 const PipelineStatusCB& init_cb) override; |
44 void SetCdm(CdmContext* cdm_context, | 48 void SetCdm(CdmContext* cdm_context, |
45 const CdmAttachedCB& cdm_attached_cb) override; | 49 const CdmAttachedCB& cdm_attached_cb) override; |
46 void Flush(const base::Closure& flush_cb) override; | 50 void Flush(const base::Closure& flush_cb) override; |
(...skipping 17 matching lines...) Expand all Loading... |
64 // Callback for connection error on |remote_renderer_|. | 68 // Callback for connection error on |remote_renderer_|. |
65 void OnConnectionError(); | 69 void OnConnectionError(); |
66 | 70 |
67 // Called when |remote_renderer_| has finished initializing. | 71 // Called when |remote_renderer_| has finished initializing. |
68 void OnInitialized(bool success); | 72 void OnInitialized(bool success); |
69 | 73 |
70 // |task_runner| on which all methods are invoked, except for GetMediaTime(), | 74 // |task_runner| on which all methods are invoked, except for GetMediaTime(), |
71 // which can be called on any thread. | 75 // which can be called on any thread. |
72 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 76 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
73 | 77 |
| 78 // Overlay factory used to create overlays for video frames rendered |
| 79 // by the remote renderer. |
| 80 std::unique_ptr<VideoOverlayFactory> video_overlay_factory_; |
| 81 |
| 82 // Video frame overlays are rendered onto this sink. |
| 83 // Rendering of a new overlay is only needed when video natural size changes. |
| 84 VideoRendererSink* video_renderer_sink_; |
| 85 |
74 // Provider of audio/video DemuxerStreams. Must be valid throughout the | 86 // Provider of audio/video DemuxerStreams. Must be valid throughout the |
75 // lifetime of |this|. | 87 // lifetime of |this|. |
76 DemuxerStreamProvider* demuxer_stream_provider_; | 88 DemuxerStreamProvider* demuxer_stream_provider_; |
77 | 89 |
78 // Client of |this| renderer passed in Initialize. | 90 // Client of |this| renderer passed in Initialize. |
79 media::RendererClient* client_; | 91 media::RendererClient* client_; |
80 | 92 |
81 // This class is constructed on one thread and used exclusively on another | 93 // This class is constructed on one thread and used exclusively on another |
82 // thread. This member is used to safely pass the RendererPtr from one thread | 94 // thread. This member is used to safely pass the RendererPtr from one thread |
83 // to another. It is set in the constructor and is consumed in Initialize(). | 95 // to another. It is set in the constructor and is consumed in Initialize(). |
(...skipping 12 matching lines...) Expand all Loading... |
96 // Lock used to serialize access for |time_|. | 108 // Lock used to serialize access for |time_|. |
97 mutable base::Lock lock_; | 109 mutable base::Lock lock_; |
98 base::TimeDelta time_; | 110 base::TimeDelta time_; |
99 | 111 |
100 DISALLOW_COPY_AND_ASSIGN(MojoRendererImpl); | 112 DISALLOW_COPY_AND_ASSIGN(MojoRendererImpl); |
101 }; | 113 }; |
102 | 114 |
103 } // namespace media | 115 } // namespace media |
104 | 116 |
105 #endif // MEDIA_MOJO_SERVICES_MOJO_RENDERER_IMPL_H_ | 117 #endif // MEDIA_MOJO_SERVICES_MOJO_RENDERER_IMPL_H_ |
OLD | NEW |