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_FILTERS_RENDERER_IMPL_H_ | 5 #ifndef MEDIA_FILTERS_RENDERER_IMPL_H_ |
6 #define MEDIA_FILTERS_RENDERER_IMPL_H_ | 6 #define MEDIA_FILTERS_RENDERER_IMPL_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
12 #include "base/time/clock.h" | 12 #include "base/time/clock.h" |
13 #include "base/time/default_tick_clock.h" | 13 #include "base/time/default_tick_clock.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "media/base/buffering_state.h" | 15 #include "media/base/buffering_state.h" |
16 #include "media/base/media_export.h" | 16 #include "media/base/media_export.h" |
17 #include "media/base/pipeline_status.h" | 17 #include "media/base/pipeline_status.h" |
18 #include "media/base/renderer.h" | 18 #include "media/base/renderer.h" |
19 | 19 |
20 namespace base { | 20 namespace base { |
21 class SingleThreadTaskRunner; | 21 class SingleThreadTaskRunner; |
22 } | 22 } |
23 | 23 |
24 namespace media { | 24 namespace media { |
25 | 25 |
26 class AudioRenderer; | 26 class AudioRenderer; |
27 class Demuxer; | 27 class DemuxerStreamProvider; |
28 class TimeDeltaInterpolator; | 28 class TimeDeltaInterpolator; |
29 class TimeSource; | 29 class TimeSource; |
30 class VideoRenderer; | 30 class VideoRenderer; |
31 | 31 |
32 class MEDIA_EXPORT RendererImpl : public Renderer { | 32 class MEDIA_EXPORT RendererImpl : public Renderer { |
33 public: | 33 public: |
34 // Renders audio/video streams in |demuxer| using |audio_renderer| and | 34 // Renders audio/video streams in |demuxer_stream_provider| using |
35 // |video_renderer| provided. All methods except for GetMediaTime() run on the | 35 // |audio_renderer| and |video_renderer| provided. |
36 // |task_runner|. GetMediaTime() runs on the render main thread because it's | 36 // Notes: |
37 // part of JS sync API. |get_duration_cb| is used to get the duration of the | 37 // - |demuxer_stream_provider| and the streams it provides are guaranteed to |
38 // stream. | 38 // be valid during the lifetime of this object. |
| 39 // - All methods except for GetMediaTime() run on the |task_runner|. |
| 40 // GetMediaTime() runs on the render main thread because it's part of JS |
| 41 // sync API. |get_duration_cb| is used to get the duration of the stream. |
39 RendererImpl(const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 42 RendererImpl(const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
40 Demuxer* demuxer, | 43 DemuxerStreamProvider* demuxer_stream_provider, |
41 scoped_ptr<AudioRenderer> audio_renderer, | 44 scoped_ptr<AudioRenderer> audio_renderer, |
42 scoped_ptr<VideoRenderer> video_renderer); | 45 scoped_ptr<VideoRenderer> video_renderer); |
43 | 46 |
44 virtual ~RendererImpl(); | 47 virtual ~RendererImpl(); |
45 | 48 |
46 // Renderer implementation. | 49 // Renderer implementation. |
47 virtual void Initialize(const PipelineStatusCB& init_cb, | 50 virtual void Initialize(const PipelineStatusCB& init_cb, |
48 const StatisticsCB& statistics_cb, | 51 const StatisticsCB& statistics_cb, |
49 const base::Closure& ended_cb, | 52 const base::Closure& ended_cb, |
50 const PipelineStatusCB& error_cb, | 53 const PipelineStatusCB& error_cb, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 // Callback executed when a runtime error happens. | 124 // Callback executed when a runtime error happens. |
122 void OnError(PipelineStatus error); | 125 void OnError(PipelineStatus error); |
123 | 126 |
124 void FireAllPendingCallbacks(); | 127 void FireAllPendingCallbacks(); |
125 | 128 |
126 State state_; | 129 State state_; |
127 | 130 |
128 // Task runner used to execute pipeline tasks. | 131 // Task runner used to execute pipeline tasks. |
129 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 132 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
130 | 133 |
131 Demuxer* demuxer_; | 134 DemuxerStreamProvider* demuxer_stream_provider_; |
132 | 135 |
133 // Permanent callback to get the media duration. | 136 // Permanent callback to get the media duration. |
134 TimeDeltaCB get_duration_cb_; | 137 TimeDeltaCB get_duration_cb_; |
135 | 138 |
136 // Permanent callbacks to notify various renderer states/stats. | 139 // Permanent callbacks to notify various renderer states/stats. |
137 StatisticsCB statistics_cb_; | 140 StatisticsCB statistics_cb_; |
138 base::Closure ended_cb_; | 141 base::Closure ended_cb_; |
139 PipelineStatusCB error_cb_; | 142 PipelineStatusCB error_cb_; |
140 BufferingStateCB buffering_state_cb_; | 143 BufferingStateCB buffering_state_cb_; |
141 | 144 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 // NOTE: Weak pointers must be invalidated before all other member variables. | 193 // NOTE: Weak pointers must be invalidated before all other member variables. |
191 base::WeakPtrFactory<RendererImpl> weak_factory_; | 194 base::WeakPtrFactory<RendererImpl> weak_factory_; |
192 base::WeakPtr<RendererImpl> weak_this_; | 195 base::WeakPtr<RendererImpl> weak_this_; |
193 | 196 |
194 DISALLOW_COPY_AND_ASSIGN(RendererImpl); | 197 DISALLOW_COPY_AND_ASSIGN(RendererImpl); |
195 }; | 198 }; |
196 | 199 |
197 } // namespace media | 200 } // namespace media |
198 | 201 |
199 #endif // MEDIA_FILTERS_RENDERER_IMPL_H_ | 202 #endif // MEDIA_FILTERS_RENDERER_IMPL_H_ |
OLD | NEW |