| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 virtual bool IsSurfaceInUse() const OVERRIDE; | 72 virtual bool IsSurfaceInUse() const OVERRIDE; |
| 73 | 73 |
| 74 // DemuxerAndroidClient implementation. | 74 // DemuxerAndroidClient implementation. |
| 75 virtual void OnDemuxerConfigsAvailable(const DemuxerConfigs& params) OVERRIDE; | 75 virtual void OnDemuxerConfigsAvailable(const DemuxerConfigs& params) OVERRIDE; |
| 76 virtual void OnDemuxerDataAvailable(const DemuxerData& params) OVERRIDE; | 76 virtual void OnDemuxerDataAvailable(const DemuxerData& params) OVERRIDE; |
| 77 virtual void OnDemuxerSeekDone( | 77 virtual void OnDemuxerSeekDone( |
| 78 const base::TimeDelta& actual_browser_seek_time) OVERRIDE; | 78 const base::TimeDelta& actual_browser_seek_time) OVERRIDE; |
| 79 virtual void OnDemuxerDurationChanged(base::TimeDelta duration) OVERRIDE; | 79 virtual void OnDemuxerDurationChanged(base::TimeDelta duration) OVERRIDE; |
| 80 | 80 |
| 81 private: | 81 private: |
| 82 friend class MediaSourcePlayerTest; |
| 83 |
| 82 // Update the current timestamp. | 84 // Update the current timestamp. |
| 83 void UpdateTimestamps(const base::TimeDelta& presentation_timestamp, | 85 void UpdateTimestamps(const base::TimeDelta& presentation_timestamp, |
| 84 size_t audio_output_bytes); | 86 size_t audio_output_bytes); |
| 85 | 87 |
| 86 // Helper function for starting media playback. | 88 // Helper function for starting media playback. |
| 87 void StartInternal(); | 89 void StartInternal(); |
| 88 | 90 |
| 89 // Playback is completed for one channel. | 91 // Playback is completed for one channel. |
| 90 void PlaybackCompleted(bool is_audio); | 92 void PlaybackCompleted(bool is_audio); |
| 91 | 93 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 base::TimeDelta preroll_timestamp_; | 266 base::TimeDelta preroll_timestamp_; |
| 265 | 267 |
| 266 // A cancelable task that is posted when the audio decoder starts requesting | 268 // A cancelable task that is posted when the audio decoder starts requesting |
| 267 // new data. This callback runs if no data arrives before the timeout period | 269 // new data. This callback runs if no data arrives before the timeout period |
| 268 // elapses. | 270 // elapses. |
| 269 base::CancelableClosure decoder_starvation_callback_; | 271 base::CancelableClosure decoder_starvation_callback_; |
| 270 | 272 |
| 271 // Object to calculate the current audio timestamp for A/V sync. | 273 // Object to calculate the current audio timestamp for A/V sync. |
| 272 scoped_ptr<AudioTimestampHelper> audio_timestamp_helper_; | 274 scoped_ptr<AudioTimestampHelper> audio_timestamp_helper_; |
| 273 | 275 |
| 274 // Weak pointer passed to media decoder jobs for callbacks. | |
| 275 base::WeakPtrFactory<MediaSourcePlayer> weak_this_; | |
| 276 | |
| 277 MediaDrmBridge* drm_bridge_; | 276 MediaDrmBridge* drm_bridge_; |
| 278 | 277 |
| 279 // No decryption key available to decrypt the encrypted buffer. In this case, | 278 // No decryption key available to decrypt the encrypted buffer. In this case, |
| 280 // the player should pause. When a new key is added (OnKeyAdded()), we should | 279 // the player should pause. When a new key is added (OnKeyAdded()), we should |
| 281 // try to start playback again. | 280 // try to start playback again. |
| 282 bool is_waiting_for_key_; | 281 bool is_waiting_for_key_; |
| 283 | 282 |
| 284 // Test-only callback for hooking the completion of the next decode cycle. | 283 // Test-only callback for hooking the completion of the next decode cycle. |
| 285 base::Closure decode_callback_for_testing_; | 284 base::Closure decode_callback_for_testing_; |
| 286 | 285 |
| 287 // Whether |surface_| is currently used by the player. | 286 // Whether |surface_| is currently used by the player. |
| 288 bool is_surface_in_use_; | 287 bool is_surface_in_use_; |
| 289 | 288 |
| 290 friend class MediaSourcePlayerTest; | 289 // Weak pointer passed to media decoder jobs for callbacks. NOTE: This must |
| 290 // always be last so it's invalidated before other member variables might be |
| 291 // accessed. |
| 292 base::WeakPtrFactory<MediaSourcePlayer> weak_factory_; |
| 293 |
| 291 DISALLOW_COPY_AND_ASSIGN(MediaSourcePlayer); | 294 DISALLOW_COPY_AND_ASSIGN(MediaSourcePlayer); |
| 292 }; | 295 }; |
| 293 | 296 |
| 294 } // namespace media | 297 } // namespace media |
| 295 | 298 |
| 296 #endif // MEDIA_BASE_ANDROID_MEDIA_SOURCE_PLAYER_H_ | 299 #endif // MEDIA_BASE_ANDROID_MEDIA_SOURCE_PLAYER_H_ |
| OLD | NEW |