| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ | 5 #ifndef MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ |
| 6 #define MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ | 6 #define MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "media/gpu/media_gpu_export.h" | 28 #include "media/gpu/media_gpu_export.h" |
| 29 #include "media/video/video_decode_accelerator.h" | 29 #include "media/video/video_decode_accelerator.h" |
| 30 #include "ui/gl/android/scoped_java_surface.h" | 30 #include "ui/gl/android/scoped_java_surface.h" |
| 31 | 31 |
| 32 namespace gfx { | 32 namespace gfx { |
| 33 class SurfaceTexture; | 33 class SurfaceTexture; |
| 34 } | 34 } |
| 35 | 35 |
| 36 namespace media { | 36 namespace media { |
| 37 | 37 |
| 38 class SharedMemoryRegion; |
| 39 |
| 38 // A VideoDecodeAccelerator implementation for Android. | 40 // A VideoDecodeAccelerator implementation for Android. |
| 39 // This class decodes the input encoded stream by using Android's MediaCodec | 41 // This class decodes the input encoded stream by using Android's MediaCodec |
| 40 // class. http://developer.android.com/reference/android/media/MediaCodec.html | 42 // class. http://developer.android.com/reference/android/media/MediaCodec.html |
| 41 // It delegates attaching pictures to PictureBuffers to a BackingStrategy, but | 43 // It delegates attaching pictures to PictureBuffers to a BackingStrategy, but |
| 42 // otherwise handles the work of transferring data to / from MediaCodec. | 44 // otherwise handles the work of transferring data to / from MediaCodec. |
| 43 class MEDIA_GPU_EXPORT AndroidVideoDecodeAccelerator | 45 class MEDIA_GPU_EXPORT AndroidVideoDecodeAccelerator |
| 44 : public media::VideoDecodeAccelerator, | 46 : public media::VideoDecodeAccelerator, |
| 45 public AVDAStateProvider { | 47 public AVDAStateProvider { |
| 46 public: | 48 public: |
| 47 using OutputBufferMap = std::map<int32_t, media::PictureBuffer>; | 49 using OutputBufferMap = std::map<int32_t, media::PictureBuffer>; |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 | 373 |
| 372 // The low-level decoder which Android SDK provides. | 374 // The low-level decoder which Android SDK provides. |
| 373 std::unique_ptr<media::VideoCodecBridge> media_codec_; | 375 std::unique_ptr<media::VideoCodecBridge> media_codec_; |
| 374 | 376 |
| 375 // Set to true after requesting picture buffers to the client. | 377 // Set to true after requesting picture buffers to the client. |
| 376 bool picturebuffers_requested_; | 378 bool picturebuffers_requested_; |
| 377 | 379 |
| 378 // The resolution of the stream. | 380 // The resolution of the stream. |
| 379 gfx::Size size_; | 381 gfx::Size size_; |
| 380 | 382 |
| 383 // Handy structure to remember a BitstreamBuffer and also its shared memory, |
| 384 // if any. The goal is to prevent leaving a BitstreamBuffer's shared memory |
| 385 // handle open. |
| 386 struct BitstreamRecord { |
| 387 BitstreamRecord(const media::BitstreamBuffer&); |
| 388 BitstreamRecord(BitstreamRecord&& other); |
| 389 ~BitstreamRecord(); |
| 390 |
| 391 media::BitstreamBuffer buffer; |
| 392 |
| 393 // |memory| is not mapped, and may be null if buffer has no data. |
| 394 std::unique_ptr<SharedMemoryRegion> memory; |
| 395 }; |
| 396 |
| 381 // Encoded bitstream buffers to be passed to media codec, queued until an | 397 // Encoded bitstream buffers to be passed to media codec, queued until an |
| 382 // input buffer is available. | 398 // input buffer is available. |
| 383 std::queue<media::BitstreamBuffer> pending_bitstream_buffers_; | 399 std::queue<BitstreamRecord> pending_bitstream_records_; |
| 384 | 400 |
| 385 // A map of presentation timestamp to bitstream buffer id for the bitstream | 401 // A map of presentation timestamp to bitstream buffer id for the bitstream |
| 386 // buffers that have been submitted to the decoder but haven't yet produced an | 402 // buffers that have been submitted to the decoder but haven't yet produced an |
| 387 // output frame with the same timestamp. Note: there will only be one entry | 403 // output frame with the same timestamp. Note: there will only be one entry |
| 388 // for multiple bitstream buffers that have the same presentation timestamp. | 404 // for multiple bitstream buffers that have the same presentation timestamp. |
| 389 std::map<base::TimeDelta, int32_t> bitstream_buffers_in_decoder_; | 405 std::map<base::TimeDelta, int32_t> bitstream_buffers_in_decoder_; |
| 390 | 406 |
| 391 // Keeps track of bitstream ids notified to the client with | 407 // Keeps track of bitstream ids notified to the client with |
| 392 // NotifyEndOfBitstreamBuffer() before getting output from the bitstream. | 408 // NotifyEndOfBitstreamBuffer() before getting output from the bitstream. |
| 393 std::list<int32_t> bitstreams_notified_in_advance_; | 409 std::list<int32_t> bitstreams_notified_in_advance_; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 | 457 |
| 442 // WeakPtrFactory for posting tasks back to |this|. | 458 // WeakPtrFactory for posting tasks back to |this|. |
| 443 base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_; | 459 base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_; |
| 444 | 460 |
| 445 friend class AndroidVideoDecodeAcceleratorTest; | 461 friend class AndroidVideoDecodeAcceleratorTest; |
| 446 }; | 462 }; |
| 447 | 463 |
| 448 } // namespace media | 464 } // namespace media |
| 449 | 465 |
| 450 #endif // MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ | 466 #endif // MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ |
| OLD | NEW |