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_RENDERERS_RENDERER_IMPL_H_ | 5 #ifndef MEDIA_RENDERERS_RENDERER_IMPL_H_ |
6 #define MEDIA_RENDERERS_RENDERER_IMPL_H_ | 6 #define MEDIA_RENDERERS_RENDERER_IMPL_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
| 9 #include <queue> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/cancelable_callback.h" | 12 #include "base/cancelable_callback.h" |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
15 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
16 #include "base/time/clock.h" | 17 #include "base/time/clock.h" |
17 #include "base/time/default_tick_clock.h" | 18 #include "base/time/default_tick_clock.h" |
18 #include "base/time/time.h" | 19 #include "base/time/time.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 RendererClient* client, | 54 RendererClient* client, |
54 const PipelineStatusCB& init_cb) final; | 55 const PipelineStatusCB& init_cb) final; |
55 void SetCdm(CdmContext* cdm_context, | 56 void SetCdm(CdmContext* cdm_context, |
56 const CdmAttachedCB& cdm_attached_cb) final; | 57 const CdmAttachedCB& cdm_attached_cb) final; |
57 void Flush(const base::Closure& flush_cb) final; | 58 void Flush(const base::Closure& flush_cb) final; |
58 void StartPlayingFrom(base::TimeDelta time) final; | 59 void StartPlayingFrom(base::TimeDelta time) final; |
59 void SetPlaybackRate(double playback_rate) final; | 60 void SetPlaybackRate(double playback_rate) final; |
60 void SetVolume(float volume) final; | 61 void SetVolume(float volume) final; |
61 base::TimeDelta GetMediaTime() final; | 62 base::TimeDelta GetMediaTime() final; |
62 | 63 |
63 void RestartStreamPlayback(DemuxerStream* stream, | 64 void OnStreamStatusChanged(DemuxerStream* stream, |
64 bool enabled, | 65 bool enabled, |
65 base::TimeDelta time); | 66 base::TimeDelta time); |
66 | 67 |
67 // Helper functions for testing purposes. Must be called before Initialize(). | 68 // Helper functions for testing purposes. Must be called before Initialize(). |
68 void DisableUnderflowForTesting(); | 69 void DisableUnderflowForTesting(); |
69 void EnableClocklessVideoPlaybackForTesting(); | 70 void EnableClocklessVideoPlaybackForTesting(); |
70 void set_time_source_for_testing(TimeSource* time_source) { | 71 void set_time_source_for_testing(TimeSource* time_source) { |
71 time_source_ = time_source; | 72 time_source_ = time_source; |
72 } | 73 } |
73 void set_video_underflow_threshold_for_testing(base::TimeDelta threshold) { | 74 void set_video_underflow_threshold_for_testing(base::TimeDelta threshold) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 void OnRendererEnded(DemuxerStream::Type type); | 140 void OnRendererEnded(DemuxerStream::Type type); |
140 bool PlaybackHasEnded() const; | 141 bool PlaybackHasEnded() const; |
141 void RunEndedCallbackIfNeeded(); | 142 void RunEndedCallbackIfNeeded(); |
142 | 143 |
143 // Callback executed when a runtime error happens. | 144 // Callback executed when a runtime error happens. |
144 void OnError(PipelineStatus error); | 145 void OnError(PipelineStatus error); |
145 void OnWaitingForDecryptionKey(); | 146 void OnWaitingForDecryptionKey(); |
146 void OnVideoNaturalSizeChange(const gfx::Size& size); | 147 void OnVideoNaturalSizeChange(const gfx::Size& size); |
147 void OnVideoOpacityChange(bool opaque); | 148 void OnVideoOpacityChange(bool opaque); |
148 | 149 |
| 150 void OnAudioRestartCompleted(); |
| 151 void OnVideoRestartCompleted(); |
| 152 |
149 State state_; | 153 State state_; |
150 | 154 |
151 // Task runner used to execute pipeline tasks. | 155 // Task runner used to execute pipeline tasks. |
152 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 156 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
153 | 157 |
154 DemuxerStreamProvider* demuxer_stream_provider_; | 158 DemuxerStreamProvider* demuxer_stream_provider_; |
155 RendererClient* client_; | 159 RendererClient* client_; |
156 | 160 |
157 // Temporary callback used for Initialize() and Flush(). | 161 // Temporary callback used for Initialize() and Flush(). |
158 PipelineStatusCB init_cb_; | 162 PipelineStatusCB init_cb_; |
(...skipping 30 matching lines...) Expand all Loading... |
189 base::CancelableClosure deferred_video_underflow_cb_; | 193 base::CancelableClosure deferred_video_underflow_cb_; |
190 | 194 |
191 // Used to defer underflow for audio when restarting audio playback. | 195 // Used to defer underflow for audio when restarting audio playback. |
192 base::CancelableClosure deferred_audio_restart_underflow_cb_; | 196 base::CancelableClosure deferred_audio_restart_underflow_cb_; |
193 | 197 |
194 // The amount of time to wait before declaring underflow if the video renderer | 198 // The amount of time to wait before declaring underflow if the video renderer |
195 // runs out of data but the audio renderer still has enough. | 199 // runs out of data but the audio renderer still has enough. |
196 base::TimeDelta video_underflow_threshold_; | 200 base::TimeDelta video_underflow_threshold_; |
197 | 201 |
198 bool restarting_audio_ = false; | 202 bool restarting_audio_ = false; |
| 203 std::queue<base::Closure> pending_audio_status_notifications_; |
199 bool restarting_video_ = false; | 204 bool restarting_video_ = false; |
| 205 std::queue<base::Closure> pending_video_status_notifications_; |
200 | 206 |
201 base::WeakPtr<RendererImpl> weak_this_; | 207 base::WeakPtr<RendererImpl> weak_this_; |
202 base::WeakPtrFactory<RendererImpl> weak_factory_; | 208 base::WeakPtrFactory<RendererImpl> weak_factory_; |
203 | 209 |
204 DISALLOW_COPY_AND_ASSIGN(RendererImpl); | 210 DISALLOW_COPY_AND_ASSIGN(RendererImpl); |
205 }; | 211 }; |
206 | 212 |
207 } // namespace media | 213 } // namespace media |
208 | 214 |
209 #endif // MEDIA_RENDERERS_RENDERER_IMPL_H_ | 215 #endif // MEDIA_RENDERERS_RENDERER_IMPL_H_ |
OLD | NEW |