Chromium Code Reviews| 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 <list> | 8 #include <list> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 void SetCdm(CdmContext* cdm_context, | 56 void SetCdm(CdmContext* cdm_context, |
| 57 const CdmAttachedCB& cdm_attached_cb) final; | 57 const CdmAttachedCB& cdm_attached_cb) final; |
| 58 void Flush(const base::Closure& flush_cb) final; | 58 void Flush(const base::Closure& flush_cb) final; |
| 59 void StartPlayingFrom(base::TimeDelta time) final; | 59 void StartPlayingFrom(base::TimeDelta time) final; |
| 60 void SetPlaybackRate(double playback_rate) final; | 60 void SetPlaybackRate(double playback_rate) final; |
| 61 void SetVolume(float volume) final; | 61 void SetVolume(float volume) final; |
| 62 base::TimeDelta GetMediaTime() final; | 62 base::TimeDelta GetMediaTime() final; |
| 63 | 63 |
| 64 void OnStreamStatusChanged(DemuxerStream* stream, | 64 void OnStreamStatusChanged(DemuxerStream* stream, |
| 65 bool enabled, | 65 bool enabled, |
| 66 base::TimeDelta time); | 66 base::TimeDelta time); |
|
xhwang
2017/03/29 00:16:47
This doesn't need to be public. Also it would be n
servolk
2017/03/29 01:49:33
Done.
| |
| 67 | 67 |
| 68 // Helper functions for testing purposes. Must be called before Initialize(). | 68 // Helper functions for testing purposes. Must be called before Initialize(). |
| 69 void DisableUnderflowForTesting(); | 69 void DisableUnderflowForTesting(); |
| 70 void EnableClocklessVideoPlaybackForTesting(); | 70 void EnableClocklessVideoPlaybackForTesting(); |
| 71 void set_time_source_for_testing(TimeSource* time_source) { | 71 void set_time_source_for_testing(TimeSource* time_source) { |
| 72 time_source_ = time_source; | 72 time_source_ = time_source; |
| 73 } | 73 } |
| 74 void set_video_underflow_threshold_for_testing(base::TimeDelta threshold) { | 74 void set_video_underflow_threshold_for_testing(base::TimeDelta threshold) { |
| 75 video_underflow_threshold_ = threshold; | 75 video_underflow_threshold_ = threshold; |
| 76 } | 76 } |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 99 void OnAudioRendererInitializeDone(PipelineStatus status); | 99 void OnAudioRendererInitializeDone(PipelineStatus status); |
| 100 void InitializeVideoRenderer(); | 100 void InitializeVideoRenderer(); |
| 101 void OnVideoRendererInitializeDone(PipelineStatus status); | 101 void OnVideoRendererInitializeDone(PipelineStatus status); |
| 102 | 102 |
| 103 // Helper functions and callbacks for Flush(). | 103 // Helper functions and callbacks for Flush(). |
| 104 void FlushAudioRenderer(); | 104 void FlushAudioRenderer(); |
| 105 void OnAudioRendererFlushDone(); | 105 void OnAudioRendererFlushDone(); |
| 106 void FlushVideoRenderer(); | 106 void FlushVideoRenderer(); |
| 107 void OnVideoRendererFlushDone(); | 107 void OnVideoRendererFlushDone(); |
| 108 | 108 |
| 109 void RestartAudioRenderer(base::TimeDelta time); | 109 // Reinitialize audio/video renderer during a media track switching. The |
| 110 void RestartVideoRenderer(base::TimeDelta time); | 110 // renderer must be flushed first, and when the re-init is completed the |
| 111 // corresponding callback will be invoked to restart playback. | |
| 112 // The |stream| parameter specifies the demuxer stream representing the new | |
| 113 // media track. And the |time| parameter specifies the time on media timeline | |
| 114 // where the switch occured. | |
|
xhwang
2017/03/29 00:16:47
nit: At this level, we are dealing with DemuxerStr
servolk
2017/03/29 01:49:33
Done.
| |
| 115 void ReinitializeAudioRenderer(DemuxerStream* stream, base::TimeDelta time); | |
| 116 void OnAudioRendererReinitialized(DemuxerStream* stream, | |
| 117 base::TimeDelta time, | |
| 118 PipelineStatus status); | |
| 119 void ReinitializeVideoRenderer(DemuxerStream* stream, base::TimeDelta time); | |
| 120 void OnVideoRendererReinitialized(DemuxerStream* stream, | |
| 121 base::TimeDelta time, | |
| 122 PipelineStatus status); | |
| 123 | |
| 124 // Restart audio/video renderer playback after a media track switch or after a | |
| 125 // media track has been disabled and re-enabled. The |stream| parameter | |
|
xhwang
2017/03/29 00:16:47
ditto about "media track"
servolk
2017/03/29 01:49:33
Done.
| |
| 126 // specifies which stream needs to be restarted. The |time| parameter | |
| 127 // specifies the position on the media timeline where the playback needs to be | |
| 128 // restarted. It is necessary for demuxers with independent streams (e.g. MSE | |
| 129 // / ChunkDemuxer) to synchronize data reading between those streams. | |
| 130 void RestartAudioRenderer(DemuxerStream* stream, base::TimeDelta time); | |
| 131 void RestartVideoRenderer(DemuxerStream* stream, base::TimeDelta time); | |
| 111 | 132 |
| 112 // Callback executed by filters to update statistics. | 133 // Callback executed by filters to update statistics. |
| 113 void OnStatisticsUpdate(const PipelineStatistics& stats); | 134 void OnStatisticsUpdate(const PipelineStatistics& stats); |
| 114 | 135 |
| 115 // Collection of callback methods and helpers for tracking changes in | 136 // Collection of callback methods and helpers for tracking changes in |
| 116 // buffering state and transition from paused/underflow states and playing | 137 // buffering state and transition from paused/underflow states and playing |
| 117 // states. | 138 // states. |
| 118 // | 139 // |
| 119 // While in the kPlaying state: | 140 // While in the kPlaying state: |
| 120 // - A waiting to non-waiting transition indicates preroll has completed | 141 // - A waiting to non-waiting transition indicates preroll has completed |
| 121 // and StartPlayback() should be called | 142 // and StartPlayback() should be called |
| 122 // - A non-waiting to waiting transition indicates underflow has occurred | 143 // - A non-waiting to waiting transition indicates underflow has occurred |
| 123 // and PausePlayback() should be called | 144 // and PausePlayback() should be called |
| 124 void OnBufferingStateChange(DemuxerStream::Type type, | 145 void OnBufferingStateChange(DemuxerStream::Type type, |
| 125 BufferingState new_buffering_state); | 146 BufferingState new_buffering_state); |
|
xhwang
2017/03/29 00:16:47
empty line
servolk
2017/03/29 01:49:33
Done.
| |
| 126 // Handles the buffering notifications that we might get while an audio or a | 147 // Handles the buffering notifications that we might get while an audio or a |
| 127 // video stream is being restarted. In those cases we don't want to report | 148 // video stream is being restarted. In those cases we don't want to report |
| 128 // underflows immediately and instead give decoders a chance to catch up with | 149 // underflows immediately and instead give decoders a chance to catch up with |
| 129 // currently playing stream. Returns true if the buffering nofication has been | 150 // currently playing stream. Returns true if the buffering nofication has been |
| 130 // handled and no further processing is necessary, returns false to indicate | 151 // handled and no further processing is necessary, returns false to indicate |
| 131 // that we should fall back to the regular OnBufferingStateChange logic. | 152 // that we should fall back to the regular OnBufferingStateChange logic. |
| 132 bool HandleRestartedStreamBufferingChanges( | 153 bool HandleRestartedStreamBufferingChanges( |
| 133 DemuxerStream::Type type, | 154 DemuxerStream::Type type, |
| 134 BufferingState new_buffering_state); | 155 BufferingState new_buffering_state); |
|
xhwang
2017/03/29 00:16:47
empty line
servolk
2017/03/29 01:49:33
Done.
| |
| 135 bool WaitingForEnoughData() const; | 156 bool WaitingForEnoughData() const; |
| 136 void PausePlayback(); | 157 void PausePlayback(); |
| 137 void StartPlayback(); | 158 void StartPlayback(); |
| 138 | 159 |
| 139 // Callbacks executed when a renderer has ended. | 160 // Callbacks executed when a renderer has ended. |
| 140 void OnRendererEnded(DemuxerStream::Type type); | 161 void OnRendererEnded(DemuxerStream::Type type); |
| 141 bool PlaybackHasEnded() const; | 162 bool PlaybackHasEnded() const; |
| 142 void RunEndedCallbackIfNeeded(); | 163 void RunEndedCallbackIfNeeded(); |
| 143 | 164 |
| 144 // Callback executed when a runtime error happens. | 165 // Callback executed when a runtime error happens. |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 159 | 180 |
| 160 // Temporary callback used for Initialize() and Flush(). | 181 // Temporary callback used for Initialize() and Flush(). |
| 161 PipelineStatusCB init_cb_; | 182 PipelineStatusCB init_cb_; |
| 162 base::Closure flush_cb_; | 183 base::Closure flush_cb_; |
| 163 | 184 |
| 164 std::unique_ptr<RendererClientInternal> audio_renderer_client_; | 185 std::unique_ptr<RendererClientInternal> audio_renderer_client_; |
| 165 std::unique_ptr<RendererClientInternal> video_renderer_client_; | 186 std::unique_ptr<RendererClientInternal> video_renderer_client_; |
| 166 std::unique_ptr<AudioRenderer> audio_renderer_; | 187 std::unique_ptr<AudioRenderer> audio_renderer_; |
| 167 std::unique_ptr<VideoRenderer> video_renderer_; | 188 std::unique_ptr<VideoRenderer> video_renderer_; |
| 168 | 189 |
| 190 DemuxerStream* current_audio_stream_; | |
| 191 DemuxerStream* current_video_stream_; | |
| 192 | |
| 169 // Renderer-provided time source used to control playback. | 193 // Renderer-provided time source used to control playback. |
| 170 TimeSource* time_source_; | 194 TimeSource* time_source_; |
| 171 std::unique_ptr<WallClockTimeSource> wall_clock_time_source_; | 195 std::unique_ptr<WallClockTimeSource> wall_clock_time_source_; |
| 172 bool time_ticking_; | 196 bool time_ticking_; |
| 173 double playback_rate_; | 197 double playback_rate_; |
| 174 | 198 |
| 175 // The time to start playback from after starting/seeking has completed. | 199 // The time to start playback from after starting/seeking has completed. |
| 176 base::TimeDelta start_time_; | 200 base::TimeDelta start_time_; |
| 177 | 201 |
| 178 BufferingState audio_buffering_state_; | 202 BufferingState audio_buffering_state_; |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 204 | 228 |
| 205 base::WeakPtr<RendererImpl> weak_this_; | 229 base::WeakPtr<RendererImpl> weak_this_; |
| 206 base::WeakPtrFactory<RendererImpl> weak_factory_; | 230 base::WeakPtrFactory<RendererImpl> weak_factory_; |
| 207 | 231 |
| 208 DISALLOW_COPY_AND_ASSIGN(RendererImpl); | 232 DISALLOW_COPY_AND_ASSIGN(RendererImpl); |
| 209 }; | 233 }; |
| 210 | 234 |
| 211 } // namespace media | 235 } // namespace media |
| 212 | 236 |
| 213 #endif // MEDIA_RENDERERS_RENDERER_IMPL_H_ | 237 #endif // MEDIA_RENDERERS_RENDERER_IMPL_H_ |
| OLD | NEW |