Index: content/common/gpu/media/arc/arc_gpu_video_decode_accelerator.h |
diff --git a/content/common/gpu/media/arc/arc_gpu_video_decode_accelerator.h b/content/common/gpu/media/arc/arc_gpu_video_decode_accelerator.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d40198f225c651f8af170db1b76aeb8d98eae2e0 |
--- /dev/null |
+++ b/content/common/gpu/media/arc/arc_gpu_video_decode_accelerator.h |
@@ -0,0 +1,136 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
Pawel Osciak
2016/01/07 09:22:36
We'll have to s/2015/2016/ at some point I think.
Owen Lin
2016/01/12 09:30:23
Done.
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_COMMON_GPU_MEDIA_ARC_ARC_VIDEO_ACCELERATOR_ADAPTER_H_ |
+#define CONTENT_COMMON_GPU_MEDIA_ARC_ARC_VIDEO_ACCELERATOR_ADAPTER_H_ |
+ |
+#include <list> |
+#include <vector> |
+ |
+#include "base/callback.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "content/common/gpu/media/arc/arc_video_accelerator.h" |
+#include "media/video/video_decode_accelerator.h" |
+ |
+namespace content { |
+namespace arc { |
+ |
+class ArcGpuVideoDecodeAccelerator |
Pawel Osciak
2016/01/07 09:22:36
Please document what this class is for.
Owen Lin
2016/01/12 09:30:23
Done.
|
+ : public ArcVideoAccelerator, |
+ public media::VideoDecodeAccelerator::Client { |
+ public: |
+ ArcGpuVideoDecodeAccelerator(); |
+ |
+ // Implementation of the ArcVideoAccelerator interface. |
+ status_t Initialize(DeviceType device, |
+ ArcVideoAccelerator::Client* client) override; |
+ status_t SetBufferCount(PortType port, size_t* count) override; |
+ status_t SetBufferFormat(PortType port, const BufferFormat& format) override; |
+ status_t BindSharedBuffer(PortType port, |
+ uint32_t index, |
+ int ashmem_fd, |
+ size_t offset, |
+ size_t length) override; |
+ status_t BindGraphicBuffer(PortType port, |
+ uint32_t index, |
+ int dmabuf_fd) override; |
+ void UseBuffer(PortType port, |
+ uint32_t index, |
+ const BufferMetadata& metadata) override; |
+ void Reset() override; |
+ |
+ // Implementation of the VideoDecodeAccelerator::Client interface. |
+ void ProvidePictureBuffers(uint32_t requested_num_of_buffers, |
+ const gfx::Size& dimensions, |
+ uint32_t texture_target) override; |
+ void DismissPictureBuffer(int32_t picture_buffer); |
Pawel Osciak
2016/01/07 09:22:36
override
Owen Lin
2016/01/12 09:30:23
Done.
|
+ void PictureReady(const media::Picture& picture) override; |
+ void NotifyEndOfBitstreamBuffer(int32_t bitstream_buffer_id) override; |
+ void NotifyFlushDone() override; |
+ void NotifyResetDone() override; |
+ void NotifyError(media::VideoDecodeAccelerator::Error error) override; |
+ |
+ private: |
+ // Enumerations indicate the state of an buffer. |
+ enum BufferState { |
+ NOT_BOUND, // The buffer is not bound yet. |
+ OWNED_BY_CLIENT, // The buffer is sent to and used by |client_|. |
+ OWNED_BY_US, // The buffer is owned by us. |
+ OWNED_BY_VDA, // The buffer is sent to and used by |vda_|. |
+ }; |
+ |
+ struct BufferInfo { |
Pawel Osciak
2016/01/07 09:22:36
For bitstream buffers (inputs), I think we could s
Owen Lin
2016/01/12 09:30:23
Done.
|
+ BufferState state; |
+ |
+ // The file handle to access the buffer. It is owned by this ArcGVDA and |
+ // should be freed if not used. |
+ base::ScopedFD handle; |
+ off_t offset; |
+ size_t length; |
+ |
+ BufferInfo(); |
+ }; |
+ |
+ struct PortInfo { |
+ MemoryType memory_type; |
+ std::vector<BufferInfo> buffers; |
+ |
+ PortInfo(); |
+ }; |
+ |
+ // The related information of a bitstream buffer. |
+ struct InputRecord { |
+ int32_t bitstream_buffer_id; |
+ uint32_t index; |
+ int64_t timestamp; |
+ |
+ InputRecord(int32_t bitstream_buffer_id, uint32_t index, int64_t timestamp); |
+ }; |
+ |
+ // Helper function to Send the end-of-stream output buffer if |
+ // |pending_eos_output_buffer_| is true, or reuse the picture in ArcVDA. |
+ void SendEosIfNeededOrReusePicture(uint32_t index, BufferInfo* info); |
+ |
+ // Helper function to get a BufferInfo. Returns |nullptr| if the |port| or |
+ // |index| is invalid. |
+ BufferInfo* GetBufferInfo(PortType port, uint32_t index); |
+ |
+ // Helper function to get the used buffer index and timestamp of the |
+ // |bitstream_buffer_id|. |
+ void GetInputRecord(int32_t bitstream_buffer_id, |
+ uint32_t* index, |
+ int64_t* timestamp); |
+ |
+ // Helper function to set the used buffer index and timestamp of the |
+ // |bitstream_buffer_id|. |
+ void SetInputRecord(int32_t bitstream_buffer_id, |
+ uint32_t index, |
+ int64_t timestamp); |
+ |
+ // Indicates a pending EOS output buffer. When it is true, an EOS output |
+ // buffer need to be sent to |arc_client_| once an output buffer is available. |
+ bool pending_eos_output_buffer_; |
+ scoped_ptr<media::VideoDecodeAccelerator> vda_; |
+ |
+ // It's safe to use the pointer here, the life cycle of the |arc_client_| |
+ // is longer than this ArcGpuVideoDecodeAccelerator. |
+ ArcVideoAccelerator::Client* arc_client_; |
+ |
+ // The callback called when reset completes. |
+ base::Closure reset_done_callback_; |
+ |
+ PortInfo port_info_[PORT_COUNT]; |
+ |
+ // The serial number used as the bitstream_buffer_id, started from 0. |
+ int32_t bitstream_buffer_serial_; |
+ |
+ std::list<InputRecord> input_records_; |
+ |
+ gfx::Size coded_size_; |
+}; |
+ |
+} // namespace arc |
+} // namespace content |
+ |
+#endif // CONTENT_COMMON_GPU_MEDIA_ARC_ARC_VIDEO_ACCELERATOR_ADAPTER_H_ |