blob: be1b2fc5316166630c20eb9f046834b47c7e4de6 [file] [log] [blame]
Andreas Huber20111aa2009-07-14 16:56:47 -07001/*
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 ANDROID_IOMX_H_
18
19#define ANDROID_IOMX_H_
20
21#include <binder/IInterface.h>
Jamie Gennis83750ea2010-08-30 16:48:38 -070022#include <ui/GraphicBuffer.h>
Andreas Huber20111aa2009-07-14 16:56:47 -070023#include <utils/List.h>
24#include <utils/String8.h>
25
26#include <OMX_Core.h>
Andreas Huber8b938cd2009-07-31 11:52:50 -070027#include <OMX_Video.h>
Andreas Huber20111aa2009-07-14 16:56:47 -070028
Andreas Huber20111aa2009-07-14 16:56:47 -070029namespace android {
30
31class IMemory;
32class IOMXObserver;
Andreas Huber8b938cd2009-07-31 11:52:50 -070033class IOMXRenderer;
Andreas Huberf4148b52009-08-07 12:01:29 -070034class Surface;
Andreas Huber20111aa2009-07-14 16:56:47 -070035
36class IOMX : public IInterface {
37public:
38 DECLARE_META_INTERFACE(OMX);
39
40 typedef void *buffer_id;
41 typedef void *node_id;
42
Andreas Huberd459b482012-01-31 11:16:24 -080043 // Given a node_id and the calling process' pid, returns true iff
Andreas Huber7eaa9c92010-01-15 15:28:19 -080044 // the implementation of the OMX interface lives in the same
45 // process.
Andreas Huberd459b482012-01-31 11:16:24 -080046 virtual bool livesLocally(node_id node, pid_t pid) = 0;
Andreas Huber7eaa9c92010-01-15 15:28:19 -080047
Andreas Huber134ee6a2009-12-16 09:30:55 -080048 struct ComponentInfo {
49 String8 mName;
50 List<String8> mRoles;
51 };
52 virtual status_t listNodes(List<ComponentInfo> *list) = 0;
Andreas Huber20111aa2009-07-14 16:56:47 -070053
Andreas Huber318ad9c2009-10-15 13:46:54 -070054 virtual status_t allocateNode(
55 const char *name, const sp<IOMXObserver> &observer,
56 node_id *node) = 0;
Andreas Huber20111aa2009-07-14 16:56:47 -070057
Andreas Huber318ad9c2009-10-15 13:46:54 -070058 virtual status_t freeNode(node_id node) = 0;
59
60 virtual status_t sendCommand(
Andreas Huber20111aa2009-07-14 16:56:47 -070061 node_id node, OMX_COMMANDTYPE cmd, OMX_S32 param) = 0;
62
Andreas Huber318ad9c2009-10-15 13:46:54 -070063 virtual status_t getParameter(
Andreas Huber20111aa2009-07-14 16:56:47 -070064 node_id node, OMX_INDEXTYPE index,
65 void *params, size_t size) = 0;
66
Andreas Huber318ad9c2009-10-15 13:46:54 -070067 virtual status_t setParameter(
Andreas Huber20111aa2009-07-14 16:56:47 -070068 node_id node, OMX_INDEXTYPE index,
69 const void *params, size_t size) = 0;
70
Andreas Huber318ad9c2009-10-15 13:46:54 -070071 virtual status_t getConfig(
Andreas Huber693d2712009-08-14 14:37:10 -070072 node_id node, OMX_INDEXTYPE index,
73 void *params, size_t size) = 0;
74
Andreas Huber318ad9c2009-10-15 13:46:54 -070075 virtual status_t setConfig(
Andreas Huber693d2712009-08-14 14:37:10 -070076 node_id node, OMX_INDEXTYPE index,
77 const void *params, size_t size) = 0;
78
Jamie Gennisb1d666f2011-10-19 21:14:13 -070079 virtual status_t getState(
80 node_id node, OMX_STATETYPE* state) = 0;
81
James Donge8707722010-10-20 17:38:41 -070082 virtual status_t storeMetaDataInBuffers(
83 node_id node, OMX_U32 port_index, OMX_BOOL enable) = 0;
84
Jamie Gennis83750ea2010-08-30 16:48:38 -070085 virtual status_t enableGraphicBuffers(
86 node_id node, OMX_U32 port_index, OMX_BOOL enable) = 0;
87
Jamie Gennise2ce6452011-02-23 19:01:28 -080088 virtual status_t getGraphicBufferUsage(
89 node_id node, OMX_U32 port_index, OMX_U32* usage) = 0;
90
Andreas Huber318ad9c2009-10-15 13:46:54 -070091 virtual status_t useBuffer(
Andreas Huber20111aa2009-07-14 16:56:47 -070092 node_id node, OMX_U32 port_index, const sp<IMemory> &params,
93 buffer_id *buffer) = 0;
94
Jamie Gennis83750ea2010-08-30 16:48:38 -070095 virtual status_t useGraphicBuffer(
96 node_id node, OMX_U32 port_index,
97 const sp<GraphicBuffer> &graphicBuffer, buffer_id *buffer) = 0;
98
Andreas Huber570a3cb2010-01-20 15:05:46 -080099 // This API clearly only makes sense if the caller lives in the
100 // same process as the callee, i.e. is the media_server, as the
101 // returned "buffer_data" pointer is just that, a pointer into local
102 // address space.
Andreas Huber318ad9c2009-10-15 13:46:54 -0700103 virtual status_t allocateBuffer(
Andreas Huber20111aa2009-07-14 16:56:47 -0700104 node_id node, OMX_U32 port_index, size_t size,
Andreas Huber570a3cb2010-01-20 15:05:46 -0800105 buffer_id *buffer, void **buffer_data) = 0;
Andreas Huber20111aa2009-07-14 16:56:47 -0700106
Andreas Huber318ad9c2009-10-15 13:46:54 -0700107 virtual status_t allocateBufferWithBackup(
Andreas Huber20111aa2009-07-14 16:56:47 -0700108 node_id node, OMX_U32 port_index, const sp<IMemory> &params,
109 buffer_id *buffer) = 0;
110
Andreas Huber318ad9c2009-10-15 13:46:54 -0700111 virtual status_t freeBuffer(
Andreas Huber20111aa2009-07-14 16:56:47 -0700112 node_id node, OMX_U32 port_index, buffer_id buffer) = 0;
113
Andreas Huber318ad9c2009-10-15 13:46:54 -0700114 virtual status_t fillBuffer(node_id node, buffer_id buffer) = 0;
Andreas Huber20111aa2009-07-14 16:56:47 -0700115
Andreas Huber318ad9c2009-10-15 13:46:54 -0700116 virtual status_t emptyBuffer(
Andreas Huber20111aa2009-07-14 16:56:47 -0700117 node_id node,
118 buffer_id buffer,
119 OMX_U32 range_offset, OMX_U32 range_length,
120 OMX_U32 flags, OMX_TICKS timestamp) = 0;
Andreas Huber8b938cd2009-07-31 11:52:50 -0700121
Andreas Huber318ad9c2009-10-15 13:46:54 -0700122 virtual status_t getExtensionIndex(
Andreas Huber693d2712009-08-14 14:37:10 -0700123 node_id node,
124 const char *parameter_name,
125 OMX_INDEXTYPE *index) = 0;
Andreas Huber20111aa2009-07-14 16:56:47 -0700126};
127
128struct omx_message {
129 enum {
130 EVENT,
131 EMPTY_BUFFER_DONE,
132 FILL_BUFFER_DONE,
133
Andreas Huber20111aa2009-07-14 16:56:47 -0700134 } type;
135
Andreas Huber693d2712009-08-14 14:37:10 -0700136 IOMX::node_id node;
137
Andreas Huber20111aa2009-07-14 16:56:47 -0700138 union {
139 // if type == EVENT
140 struct {
Andreas Huber20111aa2009-07-14 16:56:47 -0700141 OMX_EVENTTYPE event;
142 OMX_U32 data1;
143 OMX_U32 data2;
144 } event_data;
145
Andreas Hubere0f0b082009-08-27 14:50:58 -0700146 // if type == EMPTY_BUFFER_DONE
Andreas Huber20111aa2009-07-14 16:56:47 -0700147 struct {
Andreas Huber20111aa2009-07-14 16:56:47 -0700148 IOMX::buffer_id buffer;
149 } buffer_data;
150
Andreas Hubere0f0b082009-08-27 14:50:58 -0700151 // if type == FILL_BUFFER_DONE
Andreas Huber20111aa2009-07-14 16:56:47 -0700152 struct {
Andreas Huber20111aa2009-07-14 16:56:47 -0700153 IOMX::buffer_id buffer;
154 OMX_U32 range_offset;
155 OMX_U32 range_length;
156 OMX_U32 flags;
157 OMX_TICKS timestamp;
Andreas Hubere0f0b082009-08-27 14:50:58 -0700158 OMX_PTR platform_private;
Andreas Huber213addf2010-01-25 10:41:35 -0800159 OMX_PTR data_ptr;
Andreas Huber20111aa2009-07-14 16:56:47 -0700160 } extended_buffer_data;
161
Andreas Huber20111aa2009-07-14 16:56:47 -0700162 } u;
163};
164
165class IOMXObserver : public IInterface {
166public:
167 DECLARE_META_INTERFACE(OMXObserver);
168
Andreas Huber318ad9c2009-10-15 13:46:54 -0700169 virtual void onMessage(const omx_message &msg) = 0;
Andreas Huber20111aa2009-07-14 16:56:47 -0700170};
171
172////////////////////////////////////////////////////////////////////////////////
173
174class BnOMX : public BnInterface<IOMX> {
175public:
176 virtual status_t onTransact(
177 uint32_t code, const Parcel &data, Parcel *reply,
178 uint32_t flags = 0);
179};
180
181class BnOMXObserver : public BnInterface<IOMXObserver> {
182public:
183 virtual status_t onTransact(
184 uint32_t code, const Parcel &data, Parcel *reply,
185 uint32_t flags = 0);
186};
187
James Dong457116d2011-07-11 12:29:10 -0700188struct CodecProfileLevel {
189 OMX_U32 mProfile;
190 OMX_U32 mLevel;
191};
192
Andreas Huber20111aa2009-07-14 16:56:47 -0700193} // namespace android
194
195#endif // ANDROID_IOMX_H_