Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Side by Side Diff: media/renderers/renderer_impl.h

Issue 2605473002: Fix processing of multiple stream status changes by renderer (Closed)
Patch Set: CR feedback Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | media/renderers/renderer_impl.cc » ('j') | media/renderers/renderer_impl.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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_
OLDNEW
« no previous file with comments | « no previous file | media/renderers/renderer_impl.cc » ('j') | media/renderers/renderer_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698