OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_COMMON_GPU_MEDIA_ARC_ARC_VIDEO_ACCELERATOR_ADAPTER_H_ | |
6 #define CONTENT_COMMON_GPU_MEDIA_ARC_ARC_VIDEO_ACCELERATOR_ADAPTER_H_ | |
7 | |
8 #include <list> | |
9 #include <vector> | |
10 | |
11 #include "base/callback.h" | |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "content/common/gpu/media/arc/arc_video_accelerator.h" | |
14 #include "content/common/gpu/media/arc/arc_video_decode_accelerator.h" | |
15 | |
16 namespace content { | |
17 namespace arc { | |
18 | |
19 class ArcGpuVideoDecodeAccelerator : public ArcVideoAccelerator, | |
20 public ArcVideoDecodeAccelerator::Client { | |
21 public: | |
22 ArcGpuVideoDecodeAccelerator(); | |
23 | |
24 // Implementation of the VideoAccelerator interface. | |
kcwu
2015/12/23 06:25:43
s/ArcVideoAccelerator/
Owen Lin
2015/12/31 07:22:14
Done.
| |
25 status_t initialize(DeviceType device, | |
26 ArcVideoAccelerator::Client* client) override; | |
27 | |
kcwu
2015/12/23 06:25:43
remove blank lines between ArcVideoAccelerator met
Owen Lin
2015/12/31 07:22:14
Done.
| |
28 status_t setBufferCount(PortType port, size_t* count) override; | |
29 | |
30 status_t setBufferFormat(PortType port, const BufferFormat& format) override; | |
31 | |
32 status_t bindSharedBuffer(PortType port, | |
33 uint32_t index, | |
34 int ashmem_fd, | |
35 size_t offset, | |
36 size_t length) override; | |
37 | |
38 status_t bindGraphicBuffer(PortType port, | |
39 uint32_t index, | |
40 int dmabuf_fd) override; | |
41 | |
42 void useBuffer(PortType port, | |
43 uint32_t index, | |
44 const BufferMetadata& metadata) override; | |
45 | |
46 void reset() override; | |
47 | |
48 // Implementation of the VideoDecodeAccelerator::Client interface. | |
49 void RequestPictureBuffers(size_t requested_num_of_buffers, | |
50 const gfx::Size& coded_size, | |
51 const gfx::Rect& crop_rect) override; | |
52 void DismissPictureBuffer(int32_t picture_buffer); | |
53 void PictureReady(const media::Picture& picture) override; | |
54 void NotifyEndOfBitstreamBuffer(int32_t bitstream_buffer_id) override; | |
55 void NotifyFlushDone() override; | |
56 void NotifyResetDone() override; | |
57 void NotifyError(ArcVideoDecodeAccelerator::Error error) override; | |
58 | |
59 private: | |
60 // Enumerations indicates the state of an buffer. | |
kcwu
2015/12/23 06:25:43
s/indicates/indicate/
| |
61 enum BufferState { | |
62 OWNED_BY_CLIENT, // The buffer is sent to and used by |client_|. | |
kcwu
2015/12/23 06:25:43
How about add a new state, something like NO_BINDE
Owen Lin
2015/12/31 07:22:14
Done.
| |
63 OWNED_BY_US, // The buffer is owned by us. | |
64 OWNED_BY_VDA, // The buffer is sent to and used by |arc_vda_|. | |
65 }; | |
66 | |
67 struct BufferInfo { | |
68 BufferState state; | |
69 | |
70 // The file handle to access the buffer. It is owned by this ArcGVDA and | |
71 // should be freed if not used. | |
72 base::ScopedFD handle; | |
73 off_t offset; | |
74 size_t length; | |
75 | |
76 BufferInfo(); | |
77 }; | |
78 | |
79 struct PortInfo { | |
80 MemoryType memory_type; | |
81 std::vector<BufferInfo> buffers; | |
82 | |
83 PortInfo(); | |
84 }; | |
85 | |
86 // The related information of a bitstream buffer. | |
87 struct InputRecord { | |
88 int32_t bitstream_buffer_id; | |
89 uint32_t index; | |
90 int64_t timestamp; | |
91 | |
92 InputRecord(int32_t bitstream_buffer_id, uint32_t index, int64_t timestamp); | |
93 }; | |
94 | |
95 // Indicates a pending EOS output buffer. When it is true, an EOS output | |
96 // buffer need to be sent to |arc_client_| once an output buffer is available. | |
97 bool pending_eos_output_buffer_; | |
98 scoped_ptr<ArcVideoDecodeAccelerator> arc_vda_; | |
99 | |
100 // It's safe to use the pointer here, the life cycle of the |arc_client_| | |
101 // is longer than this ArcGpuVideoDecodeAccelerator. | |
102 ArcVideoAccelerator::Client* arc_client_; | |
103 | |
104 // The callback called when reset completes. | |
105 base::Closure reset_done_callback_; | |
106 | |
107 PortInfo port_info_[PORT_COUNT]; | |
108 | |
109 // The serial number used as the bitstream_buffer_id, started from 0. | |
110 int32_t bitstream_buffer_serial_; | |
111 | |
112 std::list<InputRecord> input_records_; | |
113 | |
114 // Helper function to Send the end-of-stream output buffer if | |
kcwu
2015/12/23 06:25:43
Put these member functions before member variables
Owen Lin
2015/12/31 07:22:14
Done.
| |
115 // |pending_eos_output_buffer_| is true, or reuse the picture in ArcVDA. | |
116 void SendEosIfNeededOrReusePicture(uint32_t index, BufferInfo* info); | |
117 | |
118 // Helper function to get a BufferInfo. Returns |nullptr| if the |port| or | |
119 // |index| is invalid. | |
120 BufferInfo* GetBufferInfo(PortType port, uint32_t index); | |
121 | |
122 // Helper function to get the used buffer index and timestamp of the | |
123 // |bitstream_buffer_id|. | |
124 void GetInputRecord(int32_t bitstream_buffer_id, | |
125 uint32_t* index, | |
126 int64_t* timestamp); | |
127 | |
128 // Helper function to set the used buffer index and timestamp of the | |
129 // |bitstream_buffer_id|. | |
130 void SetInputRecord(int32_t bitstream_buffer_id, | |
131 uint32_t index, | |
132 int64_t timestamp); | |
133 }; | |
134 | |
135 } // namespace arc | |
136 } // namespace content | |
137 | |
138 #endif // CONTENT_COMMON_GPU_MEDIA_ARC_ARC_VIDEO_ACCELERATOR_ADAPTER_H_ | |
OLD | NEW |