| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_CODEC_DECODER_H_ | 5 #ifndef MEDIA_BASE_ANDROID_MEDIA_CODEC_DECODER_H_ |
| 6 #define MEDIA_BASE_ANDROID_MEDIA_CODEC_DECODER_H_ | 6 #define MEDIA_BASE_ANDROID_MEDIA_CODEC_DECODER_H_ |
| 7 | 7 |
| 8 #include "base/android/scoped_java_ref.h" | 8 #include "base/android/scoped_java_ref.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 // a delayed task to do it at a later time, | 223 // a delayed task to do it at a later time, |
| 224 virtual void Render(int buffer_index, | 224 virtual void Render(int buffer_index, |
| 225 size_t size, | 225 size_t size, |
| 226 bool render_output, | 226 bool render_output, |
| 227 base::TimeDelta pts, | 227 base::TimeDelta pts, |
| 228 bool eos_encountered) = 0; | 228 bool eos_encountered) = 0; |
| 229 | 229 |
| 230 // Returns the number of delayed task (we might have them for video). | 230 // Returns the number of delayed task (we might have them for video). |
| 231 virtual int NumDelayedRenderTasks() const; | 231 virtual int NumDelayedRenderTasks() const; |
| 232 | 232 |
| 233 // Releases output buffers that are dequeued and not released yet | 233 // Releases output buffers that are dequeued and not released yet (video) |
| 234 // because their rendering is delayed (video). | 234 // if the |release| parameter is set and then remove the references to them. |
| 235 virtual void ReleaseDelayedBuffers() {} | 235 virtual void ClearDelayedBuffers(bool release) {} |
| 236 | 236 |
| 237 #ifndef NDEBUG | 237 #ifndef NDEBUG |
| 238 // For video, checks that access unit is the key frame or stand-alone EOS. | 238 // For video, checks that access unit is the key frame or stand-alone EOS. |
| 239 virtual void VerifyUnitIsKeyFrame(const AccessUnit* unit) const {} | 239 virtual void VerifyUnitIsKeyFrame(const AccessUnit* unit) const {} |
| 240 #endif | 240 #endif |
| 241 | 241 |
| 242 // Helper methods. | 242 // Helper methods. |
| 243 | 243 |
| 244 // Notifies the decoder if the frame is the last one. | 244 // Notifies the decoder if the frame is the last one. |
| 245 void CheckLastFrame(bool eos_encountered, bool has_delayed_tasks); | 245 void CheckLastFrame(bool eos_encountered, bool has_delayed_tasks); |
| 246 | 246 |
| 247 // Protected data. | 247 // Protected data. |
| 248 | 248 |
| 249 // Object for posting tasks on Media thread. | 249 // Object for posting tasks on Media thread. |
| 250 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; | 250 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; |
| 251 | 251 |
| 252 // Controls Android MediaCodec | 252 // Controls Android MediaCodec |
| 253 scoped_ptr<MediaCodecBridge> media_codec_bridge_; | 253 scoped_ptr<MediaCodecBridge> media_codec_bridge_; |
| 254 | 254 |
| 255 // We call MediaCodecBridge on this thread for both | 255 // We call MediaCodecBridge on this thread for both |
| 256 // input and output buffers. | 256 // input and output buffers. |
| 257 base::Thread decoder_thread_; | 257 base::Thread decoder_thread_; |
| 258 | 258 |
| 259 // The queue of access units. | 259 // The queue of access units. |
| 260 AccessUnitQueue au_queue_; | 260 AccessUnitQueue au_queue_; |
| 261 | 261 |
| 262 // Flag forces reconfiguration even if |media_codec_bridge_| exists. Currently |
| 263 // is set by video decoder when the video surface changes. |
| 264 bool needs_reconfigure_; |
| 265 |
| 262 private: | 266 private: |
| 263 enum DecoderState { | 267 enum DecoderState { |
| 264 kStopped = 0, | 268 kStopped = 0, |
| 265 kPrefetching, | 269 kPrefetching, |
| 266 kPrefetched, | 270 kPrefetched, |
| 267 kRunning, | 271 kRunning, |
| 268 kStopping, | 272 kStopping, |
| 273 kInEmergencyStop, |
| 269 kError, | 274 kError, |
| 270 }; | 275 }; |
| 271 | 276 |
| 272 // Helper method that processes an error from MediaCodec. | 277 // Helper method that processes an error from MediaCodec. |
| 273 void OnCodecError(); | 278 void OnCodecError(); |
| 274 | 279 |
| 275 // Requests data. Ensures there is no more than one request at a time. | 280 // Requests data. Ensures there is no more than one request at a time. |
| 276 void RequestData(); | 281 void RequestData(); |
| 277 | 282 |
| 278 // Prefetching callback that is posted to Media thread | 283 // Prefetching callback that is posted to Media thread |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 | 345 |
| 341 // NOTE: Weak pointers must be invalidated before all other member variables. | 346 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 342 base::WeakPtrFactory<MediaCodecDecoder> weak_factory_; | 347 base::WeakPtrFactory<MediaCodecDecoder> weak_factory_; |
| 343 | 348 |
| 344 DISALLOW_COPY_AND_ASSIGN(MediaCodecDecoder); | 349 DISALLOW_COPY_AND_ASSIGN(MediaCodecDecoder); |
| 345 }; | 350 }; |
| 346 | 351 |
| 347 } // namespace media | 352 } // namespace media |
| 348 | 353 |
| 349 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_DECODER_H_ | 354 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_DECODER_H_ |
| OLD | NEW |