1 /* 2 * Copyright (C) 2009 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 HARDWARE_API_H_ 18 19 #define HARDWARE_API_H_ 20 21 #include <media/hardware/OMXPluginBase.h> 22 #include <media/hardware/MetadataBufferType.h> 23 #include <system/window.h> 24 #include <utils/RefBase.h> 25 26 #include <OMX_Component.h> 27 28 namespace android { 29 30 // A pointer to this struct is passed to the OMX_SetParameter when the extension 31 // index for the 'OMX.google.android.index.enableAndroidNativeBuffers' extension 32 // is given. 33 // 34 // When Android native buffer use is disabled for a port (the default state), 35 // the OMX node should operate as normal, and expect UseBuffer calls to set its 36 // buffers. This is the mode that will be used when CPU access to the buffer is 37 // required. 38 // 39 // When Android native buffer use has been enabled for a given port, the video 40 // color format for the port is to be interpreted as an Android pixel format 41 // rather than an OMX color format. Enabling Android native buffers may also 42 // change how the component receives the native buffers. If store-metadata-mode 43 // is enabled on the port, the component will receive the buffers as specified 44 // in the section below. Otherwise, unless the node supports the 45 // 'OMX.google.android.index.useAndroidNativeBuffer2' extension, it should 46 // expect to receive UseAndroidNativeBuffer calls (via OMX_SetParameter) rather 47 // than UseBuffer calls for that port. 48 struct EnableAndroidNativeBuffersParams { 49 OMX_U32 nSize; 50 OMX_VERSIONTYPE nVersion; 51 OMX_U32 nPortIndex; 52 OMX_BOOL enable; 53 }; 54 55 // A pointer to this struct is passed to OMX_SetParameter() when the extension 56 // index "OMX.google.android.index.storeMetaDataInBuffers" 57 // is given. 58 // 59 // When meta data is stored in the video buffers passed between OMX clients 60 // and OMX components, interpretation of the buffer data is up to the 61 // buffer receiver, and the data may or may not be the actual video data, but 62 // some information helpful for the receiver to locate the actual data. 63 // The buffer receiver thus needs to know how to interpret what is stored 64 // in these buffers, with mechanisms pre-determined externally. How to 65 // interpret the meta data is outside of the scope of this method. 66 // 67 // Currently, this is specifically used to pass meta data from video source 68 // (camera component, for instance) to video encoder to avoid memcpying of 69 // input video frame data. To do this, bStoreMetaData is set to OMX_TRUE. 70 // If bStoreMetaData is set to false, real YUV frame data will be stored 71 // in the buffers. In addition, if no OMX_SetParameter() call is made 72 // with the corresponding extension index, real YUV data is stored 73 // in the buffers. 74 // 75 // For video decoder output port, the metadata buffer layout is defined below. 76 // 77 // Metadata buffers are registered with the component using UseBuffer calls. 78 struct StoreMetaDataInBuffersParams { 79 OMX_U32 nSize; 80 OMX_VERSIONTYPE nVersion; 81 OMX_U32 nPortIndex; 82 OMX_BOOL bStoreMetaData; 83 }; 84 85 // Meta data buffer layout used to transport output frames to the decoder for 86 // dynamic buffer handling. 87 struct VideoDecoderOutputMetaData { 88 MetadataBufferType eType; 89 buffer_handle_t pHandle; 90 }; 91 92 // A pointer to this struct is passed to OMX_SetParameter() when the extension 93 // index "OMX.google.android.index.prepareForAdaptivePlayback" is given. 94 // 95 // This method is used to signal a video decoder, that the user has requested 96 // seamless resolution change support (if bEnable is set to OMX_TRUE). 97 // nMaxFrameWidth and nMaxFrameHeight are the dimensions of the largest 98 // anticipated frames in the video. If bEnable is OMX_FALSE, no resolution 99 // change is expected, and the nMaxFrameWidth/Height fields are unused. 100 // 101 // If the decoder supports dynamic output buffers, it may ignore this 102 // request. Otherwise, it shall request resources in such a way so that it 103 // avoids full port-reconfiguration (due to output port-definition change) 104 // during resolution changes. 105 // 106 // DO NOT USE THIS STRUCTURE AS IT WILL BE REMOVED. INSTEAD, IMPLEMENT 107 // METADATA SUPPORT FOR VIDEO DECODERS. 108 struct PrepareForAdaptivePlaybackParams { 109 OMX_U32 nSize; 110 OMX_VERSIONTYPE nVersion; 111 OMX_U32 nPortIndex; 112 OMX_BOOL bEnable; 113 OMX_U32 nMaxFrameWidth; 114 OMX_U32 nMaxFrameHeight; 115 }; 116 117 // A pointer to this struct is passed to OMX_SetParameter when the extension 118 // index for the 'OMX.google.android.index.useAndroidNativeBuffer' extension is 119 // given. This call will only be performed if a prior call was made with the 120 // 'OMX.google.android.index.enableAndroidNativeBuffers' extension index, 121 // enabling use of Android native buffers. 122 struct UseAndroidNativeBufferParams { 123 OMX_U32 nSize; 124 OMX_VERSIONTYPE nVersion; 125 OMX_U32 nPortIndex; 126 OMX_PTR pAppPrivate; 127 OMX_BUFFERHEADERTYPE **bufferHeader; 128 const sp<ANativeWindowBuffer>& nativeBuffer; 129 }; 130 131 // A pointer to this struct is passed to OMX_GetParameter when the extension 132 // index for the 'OMX.google.android.index.getAndroidNativeBufferUsage' 133 // extension is given. The usage bits returned from this query will be used to 134 // allocate the Gralloc buffers that get passed to the useAndroidNativeBuffer 135 // command. 136 struct GetAndroidNativeBufferUsageParams { 137 OMX_U32 nSize; // IN 138 OMX_VERSIONTYPE nVersion; // IN 139 OMX_U32 nPortIndex; // IN 140 OMX_U32 nUsage; // OUT 141 }; 142 143 // An enum OMX_COLOR_FormatAndroidOpaque to indicate an opaque colorformat 144 // is declared in media/stagefright/openmax/OMX_IVCommon.h 145 // This will inform the encoder that the actual 146 // colorformat will be relayed by the GRalloc Buffers. 147 // OMX_COLOR_FormatAndroidOpaque = 0x7F000001, 148 149 // A pointer to this struct is passed to OMX_SetParameter when the extension 150 // index for the 'OMX.google.android.index.prependSPSPPSToIDRFrames' extension 151 // is given. 152 // A successful result indicates that future IDR frames will be prefixed by 153 // SPS/PPS. 154 struct PrependSPSPPSToIDRFramesParams { 155 OMX_U32 nSize; 156 OMX_VERSIONTYPE nVersion; 157 OMX_BOOL bEnable; 158 }; 159 160 } // namespace android 161 162 extern android::OMXPluginBase *createOMXPlugin(); 163 164 #endif // HARDWARE_API_H_ 165