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

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

Issue 1341883003: Prepare MediaDrmBridge to work with MediaCodecPlayer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bug526755
Patch Set: Created 5 years, 3 months 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // [ Stopping ] -----------------------> | | 131 // [ Stopping ] -----------------------> | |
132 // StopDone -- -- 132 // StopDone -- --
133 // w/pending seek: 133 // w/pending seek:
134 // demuxer.RequestSeek 134 // demuxer.RequestSeek
135 135
136 namespace media { 136 namespace media {
137 137
138 class BrowserCdm; 138 class BrowserCdm;
139 class MediaCodecAudioDecoder; 139 class MediaCodecAudioDecoder;
140 class MediaCodecVideoDecoder; 140 class MediaCodecVideoDecoder;
141 class MediaDrmBridge;
141 142
142 // Returns the task runner for the media thread 143 // Returns the task runner for the media thread
143 MEDIA_EXPORT scoped_refptr<base::SingleThreadTaskRunner> GetMediaTaskRunner(); 144 MEDIA_EXPORT scoped_refptr<base::SingleThreadTaskRunner> GetMediaTaskRunner();
144 145
145 class MEDIA_EXPORT MediaCodecPlayer : public MediaPlayerAndroid, 146 class MEDIA_EXPORT MediaCodecPlayer : public MediaPlayerAndroid,
146 public DemuxerAndroidClient { 147 public DemuxerAndroidClient {
147 public: 148 public:
148 // Typedefs for the notification callbacks 149 // Typedefs for the notification callbacks
149 typedef base::Callback<void(base::TimeDelta, const gfx::Size&)> 150 typedef base::Callback<void(base::TimeDelta, const gfx::Size&)>
150 MetadataChangedCallback; 151 MetadataChangedCallback;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 211
211 private: 212 private:
212 // The state machine states. 213 // The state machine states.
213 enum PlayerState { 214 enum PlayerState {
214 kStatePaused, 215 kStatePaused,
215 kStateWaitingForConfig, 216 kStateWaitingForConfig,
216 kStatePrefetching, 217 kStatePrefetching,
217 kStatePlaying, 218 kStatePlaying,
218 kStateStopping, 219 kStateStopping,
219 kStateWaitingForSurface, 220 kStateWaitingForSurface,
221 kStateWaitingForKey,
222 kStateWaitingForCrypto,
220 kStateWaitingForSeek, 223 kStateWaitingForSeek,
221 kStateError, 224 kStateError,
222 }; 225 };
223 226
224 enum StartStatus { 227 enum StartStatus {
225 kStartOk = 0, 228 kStartOk = 0,
226 kStartBrowserSeekRequired, 229 kStartBrowserSeekRequired,
230 kStartCryptoRequired,
227 kStartFailed, 231 kStartFailed,
228 }; 232 };
229 233
230 // Cached values for the manager. 234 // Cached values for the manager.
231 struct MediaMetadata { 235 struct MediaMetadata {
232 base::TimeDelta duration; 236 base::TimeDelta duration;
233 gfx::Size video_size; 237 gfx::Size video_size;
234 }; 238 };
235 239
236 // Information about current seek in progress. 240 // Information about current seek in progress.
(...skipping 12 matching lines...) Expand all
249 // This method caches the current time and calls manager's OnTimeUpdate(). 253 // This method caches the current time and calls manager's OnTimeUpdate().
250 void OnTimeUpdate(base::TimeDelta current_timestamp, 254 void OnTimeUpdate(base::TimeDelta current_timestamp,
251 base::TimeTicks current_time_ticks) override; 255 base::TimeTicks current_time_ticks) override;
252 256
253 // Callbacks from decoders 257 // Callbacks from decoders
254 void RequestDemuxerData(DemuxerStream::Type stream_type); 258 void RequestDemuxerData(DemuxerStream::Type stream_type);
255 void OnPrefetchDone(); 259 void OnPrefetchDone();
256 void OnPrerollDone(); 260 void OnPrerollDone();
257 void OnDecoderDrained(DemuxerStream::Type type); 261 void OnDecoderDrained(DemuxerStream::Type type);
258 void OnStopDone(DemuxerStream::Type type); 262 void OnStopDone(DemuxerStream::Type type);
263 void OnKeyRequired(DemuxerStream::Type type);
259 void OnError(); 264 void OnError();
260 void OnStarvation(DemuxerStream::Type stream_type); 265 void OnStarvation(DemuxerStream::Type stream_type);
261 void OnTimeIntervalUpdate(DemuxerStream::Type stream_type, 266 void OnTimeIntervalUpdate(DemuxerStream::Type stream_type,
262 base::TimeDelta now_playing, 267 base::TimeDelta now_playing,
263 base::TimeDelta last_buffered, 268 base::TimeDelta last_buffered,
264 bool postpone); 269 bool postpone);
265 270
266 // Callbacks from video decoder 271 // Callbacks from video decoder
267 void OnVideoCodecCreated(); 272 void OnVideoCodecCreated();
268 void OnVideoResolutionChanged(const gfx::Size& size); 273 void OnVideoResolutionChanged(const gfx::Size& size);
269 274
275 // Callbacks from DRM
276 void OnMediaCryptoReady();
277 void OnKeyAdded();
278 void OnCdmUnset();
279
270 // Operations called from the state machine. 280 // Operations called from the state machine.
271 void SetState(PlayerState new_state); 281 void SetState(PlayerState new_state);
272 void SetPendingStart(bool need_to_start); 282 void SetPendingStart(bool need_to_start);
273 bool HasPendingStart() const; 283 bool HasPendingStart() const;
274 void SetPendingSeek(base::TimeDelta timestamp); 284 void SetPendingSeek(base::TimeDelta timestamp);
275 base::TimeDelta GetPendingSeek() const; 285 base::TimeDelta GetPendingSeek() const;
276 bool HasVideo() const; 286 bool HasVideo() const;
277 bool HasAudio() const; 287 bool HasAudio() const;
278 void SetDemuxerConfigs(const DemuxerConfigs& configs); 288 void SetDemuxerConfigs(const DemuxerConfigs& configs);
279 void StartPrefetchDecoders(); 289 void StartPrefetchDecoders();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 358
349 // Configuration data for the manager, accessed on the UI thread. 359 // Configuration data for the manager, accessed on the UI thread.
350 MediaMetadata metadata_cache_; 360 MediaMetadata metadata_cache_;
351 361
352 // Cached current time, accessed on UI thread. 362 // Cached current time, accessed on UI thread.
353 base::TimeDelta current_time_cache_; 363 base::TimeDelta current_time_cache_;
354 364
355 // For testing only. 365 // For testing only.
356 DecodersTimeCallback decoders_time_cb_; 366 DecodersTimeCallback decoders_time_cb_;
357 367
368 // DRM
369 MediaDrmBridge* drm_bridge_;
370 int cdm_registration_id_;
371
372 // The flag is set when the player receives the error from decoder that the
373 // decoderneeds a new encryption key. Cleared on starting the playback.
374 bool key_is_required_;
375
376 // The flag is set after the new encryption key is added to MediaDrm. Cleared
377 // on starting the playback.
378 bool key_is_added_;
379
358 base::WeakPtr<MediaCodecPlayer> media_weak_this_; 380 base::WeakPtr<MediaCodecPlayer> media_weak_this_;
359 // NOTE: Weak pointers must be invalidated before all other member variables. 381 // NOTE: Weak pointers must be invalidated before all other member variables.
360 base::WeakPtrFactory<MediaCodecPlayer> media_weak_factory_; 382 base::WeakPtrFactory<MediaCodecPlayer> media_weak_factory_;
361 383
362 DISALLOW_COPY_AND_ASSIGN(MediaCodecPlayer); 384 DISALLOW_COPY_AND_ASSIGN(MediaCodecPlayer);
363 }; 385 };
364 386
365 } // namespace media 387 } // namespace media
366 388
367 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_PLAYER_H_ 389 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_PLAYER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698