• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2016, The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ANDROID_HARDWARE_MEDIA_OMX_V1_0_WOMXNODE_H
18 #define ANDROID_HARDWARE_MEDIA_OMX_V1_0_WOMXNODE_H
19 
20 #include <hidl/MQDescriptor.h>
21 #include <hidl/Status.h>
22 
23 #include <utils/Errors.h>
24 #include <media/IOMX.h>
25 #include <hidl/HybridInterface.h>
26 
27 #include <android/hardware/media/omx/1.0/IOmxNode.h>
28 #include <android/hardware/media/omx/1.0/IOmxObserver.h>
29 
30 namespace android {
31 namespace hardware {
32 namespace media {
33 namespace omx {
34 namespace V1_0 {
35 namespace utils {
36 
37 using ::android::hardware::media::omx::V1_0::CodecBuffer;
38 using ::android::hardware::media::omx::V1_0::IOmxBufferSource;
39 using ::android::hardware::media::omx::V1_0::IOmxNode;
40 using ::android::hardware::media::omx::V1_0::IOmxObserver;
41 using ::android::hardware::media::omx::V1_0::Message;
42 using ::android::hardware::media::omx::V1_0::PortMode;
43 using ::android::hardware::media::omx::V1_0::Status;
44 using ::android::hidl::base::V1_0::IBase;
45 using ::android::hardware::hidl_array;
46 using ::android::hardware::hidl_memory;
47 using ::android::hardware::hidl_string;
48 using ::android::hardware::hidl_vec;
49 using ::android::hardware::Return;
50 using ::android::hardware::Void;
51 using ::android::sp;
52 
53 /**
54  * Wrapper classes for conversion
55  * ==============================
56  *
57  * Naming convention:
58  * - LW = Legacy Wrapper --- It wraps a Treble object inside a legacy object.
59  * - TW = Treble Wrapper --- It wraps a legacy object inside a Treble object.
60  */
61 
62 struct LWOmxNode : public H2BConverter<IOmxNode, BnOMXNode> {
LWOmxNodeLWOmxNode63     LWOmxNode(sp<IOmxNode> const& base) : CBase(base) {}
64     status_t freeNode() override;
65     status_t sendCommand(
66             OMX_COMMANDTYPE cmd, OMX_S32 param) override;
67     status_t getParameter(
68             OMX_INDEXTYPE index, void *params, size_t size) override;
69     status_t setParameter(
70             OMX_INDEXTYPE index, const void *params, size_t size) override;
71     status_t getConfig(
72             OMX_INDEXTYPE index, void *params, size_t size) override;
73     status_t setConfig(
74             OMX_INDEXTYPE index, const void *params, size_t size) override;
75     status_t setPortMode(
76             OMX_U32 port_index, IOMX::PortMode mode) override;
77     status_t prepareForAdaptivePlayback(
78             OMX_U32 portIndex, OMX_BOOL enable,
79             OMX_U32 maxFrameWidth, OMX_U32 maxFrameHeight) override;
80     status_t configureVideoTunnelMode(
81             OMX_U32 portIndex, OMX_BOOL tunneled,
82             OMX_U32 audioHwSync, native_handle_t **sidebandHandle) override;
83     status_t getGraphicBufferUsage(
84             OMX_U32 port_index, OMX_U32* usage) override;
85     status_t setInputSurface(
86             const sp<IOMXBufferSource> &bufferSource) override;
87     status_t allocateSecureBuffer(
88             OMX_U32 port_index, size_t size, buffer_id *buffer,
89             void **buffer_data, sp<NativeHandle> *native_handle) override;
90     status_t useBuffer(
91             OMX_U32 port_index, const OMXBuffer &omxBuf,
92             buffer_id *buffer) override;
93     status_t freeBuffer(
94             OMX_U32 port_index, buffer_id buffer) override;
95     status_t fillBuffer(
96             buffer_id buffer, const OMXBuffer &omxBuf,
97             int fenceFd = -1) override;
98     status_t emptyBuffer(
99             buffer_id buffer, const OMXBuffer &omxBuf,
100             OMX_U32 flags, OMX_TICKS timestamp, int fenceFd = -1) override;
101     status_t getExtensionIndex(
102             const char *parameter_name,
103             OMX_INDEXTYPE *index) override;
104     status_t dispatchMessage(const omx_message &msg) override;
105 };
106 
107 struct TWOmxNode : public IOmxNode {
108     sp<IOMXNode> mBase;
109     TWOmxNode(sp<IOMXNode> const& base);
110 
111     Return<Status> freeNode() override;
112     Return<Status> sendCommand(uint32_t cmd, int32_t param) override;
113     Return<void> getParameter(
114             uint32_t index, hidl_vec<uint8_t> const& inParams,
115             getParameter_cb _hidl_cb) override;
116     Return<Status> setParameter(
117             uint32_t index, hidl_vec<uint8_t> const& params) override;
118     Return<void> getConfig(
119             uint32_t index, hidl_vec<uint8_t> const& inConfig,
120             getConfig_cb _hidl_cb) override;
121     Return<Status> setConfig(
122             uint32_t index, hidl_vec<uint8_t> const& config) override;
123     Return<Status> setPortMode(uint32_t portIndex, PortMode mode) override;
124     Return<Status> prepareForAdaptivePlayback(
125             uint32_t portIndex, bool enable,
126             uint32_t maxFrameWidth, uint32_t maxFrameHeight) override;
127     Return<void> configureVideoTunnelMode(
128             uint32_t portIndex, bool tunneled, uint32_t audioHwSync,
129             configureVideoTunnelMode_cb _hidl_cb) override;
130     Return<void> getGraphicBufferUsage(
131             uint32_t portIndex,
132             getGraphicBufferUsage_cb _hidl_cb) override;
133     Return<Status> setInputSurface(
134             sp<IOmxBufferSource> const& bufferSource) override;
135     Return<void> allocateSecureBuffer(
136             uint32_t portIndex, uint64_t size,
137             allocateSecureBuffer_cb _hidl_cb) override;
138     Return<void> useBuffer(
139             uint32_t portIndex, CodecBuffer const& codecBuffer,
140             useBuffer_cb _hidl_cb) override;
141     Return<Status> freeBuffer(uint32_t portIndex, uint32_t buffer) override;
142     Return<Status> fillBuffer(
143             uint32_t buffer, CodecBuffer const& codecBuffer,
144             const hidl_handle& fence) override;
145     Return<Status> emptyBuffer(
146             uint32_t buffer, CodecBuffer const& codecBuffer,
147             uint32_t flags, uint64_t timestampUs,
148             hidl_handle const& fence) override;
149     Return<void> getExtensionIndex(
150             hidl_string const& parameterName,
151             getExtensionIndex_cb _hidl_cb) override;
152     Return<Status> dispatchMessage(Message const& msg) override;
153 };
154 
155 }  // namespace utils
156 }  // namespace V1_0
157 }  // namespace omx
158 }  // namespace media
159 }  // namespace hardware
160 }  // namespace android
161 
162 #endif  // ANDROID_HARDWARE_MEDIA_OMX_V1_0_WOMXNODE_H
163