blob: cb36bbb6476b262f23a4c1206bef47e685ec4ca5 [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 Huber1b84df12009-09-15 12:49:11 -070029#include "jni.h"
30
Andreas Huber20111aa2009-07-14 16:56:47 -070031namespace android {
32
33class IMemory;
34class IOMXObserver;
Andreas Huber8b938cd2009-07-31 11:52:50 -070035class IOMXRenderer;
36class ISurface;
Andreas Huberf4148b52009-08-07 12:01:29 -070037class Surface;
Andreas Huber20111aa2009-07-14 16:56:47 -070038
39class IOMX : public IInterface {
40public:
41 DECLARE_META_INTERFACE(OMX);
42
43 typedef void *buffer_id;
44 typedef void *node_id;
45
Andreas Huber7eaa9c92010-01-15 15:28:19 -080046 // Given the calling process' pid, returns true iff
47 // the implementation of the OMX interface lives in the same
48 // process.
49 virtual bool livesLocally(pid_t pid) = 0;
50
Andreas Huber134ee6a2009-12-16 09:30:55 -080051 struct ComponentInfo {
52 String8 mName;
53 List<String8> mRoles;
54 };
55 virtual status_t listNodes(List<ComponentInfo> *list) = 0;
Andreas Huber20111aa2009-07-14 16:56:47 -070056
Andreas Huber318ad9c2009-10-15 13:46:54 -070057 virtual status_t allocateNode(
58 const char *name, const sp<IOMXObserver> &observer,
59 node_id *node) = 0;
Andreas Huber20111aa2009-07-14 16:56:47 -070060
Andreas Huber318ad9c2009-10-15 13:46:54 -070061 virtual status_t freeNode(node_id node) = 0;
62
63 virtual status_t sendCommand(
Andreas Huber20111aa2009-07-14 16:56:47 -070064 node_id node, OMX_COMMANDTYPE cmd, OMX_S32 param) = 0;
65
Andreas Huber318ad9c2009-10-15 13:46:54 -070066 virtual status_t getParameter(
Andreas Huber20111aa2009-07-14 16:56:47 -070067 node_id node, OMX_INDEXTYPE index,
68 void *params, size_t size) = 0;
69
Andreas Huber318ad9c2009-10-15 13:46:54 -070070 virtual status_t setParameter(
Andreas Huber20111aa2009-07-14 16:56:47 -070071 node_id node, OMX_INDEXTYPE index,
72 const void *params, size_t size) = 0;
73
Andreas Huber318ad9c2009-10-15 13:46:54 -070074 virtual status_t getConfig(
Andreas Huber693d2712009-08-14 14:37:10 -070075 node_id node, OMX_INDEXTYPE index,
76 void *params, size_t size) = 0;
77
Andreas Huber318ad9c2009-10-15 13:46:54 -070078 virtual status_t setConfig(
Andreas Huber693d2712009-08-14 14:37:10 -070079 node_id node, OMX_INDEXTYPE index,
80 const void *params, size_t size) = 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
Andreas Huber318ad9c2009-10-15 13:46:54 -070088 virtual status_t useBuffer(
Andreas Huber20111aa2009-07-14 16:56:47 -070089 node_id node, OMX_U32 port_index, const sp<IMemory> &params,
90 buffer_id *buffer) = 0;
91
Jamie Gennis83750ea2010-08-30 16:48:38 -070092 virtual status_t useGraphicBuffer(
93 node_id node, OMX_U32 port_index,
94 const sp<GraphicBuffer> &graphicBuffer, buffer_id *buffer) = 0;
95
Andreas Huber570a3cb2010-01-20 15:05:46 -080096 // This API clearly only makes sense if the caller lives in the
97 // same process as the callee, i.e. is the media_server, as the
98 // returned "buffer_data" pointer is just that, a pointer into local
99 // address space.
Andreas Huber318ad9c2009-10-15 13:46:54 -0700100 virtual status_t allocateBuffer(
Andreas Huber20111aa2009-07-14 16:56:47 -0700101 node_id node, OMX_U32 port_index, size_t size,
Andreas Huber570a3cb2010-01-20 15:05:46 -0800102 buffer_id *buffer, void **buffer_data) = 0;
Andreas Huber20111aa2009-07-14 16:56:47 -0700103
Andreas Huber318ad9c2009-10-15 13:46:54 -0700104 virtual status_t allocateBufferWithBackup(
Andreas Huber20111aa2009-07-14 16:56:47 -0700105 node_id node, OMX_U32 port_index, const sp<IMemory> &params,
106 buffer_id *buffer) = 0;
107
Andreas Huber318ad9c2009-10-15 13:46:54 -0700108 virtual status_t freeBuffer(
Andreas Huber20111aa2009-07-14 16:56:47 -0700109 node_id node, OMX_U32 port_index, buffer_id buffer) = 0;
110
Andreas Huber318ad9c2009-10-15 13:46:54 -0700111 virtual status_t fillBuffer(node_id node, buffer_id buffer) = 0;
Andreas Huber20111aa2009-07-14 16:56:47 -0700112
Andreas Huber318ad9c2009-10-15 13:46:54 -0700113 virtual status_t emptyBuffer(
Andreas Huber20111aa2009-07-14 16:56:47 -0700114 node_id node,
115 buffer_id buffer,
116 OMX_U32 range_offset, OMX_U32 range_length,
117 OMX_U32 flags, OMX_TICKS timestamp) = 0;
Andreas Huber8b938cd2009-07-31 11:52:50 -0700118
Andreas Huber318ad9c2009-10-15 13:46:54 -0700119 virtual status_t getExtensionIndex(
Andreas Huber693d2712009-08-14 14:37:10 -0700120 node_id node,
121 const char *parameter_name,
122 OMX_INDEXTYPE *index) = 0;
Andreas Huber20111aa2009-07-14 16:56:47 -0700123};
124
125struct omx_message {
126 enum {
127 EVENT,
128 EMPTY_BUFFER_DONE,
129 FILL_BUFFER_DONE,
130
Andreas Huber20111aa2009-07-14 16:56:47 -0700131 } type;
132
Andreas Huber693d2712009-08-14 14:37:10 -0700133 IOMX::node_id node;
134
Andreas Huber20111aa2009-07-14 16:56:47 -0700135 union {
136 // if type == EVENT
137 struct {
Andreas Huber20111aa2009-07-14 16:56:47 -0700138 OMX_EVENTTYPE event;
139 OMX_U32 data1;
140 OMX_U32 data2;
141 } event_data;
142
Andreas Hubere0f0b082009-08-27 14:50:58 -0700143 // if type == EMPTY_BUFFER_DONE
Andreas Huber20111aa2009-07-14 16:56:47 -0700144 struct {
Andreas Huber20111aa2009-07-14 16:56:47 -0700145 IOMX::buffer_id buffer;
146 } buffer_data;
147
Andreas Hubere0f0b082009-08-27 14:50:58 -0700148 // if type == FILL_BUFFER_DONE
Andreas Huber20111aa2009-07-14 16:56:47 -0700149 struct {
Andreas Huber20111aa2009-07-14 16:56:47 -0700150 IOMX::buffer_id buffer;
151 OMX_U32 range_offset;
152 OMX_U32 range_length;
153 OMX_U32 flags;
154 OMX_TICKS timestamp;
Andreas Hubere0f0b082009-08-27 14:50:58 -0700155 OMX_PTR platform_private;
Andreas Huber213addf2010-01-25 10:41:35 -0800156 OMX_PTR data_ptr;
Andreas Huber20111aa2009-07-14 16:56:47 -0700157 } extended_buffer_data;
158
Andreas Huber20111aa2009-07-14 16:56:47 -0700159 } u;
160};
161
162class IOMXObserver : public IInterface {
163public:
164 DECLARE_META_INTERFACE(OMXObserver);
165
Andreas Huber318ad9c2009-10-15 13:46:54 -0700166 virtual void onMessage(const omx_message &msg) = 0;
Andreas Huber20111aa2009-07-14 16:56:47 -0700167};
168
169////////////////////////////////////////////////////////////////////////////////
170
171class BnOMX : public BnInterface<IOMX> {
172public:
173 virtual status_t onTransact(
174 uint32_t code, const Parcel &data, Parcel *reply,
175 uint32_t flags = 0);
176};
177
178class BnOMXObserver : public BnInterface<IOMXObserver> {
179public:
180 virtual status_t onTransact(
181 uint32_t code, const Parcel &data, Parcel *reply,
182 uint32_t flags = 0);
183};
184
Andreas Huber20111aa2009-07-14 16:56:47 -0700185} // namespace android
186
187#endif // ANDROID_IOMX_H_