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 "base/cancelable_callback.h" |
8 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
11 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
12 #include "base/time/clock.h" | 13 #include "base/time/clock.h" |
13 #include "base/time/default_tick_clock.h" | 14 #include "base/time/default_tick_clock.h" |
14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
15 #include "media/base/buffering_state.h" | 16 #include "media/base/buffering_state.h" |
16 #include "media/base/decryptor.h" | 17 #include "media/base/decryptor.h" |
17 #include "media/base/media_export.h" | 18 #include "media/base/media_export.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 void StartPlayingFrom(base::TimeDelta time) final; | 58 void StartPlayingFrom(base::TimeDelta time) final; |
58 void SetPlaybackRate(float playback_rate) final; | 59 void SetPlaybackRate(float playback_rate) final; |
59 void SetVolume(float volume) final; | 60 void SetVolume(float volume) final; |
60 base::TimeDelta GetMediaTime() final; | 61 base::TimeDelta GetMediaTime() final; |
61 bool HasAudio() final; | 62 bool HasAudio() final; |
62 bool HasVideo() final; | 63 bool HasVideo() final; |
63 | 64 |
64 // Helper functions for testing purposes. Must be called before Initialize(). | 65 // Helper functions for testing purposes. Must be called before Initialize(). |
65 void DisableUnderflowForTesting(); | 66 void DisableUnderflowForTesting(); |
66 void EnableClocklessVideoPlaybackForTesting(); | 67 void EnableClocklessVideoPlaybackForTesting(); |
| 68 void set_time_source_for_testing(TimeSource* time_source) { |
| 69 time_source_ = time_source; |
| 70 } |
| 71 void set_video_underflow_threshold_for_testing(base::TimeDelta threshold) { |
| 72 video_underflow_threshold_ = threshold; |
| 73 } |
67 | 74 |
68 private: | 75 private: |
69 enum State { | 76 enum State { |
70 STATE_UNINITIALIZED, | 77 STATE_UNINITIALIZED, |
71 STATE_INITIALIZING, | 78 STATE_INITIALIZING, |
72 STATE_FLUSHING, | 79 STATE_FLUSHING, |
73 STATE_PLAYING, | 80 STATE_PLAYING, |
74 STATE_ERROR | 81 STATE_ERROR |
75 }; | 82 }; |
76 | 83 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 // Decryptor. | 171 // Decryptor. |
165 // Note: We could have multiple filters registering this callback. One | 172 // Note: We could have multiple filters registering this callback. One |
166 // callback is okay because: | 173 // callback is okay because: |
167 // 1, We always initialize filters in sequence. | 174 // 1, We always initialize filters in sequence. |
168 // 2, Filter initialization will not finish until this callback is satisfied. | 175 // 2, Filter initialization will not finish until this callback is satisfied. |
169 DecryptorReadyCB decryptor_ready_cb_; | 176 DecryptorReadyCB decryptor_ready_cb_; |
170 | 177 |
171 bool underflow_disabled_for_testing_; | 178 bool underflow_disabled_for_testing_; |
172 bool clockless_video_playback_enabled_for_testing_; | 179 bool clockless_video_playback_enabled_for_testing_; |
173 | 180 |
| 181 // Used to defer underflow for video when audio is present. |
| 182 base::CancelableClosure deferred_underflow_cb_; |
| 183 |
| 184 // The amount of time to wait before declaring underflow if the video renderer |
| 185 // runs out of data but the audio renderer still has enough. |
| 186 base::TimeDelta video_underflow_threshold_; |
| 187 |
174 base::WeakPtr<RendererImpl> weak_this_; | 188 base::WeakPtr<RendererImpl> weak_this_; |
175 base::WeakPtrFactory<RendererImpl> weak_factory_; | 189 base::WeakPtrFactory<RendererImpl> weak_factory_; |
176 | 190 |
177 DISALLOW_COPY_AND_ASSIGN(RendererImpl); | 191 DISALLOW_COPY_AND_ASSIGN(RendererImpl); |
178 }; | 192 }; |
179 | 193 |
180 } // namespace media | 194 } // namespace media |
181 | 195 |
182 #endif // MEDIA_RENDERERS_RENDERER_IMPL_H_ | 196 #endif // MEDIA_RENDERERS_RENDERER_IMPL_H_ |
OLD | NEW |