| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/cancelable_callback.h" | 10 #include "base/cancelable_callback.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 void set_time_source_for_testing(TimeSource* time_source) { | 70 void set_time_source_for_testing(TimeSource* time_source) { |
| 71 time_source_ = time_source; | 71 time_source_ = time_source; |
| 72 } | 72 } |
| 73 void set_video_underflow_threshold_for_testing(base::TimeDelta threshold) { | 73 void set_video_underflow_threshold_for_testing(base::TimeDelta threshold) { |
| 74 video_underflow_threshold_ = threshold; | 74 video_underflow_threshold_ = threshold; |
| 75 } | 75 } |
| 76 | 76 |
| 77 private: | 77 private: |
| 78 enum State { | 78 enum State { |
| 79 STATE_UNINITIALIZED, | 79 STATE_UNINITIALIZED, |
| 80 STATE_INIT_PENDING_CDM, |
| 80 STATE_INITIALIZING, | 81 STATE_INITIALIZING, |
| 81 STATE_FLUSHING, | 82 STATE_FLUSHING, |
| 82 STATE_PLAYING, | 83 STATE_PLAYING, |
| 83 STATE_ERROR | 84 STATE_ERROR |
| 84 }; | 85 }; |
| 85 | 86 |
| 86 bool GetWallClockTimes(const std::vector<base::TimeDelta>& media_timestamps, | 87 bool GetWallClockTimes(const std::vector<base::TimeDelta>& media_timestamps, |
| 87 std::vector<base::TimeTicks>* wall_clock_times); | 88 std::vector<base::TimeTicks>* wall_clock_times); |
| 88 | 89 |
| 89 // Requests that this object notifies when a CDM is ready through the | 90 bool HasEncryptedStream(); |
| 90 // |cdm_ready_cb| provided. | 91 |
| 91 // If |cdm_ready_cb| is null, the existing callback will be fired with | 92 void FinishInitialization(PipelineStatus status); |
| 92 // nullptr immediately and reset. | |
| 93 void SetCdmReadyCallback(const CdmReadyCB& cdm_ready_cb); | |
| 94 | 93 |
| 95 // Helper functions and callbacks for Initialize(). | 94 // Helper functions and callbacks for Initialize(). |
| 96 void InitializeAudioRenderer(); | 95 void InitializeAudioRenderer(); |
| 97 void OnAudioRendererInitializeDone(PipelineStatus status); | 96 void OnAudioRendererInitializeDone(PipelineStatus status); |
| 98 void InitializeVideoRenderer(); | 97 void InitializeVideoRenderer(); |
| 99 void OnVideoRendererInitializeDone(PipelineStatus status); | 98 void OnVideoRendererInitializeDone(PipelineStatus status); |
| 100 | 99 |
| 101 // Helper functions and callbacks for Flush(). | 100 // Helper functions and callbacks for Flush(). |
| 102 void FlushAudioRenderer(); | 101 void FlushAudioRenderer(); |
| 103 void OnAudioRendererFlushDone(); | 102 void OnAudioRendererFlushDone(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 base::TimeDelta start_time_; | 161 base::TimeDelta start_time_; |
| 163 | 162 |
| 164 BufferingState audio_buffering_state_; | 163 BufferingState audio_buffering_state_; |
| 165 BufferingState video_buffering_state_; | 164 BufferingState video_buffering_state_; |
| 166 | 165 |
| 167 // Whether we've received the audio/video ended events. | 166 // Whether we've received the audio/video ended events. |
| 168 bool audio_ended_; | 167 bool audio_ended_; |
| 169 bool video_ended_; | 168 bool video_ended_; |
| 170 | 169 |
| 171 CdmContext* cdm_context_; | 170 CdmContext* cdm_context_; |
| 172 | 171 CdmAttachedCB pending_cdm_attached_cb_; |
| 173 // Callback registered by filters (decoder or demuxer) to be informed of a | |
| 174 // CDM. | |
| 175 // Note: We could have multiple filters registering this callback. One | |
| 176 // callback is okay because: | |
| 177 // 1, We always initialize filters in sequence. | |
| 178 // 2, Filter initialization will not finish until this callback is satisfied. | |
| 179 CdmReadyCB cdm_ready_cb_; | |
| 180 | 172 |
| 181 bool underflow_disabled_for_testing_; | 173 bool underflow_disabled_for_testing_; |
| 182 bool clockless_video_playback_enabled_for_testing_; | 174 bool clockless_video_playback_enabled_for_testing_; |
| 183 | 175 |
| 184 // Used to defer underflow for video when audio is present. | 176 // Used to defer underflow for video when audio is present. |
| 185 base::CancelableClosure deferred_underflow_cb_; | 177 base::CancelableClosure deferred_underflow_cb_; |
| 186 | 178 |
| 187 // The amount of time to wait before declaring underflow if the video renderer | 179 // The amount of time to wait before declaring underflow if the video renderer |
| 188 // runs out of data but the audio renderer still has enough. | 180 // runs out of data but the audio renderer still has enough. |
| 189 base::TimeDelta video_underflow_threshold_; | 181 base::TimeDelta video_underflow_threshold_; |
| 190 | 182 |
| 191 base::WeakPtr<RendererImpl> weak_this_; | 183 base::WeakPtr<RendererImpl> weak_this_; |
| 192 base::WeakPtrFactory<RendererImpl> weak_factory_; | 184 base::WeakPtrFactory<RendererImpl> weak_factory_; |
| 193 | 185 |
| 194 DISALLOW_COPY_AND_ASSIGN(RendererImpl); | 186 DISALLOW_COPY_AND_ASSIGN(RendererImpl); |
| 195 }; | 187 }; |
| 196 | 188 |
| 197 } // namespace media | 189 } // namespace media |
| 198 | 190 |
| 199 #endif // MEDIA_RENDERERS_RENDERER_IMPL_H_ | 191 #endif // MEDIA_RENDERERS_RENDERER_IMPL_H_ |
| OLD | NEW |