| 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 234 // because their rendering is delayed (video). | 234 // because their rendering is delayed (video). |
| 235 virtual void ReleaseDelayedBuffers() {} | 235 virtual void ReleaseDelayedBuffers() {} |
| 236 | 236 |
| 237 // Remove all references to the delayed buffers after the |
| 238 // |media_codec_bridge_| is deleted. |
| 239 virtual void ClearDelayedBuffers() {} |
| 240 |
| 237 #ifndef NDEBUG | 241 #ifndef NDEBUG |
| 238 // For video, checks that access unit is the key frame or stand-alone EOS. | 242 // For video, checks that access unit is the key frame or stand-alone EOS. |
| 239 virtual void VerifyUnitIsKeyFrame(const AccessUnit* unit) const {} | 243 virtual void VerifyUnitIsKeyFrame(const AccessUnit* unit) const {} |
| 240 #endif | 244 #endif |
| 241 | 245 |
| 242 // Helper methods. | 246 // Helper methods. |
| 243 | 247 |
| 244 // Notifies the decoder if the frame is the last one. | 248 // Notifies the decoder if the frame is the last one. |
| 245 void CheckLastFrame(bool eos_encountered, bool has_delayed_tasks); | 249 void CheckLastFrame(bool eos_encountered, bool has_delayed_tasks); |
| 246 | 250 |
| 247 // Protected data. | 251 // Protected data. |
| 248 | 252 |
| 249 // Object for posting tasks on Media thread. | 253 // Object for posting tasks on Media thread. |
| 250 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; | 254 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; |
| 251 | 255 |
| 252 // Controls Android MediaCodec | 256 // Controls Android MediaCodec |
| 253 scoped_ptr<MediaCodecBridge> media_codec_bridge_; | 257 scoped_ptr<MediaCodecBridge> media_codec_bridge_; |
| 254 | 258 |
| 255 // We call MediaCodecBridge on this thread for both | 259 // We call MediaCodecBridge on this thread for both |
| 256 // input and output buffers. | 260 // input and output buffers. |
| 257 base::Thread decoder_thread_; | 261 base::Thread decoder_thread_; |
| 258 | 262 |
| 259 // The queue of access units. | 263 // The queue of access units. |
| 260 AccessUnitQueue au_queue_; | 264 AccessUnitQueue au_queue_; |
| 261 | 265 |
| 266 // Flag forces reconfiguration even if |media_codec_bridge_| exists. Currently |
| 267 // is set by video decoder when the video surface changes. |
| 268 bool needs_reconfigure_; |
| 269 |
| 262 private: | 270 private: |
| 263 enum DecoderState { | 271 enum DecoderState { |
| 264 kStopped = 0, | 272 kStopped = 0, |
| 265 kPrefetching, | 273 kPrefetching, |
| 266 kPrefetched, | 274 kPrefetched, |
| 267 kRunning, | 275 kRunning, |
| 268 kStopping, | 276 kStopping, |
| 277 kInEmergencyStop, |
| 269 kError, | 278 kError, |
| 270 }; | 279 }; |
| 271 | 280 |
| 272 // Helper method that processes an error from MediaCodec. | 281 // Helper method that processes an error from MediaCodec. |
| 273 void OnCodecError(); | 282 void OnCodecError(); |
| 274 | 283 |
| 275 // Requests data. Ensures there is no more than one request at a time. | 284 // Requests data. Ensures there is no more than one request at a time. |
| 276 void RequestData(); | 285 void RequestData(); |
| 277 | 286 |
| 278 // Prefetching callback that is posted to Media thread | 287 // Prefetching callback that is posted to Media thread |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 | 349 |
| 341 // NOTE: Weak pointers must be invalidated before all other member variables. | 350 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 342 base::WeakPtrFactory<MediaCodecDecoder> weak_factory_; | 351 base::WeakPtrFactory<MediaCodecDecoder> weak_factory_; |
| 343 | 352 |
| 344 DISALLOW_COPY_AND_ASSIGN(MediaCodecDecoder); | 353 DISALLOW_COPY_AND_ASSIGN(MediaCodecDecoder); |
| 345 }; | 354 }; |
| 346 | 355 |
| 347 } // namespace media | 356 } // namespace media |
| 348 | 357 |
| 349 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_DECODER_H_ | 358 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_DECODER_H_ |
| OLD | NEW |