Chromium Code Reviews| 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_H_ | |
| 6 #define CONTENT_COMMON_GPU_MEDIA_ARC_ARC_VIDEO_ACCELERATOR_H_ | |
| 7 | |
| 8 namespace content { | |
| 9 namespace arc { | |
| 10 | |
| 11 typedef uint32_t status_t; | |
| 12 | |
| 13 enum HalPixelFormatExtension { | |
| 14 HAL_PIXEL_FORMAT_H264 = 0x34363248, | |
| 15 HAL_PIXEL_FORMAT_VP8 = 0x00385056, | |
| 16 }; | |
| 17 | |
| 18 enum PortType { | |
| 19 PORT_INPUT = 0, | |
| 20 PORT_OUTPUT = 1, | |
| 21 PORT_COUNT = 2, | |
| 22 }; | |
| 23 | |
| 24 enum DeviceType { | |
| 25 DEVICE_ENCODER = 0, | |
| 26 DEVICE_DECODER = 1, | |
| 27 }; | |
| 28 | |
| 29 enum MemoryType { | |
| 30 MEMORY_SHARED_MEMORY = 1, | |
|
Pawel Osciak
2016/01/07 09:22:36
Is there any specific reason to start with 1 here?
Owen Lin
2016/01/12 09:30:23
I don't really remember why. Let's start with 0 ju
| |
| 31 MEMORY_DMABUF = 2, | |
| 32 }; | |
| 33 | |
| 34 enum BufferFlag { | |
| 35 BUFFER_FLAG_EOS = 1, | |
| 36 }; | |
| 37 | |
| 38 struct BufferMetadata { | |
| 39 int64_t timestamp; // in microseconds | |
| 40 uint32_t flags; | |
| 41 uint32_t bytes_used; | |
| 42 }; | |
| 43 | |
| 44 struct BufferFormat { | |
| 45 uint32_t pixel_format; // the v4l2 fourcc format | |
|
Pawel Osciak
2016/01/07 09:22:36
could we call this fourcc and remove v4l2 mention
Owen Lin
2016/01/12 09:30:23
Done.
| |
| 46 uint32_t image_size; | |
|
Pawel Osciak
2016/01/07 09:22:36
Is this used?
Owen Lin
2016/01/12 09:30:23
Actually not. Removed.
| |
| 47 MemoryType memory_type; | |
| 48 }; | |
| 49 | |
| 50 struct VideoFormat { | |
| 51 uint32_t pixel_format; | |
| 52 uint32_t image_size; | |
| 53 | |
| 54 // minimal number of buffers required to process the video. | |
| 55 uint32_t min_num_buffers; | |
| 56 uint32_t coded_width; | |
| 57 uint32_t coded_height; | |
| 58 uint32_t crop_left; | |
| 59 uint32_t crop_width; | |
| 60 uint32_t crop_top; | |
| 61 uint32_t crop_height; | |
| 62 }; | |
| 63 | |
| 64 // ArcVideoAccelerator is a component of ArcCodec to deal with video | |
| 65 // buffers. It is also an IPC interface between Android and Chromium. | |
| 66 // So that the video buffers are sent to Chromium side and decoded. | |
| 67 // ArcCodec implements ArcVideoAccelerator::Client and is responsible for | |
| 68 // rendering and interacting with the Android media framework. | |
| 69 class ArcVideoAccelerator { | |
| 70 public: | |
| 71 enum Error { | |
| 72 NO_ERROR = 0, | |
| 73 ILLEGAL_STATE = 1, | |
| 74 INVALID_ARGUMENT = 2, | |
| 75 UNREADABLE_INPUT = 3, | |
| 76 PLATFORM_FAILURE = 4, | |
| 77 }; | |
| 78 | |
| 79 // The callbacks of the ArcVideoAccelerator. ArcCodec implmenets this | |
| 80 // interface. | |
| 81 class Client { | |
| 82 public: | |
| 83 virtual ~Client(); | |
| 84 | |
| 85 // Called when an asynchronous error happens. Asynchronous errors happen | |
| 86 // only when the accelerator processes the input buffer and tried to | |
| 87 // generate the output to the output buffer. | |
| 88 virtual void OnError(Error error) = 0; | |
| 89 | |
| 90 // Called when a buffer with the specified @index and @port has been | |
|
Pawel Osciak
2016/01/07 09:22:36
|index| |port|
Owen Lin
2016/01/12 09:30:23
Done.
| |
| 91 // processed and is no longer used in the accelerator. For input buffer, | |
| 92 // it can be filled with new content. For output buffer, it is ready to | |
| 93 // be used. | |
|
Pawel Osciak
2016/01/07 09:22:36
s/used/consumed by the client/
Owen Lin
2016/01/12 09:30:23
Done.
| |
| 94 virtual void OnBufferDone(PortType port, | |
| 95 uint32_t index, | |
| 96 const BufferMetadata& metadata) = 0; | |
| 97 | |
| 98 // Called when the output format has changed or the output format | |
| 99 // becomes available at beginning of the stream after initial parsing. | |
| 100 virtual void OnOutputFormatChanged(const VideoFormat& format) = 0; | |
| 101 }; | |
| 102 | |
| 103 virtual status_t Initialize(DeviceType device, Client* client); | |
|
Pawel Osciak
2016/01/07 09:22:36
= 0 here and in methods below please
Owen Lin
2016/01/12 09:30:23
Done.
| |
| 104 | |
| 105 // Assigns a shared memory to be used for the accelerator at the specified | |
| 106 // port and index. A buffer must be bound before asking the accelerator to | |
| 107 // use it via useBuffer(). | |
| 108 virtual status_t BindSharedBuffer(PortType port, | |
|
Pawel Osciak
2016/01/07 09:22:36
BindSharedMemory
Owen Lin
2016/01/12 09:30:23
Done.
| |
| 109 uint32_t index, | |
| 110 int ashmem_fd, | |
|
Pawel Osciak
2016/01/07 09:22:36
Could we use base::SharedMemoryHandle here?
Owen Lin
2016/01/12 09:30:23
No, it's a common interface used on both Android a
| |
| 111 size_t offset, | |
| 112 size_t length); | |
| 113 | |
| 114 // Assigns a graphic buffer to be used for the accelerator at the specified | |
| 115 // port and index. A buffer must be bound before asking the accelerator to | |
| 116 // use it via useBuffer(). | |
| 117 virtual status_t BindGraphicBuffer(PortType port, | |
|
Pawel Osciak
2016/01/07 09:22:36
BindDmabuf
Owen Lin
2016/01/12 09:30:23
Done.
| |
| 118 uint32_t index, | |
| 119 int dmabuf_fd); | |
| 120 | |
| 121 // Passes a buffer to the accelerator. For input buffer, the accelerator | |
| 122 // will process it. For output buffer, the accelerator will output content | |
| 123 // to it. | |
| 124 virtual void UseBuffer(PortType port, | |
| 125 uint32_t index, | |
| 126 const BufferMetadata& metadata) = 0; | |
| 127 | |
| 128 // Sets the number of requested buffers. The accelerator may change the | |
| 129 // count due to hardware limitation. The caller is responsible to check | |
| 130 // the returned value to see if it is acceptable. | |
| 131 virtual status_t SetBufferCount(PortType port, size_t* count) = 0; | |
| 132 | |
| 133 // Resets the accelerator. After this function, all buffers won't be | |
| 134 // accessed by the accelerator and there won't be more callbacks. | |
|
Pawel Osciak
2016/01/07 09:22:36
Does this mean we require the VDA to return all bu
Owen Lin
2016/01/12 09:30:23
I have modified the code in ArcCodec to allow VDA
| |
| 135 virtual void Reset() = 0; | |
| 136 | |
| 137 // Sets the buffer format of the given port. | |
| 138 virtual status_t SetBufferFormat(PortType port, const BufferFormat& format); | |
|
Pawel Osciak
2016/01/07 09:22:36
Sorry, I think I'm forgetting why we needed this c
Owen Lin
2016/01/12 09:30:23
For output, we only use it to set the MemoryType.
| |
| 139 | |
| 140 virtual ~ArcVideoAccelerator(); | |
| 141 | |
| 142 private: | |
| 143 // DISALLOW_EVIL_CONSTRUCTORS(ArcVideoAccelerator); | |
|
Pawel Osciak
2016/01/07 09:22:36
I think we should remove this?
Owen Lin
2016/01/12 09:30:23
Done.
| |
| 144 }; | |
| 145 | |
| 146 } // namespace arc | |
| 147 } // namespace content | |
| 148 | |
| 149 #endif // CONTENT_COMMON_GPU_MEDIA_ARC_ARC_VIDEO_ACCELERATOR_H_ | |
| OLD | NEW |