1334de520b0369215b7931fefa424fb92d295f0ebJames Dong/*
2334de520b0369215b7931fefa424fb92d295f0ebJames Dong * Copyright (C) 2009 The Android Open Source Project
3334de520b0369215b7931fefa424fb92d295f0ebJames Dong *
4334de520b0369215b7931fefa424fb92d295f0ebJames Dong * Licensed under the Apache License, Version 2.0 (the "License");
5334de520b0369215b7931fefa424fb92d295f0ebJames Dong * you may not use this file except in compliance with the License.
6334de520b0369215b7931fefa424fb92d295f0ebJames Dong * You may obtain a copy of the License at
7334de520b0369215b7931fefa424fb92d295f0ebJames Dong *
8334de520b0369215b7931fefa424fb92d295f0ebJames Dong *      http://www.apache.org/licenses/LICENSE-2.0
9334de520b0369215b7931fefa424fb92d295f0ebJames Dong *
10334de520b0369215b7931fefa424fb92d295f0ebJames Dong * Unless required by applicable law or agreed to in writing, software
11334de520b0369215b7931fefa424fb92d295f0ebJames Dong * distributed under the License is distributed on an "AS IS" BASIS,
12334de520b0369215b7931fefa424fb92d295f0ebJames Dong * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13334de520b0369215b7931fefa424fb92d295f0ebJames Dong * See the License for the specific language governing permissions and
14334de520b0369215b7931fefa424fb92d295f0ebJames Dong * limitations under the License.
15334de520b0369215b7931fefa424fb92d295f0ebJames Dong */
16334de520b0369215b7931fefa424fb92d295f0ebJames Dong
17334de520b0369215b7931fefa424fb92d295f0ebJames Dong#ifndef HARDWARE_API_H_
18334de520b0369215b7931fefa424fb92d295f0ebJames Dong
19334de520b0369215b7931fefa424fb92d295f0ebJames Dong#define HARDWARE_API_H_
20334de520b0369215b7931fefa424fb92d295f0ebJames Dong
21334de520b0369215b7931fefa424fb92d295f0ebJames Dong#include <OMXPluginBase.h>
22334de520b0369215b7931fefa424fb92d295f0ebJames Dong#include <system/window.h>
23334de520b0369215b7931fefa424fb92d295f0ebJames Dong#include <utils/RefBase.h>
24334de520b0369215b7931fefa424fb92d295f0ebJames Dong
25334de520b0369215b7931fefa424fb92d295f0ebJames Dong#include <OMX_Component.h>
26334de520b0369215b7931fefa424fb92d295f0ebJames Dong
27334de520b0369215b7931fefa424fb92d295f0ebJames Dongnamespace android {
28334de520b0369215b7931fefa424fb92d295f0ebJames Dong
29334de520b0369215b7931fefa424fb92d295f0ebJames Dong// A pointer to this struct is passed to the OMX_SetParameter when the extension
30334de520b0369215b7931fefa424fb92d295f0ebJames Dong// index for the 'OMX.google.android.index.enableAndroidNativeBuffers' extension
31334de520b0369215b7931fefa424fb92d295f0ebJames Dong// is given.
32334de520b0369215b7931fefa424fb92d295f0ebJames Dong//
33334de520b0369215b7931fefa424fb92d295f0ebJames Dong// When Android native buffer use is disabled for a port (the default state),
34334de520b0369215b7931fefa424fb92d295f0ebJames Dong// the OMX node should operate as normal, and expect UseBuffer calls to set its
35334de520b0369215b7931fefa424fb92d295f0ebJames Dong// buffers.  This is the mode that will be used when CPU access to the buffer is
36334de520b0369215b7931fefa424fb92d295f0ebJames Dong// required.
37334de520b0369215b7931fefa424fb92d295f0ebJames Dong//
38334de520b0369215b7931fefa424fb92d295f0ebJames Dong// When Android native buffer use has been enabled for a given port, the video
39334de520b0369215b7931fefa424fb92d295f0ebJames Dong// color format for the port is to be interpreted as an Android pixel format
40334de520b0369215b7931fefa424fb92d295f0ebJames Dong// rather than an OMX color format.  The node should then expect to receive
41334de520b0369215b7931fefa424fb92d295f0ebJames Dong// UseAndroidNativeBuffer calls (via OMX_SetParameter) rather than UseBuffer
42334de520b0369215b7931fefa424fb92d295f0ebJames Dong// calls for that port.
43334de520b0369215b7931fefa424fb92d295f0ebJames Dongstruct EnableAndroidNativeBuffersParams {
44334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_U32 nSize;
45334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_VERSIONTYPE nVersion;
46334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_U32 nPortIndex;
47334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_BOOL enable;
48334de520b0369215b7931fefa424fb92d295f0ebJames Dong};
49334de520b0369215b7931fefa424fb92d295f0ebJames Dong
50334de520b0369215b7931fefa424fb92d295f0ebJames Dong// A pointer to this struct is passed to OMX_SetParameter() when the extension
51334de520b0369215b7931fefa424fb92d295f0ebJames Dong// index "OMX.google.android.index.storeMetaDataInBuffers"
52334de520b0369215b7931fefa424fb92d295f0ebJames Dong// is given.
53334de520b0369215b7931fefa424fb92d295f0ebJames Dong//
54334de520b0369215b7931fefa424fb92d295f0ebJames Dong// When meta data is stored in the video buffers passed between OMX clients
55334de520b0369215b7931fefa424fb92d295f0ebJames Dong// and OMX components, interpretation of the buffer data is up to the
56334de520b0369215b7931fefa424fb92d295f0ebJames Dong// buffer receiver, and the data may or may not be the actual video data, but
57334de520b0369215b7931fefa424fb92d295f0ebJames Dong// some information helpful for the receiver to locate the actual data.
58334de520b0369215b7931fefa424fb92d295f0ebJames Dong// The buffer receiver thus needs to know how to interpret what is stored
59334de520b0369215b7931fefa424fb92d295f0ebJames Dong// in these buffers, with mechanisms pre-determined externally. How to
60334de520b0369215b7931fefa424fb92d295f0ebJames Dong// interpret the meta data is outside of the scope of this method.
61334de520b0369215b7931fefa424fb92d295f0ebJames Dong//
62334de520b0369215b7931fefa424fb92d295f0ebJames Dong// Currently, this is specifically used to pass meta data from video source
63334de520b0369215b7931fefa424fb92d295f0ebJames Dong// (camera component, for instance) to video encoder to avoid memcpying of
64334de520b0369215b7931fefa424fb92d295f0ebJames Dong// input video frame data. To do this, bStoreMetaDta is set to OMX_TRUE.
65334de520b0369215b7931fefa424fb92d295f0ebJames Dong// If bStoreMetaData is set to false, real YUV frame data will be stored
66334de520b0369215b7931fefa424fb92d295f0ebJames Dong// in the buffers. In addition, if no OMX_SetParameter() call is made
67334de520b0369215b7931fefa424fb92d295f0ebJames Dong// with the corresponding extension index, real YUV data is stored
68334de520b0369215b7931fefa424fb92d295f0ebJames Dong// in the buffers.
69334de520b0369215b7931fefa424fb92d295f0ebJames Dongstruct StoreMetaDataInBuffersParams {
70334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_U32 nSize;
71334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_VERSIONTYPE nVersion;
72334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_U32 nPortIndex;
73334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_BOOL bStoreMetaData;
74334de520b0369215b7931fefa424fb92d295f0ebJames Dong};
75334de520b0369215b7931fefa424fb92d295f0ebJames Dong
76334de520b0369215b7931fefa424fb92d295f0ebJames Dong// A pointer to this struct is passed to OMX_SetParameter when the extension
77334de520b0369215b7931fefa424fb92d295f0ebJames Dong// index for the 'OMX.google.android.index.useAndroidNativeBuffer' extension is
78334de520b0369215b7931fefa424fb92d295f0ebJames Dong// given.  This call will only be performed if a prior call was made with the
79334de520b0369215b7931fefa424fb92d295f0ebJames Dong// 'OMX.google.android.index.enableAndroidNativeBuffers' extension index,
80334de520b0369215b7931fefa424fb92d295f0ebJames Dong// enabling use of Android native buffers.
81334de520b0369215b7931fefa424fb92d295f0ebJames Dongstruct UseAndroidNativeBufferParams {
82334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_U32 nSize;
83334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_VERSIONTYPE nVersion;
84334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_U32 nPortIndex;
85334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_PTR pAppPrivate;
86334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_BUFFERHEADERTYPE **bufferHeader;
87334de520b0369215b7931fefa424fb92d295f0ebJames Dong    const sp<ANativeWindowBuffer>& nativeBuffer;
88334de520b0369215b7931fefa424fb92d295f0ebJames Dong};
89334de520b0369215b7931fefa424fb92d295f0ebJames Dong
90334de520b0369215b7931fefa424fb92d295f0ebJames Dong// A pointer to this struct is passed to OMX_GetParameter when the extension
91334de520b0369215b7931fefa424fb92d295f0ebJames Dong// index for the 'OMX.google.android.index.getAndroidNativeBufferUsage'
92334de520b0369215b7931fefa424fb92d295f0ebJames Dong// extension is given.  The usage bits returned from this query will be used to
93334de520b0369215b7931fefa424fb92d295f0ebJames Dong// allocate the Gralloc buffers that get passed to the useAndroidNativeBuffer
94334de520b0369215b7931fefa424fb92d295f0ebJames Dong// command.
95334de520b0369215b7931fefa424fb92d295f0ebJames Dongstruct GetAndroidNativeBufferUsageParams {
96334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_U32 nSize;              // IN
97334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_VERSIONTYPE nVersion;   // IN
98334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_U32 nPortIndex;         // IN
99334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_U32 nUsage;             // OUT
100334de520b0369215b7931fefa424fb92d295f0ebJames Dong};
101334de520b0369215b7931fefa424fb92d295f0ebJames Dong
102334de520b0369215b7931fefa424fb92d295f0ebJames Dong// An enum OMX_COLOR_FormatAndroidOpaque to indicate an opaque colorformat
103334de520b0369215b7931fefa424fb92d295f0ebJames Dong// is declared in media/stagefright/openmax/OMX_IVCommon.h
104334de520b0369215b7931fefa424fb92d295f0ebJames Dong// This will inform the encoder that the actual
105334de520b0369215b7931fefa424fb92d295f0ebJames Dong// colorformat will be relayed by the GRalloc Buffers.
106334de520b0369215b7931fefa424fb92d295f0ebJames Dong// OMX_COLOR_FormatAndroidOpaque  = 0x7F000001,
107334de520b0369215b7931fefa424fb92d295f0ebJames Dong
108334de520b0369215b7931fefa424fb92d295f0ebJames Dong
109334de520b0369215b7931fefa424fb92d295f0ebJames Dong}  // namespace android
110334de520b0369215b7931fefa424fb92d295f0ebJames Dong
111334de520b0369215b7931fefa424fb92d295f0ebJames Dongextern android::OMXPluginBase *createOMXPlugin();
112334de520b0369215b7931fefa424fb92d295f0ebJames Dong
113334de520b0369215b7931fefa424fb92d295f0ebJames Dong#endif  // HARDWARE_API_H_
114