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

Unified Diff: media/base/android/media_codec_decoder.h

Issue 1287423004: MediaCodecPlayer implementation (stage 5 - reconfiguration) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mtplayer-cleanuptest
Patch Set: Made a helper method for advancing AU queue, report starvation if cannot advance whether we drain d… Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: media/base/android/media_codec_decoder.h
diff --git a/media/base/android/media_codec_decoder.h b/media/base/android/media_codec_decoder.h
index 0108ccd73c3f422778dfa1b09811bc1c4727dede..c47d922657a0c55ee1f8e37cdfb2d2db89c7b04c 100644
--- a/media/base/android/media_codec_decoder.h
+++ b/media/base/android/media_codec_decoder.h
@@ -149,6 +149,8 @@ class MediaCodecDecoder {
// The player is supposed to stop and then prefetch the decoder.
// stop_done_cb:
// Called when async stop request is completed.
+ // decoder_drained_cb:
+ // Called when decoder is drained for reconfiguration.
// error_cb:
// Called when a MediaCodec error occurred. If this happens, a player has
// to either call ReleaseDecoderResources() or destroy the decoder object.
@@ -158,6 +160,7 @@ class MediaCodecDecoder {
const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner,
const base::Closure& external_request_data_cb,
const base::Closure& starvation_cb,
+ const base::Closure& decoder_drained_cb,
const base::Closure& stop_done_cb,
const base::Closure& error_cb,
const char* decoder_thread_name);
@@ -190,6 +193,10 @@ class MediaCodecDecoder {
bool IsCompleted() const;
bool NotCompletedAndNeedsPreroll() const;
+ // Requests an A/V sync mechanism that is similar to preroll, but stops at the
+ // first available output frame rather than passing certain PTS.
+ void SetDecodingUntilOutputIsPresent();
+
base::android::ScopedJavaLocalRef<jobject> GetMediaCrypto();
// Starts prefetching: accumulates enough data in AccessUnitQueue.
@@ -217,7 +224,7 @@ class MediaCodecDecoder {
void RequestToStop();
// Notification posted when asynchronous stop is done or playback completed.
- void OnLastFrameRendered(bool completed);
+ void OnLastFrameRendered(bool eos_encountered);
// Notification posted when last prerolled frame has been returned to codec.
void OnPrerollDone();
@@ -225,9 +232,17 @@ class MediaCodecDecoder {
// Puts the incoming data into AccessUnitQueue.
void OnDemuxerDataAvailable(const DemuxerData& data);
- // For testing only. Returns true if the decoder is in kPrerolling state.
+ // For testing only.
+
+ // Returns true if the decoder is in kPrerolling state.
bool IsPrerollingForTests() const;
+ // Drains decoder and reconfigures for each |kConfigChanged|.
+ void SetAlwaysReconfigureForTests();
+
+ // Sets the notification to be called when MediaCodec is created.
+ void SetCodecCreatedCallbackForTests(base::Closure cb);
+
protected:
enum RenderMode {
kRenderSkip = 0,
@@ -237,8 +252,7 @@ class MediaCodecDecoder {
// Returns true if the new DemuxerConfigs requires MediaCodec
// reconfiguration.
- virtual bool IsCodecReconfigureNeeded(const DemuxerConfigs& curr,
- const DemuxerConfigs& next) const = 0;
+ virtual bool IsCodecReconfigureNeeded(const DemuxerConfigs& next) const = 0;
// Does the part of MediaCodecBridge configuration that is specific
// to audio or video.
@@ -306,6 +320,15 @@ class MediaCodecDecoder {
// is set by video decoder when the video surface changes.
bool needs_reconfigure_;
+ // Flag forces to drain decoder in the process of dynamic reconfiguration.
+ bool drain_decoder_;
+
+ // For tests only. Forces to always reconfigure for |kConfigChanged| unit.
+ bool always_reconfigure_for_tests_;
+
+ // For tests only. Callback to be callned when MediaCodec is created.
+ base::Closure codec_created_for_tests_cb_;
+
private:
enum DecoderState {
kStopped = 0,
@@ -319,6 +342,12 @@ class MediaCodecDecoder {
kError,
};
+ enum PrerollMode {
+ kNoPreroll = 0,
+ kPrerollTillOutputIsPresent,
+ kPrerollTillPTS,
+ };
+
// Helper method that processes an error from MediaCodec.
void OnCodecError();
@@ -338,6 +367,14 @@ class MediaCodecDecoder {
// Returns false if there was MediaCodec error.
bool EnqueueInputBuffer();
+ // Helper method for EnqueueInputBuffer.
+ // Gets the next data frame from the queue, requesting more data and saving
+ // configuration changes on the way. Sets |drain_decoder| to true of any of
+ // the configuration changes requires draining the decoder. Returns the Info
+ // pointing to the current data unit ot empty Info if it got past the end of
+ // the queue.
+ AccessUnitQueue::Info AdvanceAccessUnitQueue(bool* drain_decoder);
+
// Helper method for ProcessNextFrame.
// Pulls all currently available output frames and renders them.
// Returns true if we need to continue decoding process, i.e post next
@@ -357,6 +394,7 @@ class MediaCodecDecoder {
base::Closure prefetch_done_cb_;
base::Closure starvation_cb_;
base::Closure preroll_done_cb_;
+ base::Closure decoder_drained_cb_;
base::Closure stop_done_cb_;
base::Closure error_cb_;
@@ -376,8 +414,9 @@ class MediaCodecDecoder {
// Preroll timestamp is set if we need preroll and cleared after we done it.
base::TimeDelta preroll_timestamp_;
- // Indicates that playback should start with preroll.
- bool needs_preroll_;
+ // The preroll mode. If not |kNoPreroll|, the playback should start with
+ // preroll.
+ PrerollMode preroll_mode_;
// Flag is set when the EOS is enqueued into MediaCodec. Reset by Flush.
bool eos_enqueued_;

Powered by Google App Engine
This is Rietveld 408576698