HardwareAPI.h revision 5f39f6043da49ca7ab1f682374e055deb73b0c89
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
28namespace 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.
48struct 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.
78struct 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.
87struct 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 for the 'OMX.google.android.index.useAndroidNativeBuffer' extension is
94// given.  This call will only be performed if a prior call was made with the
95// 'OMX.google.android.index.enableAndroidNativeBuffers' extension index,
96// enabling use of Android native buffers.
97struct UseAndroidNativeBufferParams {
98    OMX_U32 nSize;
99    OMX_VERSIONTYPE nVersion;
100    OMX_U32 nPortIndex;
101    OMX_PTR pAppPrivate;
102    OMX_BUFFERHEADERTYPE **bufferHeader;
103    const sp<ANativeWindowBuffer>& nativeBuffer;
104};
105
106// A pointer to this struct is passed to OMX_GetParameter when the extension
107// index for the 'OMX.google.android.index.getAndroidNativeBufferUsage'
108// extension is given.  The usage bits returned from this query will be used to
109// allocate the Gralloc buffers that get passed to the useAndroidNativeBuffer
110// command.
111struct GetAndroidNativeBufferUsageParams {
112    OMX_U32 nSize;              // IN
113    OMX_VERSIONTYPE nVersion;   // IN
114    OMX_U32 nPortIndex;         // IN
115    OMX_U32 nUsage;             // OUT
116};
117
118// An enum OMX_COLOR_FormatAndroidOpaque to indicate an opaque colorformat
119// is declared in media/stagefright/openmax/OMX_IVCommon.h
120// This will inform the encoder that the actual
121// colorformat will be relayed by the GRalloc Buffers.
122// OMX_COLOR_FormatAndroidOpaque  = 0x7F000001,
123
124// A pointer to this struct is passed to OMX_SetParameter when the extension
125// index for the 'OMX.google.android.index.prependSPSPPSToIDRFrames' extension
126// is given.
127// A successful result indicates that future IDR frames will be prefixed by
128// SPS/PPS.
129struct PrependSPSPPSToIDRFramesParams {
130    OMX_U32 nSize;
131    OMX_VERSIONTYPE nVersion;
132    OMX_BOOL bEnable;
133};
134
135}  // namespace android
136
137extern android::OMXPluginBase *createOMXPlugin();
138
139#endif  // HARDWARE_API_H_
140