OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_BASE_ANDROID_MEDIA_SOURCE_PLAYER_H_ | 5 #ifndef MEDIA_BASE_ANDROID_MEDIA_SOURCE_PLAYER_H_ |
6 #define MEDIA_BASE_ANDROID_MEDIA_SOURCE_PLAYER_H_ | 6 #define MEDIA_BASE_ANDROID_MEDIA_SOURCE_PLAYER_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 bool CanSeekBackward() override; | 62 bool CanSeekBackward() override; |
63 bool IsPlayerReady() override; | 63 bool IsPlayerReady() override; |
64 void SetCdm(BrowserCdm* cdm) override; | 64 void SetCdm(BrowserCdm* cdm) override; |
65 | 65 |
66 // DemuxerAndroidClient implementation. | 66 // DemuxerAndroidClient implementation. |
67 void OnDemuxerConfigsAvailable(const DemuxerConfigs& params) override; | 67 void OnDemuxerConfigsAvailable(const DemuxerConfigs& params) override; |
68 void OnDemuxerDataAvailable(const DemuxerData& params) override; | 68 void OnDemuxerDataAvailable(const DemuxerData& params) override; |
69 void OnDemuxerSeekDone(base::TimeDelta actual_browser_seek_time) override; | 69 void OnDemuxerSeekDone(base::TimeDelta actual_browser_seek_time) override; |
70 void OnDemuxerDurationChanged(base::TimeDelta duration) override; | 70 void OnDemuxerDurationChanged(base::TimeDelta duration) override; |
71 | 71 |
72 private: | 72 // Sets the idle period after which the audible state is considered gone. |
| 73 void SetAudibleStateIdlePeriod(base::TimeDelta duration); |
| 74 |
| 75 private: |
73 friend class MediaSourcePlayerTest; | 76 friend class MediaSourcePlayerTest; |
74 | 77 |
75 // Update the current timestamp. | 78 // Update the current timestamp. |
76 void UpdateTimestamps(base::TimeDelta current_presentation_timestamp, | 79 void UpdateTimestamps(base::TimeDelta current_presentation_timestamp, |
77 base::TimeDelta max_presentation_timestamp); | 80 base::TimeDelta max_presentation_timestamp); |
78 | 81 |
79 // Helper function for starting media playback. | 82 // Helper function for starting media playback. |
80 void StartInternal(); | 83 void StartInternal(); |
81 | 84 |
82 // Playback is completed for one channel. | 85 // Playback is completed for one channel. |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // Called when new decryption key becomes available. | 164 // Called when new decryption key becomes available. |
162 void OnKeyAdded(); | 165 void OnKeyAdded(); |
163 | 166 |
164 // Called to resume playback after NO_KEY is received, but a new key is | 167 // Called to resume playback after NO_KEY is received, but a new key is |
165 // available. | 168 // available. |
166 void ResumePlaybackAfterKeyAdded(); | 169 void ResumePlaybackAfterKeyAdded(); |
167 | 170 |
168 // Called when the CDM is detached. | 171 // Called when the CDM is detached. |
169 void OnCdmUnset(); | 172 void OnCdmUnset(); |
170 | 173 |
| 174 // Set the status that the audio is currently playing |
| 175 void UpdateAudibleStatus(); |
| 176 |
171 // Test-only method to setup hook for the completion of the next decode cycle. | 177 // Test-only method to setup hook for the completion of the next decode cycle. |
172 // This callback state is cleared when it is next run. | 178 // This callback state is cleared when it is next run. |
173 // Prevent usage creep by only calling this from the | 179 // Prevent usage creep by only calling this from the |
174 // ReleaseWithOnPrefetchDoneAlreadyPosted MediaSourcePlayerTest. | 180 // ReleaseWithOnPrefetchDoneAlreadyPosted MediaSourcePlayerTest. |
175 void set_decode_callback_for_testing(const base::Closure& test_decode_cb) { | 181 void set_decode_callback_for_testing(const base::Closure& test_decode_cb) { |
176 decode_callback_for_testing_ = test_decode_cb; | 182 decode_callback_for_testing_ = test_decode_cb; |
177 } | 183 } |
178 | 184 |
179 // Please keep this in sync with |kPendingEventNames| in GetEventName(). | 185 // Please keep this in sync with |kPendingEventNames| in GetEventName(). |
180 enum PendingEventFlags { | 186 enum PendingEventFlags { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 244 |
239 // Track the most recent preroll target. Decoder re-creation needs this to | 245 // Track the most recent preroll target. Decoder re-creation needs this to |
240 // resume any in-progress preroll. | 246 // resume any in-progress preroll. |
241 base::TimeDelta preroll_timestamp_; | 247 base::TimeDelta preroll_timestamp_; |
242 | 248 |
243 // A cancelable task that is posted when the audio decoder starts requesting | 249 // A cancelable task that is posted when the audio decoder starts requesting |
244 // new data. This callback runs if no data arrives before the timeout period | 250 // new data. This callback runs if no data arrives before the timeout period |
245 // elapses. | 251 // elapses. |
246 base::CancelableClosure decoder_starvation_callback_; | 252 base::CancelableClosure decoder_starvation_callback_; |
247 | 253 |
| 254 // A cancelable task that is reposted every time we enqueue an audio frame. |
| 255 // It arrived when the stream of frames interrupted, telling there is |
| 256 // no audible audio any more. |
| 257 base::CancelableClosure audible_audio_stopped_callback_; |
| 258 |
| 259 // The delay for audible_audio_stopped_callback_. |
| 260 // If a new audio frame arrives after this delay, |
| 261 // we will report non-audible state. |
| 262 base::TimeDelta audible_state_idle_period_; |
| 263 |
248 MediaDrmBridge* drm_bridge_; | 264 MediaDrmBridge* drm_bridge_; |
249 int cdm_registration_id_; | 265 int cdm_registration_id_; |
250 | 266 |
251 // No decryption key available to decrypt the encrypted buffer. In this case, | 267 // No decryption key available to decrypt the encrypted buffer. In this case, |
252 // the player should pause. When a new key is added (OnKeyAdded()), we should | 268 // the player should pause. When a new key is added (OnKeyAdded()), we should |
253 // try to start playback again. | 269 // try to start playback again. |
254 bool is_waiting_for_key_; | 270 bool is_waiting_for_key_; |
255 | 271 |
256 // Indicates the situation where new key is added during pending decode | 272 // Indicates the situation where new key is added during pending decode |
257 // (this variable can only be set when *_decoder_job_->is_decoding()). If this | 273 // (this variable can only be set when *_decoder_job_->is_decoding()). If this |
(...skipping 17 matching lines...) Expand all Loading... |
275 base::WeakPtr<MediaSourcePlayer> weak_this_; | 291 base::WeakPtr<MediaSourcePlayer> weak_this_; |
276 // NOTE: Weak pointers must be invalidated before all other member variables. | 292 // NOTE: Weak pointers must be invalidated before all other member variables. |
277 base::WeakPtrFactory<MediaSourcePlayer> weak_factory_; | 293 base::WeakPtrFactory<MediaSourcePlayer> weak_factory_; |
278 | 294 |
279 DISALLOW_COPY_AND_ASSIGN(MediaSourcePlayer); | 295 DISALLOW_COPY_AND_ASSIGN(MediaSourcePlayer); |
280 }; | 296 }; |
281 | 297 |
282 } // namespace media | 298 } // namespace media |
283 | 299 |
284 #endif // MEDIA_BASE_ANDROID_MEDIA_SOURCE_PLAYER_H_ | 300 #endif // MEDIA_BASE_ANDROID_MEDIA_SOURCE_PLAYER_H_ |
OLD | NEW |