| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 // Called by MediaSourcePlayer when more data for this object has arrived. | 47 // Called by MediaSourcePlayer when more data for this object has arrived. |
| 48 void OnDataReceived(const DemuxerData& data); | 48 void OnDataReceived(const DemuxerData& data); |
| 49 | 49 |
| 50 // 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(). |
| 51 // |prefetch_cb| - Run when prefetching has completed. | 51 // |prefetch_cb| - Run when prefetching has completed. |
| 52 void Prefetch(const base::Closure& prefetch_cb); | 52 void Prefetch(const base::Closure& prefetch_cb); |
| 53 | 53 |
| 54 // Called by MediaSourcePlayer to decode some data. | 54 // Called by MediaSourcePlayer to decode some data. |
| 55 // |callback| - Run when decode operation has completed. | 55 // |callback| - Run when decode operation has completed. |
| 56 // | 56 // |
| 57 // Returns true if the next decode was started and |callback| will be | 57 // Returns the pointer to a DemuxerConfig if a config change is detected, or |
| 58 // called when the decode operation is complete. | 58 // NULL otherwise. Caller needs to take the ownership of the returned pointer. |
| 59 // Returns false if a config change is needed. |callback| is ignored | 59 // In the case of requiring further data before commencing |
| 60 // and will not be called. | 60 // decode, NULL will also be returned although config change may be the next |
| 61 bool Decode(base::TimeTicks start_time_ticks, | 61 // received access unit. |callback| will be called when the decode operation |
| 62 base::TimeDelta start_presentation_timestamp, | 62 // is complete. If a config change is detected, |callback| is ignored and |
| 63 const DecoderCallback& callback); | 63 // will not be called. |
| 64 DemuxerConfigs* Decode(base::TimeTicks start_time_ticks, |
| 65 base::TimeDelta start_presentation_timestamp, |
| 66 const DecoderCallback& callback); |
| 64 | 67 |
| 65 // Called to stop the last Decode() early. | 68 // Called to stop the last Decode() early. |
| 66 // If the decoder is in the process of decoding the next frame, then | 69 // If the decoder is in the process of decoding the next frame, then |
| 67 // this method will just allow the decode to complete as normal. If | 70 // this method will just allow the decode to complete as normal. If |
| 68 // this object is waiting for a data request to complete, then this method | 71 // this object is waiting for a data request to complete, then this method |
| 69 // will wait for the data to arrive and then call the |callback| | 72 // will wait for the data to arrive and then call the |callback| |
| 70 // passed to Decode() with a status of MEDIA_CODEC_STOPPED. This ensures that | 73 // passed to Decode() with a status of MEDIA_CODEC_STOPPED. This ensures that |
| 71 // the |callback| passed to Decode() is always called and the status | 74 // the |callback| passed to Decode() is always called and the status |
| 72 // reflects whether data was actually decoded or the decode terminated early. | 75 // reflects whether data was actually decoded or the decode terminated early. |
| 73 void StopDecode(); | 76 void StopDecode(); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 // Called on the UI thread to indicate that one decode cycle has completed. | 143 // Called on the UI thread to indicate that one decode cycle has completed. |
| 141 // Completes any pending job destruction or any pending decode stop. If | 144 // Completes any pending job destruction or any pending decode stop. If |
| 142 // destruction was not pending, passes its arguments to |decode_cb_|. | 145 // destruction was not pending, passes its arguments to |decode_cb_|. |
| 143 void OnDecodeCompleted(MediaCodecStatus status, | 146 void OnDecodeCompleted(MediaCodecStatus status, |
| 144 base::TimeDelta current_presentation_timestamp, | 147 base::TimeDelta current_presentation_timestamp, |
| 145 base::TimeDelta max_presentation_timestamp); | 148 base::TimeDelta max_presentation_timestamp); |
| 146 | 149 |
| 147 // Helper function to get the current access unit that is being decoded. | 150 // Helper function to get the current access unit that is being decoded. |
| 148 const AccessUnit& CurrentAccessUnit() const; | 151 const AccessUnit& CurrentAccessUnit() const; |
| 149 | 152 |
| 153 // Helper function to get the current data chunk index that is being decoded. |
| 154 size_t CurrentReceivedDataChunkIndex() const; |
| 155 |
| 150 // Check whether a chunk has no remaining access units to decode. If | 156 // Check whether a chunk has no remaining access units to decode. If |
| 151 // |is_active_chunk| is true, this function returns whether decoder has | 157 // |is_active_chunk| is true, this function returns whether decoder has |
| 152 // consumed all data in |received_data_[current_demuxer_data_index_]|. | 158 // consumed all data in |received_data_[current_demuxer_data_index_]|. |
| 153 // Otherwise, it returns whether decoder has consumed all data in the inactive | 159 // Otherwise, it returns whether decoder has consumed all data in the inactive |
| 154 // chunk. | 160 // chunk. |
| 155 bool NoAccessUnitsRemainingInChunk(bool is_active_chunk) const; | 161 bool NoAccessUnitsRemainingInChunk(bool is_active_chunk) const; |
| 156 | 162 |
| 157 // Clearn all the received data. | 163 // Clearn all the received data. |
| 158 void ClearData(); | 164 void ClearData(); |
| 159 | 165 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 // the decoder thread. | 257 // the decoder thread. |
| 252 // NOTE: Weak pointers must be invalidated before all other member variables. | 258 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 253 base::WeakPtrFactory<MediaDecoderJob> weak_factory_; | 259 base::WeakPtrFactory<MediaDecoderJob> weak_factory_; |
| 254 | 260 |
| 255 DISALLOW_IMPLICIT_CONSTRUCTORS(MediaDecoderJob); | 261 DISALLOW_IMPLICIT_CONSTRUCTORS(MediaDecoderJob); |
| 256 }; | 262 }; |
| 257 | 263 |
| 258 } // namespace media | 264 } // namespace media |
| 259 | 265 |
| 260 #endif // MEDIA_BASE_ANDROID_MEDIA_DECODER_JOB_H_ | 266 #endif // MEDIA_BASE_ANDROID_MEDIA_DECODER_JOB_H_ |
| OLD | NEW |