| 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 <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 void SetCdm(CdmContext* cdm_context, | 55 void SetCdm(CdmContext* cdm_context, |
| 56 const CdmAttachedCB& cdm_attached_cb) final; | 56 const CdmAttachedCB& cdm_attached_cb) final; |
| 57 void Flush(const base::Closure& flush_cb) final; | 57 void Flush(const base::Closure& flush_cb) final; |
| 58 void StartPlayingFrom(base::TimeDelta time) final; | 58 void StartPlayingFrom(base::TimeDelta time) final; |
| 59 void SetPlaybackRate(double playback_rate) final; | 59 void SetPlaybackRate(double playback_rate) final; |
| 60 void SetVolume(float volume) final; | 60 void SetVolume(float volume) final; |
| 61 base::TimeDelta GetMediaTime() final; | 61 base::TimeDelta GetMediaTime() final; |
| 62 bool HasAudio() final; | 62 bool HasAudio() final; |
| 63 bool HasVideo() final; | 63 bool HasVideo() final; |
| 64 | 64 |
| 65 void RestartStreamPlayback(DemuxerStream* stream, base::TimeDelta time); |
| 66 |
| 65 // Helper functions for testing purposes. Must be called before Initialize(). | 67 // Helper functions for testing purposes. Must be called before Initialize(). |
| 66 void DisableUnderflowForTesting(); | 68 void DisableUnderflowForTesting(); |
| 67 void EnableClocklessVideoPlaybackForTesting(); | 69 void EnableClocklessVideoPlaybackForTesting(); |
| 68 void set_time_source_for_testing(TimeSource* time_source) { | 70 void set_time_source_for_testing(TimeSource* time_source) { |
| 69 time_source_ = time_source; | 71 time_source_ = time_source; |
| 70 } | 72 } |
| 71 void set_video_underflow_threshold_for_testing(base::TimeDelta threshold) { | 73 void set_video_underflow_threshold_for_testing(base::TimeDelta threshold) { |
| 72 video_underflow_threshold_ = threshold; | 74 video_underflow_threshold_ = threshold; |
| 73 } | 75 } |
| 74 | 76 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 96 void OnAudioRendererInitializeDone(PipelineStatus status); | 98 void OnAudioRendererInitializeDone(PipelineStatus status); |
| 97 void InitializeVideoRenderer(); | 99 void InitializeVideoRenderer(); |
| 98 void OnVideoRendererInitializeDone(PipelineStatus status); | 100 void OnVideoRendererInitializeDone(PipelineStatus status); |
| 99 | 101 |
| 100 // Helper functions and callbacks for Flush(). | 102 // Helper functions and callbacks for Flush(). |
| 101 void FlushAudioRenderer(); | 103 void FlushAudioRenderer(); |
| 102 void OnAudioRendererFlushDone(); | 104 void OnAudioRendererFlushDone(); |
| 103 void FlushVideoRenderer(); | 105 void FlushVideoRenderer(); |
| 104 void OnVideoRendererFlushDone(); | 106 void OnVideoRendererFlushDone(); |
| 105 | 107 |
| 108 void RestartAudioRenderer(base::TimeDelta time); |
| 109 void RestartVideoRenderer(base::TimeDelta time); |
| 110 |
| 106 // Callback executed by filters to update statistics. | 111 // Callback executed by filters to update statistics. |
| 107 void OnStatisticsUpdate(const PipelineStatistics& stats); | 112 void OnStatisticsUpdate(const PipelineStatistics& stats); |
| 108 | 113 |
| 109 // Collection of callback methods and helpers for tracking changes in | 114 // Collection of callback methods and helpers for tracking changes in |
| 110 // buffering state and transition from paused/underflow states and playing | 115 // buffering state and transition from paused/underflow states and playing |
| 111 // states. | 116 // states. |
| 112 // | 117 // |
| 113 // While in the kPlaying state: | 118 // While in the kPlaying state: |
| 114 // - A waiting to non-waiting transition indicates preroll has completed | 119 // - A waiting to non-waiting transition indicates preroll has completed |
| 115 // and StartPlayback() should be called | 120 // and StartPlayback() should be called |
| 116 // - A non-waiting to waiting transition indicates underflow has occurred | 121 // - A non-waiting to waiting transition indicates underflow has occurred |
| 117 // and PausePlayback() should be called | 122 // and PausePlayback() should be called |
| 118 void OnBufferingStateChange(DemuxerStream::Type type, | 123 void OnBufferingStateChange(DemuxerStream::Type type, |
| 119 BufferingState new_buffering_state); | 124 BufferingState new_buffering_state); |
| 125 // Handles the buffering notifications that we might get while an audio or a |
| 126 // video stream is being restarted. In those cases we don't want to report |
| 127 // underflows immediately and instead give decoders a chance to catch up with |
| 128 // currently playing stream. Returns true if the buffering nofication has been |
| 129 // handled and no further processing is necessary, returns false to indicate |
| 130 // that we should fall back to the regular OnBufferingStateChange logic. |
| 131 bool HandleRestartedStreamBufferingChanges( |
| 132 DemuxerStream::Type type, |
| 133 BufferingState new_buffering_state); |
| 120 bool WaitingForEnoughData() const; | 134 bool WaitingForEnoughData() const; |
| 121 void PausePlayback(); | 135 void PausePlayback(); |
| 122 void StartPlayback(); | 136 void StartPlayback(); |
| 123 | 137 |
| 124 // Callbacks executed when a renderer has ended. | 138 // Callbacks executed when a renderer has ended. |
| 125 void OnRendererEnded(DemuxerStream::Type type); | 139 void OnRendererEnded(DemuxerStream::Type type); |
| 126 bool PlaybackHasEnded() const; | 140 bool PlaybackHasEnded() const; |
| 127 void RunEndedCallbackIfNeeded(); | 141 void RunEndedCallbackIfNeeded(); |
| 128 | 142 |
| 129 // Callback executed when a runtime error happens. | 143 // Callback executed when a runtime error happens. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 bool audio_ended_; | 179 bool audio_ended_; |
| 166 bool video_ended_; | 180 bool video_ended_; |
| 167 | 181 |
| 168 CdmContext* cdm_context_; | 182 CdmContext* cdm_context_; |
| 169 CdmAttachedCB pending_cdm_attached_cb_; | 183 CdmAttachedCB pending_cdm_attached_cb_; |
| 170 | 184 |
| 171 bool underflow_disabled_for_testing_; | 185 bool underflow_disabled_for_testing_; |
| 172 bool clockless_video_playback_enabled_for_testing_; | 186 bool clockless_video_playback_enabled_for_testing_; |
| 173 | 187 |
| 174 // Used to defer underflow for video when audio is present. | 188 // Used to defer underflow for video when audio is present. |
| 175 base::CancelableClosure deferred_underflow_cb_; | 189 base::CancelableClosure deferred_video_underflow_cb_; |
| 190 |
| 191 // Used to defer underflow for audio when restarting audio playback. |
| 192 base::CancelableClosure deferred_audio_restart_underflow_cb_; |
| 176 | 193 |
| 177 // The amount of time to wait before declaring underflow if the video renderer | 194 // The amount of time to wait before declaring underflow if the video renderer |
| 178 // runs out of data but the audio renderer still has enough. | 195 // runs out of data but the audio renderer still has enough. |
| 179 base::TimeDelta video_underflow_threshold_; | 196 base::TimeDelta video_underflow_threshold_; |
| 180 | 197 |
| 198 bool restarting_audio_ = false; |
| 199 bool restarting_video_ = false; |
| 200 |
| 181 base::WeakPtr<RendererImpl> weak_this_; | 201 base::WeakPtr<RendererImpl> weak_this_; |
| 182 base::WeakPtrFactory<RendererImpl> weak_factory_; | 202 base::WeakPtrFactory<RendererImpl> weak_factory_; |
| 183 | 203 |
| 184 DISALLOW_COPY_AND_ASSIGN(RendererImpl); | 204 DISALLOW_COPY_AND_ASSIGN(RendererImpl); |
| 185 }; | 205 }; |
| 186 | 206 |
| 187 } // namespace media | 207 } // namespace media |
| 188 | 208 |
| 189 #endif // MEDIA_RENDERERS_RENDERER_IMPL_H_ | 209 #endif // MEDIA_RENDERERS_RENDERER_IMPL_H_ |
| OLD | NEW |