blob: a295e9a192816e8ffca327d14d6f22b3f1117d25 [file] [log] [blame]
Andreas Hubere46b7be2009-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 Gennis33a78142010-08-30 16:48:38 -070022#include <ui/GraphicBuffer.h>
Andreas Hubere46b7be2009-07-14 16:56:47 -070023#include <utils/List.h>
24#include <utils/String8.h>
25
26#include <OMX_Core.h>
Andreas Huber1de13162009-07-31 11:52:50 -070027#include <OMX_Video.h>
Andreas Hubere46b7be2009-07-14 16:56:47 -070028
Andreas Huber9f9afef2009-09-15 12:49:11 -070029#include "jni.h"
30
Andreas Hubere46b7be2009-07-14 16:56:47 -070031namespace android {
32
33class IMemory;
34class IOMXObserver;
Andreas Huber1de13162009-07-31 11:52:50 -070035class IOMXRenderer;
Andreas Huberccf8b942009-08-07 12:01:29 -070036class Surface;
Andreas Hubere46b7be2009-07-14 16:56:47 -070037
38class IOMX : public IInterface {
39public:
40 DECLARE_META_INTERFACE(OMX);
41
42 typedef void *buffer_id;
43 typedef void *node_id;
44
Andreas Huberf6b4ca42012-01-31 11:16:24 -080045 // Given a node_id and the calling process' pid, returns true iff
Andreas Huberf1fe0642010-01-15 15:28:19 -080046 // the implementation of the OMX interface lives in the same
47 // process.
Andreas Huberf6b4ca42012-01-31 11:16:24 -080048 virtual bool livesLocally(node_id node, pid_t pid) = 0;
Andreas Huberf1fe0642010-01-15 15:28:19 -080049
Andreas Huber2ea14e22009-12-16 09:30:55 -080050 struct ComponentInfo {
51 String8 mName;
52 List<String8> mRoles;
53 };
54 virtual status_t listNodes(List<ComponentInfo> *list) = 0;
Andreas Hubere46b7be2009-07-14 16:56:47 -070055
Andreas Huber784202e2009-10-15 13:46:54 -070056 virtual status_t allocateNode(
57 const char *name, const sp<IOMXObserver> &observer,
58 node_id *node) = 0;
Andreas Hubere46b7be2009-07-14 16:56:47 -070059
Andreas Huber784202e2009-10-15 13:46:54 -070060 virtual status_t freeNode(node_id node) = 0;
61
62 virtual status_t sendCommand(
Andreas Hubere46b7be2009-07-14 16:56:47 -070063 node_id node, OMX_COMMANDTYPE cmd, OMX_S32 param) = 0;
64
Andreas Huber784202e2009-10-15 13:46:54 -070065 virtual status_t getParameter(
Andreas Hubere46b7be2009-07-14 16:56:47 -070066 node_id node, OMX_INDEXTYPE index,
67 void *params, size_t size) = 0;
68
Andreas Huber784202e2009-10-15 13:46:54 -070069 virtual status_t setParameter(
Andreas Hubere46b7be2009-07-14 16:56:47 -070070 node_id node, OMX_INDEXTYPE index,
71 const void *params, size_t size) = 0;
72
Andreas Huber784202e2009-10-15 13:46:54 -070073 virtual status_t getConfig(
Andreas Huberbe06d262009-08-14 14:37:10 -070074 node_id node, OMX_INDEXTYPE index,
75 void *params, size_t size) = 0;
76
Andreas Huber784202e2009-10-15 13:46:54 -070077 virtual status_t setConfig(
Andreas Huberbe06d262009-08-14 14:37:10 -070078 node_id node, OMX_INDEXTYPE index,
79 const void *params, size_t size) = 0;
80
Jamie Gennis6607b392011-10-19 21:14:13 -070081 virtual status_t getState(
82 node_id node, OMX_STATETYPE* state) = 0;
83
James Dong387e38d2010-10-20 17:38:41 -070084 virtual status_t storeMetaDataInBuffers(
85 node_id node, OMX_U32 port_index, OMX_BOOL enable) = 0;
86
Jamie Gennis33a78142010-08-30 16:48:38 -070087 virtual status_t enableGraphicBuffers(
88 node_id node, OMX_U32 port_index, OMX_BOOL enable) = 0;
89
Jamie Gennise6befb82011-02-23 19:01:28 -080090 virtual status_t getGraphicBufferUsage(
91 node_id node, OMX_U32 port_index, OMX_U32* usage) = 0;
92
Andreas Huber784202e2009-10-15 13:46:54 -070093 virtual status_t useBuffer(
Andreas Hubere46b7be2009-07-14 16:56:47 -070094 node_id node, OMX_U32 port_index, const sp<IMemory> &params,
95 buffer_id *buffer) = 0;
96
Jamie Gennis33a78142010-08-30 16:48:38 -070097 virtual status_t useGraphicBuffer(
98 node_id node, OMX_U32 port_index,
99 const sp<GraphicBuffer> &graphicBuffer, buffer_id *buffer) = 0;
100
Andreas Huberc712b9f2010-01-20 15:05:46 -0800101 // This API clearly only makes sense if the caller lives in the
102 // same process as the callee, i.e. is the media_server, as the
103 // returned "buffer_data" pointer is just that, a pointer into local
104 // address space.
Andreas Huber784202e2009-10-15 13:46:54 -0700105 virtual status_t allocateBuffer(
Andreas Hubere46b7be2009-07-14 16:56:47 -0700106 node_id node, OMX_U32 port_index, size_t size,
Andreas Huberc712b9f2010-01-20 15:05:46 -0800107 buffer_id *buffer, void **buffer_data) = 0;
Andreas Hubere46b7be2009-07-14 16:56:47 -0700108
Andreas Huber784202e2009-10-15 13:46:54 -0700109 virtual status_t allocateBufferWithBackup(
Andreas Hubere46b7be2009-07-14 16:56:47 -0700110 node_id node, OMX_U32 port_index, const sp<IMemory> &params,
111 buffer_id *buffer) = 0;
112
Andreas Huber784202e2009-10-15 13:46:54 -0700113 virtual status_t freeBuffer(
Andreas Hubere46b7be2009-07-14 16:56:47 -0700114 node_id node, OMX_U32 port_index, buffer_id buffer) = 0;
115
Andreas Huber784202e2009-10-15 13:46:54 -0700116 virtual status_t fillBuffer(node_id node, buffer_id buffer) = 0;
Andreas Hubere46b7be2009-07-14 16:56:47 -0700117
Andreas Huber784202e2009-10-15 13:46:54 -0700118 virtual status_t emptyBuffer(
Andreas Hubere46b7be2009-07-14 16:56:47 -0700119 node_id node,
120 buffer_id buffer,
121 OMX_U32 range_offset, OMX_U32 range_length,
122 OMX_U32 flags, OMX_TICKS timestamp) = 0;
Andreas Huber1de13162009-07-31 11:52:50 -0700123
Andreas Huber784202e2009-10-15 13:46:54 -0700124 virtual status_t getExtensionIndex(
Andreas Huberbe06d262009-08-14 14:37:10 -0700125 node_id node,
126 const char *parameter_name,
127 OMX_INDEXTYPE *index) = 0;
Andreas Hubere46b7be2009-07-14 16:56:47 -0700128};
129
130struct omx_message {
131 enum {
132 EVENT,
133 EMPTY_BUFFER_DONE,
134 FILL_BUFFER_DONE,
135
Andreas Hubere46b7be2009-07-14 16:56:47 -0700136 } type;
137
Andreas Huberbe06d262009-08-14 14:37:10 -0700138 IOMX::node_id node;
139
Andreas Hubere46b7be2009-07-14 16:56:47 -0700140 union {
141 // if type == EVENT
142 struct {
Andreas Hubere46b7be2009-07-14 16:56:47 -0700143 OMX_EVENTTYPE event;
144 OMX_U32 data1;
145 OMX_U32 data2;
146 } event_data;
147
Andreas Huber329577a2009-08-27 14:50:58 -0700148 // if type == EMPTY_BUFFER_DONE
Andreas Hubere46b7be2009-07-14 16:56:47 -0700149 struct {
Andreas Hubere46b7be2009-07-14 16:56:47 -0700150 IOMX::buffer_id buffer;
151 } buffer_data;
152
Andreas Huber329577a2009-08-27 14:50:58 -0700153 // if type == FILL_BUFFER_DONE
Andreas Hubere46b7be2009-07-14 16:56:47 -0700154 struct {
Andreas Hubere46b7be2009-07-14 16:56:47 -0700155 IOMX::buffer_id buffer;
156 OMX_U32 range_offset;
157 OMX_U32 range_length;
158 OMX_U32 flags;
159 OMX_TICKS timestamp;
Andreas Huber329577a2009-08-27 14:50:58 -0700160 OMX_PTR platform_private;
Andreas Huber52733b82010-01-25 10:41:35 -0800161 OMX_PTR data_ptr;
Andreas Hubere46b7be2009-07-14 16:56:47 -0700162 } extended_buffer_data;
163
Andreas Hubere46b7be2009-07-14 16:56:47 -0700164 } u;
165};
166
167class IOMXObserver : public IInterface {
168public:
169 DECLARE_META_INTERFACE(OMXObserver);
170
Andreas Huber784202e2009-10-15 13:46:54 -0700171 virtual void onMessage(const omx_message &msg) = 0;
Andreas Hubere46b7be2009-07-14 16:56:47 -0700172};
173
174////////////////////////////////////////////////////////////////////////////////
175
176class BnOMX : public BnInterface<IOMX> {
177public:
178 virtual status_t onTransact(
179 uint32_t code, const Parcel &data, Parcel *reply,
180 uint32_t flags = 0);
181};
182
183class BnOMXObserver : public BnInterface<IOMXObserver> {
184public:
185 virtual status_t onTransact(
186 uint32_t code, const Parcel &data, Parcel *reply,
187 uint32_t flags = 0);
188};
189
James Dongfbb170c2011-07-11 12:29:10 -0700190struct CodecProfileLevel {
191 OMX_U32 mProfile;
192 OMX_U32 mLevel;
193};
194
Andreas Hubere46b7be2009-07-14 16:56:47 -0700195} // namespace android
196
197#endif // ANDROID_IOMX_H_