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

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

Issue 1312103006: MediaCodecPlayer - preroll and reconfiguration fixes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mtplayer-reconfig
Patch Set: Addressed Min's comments, small changes in stop sequence 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_DECODER_H_ 5 #ifndef MEDIA_BASE_ANDROID_MEDIA_CODEC_DECODER_H_
6 #define MEDIA_BASE_ANDROID_MEDIA_CODEC_DECODER_H_ 6 #define MEDIA_BASE_ANDROID_MEDIA_CODEC_DECODER_H_
7 7
8 #include "base/android/scoped_java_ref.h" 8 #include "base/android/scoped_java_ref.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 virtual void ReleaseMediaCodec(); 188 virtual void ReleaseMediaCodec();
189 189
190 // Returns corresponding conditions. 190 // Returns corresponding conditions.
191 bool IsPrefetchingOrPlaying() const; 191 bool IsPrefetchingOrPlaying() const;
192 bool IsStopped() const; 192 bool IsStopped() const;
193 bool IsCompleted() const; 193 bool IsCompleted() const;
194 bool NotCompletedAndNeedsPreroll() const; 194 bool NotCompletedAndNeedsPreroll() const;
195 195
196 // Requests an A/V sync mechanism that is similar to preroll, but stops at the 196 // Requests an A/V sync mechanism that is similar to preroll, but stops at the
197 // first available output frame rather than passing certain PTS. 197 // first available output frame rather than passing certain PTS.
198 void SetDecodingUntilOutputIsPresent(); 198 void SetDecodingUntilOutputIsPresent();
liberato (no reviews please) 2015/09/04 21:59:13 did you mean to delete this?
Tima Vaisburd 2015/09/04 23:17:35 Yes, thank you, I will delete it.
199 199
200 // Sets preroll timestamp and requests preroll.
201 void SetPrerollTimestamp(base::TimeDelta preroll_ts);
202
200 base::android::ScopedJavaLocalRef<jobject> GetMediaCrypto(); 203 base::android::ScopedJavaLocalRef<jobject> GetMediaCrypto();
201 204
202 // Starts prefetching: accumulates enough data in AccessUnitQueue. 205 // Starts prefetching: accumulates enough data in AccessUnitQueue.
203 // Decoder thread is not running. 206 // Decoder thread is not running.
204 void Prefetch(const base::Closure& prefetch_done_cb); 207 void Prefetch(const base::Closure& prefetch_done_cb);
205 208
206 // Configures MediaCodec. 209 // Configures MediaCodec.
207 ConfigStatus Configure(); 210 ConfigStatus Configure();
208 211
209 // Starts the decoder for prerolling. This method starts the decoder thread. 212 // Starts the decoder for prerolling. This method starts the decoder thread.
210 bool Preroll(base::TimeDelta preroll_timestamp, 213 bool Preroll(const base::Closure& preroll_done_cb);
211 const base::Closure& preroll_done_cb);
212 214
213 // Starts the decoder after preroll is not needed, starting decoder thread 215 // Starts the decoder after preroll is not needed, starting decoder thread
214 // if it has not started yet. 216 // if it has not started yet.
215 bool Start(base::TimeDelta start_timestamp); 217 bool Start(base::TimeDelta start_timestamp);
216 218
217 // Stops the playback process synchronously. This method stops the decoder 219 // Stops the playback process synchronously. This method stops the decoder
218 // thread synchronously, and then releases all MediaCodec buffers. 220 // thread synchronously, and then releases all MediaCodec buffers.
219 void SyncStop(); 221 void SyncStop();
220 222
221 // Requests to stop the playback and returns. 223 // Requests to stop the playback and returns.
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 kPrefetching, 337 kPrefetching,
336 kPrefetched, 338 kPrefetched,
337 kPrerolling, 339 kPrerolling,
338 kPrerolled, 340 kPrerolled,
339 kRunning, 341 kRunning,
340 kStopping, 342 kStopping,
341 kInEmergencyStop, 343 kInEmergencyStop,
342 kError, 344 kError,
343 }; 345 };
344 346
345 enum PrerollMode {
346 kNoPreroll = 0,
347 kPrerollTillOutputIsPresent,
348 kPrerollTillPTS,
349 };
350
351 // Helper method that processes an error from MediaCodec. 347 // Helper method that processes an error from MediaCodec.
352 void OnCodecError(); 348 void OnCodecError();
353 349
354 // Requests data. Ensures there is no more than one request at a time. 350 // Requests data. Ensures there is no more than one request at a time.
355 void RequestData(); 351 void RequestData();
356 352
357 // Prefetching callback that is posted to Media thread 353 // Prefetching callback that is posted to Media thread
358 // in the kPrefetching state. 354 // in the kPrefetching state.
359 void PrefetchNextChunk(); 355 void PrefetchNextChunk();
360 356
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 // Callback for posting OnPrerollDone method. 403 // Callback for posting OnPrerollDone method.
408 base::Closure internal_preroll_done_cb_; 404 base::Closure internal_preroll_done_cb_;
409 405
410 // Internal state. 406 // Internal state.
411 DecoderState state_; 407 DecoderState state_;
412 mutable base::Lock state_lock_; 408 mutable base::Lock state_lock_;
413 409
414 // Preroll timestamp is set if we need preroll and cleared after we done it. 410 // Preroll timestamp is set if we need preroll and cleared after we done it.
415 base::TimeDelta preroll_timestamp_; 411 base::TimeDelta preroll_timestamp_;
416 412
417 // The preroll mode. If not |kNoPreroll|, the playback should start with 413 // Set to true when MediaCodec internal buffers are filled up.
418 // preroll. 414 bool is_prepared_;
419 PrerollMode preroll_mode_;
420 415
421 // Flag is set when the EOS is enqueued into MediaCodec. Reset by Flush. 416 // Flag is set when the EOS is enqueued into MediaCodec. Reset by Flush.
422 bool eos_enqueued_; 417 bool eos_enqueued_;
423 418
424 // Flag is set when the EOS is received in MediaCodec output. Reset by Flush. 419 // Flag is set when the EOS is received in MediaCodec output. Reset by Flush.
425 bool completed_; 420 bool completed_;
426 421
427 // Flag to ensure we post last frame notification once. 422 // Flag to ensure we post last frame notification once.
428 bool last_frame_posted_; 423 bool last_frame_posted_;
429 424
(...skipping 10 matching lines...) Expand all
440 435
441 // NOTE: Weak pointers must be invalidated before all other member variables. 436 // NOTE: Weak pointers must be invalidated before all other member variables.
442 base::WeakPtrFactory<MediaCodecDecoder> weak_factory_; 437 base::WeakPtrFactory<MediaCodecDecoder> weak_factory_;
443 438
444 DISALLOW_COPY_AND_ASSIGN(MediaCodecDecoder); 439 DISALLOW_COPY_AND_ASSIGN(MediaCodecDecoder);
445 }; 440 };
446 441
447 } // namespace media 442 } // namespace media
448 443
449 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_DECODER_H_ 444 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_DECODER_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/android/media_codec_decoder.cc » ('j') | media/base/android/media_codec_decoder.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698