James Dong | 27c1744 | 2011-03-17 11:02:04 -0700 | [diff] [blame] | 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 | |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 17 | //#define LOG_NDEBUG 0 |
| 18 | #define LOG_TAG "IOMX" |
| 19 | #include <utils/Log.h> |
| 20 | |
Marco Nelissen | 2720c8b | 2016-02-29 12:47:20 -0800 | [diff] [blame] | 21 | #include <sys/mman.h> |
| 22 | |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 23 | #include <binder/IMemory.h> |
| 24 | #include <binder/Parcel.h> |
| 25 | #include <media/IOMX.h> |
Andreas Huber | b391290 | 2011-01-19 10:34:52 -0800 | [diff] [blame] | 26 | #include <media/stagefright/foundation/ADebug.h> |
Marco Nelissen | c1c50e7 | 2016-03-10 15:02:13 -0800 | [diff] [blame] | 27 | #include <media/openmax/OMX_IndexExt.h> |
Lajos Molnar | 7e0bef8 | 2016-05-09 10:48:30 -0700 | [diff] [blame] | 28 | #include <utils/NativeHandle.h> |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 29 | |
Chong Zhang | 6d332d2 | 2016-09-07 12:06:50 -0700 | [diff] [blame^] | 30 | #include <android/IGraphicBufferSource.h> |
| 31 | |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 32 | namespace android { |
| 33 | |
| 34 | enum { |
| 35 | CONNECT = IBinder::FIRST_CALL_TRANSACTION, |
Andreas Huber | 7eaa9c9 | 2010-01-15 15:28:19 -0800 | [diff] [blame] | 36 | LIVES_LOCALLY, |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 37 | LIST_NODES, |
| 38 | ALLOCATE_NODE, |
| 39 | FREE_NODE, |
| 40 | SEND_COMMAND, |
| 41 | GET_PARAMETER, |
| 42 | SET_PARAMETER, |
Andreas Huber | 693d271 | 2009-08-14 14:37:10 -0700 | [diff] [blame] | 43 | GET_CONFIG, |
| 44 | SET_CONFIG, |
Jamie Gennis | b1d666f | 2011-10-19 21:14:13 -0700 | [diff] [blame] | 45 | GET_STATE, |
Lajos Molnar | a63141a | 2016-02-11 16:40:36 -0800 | [diff] [blame] | 46 | ENABLE_NATIVE_BUFFERS, |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 47 | USE_BUFFER, |
Jamie Gennis | 83750ea | 2010-08-30 16:48:38 -0700 | [diff] [blame] | 48 | USE_GRAPHIC_BUFFER, |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 49 | CREATE_INPUT_SURFACE, |
Chong Zhang | d291c22 | 2015-04-30 18:15:52 -0700 | [diff] [blame] | 50 | CREATE_PERSISTENT_INPUT_SURFACE, |
Chong Zhang | 8f469e1 | 2015-05-13 10:21:33 -0700 | [diff] [blame] | 51 | SET_INPUT_SURFACE, |
James Dong | e870772 | 2010-10-20 17:38:41 -0700 | [diff] [blame] | 52 | STORE_META_DATA_IN_BUFFERS, |
Lajos Molnar | 56ce726 | 2013-05-02 16:30:48 -0700 | [diff] [blame] | 53 | PREPARE_FOR_ADAPTIVE_PLAYBACK, |
Lajos Molnar | a63141a | 2016-02-11 16:40:36 -0800 | [diff] [blame] | 54 | ALLOC_SECURE_BUFFER, |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 55 | ALLOC_BUFFER_WITH_BACKUP, |
| 56 | FREE_BUFFER, |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 57 | FILL_BUFFER, |
| 58 | EMPTY_BUFFER, |
Chong Zhang | 6cf9a12 | 2016-09-08 23:25:52 -0700 | [diff] [blame] | 59 | EMPTY_GRAPHIC_BUFFER, |
Andreas Huber | 693d271 | 2009-08-14 14:37:10 -0700 | [diff] [blame] | 60 | GET_EXTENSION_INDEX, |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 61 | OBSERVER_ON_MSG, |
Jamie Gennis | e2ce645 | 2011-02-23 19:01:28 -0800 | [diff] [blame] | 62 | GET_GRAPHIC_BUFFER_USAGE, |
Lajos Molnar | d071586 | 2013-07-22 12:57:43 -0700 | [diff] [blame] | 63 | UPDATE_GRAPHIC_BUFFER_IN_META, |
Rachad | 5a446aa | 2014-07-29 16:47:56 -0700 | [diff] [blame] | 64 | CONFIGURE_VIDEO_TUNNEL_MODE, |
Lajos Molnar | 7e0bef8 | 2016-05-09 10:48:30 -0700 | [diff] [blame] | 65 | UPDATE_NATIVE_HANDLE_IN_META, |
Chong Zhang | 6cf9a12 | 2016-09-08 23:25:52 -0700 | [diff] [blame] | 66 | DISPATCH_MESSAGE, |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 67 | }; |
| 68 | |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 69 | class BpOMX : public BpInterface<IOMX> { |
| 70 | public: |
Chih-Hung Hsieh | 090ef60 | 2016-04-27 10:39:54 -0700 | [diff] [blame] | 71 | explicit BpOMX(const sp<IBinder> &impl) |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 72 | : BpInterface<IOMX>(impl) { |
| 73 | } |
| 74 | |
Andreas Huber | d459b48 | 2012-01-31 11:16:24 -0800 | [diff] [blame] | 75 | virtual bool livesLocally(node_id node, pid_t pid) { |
Andreas Huber | 7eaa9c9 | 2010-01-15 15:28:19 -0800 | [diff] [blame] | 76 | Parcel data, reply; |
| 77 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 78 | data.writeInt32((int32_t)node); |
Andreas Huber | 7eaa9c9 | 2010-01-15 15:28:19 -0800 | [diff] [blame] | 79 | data.writeInt32(pid); |
| 80 | remote()->transact(LIVES_LOCALLY, data, &reply); |
| 81 | |
| 82 | return reply.readInt32() != 0; |
| 83 | } |
| 84 | |
Andreas Huber | 134ee6a | 2009-12-16 09:30:55 -0800 | [diff] [blame] | 85 | virtual status_t listNodes(List<ComponentInfo> *list) { |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 86 | list->clear(); |
| 87 | |
| 88 | Parcel data, reply; |
| 89 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
| 90 | remote()->transact(LIST_NODES, data, &reply); |
| 91 | |
| 92 | int32_t n = reply.readInt32(); |
| 93 | for (int32_t i = 0; i < n; ++i) { |
Andreas Huber | 134ee6a | 2009-12-16 09:30:55 -0800 | [diff] [blame] | 94 | list->push_back(ComponentInfo()); |
| 95 | ComponentInfo &info = *--list->end(); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 96 | |
Andreas Huber | 134ee6a | 2009-12-16 09:30:55 -0800 | [diff] [blame] | 97 | info.mName = reply.readString8(); |
| 98 | int32_t numRoles = reply.readInt32(); |
| 99 | for (int32_t j = 0; j < numRoles; ++j) { |
| 100 | info.mRoles.push_back(reply.readString8()); |
| 101 | } |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | return OK; |
| 105 | } |
| 106 | |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 107 | virtual status_t allocateNode( |
Marco Nelissen | 2385887 | 2016-02-17 13:12:13 -0800 | [diff] [blame] | 108 | const char *name, const sp<IOMXObserver> &observer, |
| 109 | sp<IBinder> *nodeBinder, |
| 110 | node_id *node) { |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 111 | Parcel data, reply; |
| 112 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
| 113 | data.writeCString(name); |
Marco Nelissen | 06b4606 | 2014-11-14 07:58:25 -0800 | [diff] [blame] | 114 | data.writeStrongBinder(IInterface::asBinder(observer)); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 115 | remote()->transact(ALLOCATE_NODE, data, &reply); |
| 116 | |
| 117 | status_t err = reply.readInt32(); |
| 118 | if (err == OK) { |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 119 | *node = (node_id)reply.readInt32(); |
Marco Nelissen | 2385887 | 2016-02-17 13:12:13 -0800 | [diff] [blame] | 120 | if (nodeBinder != NULL) { |
| 121 | *nodeBinder = remote(); |
| 122 | } |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 123 | } else { |
| 124 | *node = 0; |
| 125 | } |
| 126 | |
| 127 | return err; |
| 128 | } |
| 129 | |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 130 | virtual status_t freeNode(node_id node) { |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 131 | Parcel data, reply; |
| 132 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 133 | data.writeInt32((int32_t)node); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 134 | remote()->transact(FREE_NODE, data, &reply); |
| 135 | |
| 136 | return reply.readInt32(); |
| 137 | } |
| 138 | |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 139 | virtual status_t sendCommand( |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 140 | node_id node, OMX_COMMANDTYPE cmd, OMX_S32 param) { |
| 141 | Parcel data, reply; |
| 142 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 143 | data.writeInt32((int32_t)node); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 144 | data.writeInt32(cmd); |
| 145 | data.writeInt32(param); |
| 146 | remote()->transact(SEND_COMMAND, data, &reply); |
| 147 | |
| 148 | return reply.readInt32(); |
| 149 | } |
| 150 | |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 151 | virtual status_t getParameter( |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 152 | node_id node, OMX_INDEXTYPE index, |
| 153 | void *params, size_t size) { |
| 154 | Parcel data, reply; |
| 155 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 156 | data.writeInt32((int32_t)node); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 157 | data.writeInt32(index); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 158 | data.writeInt64(size); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 159 | data.write(params, size); |
| 160 | remote()->transact(GET_PARAMETER, data, &reply); |
| 161 | |
| 162 | status_t err = reply.readInt32(); |
| 163 | if (err != OK) { |
| 164 | return err; |
| 165 | } |
| 166 | |
| 167 | reply.read(params, size); |
| 168 | |
| 169 | return OK; |
| 170 | } |
| 171 | |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 172 | virtual status_t setParameter( |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 173 | node_id node, OMX_INDEXTYPE index, |
| 174 | const void *params, size_t size) { |
| 175 | Parcel data, reply; |
| 176 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 177 | data.writeInt32((int32_t)node); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 178 | data.writeInt32(index); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 179 | data.writeInt64(size); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 180 | data.write(params, size); |
| 181 | remote()->transact(SET_PARAMETER, data, &reply); |
| 182 | |
| 183 | return reply.readInt32(); |
| 184 | } |
| 185 | |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 186 | virtual status_t getConfig( |
Andreas Huber | 693d271 | 2009-08-14 14:37:10 -0700 | [diff] [blame] | 187 | node_id node, OMX_INDEXTYPE index, |
| 188 | void *params, size_t size) { |
| 189 | Parcel data, reply; |
| 190 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 191 | data.writeInt32((int32_t)node); |
Andreas Huber | 693d271 | 2009-08-14 14:37:10 -0700 | [diff] [blame] | 192 | data.writeInt32(index); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 193 | data.writeInt64(size); |
Andreas Huber | 693d271 | 2009-08-14 14:37:10 -0700 | [diff] [blame] | 194 | data.write(params, size); |
| 195 | remote()->transact(GET_CONFIG, data, &reply); |
| 196 | |
| 197 | status_t err = reply.readInt32(); |
| 198 | if (err != OK) { |
| 199 | return err; |
| 200 | } |
| 201 | |
| 202 | reply.read(params, size); |
| 203 | |
| 204 | return OK; |
| 205 | } |
| 206 | |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 207 | virtual status_t setConfig( |
Andreas Huber | 693d271 | 2009-08-14 14:37:10 -0700 | [diff] [blame] | 208 | node_id node, OMX_INDEXTYPE index, |
| 209 | const void *params, size_t size) { |
| 210 | Parcel data, reply; |
| 211 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 212 | data.writeInt32((int32_t)node); |
Andreas Huber | 693d271 | 2009-08-14 14:37:10 -0700 | [diff] [blame] | 213 | data.writeInt32(index); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 214 | data.writeInt64(size); |
Andreas Huber | 693d271 | 2009-08-14 14:37:10 -0700 | [diff] [blame] | 215 | data.write(params, size); |
| 216 | remote()->transact(SET_CONFIG, data, &reply); |
| 217 | |
| 218 | return reply.readInt32(); |
| 219 | } |
| 220 | |
Jamie Gennis | b1d666f | 2011-10-19 21:14:13 -0700 | [diff] [blame] | 221 | virtual status_t getState( |
| 222 | node_id node, OMX_STATETYPE* state) { |
| 223 | Parcel data, reply; |
| 224 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 225 | data.writeInt32((int32_t)node); |
Jamie Gennis | b1d666f | 2011-10-19 21:14:13 -0700 | [diff] [blame] | 226 | remote()->transact(GET_STATE, data, &reply); |
| 227 | |
| 228 | *state = static_cast<OMX_STATETYPE>(reply.readInt32()); |
| 229 | return reply.readInt32(); |
| 230 | } |
| 231 | |
Lajos Molnar | a63141a | 2016-02-11 16:40:36 -0800 | [diff] [blame] | 232 | virtual status_t enableNativeBuffers( |
| 233 | node_id node, OMX_U32 port_index, OMX_BOOL graphic, OMX_BOOL enable) { |
Jamie Gennis | 83750ea | 2010-08-30 16:48:38 -0700 | [diff] [blame] | 234 | Parcel data, reply; |
| 235 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 236 | data.writeInt32((int32_t)node); |
Jamie Gennis | 83750ea | 2010-08-30 16:48:38 -0700 | [diff] [blame] | 237 | data.writeInt32(port_index); |
Lajos Molnar | a63141a | 2016-02-11 16:40:36 -0800 | [diff] [blame] | 238 | data.writeInt32((uint32_t)graphic); |
Jamie Gennis | 83750ea | 2010-08-30 16:48:38 -0700 | [diff] [blame] | 239 | data.writeInt32((uint32_t)enable); |
Lajos Molnar | a63141a | 2016-02-11 16:40:36 -0800 | [diff] [blame] | 240 | remote()->transact(ENABLE_NATIVE_BUFFERS, data, &reply); |
Jamie Gennis | 83750ea | 2010-08-30 16:48:38 -0700 | [diff] [blame] | 241 | |
| 242 | status_t err = reply.readInt32(); |
| 243 | return err; |
| 244 | } |
| 245 | |
Jamie Gennis | e2ce645 | 2011-02-23 19:01:28 -0800 | [diff] [blame] | 246 | virtual status_t getGraphicBufferUsage( |
| 247 | node_id node, OMX_U32 port_index, OMX_U32* usage) { |
| 248 | Parcel data, reply; |
| 249 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 250 | data.writeInt32((int32_t)node); |
Jamie Gennis | e2ce645 | 2011-02-23 19:01:28 -0800 | [diff] [blame] | 251 | data.writeInt32(port_index); |
| 252 | remote()->transact(GET_GRAPHIC_BUFFER_USAGE, data, &reply); |
| 253 | |
| 254 | status_t err = reply.readInt32(); |
| 255 | *usage = reply.readInt32(); |
| 256 | return err; |
| 257 | } |
| 258 | |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 259 | virtual status_t useBuffer( |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 260 | node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms, |
Lajos Molnar | cc7cc67 | 2015-06-01 14:58:37 -0700 | [diff] [blame] | 261 | buffer_id *buffer, OMX_U32 allottedSize) { |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 262 | Parcel data, reply; |
| 263 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 264 | data.writeInt32((int32_t)node); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 265 | data.writeInt32(port_index); |
Marco Nelissen | 06b4606 | 2014-11-14 07:58:25 -0800 | [diff] [blame] | 266 | data.writeStrongBinder(IInterface::asBinder(params)); |
Lajos Molnar | cc7cc67 | 2015-06-01 14:58:37 -0700 | [diff] [blame] | 267 | data.writeInt32(allottedSize); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 268 | remote()->transact(USE_BUFFER, data, &reply); |
| 269 | |
| 270 | status_t err = reply.readInt32(); |
| 271 | if (err != OK) { |
| 272 | *buffer = 0; |
| 273 | |
| 274 | return err; |
| 275 | } |
| 276 | |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 277 | *buffer = (buffer_id)reply.readInt32(); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 278 | |
| 279 | return err; |
| 280 | } |
| 281 | |
Jamie Gennis | 83750ea | 2010-08-30 16:48:38 -0700 | [diff] [blame] | 282 | |
| 283 | virtual status_t useGraphicBuffer( |
| 284 | node_id node, OMX_U32 port_index, |
| 285 | const sp<GraphicBuffer> &graphicBuffer, buffer_id *buffer) { |
| 286 | Parcel data, reply; |
| 287 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 288 | data.writeInt32((int32_t)node); |
Jamie Gennis | 83750ea | 2010-08-30 16:48:38 -0700 | [diff] [blame] | 289 | data.writeInt32(port_index); |
| 290 | data.write(*graphicBuffer); |
| 291 | remote()->transact(USE_GRAPHIC_BUFFER, data, &reply); |
| 292 | |
| 293 | status_t err = reply.readInt32(); |
| 294 | if (err != OK) { |
| 295 | *buffer = 0; |
| 296 | |
| 297 | return err; |
| 298 | } |
| 299 | |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 300 | *buffer = (buffer_id)reply.readInt32(); |
Jamie Gennis | 83750ea | 2010-08-30 16:48:38 -0700 | [diff] [blame] | 301 | |
| 302 | return err; |
| 303 | } |
| 304 | |
Lajos Molnar | d071586 | 2013-07-22 12:57:43 -0700 | [diff] [blame] | 305 | virtual status_t updateGraphicBufferInMeta( |
| 306 | node_id node, OMX_U32 port_index, |
| 307 | const sp<GraphicBuffer> &graphicBuffer, buffer_id buffer) { |
| 308 | Parcel data, reply; |
| 309 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 310 | data.writeInt32((int32_t)node); |
Lajos Molnar | d071586 | 2013-07-22 12:57:43 -0700 | [diff] [blame] | 311 | data.writeInt32(port_index); |
| 312 | data.write(*graphicBuffer); |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 313 | data.writeInt32((int32_t)buffer); |
Lajos Molnar | d071586 | 2013-07-22 12:57:43 -0700 | [diff] [blame] | 314 | remote()->transact(UPDATE_GRAPHIC_BUFFER_IN_META, data, &reply); |
| 315 | |
| 316 | status_t err = reply.readInt32(); |
| 317 | return err; |
| 318 | } |
| 319 | |
Lajos Molnar | 7e0bef8 | 2016-05-09 10:48:30 -0700 | [diff] [blame] | 320 | virtual status_t updateNativeHandleInMeta( |
| 321 | node_id node, OMX_U32 port_index, |
| 322 | const sp<NativeHandle> &nativeHandle, buffer_id buffer) { |
| 323 | Parcel data, reply; |
| 324 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
| 325 | data.writeInt32((int32_t)node); |
| 326 | data.writeInt32(port_index); |
| 327 | data.writeInt32(nativeHandle != NULL); |
| 328 | if (nativeHandle != NULL) { |
| 329 | data.writeNativeHandle(nativeHandle->handle()); |
| 330 | } |
| 331 | data.writeInt32((int32_t)buffer); |
| 332 | remote()->transact(UPDATE_NATIVE_HANDLE_IN_META, data, &reply); |
| 333 | |
| 334 | status_t err = reply.readInt32(); |
| 335 | return err; |
| 336 | } |
| 337 | |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 338 | virtual status_t createInputSurface( |
Lajos Molnar | 57fad3c | 2016-03-08 13:09:35 -0800 | [diff] [blame] | 339 | node_id node, OMX_U32 port_index, android_dataspace dataSpace, |
Chong Zhang | 6d332d2 | 2016-09-07 12:06:50 -0700 | [diff] [blame^] | 340 | sp<IGraphicBufferProducer> *bufferProducer, |
| 341 | sp<IGraphicBufferSource> *bufferSource, |
| 342 | MetadataBufferType *type) { |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 343 | Parcel data, reply; |
| 344 | status_t err; |
| 345 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 346 | data.writeInt32((int32_t)node); |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 347 | data.writeInt32(port_index); |
Lajos Molnar | 57fad3c | 2016-03-08 13:09:35 -0800 | [diff] [blame] | 348 | data.writeInt32(dataSpace); |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 349 | err = remote()->transact(CREATE_INPUT_SURFACE, data, &reply); |
| 350 | if (err != OK) { |
| 351 | ALOGW("binder transaction failed: %d", err); |
| 352 | return err; |
| 353 | } |
| 354 | |
Lajos Molnar | 0542198 | 2015-05-15 20:39:14 -0700 | [diff] [blame] | 355 | // read type even if createInputSurface failed |
| 356 | int negotiatedType = reply.readInt32(); |
| 357 | if (type != NULL) { |
| 358 | *type = (MetadataBufferType)negotiatedType; |
| 359 | } |
| 360 | |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 361 | err = reply.readInt32(); |
| 362 | if (err != OK) { |
| 363 | return err; |
| 364 | } |
| 365 | |
| 366 | *bufferProducer = IGraphicBufferProducer::asInterface( |
| 367 | reply.readStrongBinder()); |
Chong Zhang | 6d332d2 | 2016-09-07 12:06:50 -0700 | [diff] [blame^] | 368 | *bufferSource = IGraphicBufferSource::asInterface( |
| 369 | reply.readStrongBinder()); |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 370 | |
| 371 | return err; |
| 372 | } |
| 373 | |
Chong Zhang | d291c22 | 2015-04-30 18:15:52 -0700 | [diff] [blame] | 374 | virtual status_t createPersistentInputSurface( |
| 375 | sp<IGraphicBufferProducer> *bufferProducer, |
| 376 | sp<IGraphicBufferConsumer> *bufferConsumer) { |
| 377 | Parcel data, reply; |
| 378 | status_t err; |
| 379 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
| 380 | err = remote()->transact(CREATE_PERSISTENT_INPUT_SURFACE, data, &reply); |
| 381 | if (err != OK) { |
| 382 | ALOGW("binder transaction failed: %d", err); |
| 383 | return err; |
| 384 | } |
| 385 | |
| 386 | err = reply.readInt32(); |
| 387 | if (err != OK) { |
| 388 | return err; |
| 389 | } |
| 390 | |
| 391 | *bufferProducer = IGraphicBufferProducer::asInterface( |
| 392 | reply.readStrongBinder()); |
| 393 | *bufferConsumer = IGraphicBufferConsumer::asInterface( |
| 394 | reply.readStrongBinder()); |
| 395 | |
| 396 | return err; |
| 397 | } |
| 398 | |
Chong Zhang | 8f469e1 | 2015-05-13 10:21:33 -0700 | [diff] [blame] | 399 | virtual status_t setInputSurface( |
Chong Zhang | d291c22 | 2015-04-30 18:15:52 -0700 | [diff] [blame] | 400 | node_id node, OMX_U32 port_index, |
Chong Zhang | 6d332d2 | 2016-09-07 12:06:50 -0700 | [diff] [blame^] | 401 | const sp<IGraphicBufferConsumer> &bufferConsumer, |
| 402 | sp<IGraphicBufferSource> *bufferSource, |
| 403 | MetadataBufferType *type) { |
Chong Zhang | d291c22 | 2015-04-30 18:15:52 -0700 | [diff] [blame] | 404 | Parcel data, reply; |
| 405 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
| 406 | status_t err; |
| 407 | data.writeInt32((int32_t)node); |
| 408 | data.writeInt32(port_index); |
| 409 | data.writeStrongBinder(IInterface::asBinder(bufferConsumer)); |
| 410 | |
Chong Zhang | 8f469e1 | 2015-05-13 10:21:33 -0700 | [diff] [blame] | 411 | err = remote()->transact(SET_INPUT_SURFACE, data, &reply); |
Chong Zhang | d291c22 | 2015-04-30 18:15:52 -0700 | [diff] [blame] | 412 | |
| 413 | if (err != OK) { |
| 414 | ALOGW("binder transaction failed: %d", err); |
| 415 | return err; |
| 416 | } |
Lajos Molnar | 0542198 | 2015-05-15 20:39:14 -0700 | [diff] [blame] | 417 | |
| 418 | // read type even if setInputSurface failed |
| 419 | int negotiatedType = reply.readInt32(); |
| 420 | if (type != NULL) { |
| 421 | *type = (MetadataBufferType)negotiatedType; |
| 422 | } |
| 423 | |
Chong Zhang | 6d332d2 | 2016-09-07 12:06:50 -0700 | [diff] [blame^] | 424 | err = reply.readInt32(); |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 425 | if (err != OK) { |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 426 | return err; |
| 427 | } |
| 428 | |
Chong Zhang | 6d332d2 | 2016-09-07 12:06:50 -0700 | [diff] [blame^] | 429 | *bufferSource = IGraphicBufferSource::asInterface( |
| 430 | reply.readStrongBinder()); |
| 431 | |
| 432 | return err; |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 433 | } |
| 434 | |
James Dong | e870772 | 2010-10-20 17:38:41 -0700 | [diff] [blame] | 435 | virtual status_t storeMetaDataInBuffers( |
Lajos Molnar | 0542198 | 2015-05-15 20:39:14 -0700 | [diff] [blame] | 436 | node_id node, OMX_U32 port_index, OMX_BOOL enable, MetadataBufferType *type) { |
James Dong | e870772 | 2010-10-20 17:38:41 -0700 | [diff] [blame] | 437 | Parcel data, reply; |
| 438 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 439 | data.writeInt32((int32_t)node); |
James Dong | e870772 | 2010-10-20 17:38:41 -0700 | [diff] [blame] | 440 | data.writeInt32(port_index); |
Lajos Molnar | 3e32878 | 2016-05-09 10:56:46 -0700 | [diff] [blame] | 441 | data.writeInt32((int32_t)enable); |
| 442 | data.writeInt32(type == NULL ? kMetadataBufferTypeANWBuffer : *type); |
| 443 | |
James Dong | e870772 | 2010-10-20 17:38:41 -0700 | [diff] [blame] | 444 | remote()->transact(STORE_META_DATA_IN_BUFFERS, data, &reply); |
| 445 | |
Lajos Molnar | 0542198 | 2015-05-15 20:39:14 -0700 | [diff] [blame] | 446 | // read type even storeMetaDataInBuffers failed |
| 447 | int negotiatedType = reply.readInt32(); |
| 448 | if (type != NULL) { |
| 449 | *type = (MetadataBufferType)negotiatedType; |
| 450 | } |
| 451 | |
| 452 | return reply.readInt32(); |
James Dong | e870772 | 2010-10-20 17:38:41 -0700 | [diff] [blame] | 453 | } |
| 454 | |
Lajos Molnar | 56ce726 | 2013-05-02 16:30:48 -0700 | [diff] [blame] | 455 | virtual status_t prepareForAdaptivePlayback( |
| 456 | node_id node, OMX_U32 port_index, OMX_BOOL enable, |
| 457 | OMX_U32 max_width, OMX_U32 max_height) { |
| 458 | Parcel data, reply; |
| 459 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 460 | data.writeInt32((int32_t)node); |
Lajos Molnar | 56ce726 | 2013-05-02 16:30:48 -0700 | [diff] [blame] | 461 | data.writeInt32(port_index); |
| 462 | data.writeInt32((int32_t)enable); |
| 463 | data.writeInt32(max_width); |
| 464 | data.writeInt32(max_height); |
| 465 | remote()->transact(PREPARE_FOR_ADAPTIVE_PLAYBACK, data, &reply); |
| 466 | |
| 467 | status_t err = reply.readInt32(); |
| 468 | return err; |
| 469 | } |
| 470 | |
Rachad | 5a446aa | 2014-07-29 16:47:56 -0700 | [diff] [blame] | 471 | virtual status_t configureVideoTunnelMode( |
| 472 | node_id node, OMX_U32 portIndex, OMX_BOOL tunneled, |
| 473 | OMX_U32 audioHwSync, native_handle_t **sidebandHandle ) { |
| 474 | Parcel data, reply; |
| 475 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
| 476 | data.writeInt32((int32_t)node); |
| 477 | data.writeInt32(portIndex); |
| 478 | data.writeInt32((int32_t)tunneled); |
| 479 | data.writeInt32(audioHwSync); |
| 480 | remote()->transact(CONFIGURE_VIDEO_TUNNEL_MODE, data, &reply); |
| 481 | |
| 482 | status_t err = reply.readInt32(); |
mspector@google.com | 9d72eb0 | 2016-02-08 10:56:13 -0800 | [diff] [blame] | 483 | if (err == OK && sidebandHandle) { |
Rachad | 5a446aa | 2014-07-29 16:47:56 -0700 | [diff] [blame] | 484 | *sidebandHandle = (native_handle_t *)reply.readNativeHandle(); |
| 485 | } |
| 486 | return err; |
| 487 | } |
| 488 | |
| 489 | |
Lajos Molnar | a63141a | 2016-02-11 16:40:36 -0800 | [diff] [blame] | 490 | virtual status_t allocateSecureBuffer( |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 491 | node_id node, OMX_U32 port_index, size_t size, |
Lajos Molnar | 1b40f28 | 2016-05-09 22:24:52 -0700 | [diff] [blame] | 492 | buffer_id *buffer, void **buffer_data, sp<NativeHandle> *native_handle) { |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 493 | Parcel data, reply; |
| 494 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 495 | data.writeInt32((int32_t)node); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 496 | data.writeInt32(port_index); |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 497 | data.writeInt64(size); |
Lajos Molnar | a63141a | 2016-02-11 16:40:36 -0800 | [diff] [blame] | 498 | remote()->transact(ALLOC_SECURE_BUFFER, data, &reply); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 499 | |
| 500 | status_t err = reply.readInt32(); |
| 501 | if (err != OK) { |
| 502 | *buffer = 0; |
Lajos Molnar | a63141a | 2016-02-11 16:40:36 -0800 | [diff] [blame] | 503 | *buffer_data = NULL; |
| 504 | *native_handle = NULL; |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 505 | return err; |
| 506 | } |
| 507 | |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 508 | *buffer = (buffer_id)reply.readInt32(); |
| 509 | *buffer_data = (void *)reply.readInt64(); |
Lajos Molnar | a63141a | 2016-02-11 16:40:36 -0800 | [diff] [blame] | 510 | if (*buffer_data == NULL) { |
Lajos Molnar | 1b40f28 | 2016-05-09 22:24:52 -0700 | [diff] [blame] | 511 | *native_handle = NativeHandle::create( |
| 512 | reply.readNativeHandle(), true /* ownsHandle */); |
Lajos Molnar | a63141a | 2016-02-11 16:40:36 -0800 | [diff] [blame] | 513 | } else { |
| 514 | *native_handle = NULL; |
| 515 | } |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 516 | return err; |
| 517 | } |
| 518 | |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 519 | virtual status_t allocateBufferWithBackup( |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 520 | node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms, |
Lajos Molnar | cc7cc67 | 2015-06-01 14:58:37 -0700 | [diff] [blame] | 521 | buffer_id *buffer, OMX_U32 allottedSize) { |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 522 | Parcel data, reply; |
| 523 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 524 | data.writeInt32((int32_t)node); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 525 | data.writeInt32(port_index); |
Marco Nelissen | 06b4606 | 2014-11-14 07:58:25 -0800 | [diff] [blame] | 526 | data.writeStrongBinder(IInterface::asBinder(params)); |
Lajos Molnar | cc7cc67 | 2015-06-01 14:58:37 -0700 | [diff] [blame] | 527 | data.writeInt32(allottedSize); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 528 | remote()->transact(ALLOC_BUFFER_WITH_BACKUP, data, &reply); |
| 529 | |
| 530 | status_t err = reply.readInt32(); |
| 531 | if (err != OK) { |
| 532 | *buffer = 0; |
| 533 | |
| 534 | return err; |
| 535 | } |
| 536 | |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 537 | *buffer = (buffer_id)reply.readInt32(); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 538 | |
| 539 | return err; |
| 540 | } |
| 541 | |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 542 | virtual status_t freeBuffer( |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 543 | node_id node, OMX_U32 port_index, buffer_id buffer) { |
| 544 | Parcel data, reply; |
| 545 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 546 | data.writeInt32((int32_t)node); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 547 | data.writeInt32(port_index); |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 548 | data.writeInt32((int32_t)buffer); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 549 | remote()->transact(FREE_BUFFER, data, &reply); |
| 550 | |
| 551 | return reply.readInt32(); |
| 552 | } |
| 553 | |
Lajos Molnar | 15ab499 | 2015-06-01 10:54:31 -0700 | [diff] [blame] | 554 | virtual status_t fillBuffer(node_id node, buffer_id buffer, int fenceFd) { |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 555 | Parcel data, reply; |
| 556 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 557 | data.writeInt32((int32_t)node); |
| 558 | data.writeInt32((int32_t)buffer); |
Lajos Molnar | 15ab499 | 2015-06-01 10:54:31 -0700 | [diff] [blame] | 559 | data.writeInt32(fenceFd >= 0); |
| 560 | if (fenceFd >= 0) { |
| 561 | data.writeFileDescriptor(fenceFd, true /* takeOwnership */); |
| 562 | } |
Andreas Huber | 36efa03 | 2009-10-08 11:02:27 -0700 | [diff] [blame] | 563 | remote()->transact(FILL_BUFFER, data, &reply); |
| 564 | |
| 565 | return reply.readInt32(); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 566 | } |
| 567 | |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 568 | virtual status_t emptyBuffer( |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 569 | node_id node, |
| 570 | buffer_id buffer, |
| 571 | OMX_U32 range_offset, OMX_U32 range_length, |
Lajos Molnar | 15ab499 | 2015-06-01 10:54:31 -0700 | [diff] [blame] | 572 | OMX_U32 flags, OMX_TICKS timestamp, int fenceFd) { |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 573 | Parcel data, reply; |
| 574 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 575 | data.writeInt32((int32_t)node); |
| 576 | data.writeInt32((int32_t)buffer); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 577 | data.writeInt32(range_offset); |
| 578 | data.writeInt32(range_length); |
| 579 | data.writeInt32(flags); |
| 580 | data.writeInt64(timestamp); |
Lajos Molnar | 15ab499 | 2015-06-01 10:54:31 -0700 | [diff] [blame] | 581 | data.writeInt32(fenceFd >= 0); |
| 582 | if (fenceFd >= 0) { |
| 583 | data.writeFileDescriptor(fenceFd, true /* takeOwnership */); |
| 584 | } |
Andreas Huber | 36efa03 | 2009-10-08 11:02:27 -0700 | [diff] [blame] | 585 | remote()->transact(EMPTY_BUFFER, data, &reply); |
| 586 | |
| 587 | return reply.readInt32(); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 588 | } |
Andreas Huber | 8b938cd | 2009-07-31 11:52:50 -0700 | [diff] [blame] | 589 | |
Chong Zhang | 6cf9a12 | 2016-09-08 23:25:52 -0700 | [diff] [blame] | 590 | virtual status_t emptyGraphicBuffer( |
| 591 | node_id node, |
| 592 | buffer_id buffer, |
Chong Zhang | 6d332d2 | 2016-09-07 12:06:50 -0700 | [diff] [blame^] | 593 | const sp<GraphicBuffer> &graphicBuffer, OMX_U32 flags, |
| 594 | OMX_TICKS timestamp, OMX_TICKS origTimestamp, int fenceFd) { |
Chong Zhang | 6cf9a12 | 2016-09-08 23:25:52 -0700 | [diff] [blame] | 595 | Parcel data, reply; |
| 596 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
| 597 | data.writeInt32((int32_t)node); |
| 598 | data.writeInt32((int32_t)buffer); |
| 599 | data.write(*graphicBuffer); |
| 600 | data.writeInt32(flags); |
| 601 | data.writeInt64(timestamp); |
Chong Zhang | 6d332d2 | 2016-09-07 12:06:50 -0700 | [diff] [blame^] | 602 | data.writeInt64(origTimestamp); |
Chong Zhang | 6cf9a12 | 2016-09-08 23:25:52 -0700 | [diff] [blame] | 603 | data.writeInt32(fenceFd >= 0); |
| 604 | if (fenceFd >= 0) { |
| 605 | data.writeFileDescriptor(fenceFd, true /* takeOwnership */); |
| 606 | } |
| 607 | remote()->transact(EMPTY_GRAPHIC_BUFFER, data, &reply); |
| 608 | |
| 609 | return reply.readInt32(); |
| 610 | } |
| 611 | |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 612 | virtual status_t getExtensionIndex( |
Andreas Huber | 693d271 | 2009-08-14 14:37:10 -0700 | [diff] [blame] | 613 | node_id node, |
| 614 | const char *parameter_name, |
| 615 | OMX_INDEXTYPE *index) { |
| 616 | Parcel data, reply; |
| 617 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 618 | data.writeInt32((int32_t)node); |
Andreas Huber | 693d271 | 2009-08-14 14:37:10 -0700 | [diff] [blame] | 619 | data.writeCString(parameter_name); |
| 620 | |
| 621 | remote()->transact(GET_EXTENSION_INDEX, data, &reply); |
| 622 | |
| 623 | status_t err = reply.readInt32(); |
| 624 | if (err == OK) { |
| 625 | *index = static_cast<OMX_INDEXTYPE>(reply.readInt32()); |
| 626 | } else { |
| 627 | *index = OMX_IndexComponentStartUnused; |
| 628 | } |
| 629 | |
| 630 | return err; |
| 631 | } |
Andreas Huber | e40cda7 | 2013-07-17 13:55:26 -0700 | [diff] [blame] | 632 | |
Chong Zhang | 6cf9a12 | 2016-09-08 23:25:52 -0700 | [diff] [blame] | 633 | virtual status_t dispatchMessage(const omx_message &msg) { |
| 634 | Parcel data, reply; |
| 635 | data.writeInterfaceToken(IOMX::getInterfaceDescriptor()); |
| 636 | data.writeInt32((int32_t)msg.node); |
| 637 | data.writeInt32(msg.fenceFd >= 0); |
| 638 | if (msg.fenceFd >= 0) { |
| 639 | data.writeFileDescriptor(msg.fenceFd, true /* takeOwnership */); |
| 640 | } |
| 641 | data.writeInt32(msg.type); |
| 642 | data.write(&msg.u, sizeof(msg.u)); |
| 643 | |
| 644 | remote()->transact(DISPATCH_MESSAGE, data, &reply); |
| 645 | |
| 646 | return reply.readInt32(); |
| 647 | } |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 648 | }; |
| 649 | |
| 650 | IMPLEMENT_META_INTERFACE(OMX, "android.hardware.IOMX"); |
| 651 | |
| 652 | //////////////////////////////////////////////////////////////////////////////// |
| 653 | |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 654 | #define CHECK_OMX_INTERFACE(interface, data, reply) \ |
Chih-Hung Hsieh | 83fbbb8 | 2016-05-17 15:08:10 -0700 | [diff] [blame] | 655 | do { if (!(data).enforceInterface(interface::getInterfaceDescriptor())) { \ |
Steve Block | 5ff1dd5 | 2012-01-05 23:22:43 +0000 | [diff] [blame] | 656 | ALOGW("Call incorrectly routed to " #interface); \ |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 657 | return PERMISSION_DENIED; \ |
| 658 | } } while (0) |
| 659 | |
| 660 | status_t BnOMX::onTransact( |
| 661 | uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) { |
| 662 | switch (code) { |
Andreas Huber | 7eaa9c9 | 2010-01-15 15:28:19 -0800 | [diff] [blame] | 663 | case LIVES_LOCALLY: |
| 664 | { |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 665 | CHECK_OMX_INTERFACE(IOMX, data, reply); |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 666 | node_id node = (node_id)data.readInt32(); |
Andreas Huber | d459b48 | 2012-01-31 11:16:24 -0800 | [diff] [blame] | 667 | pid_t pid = (pid_t)data.readInt32(); |
| 668 | reply->writeInt32(livesLocally(node, pid)); |
Andreas Huber | 7eaa9c9 | 2010-01-15 15:28:19 -0800 | [diff] [blame] | 669 | |
| 670 | return OK; |
| 671 | } |
| 672 | |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 673 | case LIST_NODES: |
| 674 | { |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 675 | CHECK_OMX_INTERFACE(IOMX, data, reply); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 676 | |
Andreas Huber | 134ee6a | 2009-12-16 09:30:55 -0800 | [diff] [blame] | 677 | List<ComponentInfo> list; |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 678 | listNodes(&list); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 679 | |
| 680 | reply->writeInt32(list.size()); |
Andreas Huber | 134ee6a | 2009-12-16 09:30:55 -0800 | [diff] [blame] | 681 | for (List<ComponentInfo>::iterator it = list.begin(); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 682 | it != list.end(); ++it) { |
Andreas Huber | 134ee6a | 2009-12-16 09:30:55 -0800 | [diff] [blame] | 683 | ComponentInfo &cur = *it; |
| 684 | |
| 685 | reply->writeString8(cur.mName); |
| 686 | reply->writeInt32(cur.mRoles.size()); |
| 687 | for (List<String8>::iterator role_it = cur.mRoles.begin(); |
| 688 | role_it != cur.mRoles.end(); ++role_it) { |
| 689 | reply->writeString8(*role_it); |
| 690 | } |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 691 | } |
| 692 | |
| 693 | return NO_ERROR; |
| 694 | } |
| 695 | |
| 696 | case ALLOCATE_NODE: |
| 697 | { |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 698 | CHECK_OMX_INTERFACE(IOMX, data, reply); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 699 | |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 700 | const char *name = data.readCString(); |
| 701 | |
| 702 | sp<IOMXObserver> observer = |
| 703 | interface_cast<IOMXObserver>(data.readStrongBinder()); |
| 704 | |
Wei Jia | 56c95c9 | 2016-01-06 10:30:46 -0800 | [diff] [blame] | 705 | if (name == NULL || observer == NULL) { |
| 706 | ALOGE("b/26392700"); |
| 707 | reply->writeInt32(INVALID_OPERATION); |
| 708 | return NO_ERROR; |
| 709 | } |
| 710 | |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 711 | node_id node; |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 712 | |
Marco Nelissen | 2385887 | 2016-02-17 13:12:13 -0800 | [diff] [blame] | 713 | status_t err = allocateNode(name, observer, |
| 714 | NULL /* nodeBinder */, &node); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 715 | reply->writeInt32(err); |
| 716 | if (err == OK) { |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 717 | reply->writeInt32((int32_t)node); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 718 | } |
Andreas Huber | 7eaa9c9 | 2010-01-15 15:28:19 -0800 | [diff] [blame] | 719 | |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 720 | return NO_ERROR; |
| 721 | } |
| 722 | |
| 723 | case FREE_NODE: |
| 724 | { |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 725 | CHECK_OMX_INTERFACE(IOMX, data, reply); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 726 | |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 727 | node_id node = (node_id)data.readInt32(); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 728 | |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 729 | reply->writeInt32(freeNode(node)); |
Andreas Huber | 7eaa9c9 | 2010-01-15 15:28:19 -0800 | [diff] [blame] | 730 | |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 731 | return NO_ERROR; |
| 732 | } |
| 733 | |
| 734 | case SEND_COMMAND: |
| 735 | { |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 736 | CHECK_OMX_INTERFACE(IOMX, data, reply); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 737 | |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 738 | node_id node = (node_id)data.readInt32(); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 739 | |
| 740 | OMX_COMMANDTYPE cmd = |
| 741 | static_cast<OMX_COMMANDTYPE>(data.readInt32()); |
| 742 | |
| 743 | OMX_S32 param = data.readInt32(); |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 744 | reply->writeInt32(sendCommand(node, cmd, param)); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 745 | |
| 746 | return NO_ERROR; |
| 747 | } |
| 748 | |
| 749 | case GET_PARAMETER: |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 750 | case SET_PARAMETER: |
Andreas Huber | 693d271 | 2009-08-14 14:37:10 -0700 | [diff] [blame] | 751 | case GET_CONFIG: |
Andreas Huber | 693d271 | 2009-08-14 14:37:10 -0700 | [diff] [blame] | 752 | case SET_CONFIG: |
| 753 | { |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 754 | CHECK_OMX_INTERFACE(IOMX, data, reply); |
Andreas Huber | 693d271 | 2009-08-14 14:37:10 -0700 | [diff] [blame] | 755 | |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 756 | node_id node = (node_id)data.readInt32(); |
Andreas Huber | 693d271 | 2009-08-14 14:37:10 -0700 | [diff] [blame] | 757 | OMX_INDEXTYPE index = static_cast<OMX_INDEXTYPE>(data.readInt32()); |
| 758 | |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 759 | size_t size = data.readInt64(); |
Andreas Huber | 693d271 | 2009-08-14 14:37:10 -0700 | [diff] [blame] | 760 | |
Marco Nelissen | 2720c8b | 2016-02-29 12:47:20 -0800 | [diff] [blame] | 761 | status_t err = NOT_ENOUGH_DATA; |
| 762 | void *params = NULL; |
| 763 | size_t pageSize = 0; |
| 764 | size_t allocSize = 0; |
Marco Nelissen | 788b0b6 | 2016-03-21 11:31:53 -0700 | [diff] [blame] | 765 | bool isUsageBits = (index == (OMX_INDEXTYPE) OMX_IndexParamConsumerUsageBits); |
Chong Zhang | 6d332d2 | 2016-09-07 12:06:50 -0700 | [diff] [blame^] | 766 | if ((isUsageBits && size < 4) || (!isUsageBits && size < 8)) { |
Marco Nelissen | 2720c8b | 2016-02-29 12:47:20 -0800 | [diff] [blame] | 767 | // we expect the structure to contain at least the size and |
| 768 | // version, 8 bytes total |
Marco Nelissen | 788b0b6 | 2016-03-21 11:31:53 -0700 | [diff] [blame] | 769 | ALOGE("b/27207275 (%zu) (%d/%d)", size, int(index), int(code)); |
Marco Nelissen | 2720c8b | 2016-02-29 12:47:20 -0800 | [diff] [blame] | 770 | android_errorWriteLog(0x534e4554, "27207275"); |
| 771 | } else { |
| 772 | err = NO_MEMORY; |
| 773 | pageSize = (size_t) sysconf(_SC_PAGE_SIZE); |
| 774 | if (size > SIZE_MAX - (pageSize * 2)) { |
| 775 | ALOGE("requested param size too big"); |
Marco Nelissen | f7a3882 | 2016-02-22 13:05:15 -0800 | [diff] [blame] | 776 | } else { |
Marco Nelissen | 2720c8b | 2016-02-29 12:47:20 -0800 | [diff] [blame] | 777 | allocSize = (size + pageSize * 2) & ~(pageSize - 1); |
| 778 | params = mmap(NULL, allocSize, PROT_READ | PROT_WRITE, |
| 779 | MAP_PRIVATE | MAP_ANONYMOUS, -1 /* fd */, 0 /* offset */); |
| 780 | } |
| 781 | if (params != MAP_FAILED) { |
| 782 | err = data.read(params, size); |
| 783 | if (err != OK) { |
| 784 | android_errorWriteLog(0x534e4554, "26914474"); |
| 785 | } else { |
| 786 | err = NOT_ENOUGH_DATA; |
| 787 | OMX_U32 declaredSize = *(OMX_U32*)params; |
Chong Zhang | 6d332d2 | 2016-09-07 12:06:50 -0700 | [diff] [blame^] | 788 | if (index != (OMX_INDEXTYPE) OMX_IndexParamConsumerUsageBits && |
Marco Nelissen | c1c50e7 | 2016-03-10 15:02:13 -0800 | [diff] [blame] | 789 | declaredSize > size) { |
Marco Nelissen | 2720c8b | 2016-02-29 12:47:20 -0800 | [diff] [blame] | 790 | // the buffer says it's bigger than it actually is |
| 791 | ALOGE("b/27207275 (%u/%zu)", declaredSize, size); |
| 792 | android_errorWriteLog(0x534e4554, "27207275"); |
| 793 | } else { |
| 794 | // mark the last page as inaccessible, to avoid exploitation |
| 795 | // of codecs that access past the end of the allocation because |
| 796 | // they didn't check the size |
Marco Nelissen | 866c800 | 2016-09-20 13:36:40 -0700 | [diff] [blame] | 797 | if (mprotect((char*)params + allocSize - pageSize, pageSize, |
| 798 | PROT_NONE) != 0) { |
| 799 | ALOGE("mprotect failed: %s", strerror(errno)); |
| 800 | } else { |
| 801 | switch (code) { |
| 802 | case GET_PARAMETER: |
| 803 | err = getParameter(node, index, params, size); |
| 804 | break; |
| 805 | case SET_PARAMETER: |
| 806 | err = setParameter(node, index, params, size); |
| 807 | break; |
| 808 | case GET_CONFIG: |
| 809 | err = getConfig(node, index, params, size); |
| 810 | break; |
| 811 | case SET_CONFIG: |
| 812 | err = setConfig(node, index, params, size); |
| 813 | break; |
Marco Nelissen | 866c800 | 2016-09-20 13:36:40 -0700 | [diff] [blame] | 814 | default: |
| 815 | TRESPASS(); |
Marco Nelissen | 2720c8b | 2016-02-29 12:47:20 -0800 | [diff] [blame] | 816 | } |
Marco Nelissen | 2720c8b | 2016-02-29 12:47:20 -0800 | [diff] [blame] | 817 | } |
Marco Nelissen | f7a3882 | 2016-02-22 13:05:15 -0800 | [diff] [blame] | 818 | } |
Marco Nelissen | f7a3882 | 2016-02-22 13:05:15 -0800 | [diff] [blame] | 819 | } |
Marco Nelissen | 2720c8b | 2016-02-29 12:47:20 -0800 | [diff] [blame] | 820 | } else { |
| 821 | ALOGE("couldn't map: %s", strerror(errno)); |
Andreas Huber | e40cda7 | 2013-07-17 13:55:26 -0700 | [diff] [blame] | 822 | } |
Andreas Huber | b391290 | 2011-01-19 10:34:52 -0800 | [diff] [blame] | 823 | } |
| 824 | |
| 825 | reply->writeInt32(err); |
| 826 | |
| 827 | if ((code == GET_PARAMETER || code == GET_CONFIG) && err == OK) { |
| 828 | reply->write(params, size); |
| 829 | } |
| 830 | |
Marco Nelissen | 2720c8b | 2016-02-29 12:47:20 -0800 | [diff] [blame] | 831 | if (params) { |
| 832 | munmap(params, allocSize); |
| 833 | } |
Andreas Huber | b391290 | 2011-01-19 10:34:52 -0800 | [diff] [blame] | 834 | params = NULL; |
Andreas Huber | 693d271 | 2009-08-14 14:37:10 -0700 | [diff] [blame] | 835 | |
| 836 | return NO_ERROR; |
| 837 | } |
| 838 | |
Jamie Gennis | b1d666f | 2011-10-19 21:14:13 -0700 | [diff] [blame] | 839 | case GET_STATE: |
| 840 | { |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 841 | CHECK_OMX_INTERFACE(IOMX, data, reply); |
Jamie Gennis | b1d666f | 2011-10-19 21:14:13 -0700 | [diff] [blame] | 842 | |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 843 | node_id node = (node_id)data.readInt32(); |
Jamie Gennis | b1d666f | 2011-10-19 21:14:13 -0700 | [diff] [blame] | 844 | OMX_STATETYPE state = OMX_StateInvalid; |
| 845 | |
| 846 | status_t err = getState(node, &state); |
| 847 | reply->writeInt32(state); |
| 848 | reply->writeInt32(err); |
| 849 | |
| 850 | return NO_ERROR; |
| 851 | } |
| 852 | |
Lajos Molnar | a63141a | 2016-02-11 16:40:36 -0800 | [diff] [blame] | 853 | case ENABLE_NATIVE_BUFFERS: |
Jamie Gennis | 83750ea | 2010-08-30 16:48:38 -0700 | [diff] [blame] | 854 | { |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 855 | CHECK_OMX_INTERFACE(IOMX, data, reply); |
Jamie Gennis | 83750ea | 2010-08-30 16:48:38 -0700 | [diff] [blame] | 856 | |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 857 | node_id node = (node_id)data.readInt32(); |
Jamie Gennis | 83750ea | 2010-08-30 16:48:38 -0700 | [diff] [blame] | 858 | OMX_U32 port_index = data.readInt32(); |
Lajos Molnar | a63141a | 2016-02-11 16:40:36 -0800 | [diff] [blame] | 859 | OMX_BOOL graphic = (OMX_BOOL)data.readInt32(); |
Jamie Gennis | 83750ea | 2010-08-30 16:48:38 -0700 | [diff] [blame] | 860 | OMX_BOOL enable = (OMX_BOOL)data.readInt32(); |
| 861 | |
Lajos Molnar | a63141a | 2016-02-11 16:40:36 -0800 | [diff] [blame] | 862 | status_t err = enableNativeBuffers(node, port_index, graphic, enable); |
Jamie Gennis | 83750ea | 2010-08-30 16:48:38 -0700 | [diff] [blame] | 863 | reply->writeInt32(err); |
| 864 | |
| 865 | return NO_ERROR; |
| 866 | } |
| 867 | |
Jamie Gennis | e2ce645 | 2011-02-23 19:01:28 -0800 | [diff] [blame] | 868 | case GET_GRAPHIC_BUFFER_USAGE: |
| 869 | { |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 870 | CHECK_OMX_INTERFACE(IOMX, data, reply); |
Jamie Gennis | e2ce645 | 2011-02-23 19:01:28 -0800 | [diff] [blame] | 871 | |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 872 | node_id node = (node_id)data.readInt32(); |
Jamie Gennis | e2ce645 | 2011-02-23 19:01:28 -0800 | [diff] [blame] | 873 | OMX_U32 port_index = data.readInt32(); |
| 874 | |
| 875 | OMX_U32 usage = 0; |
| 876 | status_t err = getGraphicBufferUsage(node, port_index, &usage); |
| 877 | reply->writeInt32(err); |
| 878 | reply->writeInt32(usage); |
| 879 | |
| 880 | return NO_ERROR; |
| 881 | } |
| 882 | |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 883 | case USE_BUFFER: |
| 884 | { |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 885 | CHECK_OMX_INTERFACE(IOMX, data, reply); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 886 | |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 887 | node_id node = (node_id)data.readInt32(); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 888 | OMX_U32 port_index = data.readInt32(); |
| 889 | sp<IMemory> params = |
| 890 | interface_cast<IMemory>(data.readStrongBinder()); |
Lajos Molnar | cc7cc67 | 2015-06-01 14:58:37 -0700 | [diff] [blame] | 891 | OMX_U32 allottedSize = data.readInt32(); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 892 | |
Wei Jia | 56c95c9 | 2016-01-06 10:30:46 -0800 | [diff] [blame] | 893 | if (params == NULL) { |
| 894 | ALOGE("b/26392700"); |
| 895 | reply->writeInt32(INVALID_OPERATION); |
| 896 | return NO_ERROR; |
| 897 | } |
| 898 | |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 899 | buffer_id buffer; |
Lajos Molnar | cc7cc67 | 2015-06-01 14:58:37 -0700 | [diff] [blame] | 900 | status_t err = useBuffer(node, port_index, params, &buffer, allottedSize); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 901 | reply->writeInt32(err); |
| 902 | |
| 903 | if (err == OK) { |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 904 | reply->writeInt32((int32_t)buffer); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 905 | } |
| 906 | |
| 907 | return NO_ERROR; |
| 908 | } |
| 909 | |
Jamie Gennis | 83750ea | 2010-08-30 16:48:38 -0700 | [diff] [blame] | 910 | case USE_GRAPHIC_BUFFER: |
| 911 | { |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 912 | CHECK_OMX_INTERFACE(IOMX, data, reply); |
Jamie Gennis | 83750ea | 2010-08-30 16:48:38 -0700 | [diff] [blame] | 913 | |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 914 | node_id node = (node_id)data.readInt32(); |
Jamie Gennis | 83750ea | 2010-08-30 16:48:38 -0700 | [diff] [blame] | 915 | OMX_U32 port_index = data.readInt32(); |
| 916 | sp<GraphicBuffer> graphicBuffer = new GraphicBuffer(); |
| 917 | data.read(*graphicBuffer); |
| 918 | |
| 919 | buffer_id buffer; |
| 920 | status_t err = useGraphicBuffer( |
| 921 | node, port_index, graphicBuffer, &buffer); |
| 922 | reply->writeInt32(err); |
| 923 | |
| 924 | if (err == OK) { |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 925 | reply->writeInt32((int32_t)buffer); |
Jamie Gennis | 83750ea | 2010-08-30 16:48:38 -0700 | [diff] [blame] | 926 | } |
| 927 | |
| 928 | return NO_ERROR; |
| 929 | } |
| 930 | |
Lajos Molnar | d071586 | 2013-07-22 12:57:43 -0700 | [diff] [blame] | 931 | case UPDATE_GRAPHIC_BUFFER_IN_META: |
| 932 | { |
| 933 | CHECK_OMX_INTERFACE(IOMX, data, reply); |
| 934 | |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 935 | node_id node = (node_id)data.readInt32(); |
Lajos Molnar | d071586 | 2013-07-22 12:57:43 -0700 | [diff] [blame] | 936 | OMX_U32 port_index = data.readInt32(); |
| 937 | sp<GraphicBuffer> graphicBuffer = new GraphicBuffer(); |
| 938 | data.read(*graphicBuffer); |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 939 | buffer_id buffer = (buffer_id)data.readInt32(); |
Lajos Molnar | d071586 | 2013-07-22 12:57:43 -0700 | [diff] [blame] | 940 | |
| 941 | status_t err = updateGraphicBufferInMeta( |
| 942 | node, port_index, graphicBuffer, buffer); |
| 943 | reply->writeInt32(err); |
| 944 | |
| 945 | return NO_ERROR; |
| 946 | } |
| 947 | |
Lajos Molnar | 7e0bef8 | 2016-05-09 10:48:30 -0700 | [diff] [blame] | 948 | case UPDATE_NATIVE_HANDLE_IN_META: |
| 949 | { |
| 950 | CHECK_OMX_INTERFACE(IOMX, data, reply); |
| 951 | |
| 952 | node_id node = (node_id)data.readInt32(); |
| 953 | OMX_U32 port_index = data.readInt32(); |
| 954 | native_handle *handle = NULL; |
| 955 | if (data.readInt32()) { |
| 956 | handle = data.readNativeHandle(); |
| 957 | } |
| 958 | buffer_id buffer = (buffer_id)data.readInt32(); |
| 959 | |
| 960 | status_t err = updateNativeHandleInMeta( |
| 961 | node, port_index, NativeHandle::create(handle, true /* ownshandle */), buffer); |
| 962 | reply->writeInt32(err); |
| 963 | |
| 964 | return NO_ERROR; |
| 965 | } |
| 966 | |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 967 | case CREATE_INPUT_SURFACE: |
| 968 | { |
| 969 | CHECK_OMX_INTERFACE(IOMX, data, reply); |
| 970 | |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 971 | node_id node = (node_id)data.readInt32(); |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 972 | OMX_U32 port_index = data.readInt32(); |
Lajos Molnar | 57fad3c | 2016-03-08 13:09:35 -0800 | [diff] [blame] | 973 | android_dataspace dataSpace = (android_dataspace)data.readInt32(); |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 974 | |
| 975 | sp<IGraphicBufferProducer> bufferProducer; |
Chong Zhang | 6d332d2 | 2016-09-07 12:06:50 -0700 | [diff] [blame^] | 976 | sp<IGraphicBufferSource> bufferSource; |
mspector@google.com | da9ca91 | 2016-02-08 17:07:06 -0800 | [diff] [blame] | 977 | MetadataBufferType type = kMetadataBufferTypeInvalid; |
Chong Zhang | 6d332d2 | 2016-09-07 12:06:50 -0700 | [diff] [blame^] | 978 | status_t err = createInputSurface( |
| 979 | node, port_index, dataSpace, &bufferProducer, &bufferSource, &type); |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 980 | |
mspector@google.com | da9ca91 | 2016-02-08 17:07:06 -0800 | [diff] [blame] | 981 | if ((err != OK) && (type == kMetadataBufferTypeInvalid)) { |
| 982 | android_errorWriteLog(0x534e4554, "26324358"); |
| 983 | } |
| 984 | |
Lajos Molnar | 0542198 | 2015-05-15 20:39:14 -0700 | [diff] [blame] | 985 | reply->writeInt32(type); |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 986 | reply->writeInt32(err); |
| 987 | |
| 988 | if (err == OK) { |
Marco Nelissen | 06b4606 | 2014-11-14 07:58:25 -0800 | [diff] [blame] | 989 | reply->writeStrongBinder(IInterface::asBinder(bufferProducer)); |
Chong Zhang | 6d332d2 | 2016-09-07 12:06:50 -0700 | [diff] [blame^] | 990 | reply->writeStrongBinder(IInterface::asBinder(bufferSource)); |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 991 | } |
| 992 | |
| 993 | return NO_ERROR; |
| 994 | } |
| 995 | |
Chong Zhang | d291c22 | 2015-04-30 18:15:52 -0700 | [diff] [blame] | 996 | case CREATE_PERSISTENT_INPUT_SURFACE: |
| 997 | { |
| 998 | CHECK_OMX_INTERFACE(IOMX, data, reply); |
| 999 | |
| 1000 | sp<IGraphicBufferProducer> bufferProducer; |
| 1001 | sp<IGraphicBufferConsumer> bufferConsumer; |
| 1002 | status_t err = createPersistentInputSurface( |
| 1003 | &bufferProducer, &bufferConsumer); |
| 1004 | |
| 1005 | reply->writeInt32(err); |
| 1006 | |
| 1007 | if (err == OK) { |
| 1008 | reply->writeStrongBinder(IInterface::asBinder(bufferProducer)); |
| 1009 | reply->writeStrongBinder(IInterface::asBinder(bufferConsumer)); |
| 1010 | } |
| 1011 | |
| 1012 | return NO_ERROR; |
| 1013 | } |
| 1014 | |
Chong Zhang | 8f469e1 | 2015-05-13 10:21:33 -0700 | [diff] [blame] | 1015 | case SET_INPUT_SURFACE: |
Chong Zhang | d291c22 | 2015-04-30 18:15:52 -0700 | [diff] [blame] | 1016 | { |
| 1017 | CHECK_OMX_INTERFACE(IOMX, data, reply); |
| 1018 | |
| 1019 | node_id node = (node_id)data.readInt32(); |
| 1020 | OMX_U32 port_index = data.readInt32(); |
| 1021 | |
| 1022 | sp<IGraphicBufferConsumer> bufferConsumer = |
| 1023 | interface_cast<IGraphicBufferConsumer>(data.readStrongBinder()); |
| 1024 | |
Chong Zhang | 6d332d2 | 2016-09-07 12:06:50 -0700 | [diff] [blame^] | 1025 | sp<IGraphicBufferSource> bufferSource; |
Wei Jia | 56c95c9 | 2016-01-06 10:30:46 -0800 | [diff] [blame] | 1026 | MetadataBufferType type = kMetadataBufferTypeInvalid; |
Chong Zhang | d291c22 | 2015-04-30 18:15:52 -0700 | [diff] [blame] | 1027 | |
Wei Jia | 56c95c9 | 2016-01-06 10:30:46 -0800 | [diff] [blame] | 1028 | status_t err = INVALID_OPERATION; |
| 1029 | if (bufferConsumer == NULL) { |
| 1030 | ALOGE("b/26392700"); |
| 1031 | } else { |
Chong Zhang | 6d332d2 | 2016-09-07 12:06:50 -0700 | [diff] [blame^] | 1032 | err = setInputSurface(node, port_index, bufferConsumer, &bufferSource, &type); |
mspector@google.com | c3ed9d0 | 2016-02-18 19:52:08 -0800 | [diff] [blame] | 1033 | |
| 1034 | if ((err != OK) && (type == kMetadataBufferTypeInvalid)) { |
| 1035 | android_errorWriteLog(0x534e4554, "26324358"); |
| 1036 | } |
Wei Jia | 56c95c9 | 2016-01-06 10:30:46 -0800 | [diff] [blame] | 1037 | } |
Chong Zhang | d291c22 | 2015-04-30 18:15:52 -0700 | [diff] [blame] | 1038 | |
Lajos Molnar | 0542198 | 2015-05-15 20:39:14 -0700 | [diff] [blame] | 1039 | reply->writeInt32(type); |
Chong Zhang | d291c22 | 2015-04-30 18:15:52 -0700 | [diff] [blame] | 1040 | reply->writeInt32(err); |
Chong Zhang | 6d332d2 | 2016-09-07 12:06:50 -0700 | [diff] [blame^] | 1041 | if (err == OK) { |
| 1042 | reply->writeStrongBinder(IInterface::asBinder(bufferSource)); |
| 1043 | } |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 1044 | return NO_ERROR; |
| 1045 | } |
| 1046 | |
James Dong | e870772 | 2010-10-20 17:38:41 -0700 | [diff] [blame] | 1047 | case STORE_META_DATA_IN_BUFFERS: |
| 1048 | { |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 1049 | CHECK_OMX_INTERFACE(IOMX, data, reply); |
James Dong | e870772 | 2010-10-20 17:38:41 -0700 | [diff] [blame] | 1050 | |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 1051 | node_id node = (node_id)data.readInt32(); |
James Dong | e870772 | 2010-10-20 17:38:41 -0700 | [diff] [blame] | 1052 | OMX_U32 port_index = data.readInt32(); |
| 1053 | OMX_BOOL enable = (OMX_BOOL)data.readInt32(); |
| 1054 | |
Lajos Molnar | 3e32878 | 2016-05-09 10:56:46 -0700 | [diff] [blame] | 1055 | MetadataBufferType type = (MetadataBufferType)data.readInt32(); |
Lajos Molnar | 0542198 | 2015-05-15 20:39:14 -0700 | [diff] [blame] | 1056 | status_t err = storeMetaDataInBuffers(node, port_index, enable, &type); |
mspector@google.com | da9ca91 | 2016-02-08 17:07:06 -0800 | [diff] [blame] | 1057 | |
Lajos Molnar | 0542198 | 2015-05-15 20:39:14 -0700 | [diff] [blame] | 1058 | reply->writeInt32(type); |
James Dong | e870772 | 2010-10-20 17:38:41 -0700 | [diff] [blame] | 1059 | reply->writeInt32(err); |
| 1060 | |
| 1061 | return NO_ERROR; |
| 1062 | } |
| 1063 | |
Lajos Molnar | 56ce726 | 2013-05-02 16:30:48 -0700 | [diff] [blame] | 1064 | case PREPARE_FOR_ADAPTIVE_PLAYBACK: |
| 1065 | { |
| 1066 | CHECK_OMX_INTERFACE(IOMX, data, reply); |
| 1067 | |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 1068 | node_id node = (node_id)data.readInt32(); |
Lajos Molnar | 56ce726 | 2013-05-02 16:30:48 -0700 | [diff] [blame] | 1069 | OMX_U32 port_index = data.readInt32(); |
| 1070 | OMX_BOOL enable = (OMX_BOOL)data.readInt32(); |
| 1071 | OMX_U32 max_width = data.readInt32(); |
| 1072 | OMX_U32 max_height = data.readInt32(); |
| 1073 | |
| 1074 | status_t err = prepareForAdaptivePlayback( |
| 1075 | node, port_index, enable, max_width, max_height); |
| 1076 | reply->writeInt32(err); |
| 1077 | |
| 1078 | return NO_ERROR; |
| 1079 | } |
| 1080 | |
Rachad | 5a446aa | 2014-07-29 16:47:56 -0700 | [diff] [blame] | 1081 | case CONFIGURE_VIDEO_TUNNEL_MODE: |
| 1082 | { |
| 1083 | CHECK_OMX_INTERFACE(IOMX, data, reply); |
| 1084 | |
| 1085 | node_id node = (node_id)data.readInt32(); |
| 1086 | OMX_U32 port_index = data.readInt32(); |
| 1087 | OMX_BOOL tunneled = (OMX_BOOL)data.readInt32(); |
| 1088 | OMX_U32 audio_hw_sync = data.readInt32(); |
| 1089 | |
Lajos Molnar | a63141a | 2016-02-11 16:40:36 -0800 | [diff] [blame] | 1090 | native_handle_t *sideband_handle = NULL; |
Rachad | 5a446aa | 2014-07-29 16:47:56 -0700 | [diff] [blame] | 1091 | status_t err = configureVideoTunnelMode( |
| 1092 | node, port_index, tunneled, audio_hw_sync, &sideband_handle); |
| 1093 | reply->writeInt32(err); |
mspector@google.com | 9d72eb0 | 2016-02-08 10:56:13 -0800 | [diff] [blame] | 1094 | if(err == OK){ |
| 1095 | reply->writeNativeHandle(sideband_handle); |
| 1096 | } |
Rachad | 5a446aa | 2014-07-29 16:47:56 -0700 | [diff] [blame] | 1097 | |
| 1098 | return NO_ERROR; |
| 1099 | } |
| 1100 | |
Lajos Molnar | a63141a | 2016-02-11 16:40:36 -0800 | [diff] [blame] | 1101 | case ALLOC_SECURE_BUFFER: |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1102 | { |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 1103 | CHECK_OMX_INTERFACE(IOMX, data, reply); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1104 | |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 1105 | node_id node = (node_id)data.readInt32(); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1106 | OMX_U32 port_index = data.readInt32(); |
Wei Jia | 8dde726 | 2015-09-28 11:32:23 -0700 | [diff] [blame] | 1107 | if (!isSecure(node) || port_index != 0 /* kPortIndexInput */) { |
| 1108 | ALOGE("b/24310423"); |
| 1109 | reply->writeInt32(INVALID_OPERATION); |
| 1110 | return NO_ERROR; |
| 1111 | } |
| 1112 | |
Glenn Kasten | e03dd22 | 2014-01-28 11:04:39 -0800 | [diff] [blame] | 1113 | size_t size = data.readInt64(); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1114 | |
| 1115 | buffer_id buffer; |
Lajos Molnar | a63141a | 2016-02-11 16:40:36 -0800 | [diff] [blame] | 1116 | void *buffer_data = NULL; |
Lajos Molnar | 1b40f28 | 2016-05-09 22:24:52 -0700 | [diff] [blame] | 1117 | sp<NativeHandle> native_handle; |
Lajos Molnar | a63141a | 2016-02-11 16:40:36 -0800 | [diff] [blame] | 1118 | status_t err = allocateSecureBuffer( |
| 1119 | node, port_index, size, &buffer, &buffer_data, &native_handle); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1120 | reply->writeInt32(err); |
| 1121 | |
| 1122 | if (err == OK) { |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 1123 | reply->writeInt32((int32_t)buffer); |
| 1124 | reply->writeInt64((uintptr_t)buffer_data); |
Lajos Molnar | a63141a | 2016-02-11 16:40:36 -0800 | [diff] [blame] | 1125 | if (buffer_data == NULL) { |
Lajos Molnar | 1b40f28 | 2016-05-09 22:24:52 -0700 | [diff] [blame] | 1126 | reply->writeNativeHandle(native_handle == NULL ? NULL : native_handle->handle()); |
Lajos Molnar | a63141a | 2016-02-11 16:40:36 -0800 | [diff] [blame] | 1127 | } |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1128 | } |
| 1129 | |
| 1130 | return NO_ERROR; |
| 1131 | } |
| 1132 | |
| 1133 | case ALLOC_BUFFER_WITH_BACKUP: |
| 1134 | { |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 1135 | CHECK_OMX_INTERFACE(IOMX, data, reply); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1136 | |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 1137 | node_id node = (node_id)data.readInt32(); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1138 | OMX_U32 port_index = data.readInt32(); |
| 1139 | sp<IMemory> params = |
| 1140 | interface_cast<IMemory>(data.readStrongBinder()); |
Lajos Molnar | cc7cc67 | 2015-06-01 14:58:37 -0700 | [diff] [blame] | 1141 | OMX_U32 allottedSize = data.readInt32(); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1142 | |
Wei Jia | 56c95c9 | 2016-01-06 10:30:46 -0800 | [diff] [blame] | 1143 | if (params == NULL) { |
| 1144 | ALOGE("b/26392700"); |
| 1145 | reply->writeInt32(INVALID_OPERATION); |
| 1146 | return NO_ERROR; |
| 1147 | } |
| 1148 | |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1149 | buffer_id buffer; |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 1150 | status_t err = allocateBufferWithBackup( |
Lajos Molnar | cc7cc67 | 2015-06-01 14:58:37 -0700 | [diff] [blame] | 1151 | node, port_index, params, &buffer, allottedSize); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1152 | |
| 1153 | reply->writeInt32(err); |
| 1154 | |
| 1155 | if (err == OK) { |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 1156 | reply->writeInt32((int32_t)buffer); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1157 | } |
| 1158 | |
| 1159 | return NO_ERROR; |
| 1160 | } |
| 1161 | |
| 1162 | case FREE_BUFFER: |
| 1163 | { |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 1164 | CHECK_OMX_INTERFACE(IOMX, data, reply); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1165 | |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 1166 | node_id node = (node_id)data.readInt32(); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1167 | OMX_U32 port_index = data.readInt32(); |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 1168 | buffer_id buffer = (buffer_id)data.readInt32(); |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 1169 | reply->writeInt32(freeBuffer(node, port_index, buffer)); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1170 | |
| 1171 | return NO_ERROR; |
| 1172 | } |
| 1173 | |
| 1174 | case FILL_BUFFER: |
| 1175 | { |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 1176 | CHECK_OMX_INTERFACE(IOMX, data, reply); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1177 | |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 1178 | node_id node = (node_id)data.readInt32(); |
| 1179 | buffer_id buffer = (buffer_id)data.readInt32(); |
Lajos Molnar | 15ab499 | 2015-06-01 10:54:31 -0700 | [diff] [blame] | 1180 | bool haveFence = data.readInt32(); |
| 1181 | int fenceFd = haveFence ? ::dup(data.readFileDescriptor()) : -1; |
| 1182 | reply->writeInt32(fillBuffer(node, buffer, fenceFd)); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1183 | |
| 1184 | return NO_ERROR; |
| 1185 | } |
| 1186 | |
| 1187 | case EMPTY_BUFFER: |
| 1188 | { |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 1189 | CHECK_OMX_INTERFACE(IOMX, data, reply); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1190 | |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 1191 | node_id node = (node_id)data.readInt32(); |
| 1192 | buffer_id buffer = (buffer_id)data.readInt32(); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1193 | OMX_U32 range_offset = data.readInt32(); |
| 1194 | OMX_U32 range_length = data.readInt32(); |
| 1195 | OMX_U32 flags = data.readInt32(); |
| 1196 | OMX_TICKS timestamp = data.readInt64(); |
Lajos Molnar | 15ab499 | 2015-06-01 10:54:31 -0700 | [diff] [blame] | 1197 | bool haveFence = data.readInt32(); |
| 1198 | int fenceFd = haveFence ? ::dup(data.readFileDescriptor()) : -1; |
| 1199 | reply->writeInt32(emptyBuffer( |
| 1200 | node, buffer, range_offset, range_length, flags, timestamp, fenceFd)); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1201 | |
| 1202 | return NO_ERROR; |
| 1203 | } |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1204 | |
Chong Zhang | 6cf9a12 | 2016-09-08 23:25:52 -0700 | [diff] [blame] | 1205 | case EMPTY_GRAPHIC_BUFFER: |
| 1206 | { |
| 1207 | CHECK_OMX_INTERFACE(IOMX, data, reply); |
| 1208 | |
| 1209 | node_id node = (node_id)data.readInt32(); |
| 1210 | buffer_id buffer = (buffer_id)data.readInt32(); |
| 1211 | sp<GraphicBuffer> graphicBuffer = new GraphicBuffer(); |
| 1212 | data.read(*graphicBuffer); |
| 1213 | OMX_U32 flags = data.readInt32(); |
| 1214 | OMX_TICKS timestamp = data.readInt64(); |
Chong Zhang | 6d332d2 | 2016-09-07 12:06:50 -0700 | [diff] [blame^] | 1215 | OMX_TICKS origTimestamp = data.readInt64(); |
Chong Zhang | 6cf9a12 | 2016-09-08 23:25:52 -0700 | [diff] [blame] | 1216 | bool haveFence = data.readInt32(); |
| 1217 | int fenceFd = haveFence ? ::dup(data.readFileDescriptor()) : -1; |
| 1218 | reply->writeInt32(emptyGraphicBuffer( |
Chong Zhang | 6d332d2 | 2016-09-07 12:06:50 -0700 | [diff] [blame^] | 1219 | node, buffer, graphicBuffer, flags, |
| 1220 | timestamp, origTimestamp, fenceFd)); |
Chong Zhang | 6cf9a12 | 2016-09-08 23:25:52 -0700 | [diff] [blame] | 1221 | |
| 1222 | return NO_ERROR; |
| 1223 | } |
| 1224 | |
Andreas Huber | 693d271 | 2009-08-14 14:37:10 -0700 | [diff] [blame] | 1225 | case GET_EXTENSION_INDEX: |
| 1226 | { |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 1227 | CHECK_OMX_INTERFACE(IOMX, data, reply); |
Andreas Huber | 693d271 | 2009-08-14 14:37:10 -0700 | [diff] [blame] | 1228 | |
Andy Hung | 609b815 | 2014-05-02 11:05:04 -0700 | [diff] [blame] | 1229 | node_id node = (node_id)data.readInt32(); |
Andreas Huber | 693d271 | 2009-08-14 14:37:10 -0700 | [diff] [blame] | 1230 | const char *parameter_name = data.readCString(); |
Andreas Huber | 7eaa9c9 | 2010-01-15 15:28:19 -0800 | [diff] [blame] | 1231 | |
Wei Jia | 56c95c9 | 2016-01-06 10:30:46 -0800 | [diff] [blame] | 1232 | if (parameter_name == NULL) { |
| 1233 | ALOGE("b/26392700"); |
| 1234 | reply->writeInt32(INVALID_OPERATION); |
| 1235 | return NO_ERROR; |
| 1236 | } |
| 1237 | |
Andreas Huber | 693d271 | 2009-08-14 14:37:10 -0700 | [diff] [blame] | 1238 | OMX_INDEXTYPE index; |
Andreas Huber | 318ad9c | 2009-10-15 13:46:54 -0700 | [diff] [blame] | 1239 | status_t err = getExtensionIndex(node, parameter_name, &index); |
Andreas Huber | 693d271 | 2009-08-14 14:37:10 -0700 | [diff] [blame] | 1240 | |
| 1241 | reply->writeInt32(err); |
| 1242 | |
| 1243 | if (err == OK) { |
| 1244 | reply->writeInt32(index); |
| 1245 | } |
| 1246 | |
| 1247 | return OK; |
| 1248 | } |
| 1249 | |
Chong Zhang | 6cf9a12 | 2016-09-08 23:25:52 -0700 | [diff] [blame] | 1250 | case DISPATCH_MESSAGE: |
| 1251 | { |
| 1252 | CHECK_OMX_INTERFACE(IOMX, data, reply); |
| 1253 | omx_message msg; |
| 1254 | msg.node = data.readInt32(); |
| 1255 | int haveFence = data.readInt32(); |
| 1256 | msg.fenceFd = haveFence ? ::dup(data.readFileDescriptor()) : -1; |
| 1257 | msg.type = (typeof(msg.type))data.readInt32(); |
| 1258 | status_t err = data.read(&msg.u, sizeof(msg.u)); |
| 1259 | |
| 1260 | if (err == OK) { |
| 1261 | err = dispatchMessage(msg); |
| 1262 | } |
| 1263 | reply->writeInt32(err); |
| 1264 | |
| 1265 | return NO_ERROR; |
| 1266 | } |
| 1267 | |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1268 | default: |
| 1269 | return BBinder::onTransact(code, data, reply, flags); |
| 1270 | } |
| 1271 | } |
| 1272 | |
| 1273 | //////////////////////////////////////////////////////////////////////////////// |
| 1274 | |
| 1275 | class BpOMXObserver : public BpInterface<IOMXObserver> { |
| 1276 | public: |
Chih-Hung Hsieh | 090ef60 | 2016-04-27 10:39:54 -0700 | [diff] [blame] | 1277 | explicit BpOMXObserver(const sp<IBinder> &impl) |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1278 | : BpInterface<IOMXObserver>(impl) { |
| 1279 | } |
| 1280 | |
Lajos Molnar | 26a48f3 | 2015-06-04 10:30:02 -0700 | [diff] [blame] | 1281 | virtual void onMessages(const std::list<omx_message> &messages) { |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1282 | Parcel data, reply; |
Lajos Molnar | 26a48f3 | 2015-06-04 10:30:02 -0700 | [diff] [blame] | 1283 | std::list<omx_message>::const_iterator it = messages.cbegin(); |
| 1284 | bool first = true; |
| 1285 | while (it != messages.cend()) { |
| 1286 | const omx_message &msg = *it++; |
| 1287 | if (first) { |
| 1288 | data.writeInterfaceToken(IOMXObserver::getInterfaceDescriptor()); |
| 1289 | data.writeInt32(msg.node); |
| 1290 | first = false; |
| 1291 | } |
| 1292 | data.writeInt32(msg.fenceFd >= 0); |
| 1293 | if (msg.fenceFd >= 0) { |
| 1294 | data.writeFileDescriptor(msg.fenceFd, true /* takeOwnership */); |
| 1295 | } |
| 1296 | data.writeInt32(msg.type); |
| 1297 | data.write(&msg.u, sizeof(msg.u)); |
| 1298 | ALOGV("onMessage writing message %d, size %zu", msg.type, sizeof(msg)); |
Lajos Molnar | 15ab499 | 2015-06-01 10:54:31 -0700 | [diff] [blame] | 1299 | } |
Lajos Molnar | 26a48f3 | 2015-06-04 10:30:02 -0700 | [diff] [blame] | 1300 | if (!first) { |
| 1301 | data.writeInt32(-1); // mark end |
| 1302 | remote()->transact(OBSERVER_ON_MSG, data, &reply, IBinder::FLAG_ONEWAY); |
| 1303 | } |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1304 | } |
| 1305 | }; |
| 1306 | |
| 1307 | IMPLEMENT_META_INTERFACE(OMXObserver, "android.hardware.IOMXObserver"); |
| 1308 | |
| 1309 | status_t BnOMXObserver::onTransact( |
| 1310 | uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) { |
| 1311 | switch (code) { |
| 1312 | case OBSERVER_ON_MSG: |
| 1313 | { |
Andy McFadden | 7cd5853 | 2013-02-19 07:28:30 -0800 | [diff] [blame] | 1314 | CHECK_OMX_INTERFACE(IOMXObserver, data, reply); |
Lajos Molnar | 26a48f3 | 2015-06-04 10:30:02 -0700 | [diff] [blame] | 1315 | IOMX::node_id node = data.readInt32(); |
| 1316 | std::list<omx_message> messages; |
| 1317 | status_t err = FAILED_TRANSACTION; // must receive at least one message |
| 1318 | do { |
| 1319 | int haveFence = data.readInt32(); |
| 1320 | if (haveFence < 0) { // we use -1 to mark end of messages |
| 1321 | break; |
| 1322 | } |
| 1323 | omx_message msg; |
| 1324 | msg.node = node; |
| 1325 | msg.fenceFd = haveFence ? ::dup(data.readFileDescriptor()) : -1; |
| 1326 | msg.type = (typeof(msg.type))data.readInt32(); |
| 1327 | err = data.read(&msg.u, sizeof(msg.u)); |
| 1328 | ALOGV("onTransact reading message %d, size %zu", msg.type, sizeof(msg)); |
| 1329 | messages.push_back(msg); |
| 1330 | } while (err == OK); |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1331 | |
Lajos Molnar | 26a48f3 | 2015-06-04 10:30:02 -0700 | [diff] [blame] | 1332 | if (err == OK) { |
| 1333 | onMessages(messages); |
Lajos Molnar | 15ab499 | 2015-06-01 10:54:31 -0700 | [diff] [blame] | 1334 | } |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1335 | |
Lajos Molnar | 26a48f3 | 2015-06-04 10:30:02 -0700 | [diff] [blame] | 1336 | return err; |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1337 | } |
| 1338 | |
| 1339 | default: |
| 1340 | return BBinder::onTransact(code, data, reply, flags); |
| 1341 | } |
| 1342 | } |
| 1343 | |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1344 | } // namespace android |