| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_DECODER_JOB_H_ | 5 #ifndef MEDIA_BASE_ANDROID_MEDIA_DECODER_JOB_H_ |
| 6 #define MEDIA_BASE_ANDROID_MEDIA_DECODER_JOB_H_ | 6 #define MEDIA_BASE_ANDROID_MEDIA_DECODER_JOB_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 // Data is stored in 2 chunks. When new data arrives, it is always stored in | 22 // Data is stored in 2 chunks. When new data arrives, it is always stored in |
| 23 // an inactive chunk. And when the current active chunk becomes empty, a new | 23 // an inactive chunk. And when the current active chunk becomes empty, a new |
| 24 // data request will be sent to the renderer. | 24 // data request will be sent to the renderer. |
| 25 class MediaDecoderJob { | 25 class MediaDecoderJob { |
| 26 public: | 26 public: |
| 27 struct Deleter { | 27 struct Deleter { |
| 28 inline void operator()(MediaDecoderJob* ptr) const { ptr->Release(); } | 28 inline void operator()(MediaDecoderJob* ptr) const { ptr->Release(); } |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 // Callback when a decoder job finishes its work. Args: whether decode | 31 // Callback when a decoder job finishes its work. Args: whether decode |
| 32 // finished successfully, presentation time, audio output bytes. | 32 // finished successfully, presentation time, audio output bytes, current |
| 33 // audio frame position, current time. |
| 33 // If the presentation time is equal to kNoTimestamp(), the decoder job | 34 // If the presentation time is equal to kNoTimestamp(), the decoder job |
| 34 // skipped rendering of the decoded output and the callback target should | 35 // skipped rendering of the decoded output and the callback target should |
| 35 // update its clock to avoid introducing extra delays to the next frame. | 36 // update its clock to avoid introducing extra delays to the next frame. |
| 36 typedef base::Callback<void(MediaCodecStatus, base::TimeDelta, | 37 typedef base::Callback<void(MediaCodecStatus, base::TimeDelta, |
| 37 size_t)> DecoderCallback; | 38 size_t, int64, base::TimeTicks)> DecoderCallback; |
| 38 // Callback when a decoder job finishes releasing the output buffer. | 39 // Callback when a decoder job finishes releasing the output buffer. |
| 39 // Args: audio output bytes, must be 0 for video. | 40 // Args: audio output bytes, current audio frame position, current time. |
| 40 typedef base::Callback<void(size_t)> ReleaseOutputCompletionCallback; | 41 // All of them must be 0 or empty for video. |
| 42 typedef base::Callback<void(size_t, int64, base::TimeTicks)> |
| 43 ReleaseOutputCompletionCallback; |
| 41 | 44 |
| 42 virtual ~MediaDecoderJob(); | 45 virtual ~MediaDecoderJob(); |
| 43 | 46 |
| 44 // Called by MediaSourcePlayer when more data for this object has arrived. | 47 // Called by MediaSourcePlayer when more data for this object has arrived. |
| 45 void OnDataReceived(const DemuxerData& data); | 48 void OnDataReceived(const DemuxerData& data); |
| 46 | 49 |
| 47 // Prefetch so we know the decoder job has data when we call Decode(). | 50 // Prefetch so we know the decoder job has data when we call Decode(). |
| 48 // |prefetch_cb| - Run when prefetching has completed. | 51 // |prefetch_cb| - Run when prefetching has completed. |
| 49 void Prefetch(const base::Closure& prefetch_cb); | 52 void Prefetch(const base::Closure& prefetch_cb); |
| 50 | 53 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 base::TimeTicks start_time_ticks, | 134 base::TimeTicks start_time_ticks, |
| 132 base::TimeDelta start_presentation_timestamp, | 135 base::TimeDelta start_presentation_timestamp, |
| 133 bool needs_flush, | 136 bool needs_flush, |
| 134 const DecoderCallback& callback); | 137 const DecoderCallback& callback); |
| 135 | 138 |
| 136 // Called on the UI thread to indicate that one decode cycle has completed. | 139 // Called on the UI thread to indicate that one decode cycle has completed. |
| 137 // Completes any pending job destruction or any pending decode stop. If | 140 // Completes any pending job destruction or any pending decode stop. If |
| 138 // destruction was not pending, passes its arguments to |decode_cb_|. | 141 // destruction was not pending, passes its arguments to |decode_cb_|. |
| 139 void OnDecodeCompleted(MediaCodecStatus status, | 142 void OnDecodeCompleted(MediaCodecStatus status, |
| 140 base::TimeDelta presentation_timestamp, | 143 base::TimeDelta presentation_timestamp, |
| 141 size_t audio_output_bytes); | 144 size_t audio_output_bytes, |
| 145 int64 audio_head_position, |
| 146 base::TimeTicks audio_render_time); |
| 142 | 147 |
| 143 // Helper function to get the current access unit that is being decoded. | 148 // Helper function to get the current access unit that is being decoded. |
| 144 const AccessUnit& CurrentAccessUnit() const; | 149 const AccessUnit& CurrentAccessUnit() const; |
| 145 | 150 |
| 146 // Check whether a chunk has no remaining access units to decode. If | 151 // Check whether a chunk has no remaining access units to decode. If |
| 147 // |is_active_chunk| is true, this function returns whether decoder has | 152 // |is_active_chunk| is true, this function returns whether decoder has |
| 148 // consumed all data in |received_data_[current_demuxer_data_index_]|. | 153 // consumed all data in |received_data_[current_demuxer_data_index_]|. |
| 149 // Otherwise, it returns whether decoder has consumed all data in the inactive | 154 // Otherwise, it returns whether decoder has consumed all data in the inactive |
| 150 // chunk. | 155 // chunk. |
| 151 bool NoAccessUnitsRemainingInChunk(bool is_active_chunk) const; | 156 bool NoAccessUnitsRemainingInChunk(bool is_active_chunk) const; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 // the decoder thread. | 252 // the decoder thread. |
| 248 // NOTE: Weak pointers must be invalidated before all other member variables. | 253 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 249 base::WeakPtrFactory<MediaDecoderJob> weak_factory_; | 254 base::WeakPtrFactory<MediaDecoderJob> weak_factory_; |
| 250 | 255 |
| 251 DISALLOW_IMPLICIT_CONSTRUCTORS(MediaDecoderJob); | 256 DISALLOW_IMPLICIT_CONSTRUCTORS(MediaDecoderJob); |
| 252 }; | 257 }; |
| 253 | 258 |
| 254 } // namespace media | 259 } // namespace media |
| 255 | 260 |
| 256 #endif // MEDIA_BASE_ANDROID_MEDIA_DECODER_JOB_H_ | 261 #endif // MEDIA_BASE_ANDROID_MEDIA_DECODER_JOB_H_ |
| OLD | NEW |