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/stagefright/OMXPluginBase.h> 22 #include <ui/android_native_buffer.h> 23 #include <utils/RefBase.h> 24 25 #include <OMX_Component.h> 26 27 namespace android { 28 29 // A pointer to this struct is passed to the OMX_SetParameter when the extension 30 // index for the 'OMX.google.android.index.enableAndroidNativeBuffers' extension 31 // is given. 32 // 33 // When Android native buffer use is disabled for a port (the default state), 34 // the OMX node should operate as normal, and expect UseBuffer calls to set its 35 // buffers. This is the mode that will be used when CPU access to the buffer is 36 // required. 37 // 38 // When Android native buffer use has been enabled for a given port, the video 39 // color format for the port is to be interpreted as an Android pixel format 40 // rather than an OMX color format. The node should then expect to receive 41 // UseAndroidNativeBuffer calls (via OMX_SetParameter) rather than UseBuffer 42 // calls for that port. 43 struct EnableAndroidNativeBuffersParams { 44 OMX_U32 nSize; 45 OMX_VERSIONTYPE nVersion; 46 OMX_U32 nPortIndex; 47 OMX_BOOL enable; 48 }; 49 50 // A pointer to this struct is passed to OMX_SetParameter() when the extension 51 // index "OMX.google.android.index.storeMetaDataInBuffers" 52 // is given. 53 // 54 // When meta data is stored in the video buffers passed between OMX clients 55 // and OMX components, interpretation of the buffer data is up to the 56 // buffer receiver, and the data may or may not be the actual video data, but 57 // some information helpful for the receiver to locate the actual data. 58 // The buffer receiver thus needs to know how to interpret what is stored 59 // in these buffers, with mechanisms pre-determined externally. How to 60 // interpret the meta data is outside of the scope of this method. 61 // 62 // Currently, this is specifically used to pass meta data from video source 63 // (camera component, for instance) to video encoder to avoid memcpying of 64 // input video frame data. To do this, bStoreMetaDta is set to OMX_TRUE. 65 // If bStoreMetaData is set to false, real YUV frame data will be stored 66 // in the buffers. In addition, if no OMX_SetParameter() call is made 67 // with the corresponding extension index, real YUV data is stored 68 // in the buffers. 69 struct StoreMetaDataInBuffersParams { 70 OMX_U32 nSize; 71 OMX_VERSIONTYPE nVersion; 72 OMX_U32 nPortIndex; 73 OMX_BOOL bStoreMetaData; 74 }; 75 76 // A pointer to this struct is passed to OMX_SetParameter when the extension 77 // index for the 'OMX.google.android.index.useAndroidNativeBuffer' extension is 78 // given. This call will only be performed if a prior call was made with the 79 // 'OMX.google.android.index.enableAndroidNativeBuffers' extension index, 80 // enabling use of Android native buffers. 81 struct UseAndroidNativeBufferParams { 82 OMX_U32 nSize; 83 OMX_VERSIONTYPE nVersion; 84 OMX_U32 nPortIndex; 85 OMX_PTR pAppPrivate; 86 OMX_BUFFERHEADERTYPE **bufferHeader; 87 const sp<ANativeWindowBuffer>& nativeBuffer; 88 }; 89 90 // A pointer to this struct is passed to OMX_GetParameter when the extension 91 // index for the 'OMX.google.android.index.getAndroidNativeBufferUsage' 92 // extension is given. The usage bits returned from this query will be used to 93 // allocate the Gralloc buffers that get passed to the useAndroidNativeBuffer 94 // command. 95 struct GetAndroidNativeBufferUsageParams { 96 OMX_U32 nSize; // IN 97 OMX_VERSIONTYPE nVersion; // IN 98 OMX_U32 nPortIndex; // IN 99 OMX_U32 nUsage; // OUT 100 }; 101 102 // An enum OMX_COLOR_FormatAndroidOpaque to indicate an opaque colorformat 103 // is declared in media/stagefright/openmax/OMX_IVCommon.h 104 // This will inform the encoder that the actual 105 // colorformat will be relayed by the GRalloc Buffers. 106 // OMX_COLOR_FormatAndroidOpaque = 0x7F000001, 107 108 109 } // namespace android 110 111 extern android::OMXPluginBase *createOMXPlugin(); 112 113 #endif // HARDWARE_API_H_ 114