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

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: Avoid potential frame skipping after decoder drain with a new prerolling mode 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 68de9a2f362a984dab944dc58e23c9d69a75855c..c932850ad4ce26a1af26d77221c460bba1f76b99 100644
--- a/media/base/android/media_codec_decoder.h
+++ b/media/base/android/media_codec_decoder.h
@@ -145,6 +145,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.
@@ -154,6 +156,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);
@@ -186,6 +189,9 @@ class MediaCodecDecoder {
bool IsCompleted() const;
bool NotCompletedAndNeedsPreroll() const;
+ // Sets preroll mode to kPrerollTillNextFrame.
qinmin 2015/08/27 19:38:42 PrerollTillNextFrame is protected and its hard for
Tima Vaisburd 2015/08/27 20:39:47 I did SetDecodingUntilOutputIsPresent() and change
+ void SetPrerollTillNextFrame();
+
base::android::ScopedJavaLocalRef<jobject> GetMediaCrypto();
// Starts prefetching: accumulates enough data in AccessUnitQueue.
@@ -213,7 +219,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();
@@ -221,9 +227,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;
+ // Drain decoder and reconfigure for each |kConfigChanged|.
qinmin 2015/08/27 19:38:42 s/Drain/Drains/ s/reconfigure/reconfigures/
Tima Vaisburd 2015/08/27 20:39:47 Done.
+ void SetAlwaysReconfigureForTests();
+
+ // Sets the notification to be called when MediaCodec is created.
+ void SetCodecCreatedCallbackForTests(base::Closure cb);
+
protected:
enum RenderMode {
kRenderSkip = 0,
@@ -233,8 +247,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.
@@ -302,6 +315,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,
@@ -315,6 +337,12 @@ class MediaCodecDecoder {
kError,
};
+ enum PrerollMode {
+ kNoPreroll = 0,
+ kPrerollTillNextFrame,
+ kPrerollTillPTS,
+ };
+
// Helper method that processes an error from MediaCodec.
void OnCodecError();
@@ -353,6 +381,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_;
@@ -372,8 +401,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