Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: media/base/android/media_codec_player.h

Issue 1407933010: media: Make MediaKeys ref-counted. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_CODEC_PLAYER_H_ 5 #ifndef MEDIA_BASE_ANDROID_MEDIA_CODEC_PLAYER_H_
6 #define MEDIA_BASE_ANDROID_MEDIA_CODEC_PLAYER_H_ 6 #define MEDIA_BASE_ANDROID_MEDIA_CODEC_PLAYER_H_
7 7
8 #include "base/android/scoped_java_ref.h" 8 #include "base/android/scoped_java_ref.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // | | | 150 // | | |
151 // v | | 151 // v | |
152 // | | 152 // | |
153 // [ Stopping ] -----------------------> | | 153 // [ Stopping ] -----------------------> | |
154 // StopDone -- -- 154 // StopDone -- --
155 // w/pending seek: 155 // w/pending seek:
156 // demuxer.RequestSeek 156 // demuxer.RequestSeek
157 157
158 namespace media { 158 namespace media {
159 159
160 class BrowserCdm;
161 class MediaCodecAudioDecoder; 160 class MediaCodecAudioDecoder;
162 class MediaCodecVideoDecoder; 161 class MediaCodecVideoDecoder;
163 162
164 class MEDIA_EXPORT MediaCodecPlayer : public MediaPlayerAndroid, 163 class MEDIA_EXPORT MediaCodecPlayer : public MediaPlayerAndroid,
165 public DemuxerAndroidClient { 164 public DemuxerAndroidClient {
166 public: 165 public:
167 // Typedefs for the notification callbacks 166 // Typedefs for the notification callbacks
168 typedef base::Callback<void(base::TimeDelta, const gfx::Size&)> 167 typedef base::Callback<void(base::TimeDelta, const gfx::Size&)>
169 MetadataChangedCallback; 168 MetadataChangedCallback;
170 169
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 void SetVolume(double volume) override; 206 void SetVolume(double volume) override;
208 int GetVideoWidth() override; 207 int GetVideoWidth() override;
209 int GetVideoHeight() override; 208 int GetVideoHeight() override;
210 base::TimeDelta GetCurrentTime() override; 209 base::TimeDelta GetCurrentTime() override;
211 base::TimeDelta GetDuration() override; 210 base::TimeDelta GetDuration() override;
212 bool IsPlaying() override; 211 bool IsPlaying() override;
213 bool CanPause() override; 212 bool CanPause() override;
214 bool CanSeekForward() override; 213 bool CanSeekForward() override;
215 bool CanSeekBackward() override; 214 bool CanSeekBackward() override;
216 bool IsPlayerReady() override; 215 bool IsPlayerReady() override;
217 void SetCdm(BrowserCdm* cdm) override; 216 void SetCdm(const scoped_refptr<MediaKeys>& cdm) override;
218 217
219 // DemuxerAndroidClient implementation. 218 // DemuxerAndroidClient implementation.
220 void OnDemuxerConfigsAvailable(const DemuxerConfigs& params) override; 219 void OnDemuxerConfigsAvailable(const DemuxerConfigs& params) override;
221 void OnDemuxerDataAvailable(const DemuxerData& params) override; 220 void OnDemuxerDataAvailable(const DemuxerData& params) override;
222 void OnDemuxerSeekDone(base::TimeDelta actual_browser_seek_time) override; 221 void OnDemuxerSeekDone(base::TimeDelta actual_browser_seek_time) override;
223 void OnDemuxerDurationChanged(base::TimeDelta duration) override; 222 void OnDemuxerDurationChanged(base::TimeDelta duration) override;
224 223
225 // For testing only. 224 // For testing only.
226 void SetDecodersTimeCallbackForTests(DecodersTimeCallback cb); 225 void SetDecodersTimeCallbackForTests(DecodersTimeCallback cb);
227 void SetCodecCreatedCallbackForTests(CodecCreatedCallback cb); 226 void SetCodecCreatedCallbackForTests(CodecCreatedCallback cb);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 void OnError(); 292 void OnError();
294 void OnStarvation(DemuxerStream::Type stream_type); 293 void OnStarvation(DemuxerStream::Type stream_type);
295 void OnTimeIntervalUpdate(DemuxerStream::Type stream_type, 294 void OnTimeIntervalUpdate(DemuxerStream::Type stream_type,
296 base::TimeDelta now_playing, 295 base::TimeDelta now_playing,
297 base::TimeDelta last_buffered, 296 base::TimeDelta last_buffered,
298 bool postpone); 297 bool postpone);
299 298
300 // Callbacks from video decoder 299 // Callbacks from video decoder
301 void OnVideoResolutionChanged(const gfx::Size& size); 300 void OnVideoResolutionChanged(const gfx::Size& size);
302 301
303 // Callbacks from CDM 302 // Callbacks from MediaDrmBridge.
304 void OnMediaCryptoReady(MediaDrmBridge::JavaObjectPtr media_crypto, 303 void OnMediaCryptoReady(MediaDrmBridge::JavaObjectPtr media_crypto,
305 bool needs_protected_surface); 304 bool needs_protected_surface);
306 void OnKeyAdded(); 305 void OnKeyAdded();
307 void OnCdmUnset(); 306 void OnCdmUnset();
308 307
309 // Operations called from the state machine. 308 // Operations called from the state machine.
310 void SetState(PlayerState new_state); 309 void SetState(PlayerState new_state);
311 void SetPendingStart(bool need_to_start); 310 void SetPendingStart(bool need_to_start);
312 bool HasPendingStart() const; 311 bool HasPendingStart() const;
313 void SetPendingSeek(base::TimeDelta timestamp); 312 void SetPendingSeek(base::TimeDelta timestamp);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 387
389 // Configuration data for the manager, accessed on the UI thread. 388 // Configuration data for the manager, accessed on the UI thread.
390 MediaMetadata metadata_cache_; 389 MediaMetadata metadata_cache_;
391 390
392 // Cached current time, accessed on UI thread. 391 // Cached current time, accessed on UI thread.
393 base::TimeDelta current_time_cache_; 392 base::TimeDelta current_time_cache_;
394 393
395 // For testing only. 394 // For testing only.
396 DecodersTimeCallback decoders_time_cb_; 395 DecodersTimeCallback decoders_time_cb_;
397 396
398 // DRM 397 // Holds a ref-count to the CDM to keep |media_crypto_| and |drm_bridge_|
398 // valid. Reset during destruction or when the CDM is unset.
399 scoped_refptr<MediaKeys> cdm_;
400
399 MediaDrmBridge::JavaObjectPtr media_crypto_; 401 MediaDrmBridge::JavaObjectPtr media_crypto_;
400 402
401 MediaDrmBridge* drm_bridge_; 403 MediaDrmBridge* drm_bridge_;
402 int cdm_registration_id_; 404 int cdm_registration_id_;
403 405
404 // The flag is set when the player receives the error from decoder that the 406 // The flag is set when the player receives the error from decoder that the
405 // decoder needs a new decryption key. Cleared on starting the playback. 407 // decoder needs a new decryption key. Cleared on starting the playback.
406 bool key_is_required_; 408 bool key_is_required_;
407 409
408 // The flag is set after the new encryption key is added to MediaDrm. Cleared 410 // The flag is set after the new encryption key is added to MediaDrm. Cleared
409 // on starting the playback. 411 // on starting the playback.
410 bool key_is_added_; 412 bool key_is_added_;
411 413
412 // Gathers and reports playback quality statistics to UMA. 414 // Gathers and reports playback quality statistics to UMA.
413 // Use pointer to enable replacement of this object for tests. 415 // Use pointer to enable replacement of this object for tests.
414 scoped_ptr<MediaStatistics> media_stat_; 416 scoped_ptr<MediaStatistics> media_stat_;
415 417
416 base::WeakPtr<MediaCodecPlayer> media_weak_this_; 418 base::WeakPtr<MediaCodecPlayer> media_weak_this_;
417 // NOTE: Weak pointers must be invalidated before all other member variables. 419 // NOTE: Weak pointers must be invalidated before all other member variables.
418 base::WeakPtrFactory<MediaCodecPlayer> media_weak_factory_; 420 base::WeakPtrFactory<MediaCodecPlayer> media_weak_factory_;
419 421
420 DISALLOW_COPY_AND_ASSIGN(MediaCodecPlayer); 422 DISALLOW_COPY_AND_ASSIGN(MediaCodecPlayer);
421 }; 423 };
422 424
423 } // namespace media 425 } // namespace media
424 426
425 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_PLAYER_H_ 427 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_PLAYER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698