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 aeaf4ec77957110bb4a0491e5b7f8f1ac7c78677..c3592b000c090cfb3d28102be7f40a1ffeeae039 100644 |
--- a/media/base/android/media_codec_decoder.h |
+++ b/media/base/android/media_codec_decoder.h |
@@ -154,6 +154,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& preroll_done_cb, |
const base::Closure& stop_done_cb, |
const base::Closure& error_cb, |
const char* decoder_thread_name); |
@@ -177,11 +178,12 @@ class MediaCodecDecoder { |
// the input. Decoder thread should not be running. |
virtual void Flush(); |
- // Releases MediaCodecBridge. |
- void ReleaseMediaCodec(); |
+ // Releases MediaCodecBridge and any related buffers or references. |
+ virtual void ReleaseMediaCodec(); |
// Returns corresponding conditions. |
bool IsPrefetchingOrPlaying() const; |
+ bool IsPrerollDone() const; |
bool IsStopped() const; |
bool IsCompleted() const; |
@@ -194,8 +196,13 @@ class MediaCodecDecoder { |
// Configures MediaCodec. |
ConfigStatus Configure(); |
+ // Sets preroll timestamp. The rendering starts after we reached it. |
+ void SetPrerollTimestamp(base::TimeDelta preroll_timestamp); |
+ |
// Starts the decoder thread and resumes the playback. |
- bool Start(base::TimeDelta current_time); |
+ bool Start(base::TimeDelta start_timestamp); |
+ |
+ void ResumeAfterPreroll(); |
// Stops the playback process synchronously. This method stops the decoder |
// thread synchronously, and then releases all MediaCodec buffers. |
@@ -209,10 +216,19 @@ class MediaCodecDecoder { |
// Notification posted when asynchronous stop is done or playback completed. |
void OnLastFrameRendered(bool completed); |
+ // Notification posted when last prerolled frame has been returned to codec. |
+ void OnPrerollDone(); |
+ |
// Puts the incoming data into AccessUnitQueue. |
void OnDemuxerDataAvailable(const DemuxerData& data); |
protected: |
+ enum RenderMode { |
+ kRenderSkip = 0, |
+ kRenderAfterPreroll, |
+ kRenderNow, |
+ }; |
+ |
// Returns true if the new DemuxerConfigs requires MediaCodec |
// reconfiguration. |
virtual bool IsCodecReconfigureNeeded(const DemuxerConfigs& curr, |
@@ -224,7 +240,10 @@ class MediaCodecDecoder { |
// Associates PTS with device time so we can calculate delays. |
// We use delays for video decoder only. |
- virtual void SynchronizePTSWithTime(base::TimeDelta current_time) {} |
+ virtual void AssociateCurrentTimeWithPTS(base::TimeDelta current_time) {} |
+ |
+ // Invalidate delay calculation. We use delays for video decoder only. |
+ virtual void DissociatePTSFromTime() {} |
// Processes the change of the output format, varies by stream. |
virtual void OnOutputFormatChanged() = 0; |
@@ -233,16 +252,15 @@ class MediaCodecDecoder { |
// a delayed task to do it at a later time, |
virtual void Render(int buffer_index, |
size_t size, |
- bool render_output, |
+ RenderMode render_mode, |
base::TimeDelta pts, |
bool eos_encountered) = 0; |
// Returns the number of delayed task (we might have them for video). |
virtual int NumDelayedRenderTasks() const; |
- // Releases output buffers that are dequeued and not released yet (video) |
- // if the |release| parameter is set and then remove the references to them. |
- virtual void ClearDelayedBuffers(bool release) {} |
+ // Releases output buffers that are dequeued and not released yet (video). |
+ virtual void ReleaseDelayedBuffers() {} |
#ifndef NDEBUG |
// For video, checks that access unit is the key frame or stand-alone EOS. |
@@ -254,6 +272,8 @@ class MediaCodecDecoder { |
// Notifies the decoder if the frame is the last one. |
void CheckLastFrame(bool eos_encountered, bool has_delayed_tasks); |
+ const char* AsString(RenderMode render_mode); |
+ |
// Protected data. |
// Object for posting tasks on Media thread. |
@@ -278,6 +298,8 @@ class MediaCodecDecoder { |
kStopped = 0, |
kPrefetching, |
kPrefetched, |
+ kPrerolling, |
+ kPrerolled, |
kRunning, |
kStopping, |
kInEmergencyStop, |
@@ -321,6 +343,7 @@ class MediaCodecDecoder { |
// These notifications are called on corresponding conditions. |
base::Closure prefetch_done_cb_; |
base::Closure starvation_cb_; |
+ base::Closure preroll_done_cb_; |
base::Closure stop_done_cb_; |
base::Closure error_cb_; |
@@ -330,10 +353,16 @@ class MediaCodecDecoder { |
// Callback used to post OnCodecError method. |
base::Closure internal_error_cb_; |
+ // Callback for posting OnPrerollDone method. |
+ base::Closure internal_preroll_done_cb_; |
+ |
// Internal state. |
DecoderState state_; |
mutable base::Lock state_lock_; |
+ // Preroll timestamp is set if we need preroll and cleared after we done it. |
+ base::TimeDelta preroll_timestamp_; |
+ |
// Flag is set when the EOS is enqueued into MediaCodec. Reset by Flush. |
bool eos_enqueued_; |