Andreas Huber | c8d7c14 | 2009-11-11 16:33:17 -0800 | [diff] [blame] | 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 | |
Andreas Huber | b0caf94 | 2009-12-03 11:39:54 -0800 | [diff] [blame] | 21 | #include <media/stagefright/OMXPluginBase.h> |
Mathias Agopian | af01feaf | 2012-02-24 18:25:41 -0800 | [diff] [blame] | 22 | #include <system/window.h> |
Andreas Huber | c8d7c14 | 2009-11-11 16:33:17 -0800 | [diff] [blame] | 23 | #include <utils/RefBase.h> |
| 24 | |
| 25 | #include <OMX_Component.h> |
| 26 | |
Jamie Gennis | 33a7814 | 2010-08-30 16:48:38 -0700 | [diff] [blame] | 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 | // |
Jamie Gennis | 044ace6 | 2010-10-29 15:19:29 -0700 | [diff] [blame] | 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 |
Jamie Gennis | 33a7814 | 2010-08-30 16:48:38 -0700 | [diff] [blame] | 41 | // UseAndroidNativeBuffer calls (via OMX_SetParameter) rather than UseBuffer |
Jamie Gennis | 044ace6 | 2010-10-29 15:19:29 -0700 | [diff] [blame] | 42 | // calls for that port. |
Jamie Gennis | 33a7814 | 2010-08-30 16:48:38 -0700 | [diff] [blame] | 43 | struct EnableAndroidNativeBuffersParams { |
| 44 | OMX_U32 nSize; |
| 45 | OMX_VERSIONTYPE nVersion; |
| 46 | OMX_U32 nPortIndex; |
| 47 | OMX_BOOL enable; |
| 48 | }; |
| 49 | |
James Dong | 387e38d | 2010-10-20 17:38:41 -0700 | [diff] [blame] | 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 | |
Jamie Gennis | 33a7814 | 2010-08-30 16:48:38 -0700 | [diff] [blame] | 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; |
Iliyan Malchev | b2a153a | 2011-05-01 11:33:26 -0700 | [diff] [blame] | 87 | const sp<ANativeWindowBuffer>& nativeBuffer; |
Jamie Gennis | 33a7814 | 2010-08-30 16:48:38 -0700 | [diff] [blame] | 88 | }; |
| 89 | |
Jamie Gennis | e6befb8 | 2011-02-23 19:01:28 -0800 | [diff] [blame] | 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 | |
Pannag Sanketi | 26a1971 | 2011-06-10 18:30:30 -0700 | [diff] [blame] | 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 | |
Jamie Gennis | 33a7814 | 2010-08-30 16:48:38 -0700 | [diff] [blame] | 109 | } // namespace android |
| 110 | |
Andreas Huber | b0caf94 | 2009-12-03 11:39:54 -0800 | [diff] [blame] | 111 | extern android::OMXPluginBase *createOMXPlugin(); |
| 112 | |
Andreas Huber | c8d7c14 | 2009-11-11 16:33:17 -0800 | [diff] [blame] | 113 | #endif // HARDWARE_API_H_ |