Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_ | 5 #ifndef CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_ |
| 6 #define CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_ | 6 #define CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_ |
| 7 | 7 |
| 8 #include "base/files/scoped_file.h" | 8 #include "base/files/scoped_file.h" |
| 9 | 9 |
| 10 namespace chromeos { | 10 namespace chromeos { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 uint32_t crop_width = 0; | 45 uint32_t crop_width = 0; |
| 46 uint32_t crop_top = 0; | 46 uint32_t crop_top = 0; |
| 47 uint32_t crop_height = 0; | 47 uint32_t crop_height = 0; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 // The IPC interface between Android and Chromium for video decoding and | 50 // The IPC interface between Android and Chromium for video decoding and |
| 51 // encoding. Input buffers are sent from Android side and get processed in | 51 // encoding. Input buffers are sent from Android side and get processed in |
| 52 // Chromium and the output buffers are returned back to Android side. | 52 // Chromium and the output buffers are returned back to Android side. |
| 53 class ArcVideoAccelerator { | 53 class ArcVideoAccelerator { |
| 54 public: | 54 public: |
| 55 enum Error { | 55 enum Result { |
| 56 NO_ERROR = 0, | |
|
Pawel Osciak
2016/06/06 05:49:13
Hm, actually, now that this is a Result, we could
kcwu
2016/06/06 06:53:12
Done.
| |
| 56 ILLEGAL_STATE = 1, | 57 ILLEGAL_STATE = 1, |
| 57 INVALID_ARGUMENT = 2, | 58 INVALID_ARGUMENT = 2, |
| 58 UNREADABLE_INPUT = 3, | 59 UNREADABLE_INPUT = 3, |
| 59 PLATFORM_FAILURE = 4, | 60 PLATFORM_FAILURE = 4, |
| 61 INSUFFICIENT_RESOURCES = 5, | |
| 60 }; | 62 }; |
| 61 | 63 |
| 62 struct Config { | 64 struct Config { |
| 63 enum DeviceType { | 65 enum DeviceType { |
| 64 DEVICE_ENCODER = 0, | 66 DEVICE_ENCODER = 0, |
| 65 DEVICE_DECODER = 1, | 67 DEVICE_DECODER = 1, |
| 66 }; | 68 }; |
| 67 | 69 |
| 68 DeviceType device_type = DEVICE_DECODER; | 70 DeviceType device_type = DEVICE_DECODER; |
| 69 size_t num_input_buffers = 0; | 71 size_t num_input_buffers = 0; |
| 70 uint32_t input_pixel_format = 0; | 72 uint32_t input_pixel_format = 0; |
| 71 // TODO(owenlin): Add output_pixel_format. For now only the native pixel | 73 // TODO(owenlin): Add output_pixel_format. For now only the native pixel |
| 72 // format of each VDA on Chromium is supported. | 74 // format of each VDA on Chromium is supported. |
| 73 }; | 75 }; |
| 74 | 76 |
| 75 // The callbacks of the ArcVideoAccelerator. The user of this class should | 77 // The callbacks of the ArcVideoAccelerator. The user of this class should |
| 76 // implement this interface. | 78 // implement this interface. |
| 77 class Client { | 79 class Client { |
| 78 public: | 80 public: |
| 79 virtual ~Client() {} | 81 virtual ~Client() {} |
| 80 | 82 |
| 81 // Called when an asynchronous error happens. The errors in Initialize() | 83 // Called when an asynchronous error happens. The errors in Initialize() |
| 82 // will not be reported here, but will be indicated by a false return value | 84 // will not be reported here, but will be indicated by a false return value |
|
Pawel Osciak
2016/06/06 05:49:13
This also needs an update please.
kcwu
2016/06/06 06:53:12
Done.
| |
| 83 // there. | 85 // there. |
| 84 virtual void OnError(Error error) = 0; | 86 virtual void OnError(Result error) = 0; |
| 85 | 87 |
| 86 // Called when a buffer with the specified |index| and |port| has been | 88 // Called when a buffer with the specified |index| and |port| has been |
| 87 // processed and is no longer used in the accelerator. For input buffers, | 89 // processed and is no longer used in the accelerator. For input buffers, |
| 88 // the Client may fill them with new content. For output buffers, indicates | 90 // the Client may fill them with new content. For output buffers, indicates |
| 89 // they are ready to be consumed by the client. | 91 // they are ready to be consumed by the client. |
| 90 virtual void OnBufferDone(PortType port, | 92 virtual void OnBufferDone(PortType port, |
| 91 uint32_t index, | 93 uint32_t index, |
| 92 const BufferMetadata& metadata) = 0; | 94 const BufferMetadata& metadata) = 0; |
| 93 | 95 |
| 94 // Called when the output format has changed or the output format | 96 // Called when the output format has changed or the output format |
| 95 // becomes available at beginning of the stream after initial parsing. | 97 // becomes available at beginning of the stream after initial parsing. |
| 96 virtual void OnOutputFormatChanged(const VideoFormat& format) = 0; | 98 virtual void OnOutputFormatChanged(const VideoFormat& format) = 0; |
| 97 | 99 |
| 98 // Called as a completion notification for Reset(). | 100 // Called as a completion notification for Reset(). |
| 99 virtual void OnResetDone() = 0; | 101 virtual void OnResetDone() = 0; |
| 100 | 102 |
| 101 // Called as a completion notification for Flush(). | 103 // Called as a completion notification for Flush(). |
| 102 virtual void OnFlushDone() = 0; | 104 virtual void OnFlushDone() = 0; |
| 103 }; | 105 }; |
| 104 | 106 |
| 105 // Initializes the ArcVideoAccelerator with specific configuration. This | 107 // Initializes the ArcVideoAccelerator with specific configuration. This |
| 106 // must be called before any other methods. This call is synchronous and | 108 // must be called before any other methods. This call is synchronous and |
| 107 // returns true iff initialization is successful. | 109 // returns NO_ERROR iff initialization is successful. |
| 108 virtual bool Initialize(const Config& config, Client* client) = 0; | 110 virtual Result Initialize(const Config& config, Client* client) = 0; |
| 109 | 111 |
| 110 // Assigns a shared memory to be used for the accelerator at the specified | 112 // Assigns a shared memory to be used for the accelerator at the specified |
| 111 // port and index. A buffer must be successfully bound before it can be passed | 113 // port and index. A buffer must be successfully bound before it can be passed |
| 112 // to the accelerator via UseBuffer(). Already bound buffers may be reused | 114 // to the accelerator via UseBuffer(). Already bound buffers may be reused |
| 113 // multiple times without additional bindings. | 115 // multiple times without additional bindings. |
| 114 virtual void BindSharedMemory(PortType port, | 116 virtual void BindSharedMemory(PortType port, |
| 115 uint32_t index, | 117 uint32_t index, |
| 116 base::ScopedFD ashmem_fd, | 118 base::ScopedFD ashmem_fd, |
| 117 off_t offset, | 119 off_t offset, |
| 118 size_t length) = 0; | 120 size_t length) = 0; |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 148 // called. | 150 // called. |
| 149 virtual void Flush() = 0; | 151 virtual void Flush() = 0; |
| 150 | 152 |
| 151 virtual ~ArcVideoAccelerator() {} | 153 virtual ~ArcVideoAccelerator() {} |
| 152 }; | 154 }; |
| 153 | 155 |
| 154 } // namespace arc | 156 } // namespace arc |
| 155 } // namespace chromeos | 157 } // namespace chromeos |
| 156 | 158 |
| 157 #endif // CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_ | 159 #endif // CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_ |
| OLD | NEW |