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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 virtual void SetVolume(double volume) OVERRIDE; | 54 virtual void SetVolume(double volume) OVERRIDE; |
55 virtual int GetVideoWidth() OVERRIDE; | 55 virtual int GetVideoWidth() OVERRIDE; |
56 virtual int GetVideoHeight() OVERRIDE; | 56 virtual int GetVideoHeight() OVERRIDE; |
57 virtual base::TimeDelta GetCurrentTime() OVERRIDE; | 57 virtual base::TimeDelta GetCurrentTime() OVERRIDE; |
58 virtual base::TimeDelta GetDuration() OVERRIDE; | 58 virtual base::TimeDelta GetDuration() OVERRIDE; |
59 virtual bool IsPlaying() OVERRIDE; | 59 virtual bool IsPlaying() OVERRIDE; |
60 virtual bool CanPause() OVERRIDE; | 60 virtual bool CanPause() OVERRIDE; |
61 virtual bool CanSeekForward() OVERRIDE; | 61 virtual bool CanSeekForward() OVERRIDE; |
62 virtual bool CanSeekBackward() OVERRIDE; | 62 virtual bool CanSeekBackward() OVERRIDE; |
63 virtual bool IsPlayerReady() OVERRIDE; | 63 virtual bool IsPlayerReady() OVERRIDE; |
64 virtual void SetCdm(MediaKeys* cdm) OVERRIDE; | 64 virtual void SetCdm(BrowserCdm* cdm) OVERRIDE; |
65 virtual void OnKeyAdded() OVERRIDE; | |
66 virtual bool IsSurfaceInUse() const OVERRIDE; | 65 virtual bool IsSurfaceInUse() const OVERRIDE; |
67 | 66 |
68 // DemuxerAndroidClient implementation. | 67 // DemuxerAndroidClient implementation. |
69 virtual void OnDemuxerConfigsAvailable(const DemuxerConfigs& params) OVERRIDE; | 68 virtual void OnDemuxerConfigsAvailable(const DemuxerConfigs& params) OVERRIDE; |
70 virtual void OnDemuxerDataAvailable(const DemuxerData& params) OVERRIDE; | 69 virtual void OnDemuxerDataAvailable(const DemuxerData& params) OVERRIDE; |
71 virtual void OnDemuxerSeekDone( | 70 virtual void OnDemuxerSeekDone( |
72 base::TimeDelta actual_browser_seek_time) OVERRIDE; | 71 base::TimeDelta actual_browser_seek_time) OVERRIDE; |
73 virtual void OnDemuxerDurationChanged(base::TimeDelta duration) OVERRIDE; | 72 virtual void OnDemuxerDurationChanged(base::TimeDelta duration) OVERRIDE; |
74 | 73 |
75 private: | 74 private: |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 | 163 |
165 // Called when a MediaDecoderJob finishes prefetching data. Once all | 164 // Called when a MediaDecoderJob finishes prefetching data. Once all |
166 // MediaDecoderJobs have prefetched data, then this method updates | 165 // MediaDecoderJobs have prefetched data, then this method updates |
167 // |start_time_ticks_| and |start_presentation_timestamp_| so that video can | 166 // |start_time_ticks_| and |start_presentation_timestamp_| so that video can |
168 // resync with audio and starts decoding. | 167 // resync with audio and starts decoding. |
169 void OnPrefetchDone(); | 168 void OnPrefetchDone(); |
170 | 169 |
171 // Sets the demuxer configs for audio or video stream. | 170 // Sets the demuxer configs for audio or video stream. |
172 void SetDemuxerConfigs(const DemuxerConfigs& configs, bool is_audio); | 171 void SetDemuxerConfigs(const DemuxerConfigs& configs, bool is_audio); |
173 | 172 |
173 // Called when new decryption key becomes available. | |
174 void OnKeyAdded(); | |
175 | |
176 // Called when the CDM is destroyed. | |
ddorwin
2014/06/02 20:20:29
update comment.
xhwang
2014/06/02 21:41:22
Done.
| |
177 void OnCdmUnset(); | |
178 | |
174 // Test-only method to setup hook for the completion of the next decode cycle. | 179 // Test-only method to setup hook for the completion of the next decode cycle. |
175 // This callback state is cleared when it is next run. | 180 // This callback state is cleared when it is next run. |
176 // Prevent usage creep by only calling this from the | 181 // Prevent usage creep by only calling this from the |
177 // ReleaseWithOnPrefetchDoneAlreadyPosted MediaSourcePlayerTest. | 182 // ReleaseWithOnPrefetchDoneAlreadyPosted MediaSourcePlayerTest. |
178 void set_decode_callback_for_testing(const base::Closure& test_decode_cb) { | 183 void set_decode_callback_for_testing(const base::Closure& test_decode_cb) { |
179 decode_callback_for_testing_ = test_decode_cb; | 184 decode_callback_for_testing_ = test_decode_cb; |
180 } | 185 } |
181 | 186 |
182 // TODO(qinmin/wolenetz): Reorder these based on their priority from | 187 // TODO(qinmin/wolenetz): Reorder these based on their priority from |
183 // ProcessPendingEvents(). Release() and other routines are dependent upon | 188 // ProcessPendingEvents(). Release() and other routines are dependent upon |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
266 // Track the most recent preroll target. Decoder re-creation needs this to | 271 // Track the most recent preroll target. Decoder re-creation needs this to |
267 // resume any in-progress preroll. | 272 // resume any in-progress preroll. |
268 base::TimeDelta preroll_timestamp_; | 273 base::TimeDelta preroll_timestamp_; |
269 | 274 |
270 // A cancelable task that is posted when the audio decoder starts requesting | 275 // A cancelable task that is posted when the audio decoder starts requesting |
271 // new data. This callback runs if no data arrives before the timeout period | 276 // new data. This callback runs if no data arrives before the timeout period |
272 // elapses. | 277 // elapses. |
273 base::CancelableClosure decoder_starvation_callback_; | 278 base::CancelableClosure decoder_starvation_callback_; |
274 | 279 |
275 MediaDrmBridge* drm_bridge_; | 280 MediaDrmBridge* drm_bridge_; |
281 int cdm_registration_id_; | |
276 | 282 |
277 // No decryption key available to decrypt the encrypted buffer. In this case, | 283 // No decryption key available to decrypt the encrypted buffer. In this case, |
278 // the player should pause. When a new key is added (OnKeyAdded()), we should | 284 // the player should pause. When a new key is added (OnKeyAdded()), we should |
279 // try to start playback again. | 285 // try to start playback again. |
280 bool is_waiting_for_key_; | 286 bool is_waiting_for_key_; |
281 | 287 |
282 // Test-only callback for hooking the completion of the next decode cycle. | 288 // Test-only callback for hooking the completion of the next decode cycle. |
283 base::Closure decode_callback_for_testing_; | 289 base::Closure decode_callback_for_testing_; |
284 | 290 |
285 // Whether |surface_| is currently used by the player. | 291 // Whether |surface_| is currently used by the player. |
286 bool is_surface_in_use_; | 292 bool is_surface_in_use_; |
287 | 293 |
288 // Whether there are pending data requests by the decoder. | 294 // Whether there are pending data requests by the decoder. |
289 bool has_pending_audio_data_request_; | 295 bool has_pending_audio_data_request_; |
290 bool has_pending_video_data_request_; | 296 bool has_pending_video_data_request_; |
291 | 297 |
292 // Weak pointer passed to media decoder jobs for callbacks. | 298 // Weak pointer passed to media decoder jobs for callbacks. |
293 // NOTE: Weak pointers must be invalidated before all other member variables. | 299 // NOTE: Weak pointers must be invalidated before all other member variables. |
294 base::WeakPtrFactory<MediaSourcePlayer> weak_factory_; | 300 base::WeakPtrFactory<MediaSourcePlayer> weak_factory_; |
301 base::WeakPtr<MediaSourcePlayer> weak_this_; | |
295 | 302 |
296 DISALLOW_COPY_AND_ASSIGN(MediaSourcePlayer); | 303 DISALLOW_COPY_AND_ASSIGN(MediaSourcePlayer); |
297 }; | 304 }; |
298 | 305 |
299 } // namespace media | 306 } // namespace media |
300 | 307 |
301 #endif // MEDIA_BASE_ANDROID_MEDIA_SOURCE_PLAYER_H_ | 308 #endif // MEDIA_BASE_ANDROID_MEDIA_SOURCE_PLAYER_H_ |
OLD | NEW |