Index: media/base/android/media_decoder_job.h |
diff --git a/media/base/android/media_decoder_job.h b/media/base/android/media_decoder_job.h |
index 286d27cf75b5c60251085d7000764736f7a8fd6a..4d523a015e21b0e8f37eba96970ffedf9075c827 100644 |
--- a/media/base/android/media_decoder_job.h |
+++ b/media/base/android/media_decoder_job.h |
@@ -19,6 +19,9 @@ namespace media { |
// Class for managing all the decoding tasks. Each decoding task will be posted |
// onto the same thread. The thread will be stopped once Stop() is called. |
+// Data is stored in 2 chunks. When new data arrives, it is always stored in |
+// an inactive chunk. And when the current active chunk becomes empty, a new |
+// data request will be sent to the renderer. |
class MediaDecoderJob { |
public: |
struct Deleter { |
@@ -76,6 +79,10 @@ class MediaDecoderJob { |
bool is_decoding() const { return !decode_cb_.is_null(); } |
+ bool is_requesting_demuxer_data() const { |
+ return is_requesting_demuxer_data_; |
+ } |
+ |
protected: |
MediaDecoderJob( |
const scoped_refptr<base::SingleThreadTaskRunner>& decoder_task_runner, |
@@ -107,8 +114,8 @@ class MediaDecoderJob { |
// |done_cb| is called when more data is available in |received_data_|. |
void RequestData(const base::Closure& done_cb); |
- // Posts a task to start decoding the next access unit in |received_data_|. |
- void DecodeNextAccessUnit( |
+ // Posts a task to start decoding the current access unit in |received_data_|. |
+ void DecodeCurrentAccessUnit( |
const base::TimeTicks& start_time_ticks, |
const base::TimeDelta& start_presentation_timestamp); |
wolenetz
2014/03/17 19:51:00
nit: const & for TimeDelta is not current style. U
qinmin
2014/03/18 18:58:58
Done.
|
@@ -131,6 +138,18 @@ class MediaDecoderJob { |
const base::TimeDelta& presentation_timestamp, |
size_t audio_output_bytes); |
+ // Helper function to get the current access unit that is being decoded. |
+ const AccessUnit& CurrentAccessUnit() const; |
+ |
+ // Check whether a chunk is empty. |
wolenetz
2014/03/17 19:51:00
nit: Describe meaning of |current_chunk|.
qinmin
2014/03/18 18:58:58
Done.
|
+ bool IsDemuxerDataEmpty(bool current_chunk) const; |
+ |
+ // Clearn all the received data. |
+ void ClearData(); |
+ |
+ // Request new data for the current chunk if it runs out of data. |
+ void RequestCurrentChunkIfEmpty(); |
+ |
// The UI message loop where callbacks should be dispatched. |
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
@@ -183,11 +202,19 @@ class MediaDecoderJob { |
// Callback to run when the current Decode() operation completes. |
DecoderCallback decode_cb_; |
- // The current access unit being processed. |
- size_t access_unit_index_; |
- |
// Data received over IPC from last RequestData() operation. |
- DemuxerData received_data_; |
+ // We keep 2 chunks at the same time to reduce the IPC latency between chunks. |
+ // If data inside the current chunk are all decoded, we will request a new |
+ // chunk from the demuxer and swap the current chunk with the other one. |
+ // New data will always be stored in the other chunk since the current |
+ // one may be still in use. |
+ DemuxerData received_data_[2]; |
+ |
+ // Index to the current data chunk that is being decoded. |
+ size_t current_demuxer_data_index_; |
+ |
+ // Index to the access unit inside each data chunk that is being decoded. |
+ size_t access_unit_index_[2]; |
// The index of input buffer that can be used by QueueInputBuffer(). |
// If the index is uninitialized or invalid, it must be -1. |
@@ -200,6 +227,13 @@ class MediaDecoderJob { |
// while there is a decode in progress. |
bool destroy_pending_; |
+ // Indicates whether the decoder is in the middle of requesting new data. |
+ bool is_requesting_demuxer_data_; |
+ |
+ // Indicates whether the incoming data should be ignored. |
+ bool is_incoming_data_invalid_; |
+ |
+ friend class MediaSourcePlayerTest; |
DISALLOW_IMPLICIT_CONSTRUCTORS(MediaDecoderJob); |
}; |