Andreas Huber | e46b7be | 2009-07-14 16:56:47 -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 | |
| 17 | #ifndef ANDROID_IOMX_H_ |
| 18 | |
| 19 | #define ANDROID_IOMX_H_ |
| 20 | |
| 21 | #include <binder/IInterface.h> |
| 22 | #include <utils/List.h> |
| 23 | #include <utils/String8.h> |
| 24 | |
| 25 | #include <OMX_Core.h> |
Andreas Huber | 1de1316 | 2009-07-31 11:52:50 -0700 | [diff] [blame] | 26 | #include <OMX_Video.h> |
Andreas Huber | e46b7be | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 27 | |
Andreas Huber | e46b7be | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 28 | namespace android { |
| 29 | |
| 30 | class IMemory; |
| 31 | class IOMXObserver; |
Andreas Huber | 1de1316 | 2009-07-31 11:52:50 -0700 | [diff] [blame] | 32 | class IOMXRenderer; |
| 33 | class ISurface; |
Andreas Huber | e46b7be | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 34 | |
| 35 | class IOMX : public IInterface { |
| 36 | public: |
| 37 | DECLARE_META_INTERFACE(OMX); |
| 38 | |
| 39 | typedef void *buffer_id; |
| 40 | typedef void *node_id; |
| 41 | |
Andreas Huber | e46b7be | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 42 | virtual status_t list_nodes(List<String8> *list) = 0; |
| 43 | |
| 44 | virtual status_t allocate_node(const char *name, node_id *node) = 0; |
| 45 | virtual status_t free_node(node_id node) = 0; |
| 46 | |
| 47 | virtual status_t send_command( |
| 48 | node_id node, OMX_COMMANDTYPE cmd, OMX_S32 param) = 0; |
| 49 | |
| 50 | virtual status_t get_parameter( |
| 51 | node_id node, OMX_INDEXTYPE index, |
| 52 | void *params, size_t size) = 0; |
| 53 | |
| 54 | virtual status_t set_parameter( |
| 55 | node_id node, OMX_INDEXTYPE index, |
| 56 | const void *params, size_t size) = 0; |
| 57 | |
| 58 | virtual status_t use_buffer( |
| 59 | node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms, |
| 60 | buffer_id *buffer) = 0; |
| 61 | |
| 62 | virtual status_t allocate_buffer( |
| 63 | node_id node, OMX_U32 port_index, size_t size, |
| 64 | buffer_id *buffer) = 0; |
| 65 | |
| 66 | virtual status_t allocate_buffer_with_backup( |
| 67 | node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms, |
| 68 | buffer_id *buffer) = 0; |
| 69 | |
| 70 | virtual status_t free_buffer( |
| 71 | node_id node, OMX_U32 port_index, buffer_id buffer) = 0; |
| 72 | |
Andreas Huber | e46b7be | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 73 | virtual status_t observe_node( |
| 74 | node_id node, const sp<IOMXObserver> &observer) = 0; |
| 75 | |
| 76 | virtual void fill_buffer(node_id node, buffer_id buffer) = 0; |
| 77 | |
| 78 | virtual void empty_buffer( |
| 79 | node_id node, |
| 80 | buffer_id buffer, |
| 81 | OMX_U32 range_offset, OMX_U32 range_length, |
| 82 | OMX_U32 flags, OMX_TICKS timestamp) = 0; |
Andreas Huber | 1de1316 | 2009-07-31 11:52:50 -0700 | [diff] [blame] | 83 | |
| 84 | virtual sp<IOMXRenderer> createRenderer( |
| 85 | const sp<ISurface> &surface, |
| 86 | const char *componentName, |
| 87 | OMX_COLOR_FORMATTYPE colorFormat, |
| 88 | size_t encodedWidth, size_t encodedHeight, |
| 89 | size_t displayWidth, size_t displayHeight) = 0; |
Andreas Huber | e46b7be | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | struct omx_message { |
| 93 | enum { |
| 94 | EVENT, |
| 95 | EMPTY_BUFFER_DONE, |
| 96 | FILL_BUFFER_DONE, |
| 97 | |
Andreas Huber | e46b7be | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 98 | // reserved for OMXDecoder use. |
| 99 | START, |
| 100 | INITIAL_FILL_BUFFER, |
| 101 | |
| 102 | // reserved for OMXObserver use. |
| 103 | QUIT_OBSERVER, |
| 104 | } type; |
| 105 | |
| 106 | union { |
| 107 | // if type == EVENT |
| 108 | struct { |
| 109 | IOMX::node_id node; |
| 110 | OMX_EVENTTYPE event; |
| 111 | OMX_U32 data1; |
| 112 | OMX_U32 data2; |
| 113 | } event_data; |
| 114 | |
| 115 | // if type == EMPTY_BUFFER_DONE || type == FILL_BUFFER |
| 116 | // || type == INITIAL_FILL_BUFFER |
| 117 | struct { |
| 118 | IOMX::node_id node; |
| 119 | IOMX::buffer_id buffer; |
| 120 | } buffer_data; |
| 121 | |
| 122 | // if type == EMPTY_BUFFER || type == FILL_BUFFER_DONE |
| 123 | struct { |
| 124 | IOMX::node_id node; |
| 125 | IOMX::buffer_id buffer; |
| 126 | OMX_U32 range_offset; |
| 127 | OMX_U32 range_length; |
| 128 | OMX_U32 flags; |
| 129 | OMX_TICKS timestamp; |
| 130 | OMX_PTR platform_private; // ignored if type == EMPTY_BUFFER |
| 131 | } extended_buffer_data; |
| 132 | |
| 133 | // if type == SEND_COMMAND |
| 134 | struct { |
| 135 | IOMX::node_id node; |
| 136 | OMX_COMMANDTYPE cmd; |
| 137 | OMX_S32 param; |
| 138 | } send_command_data; |
| 139 | |
| 140 | } u; |
| 141 | }; |
| 142 | |
| 143 | class IOMXObserver : public IInterface { |
| 144 | public: |
| 145 | DECLARE_META_INTERFACE(OMXObserver); |
| 146 | |
| 147 | virtual void on_message(const omx_message &msg) = 0; |
| 148 | }; |
| 149 | |
Andreas Huber | 1de1316 | 2009-07-31 11:52:50 -0700 | [diff] [blame] | 150 | class IOMXRenderer : public IInterface { |
| 151 | public: |
| 152 | DECLARE_META_INTERFACE(OMXRenderer); |
| 153 | |
| 154 | virtual void render(IOMX::buffer_id buffer) = 0; |
| 155 | }; |
| 156 | |
Andreas Huber | e46b7be | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 157 | //////////////////////////////////////////////////////////////////////////////// |
| 158 | |
| 159 | class BnOMX : public BnInterface<IOMX> { |
| 160 | public: |
| 161 | virtual status_t onTransact( |
| 162 | uint32_t code, const Parcel &data, Parcel *reply, |
| 163 | uint32_t flags = 0); |
| 164 | }; |
| 165 | |
| 166 | class BnOMXObserver : public BnInterface<IOMXObserver> { |
| 167 | public: |
| 168 | virtual status_t onTransact( |
| 169 | uint32_t code, const Parcel &data, Parcel *reply, |
| 170 | uint32_t flags = 0); |
| 171 | }; |
| 172 | |
Andreas Huber | 1de1316 | 2009-07-31 11:52:50 -0700 | [diff] [blame] | 173 | class BnOMXRenderer : public BnInterface<IOMXRenderer> { |
| 174 | public: |
| 175 | virtual status_t onTransact( |
| 176 | uint32_t code, const Parcel &data, Parcel *reply, |
| 177 | uint32_t flags = 0); |
| 178 | }; |
| 179 | |
Andreas Huber | e46b7be | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 180 | } // namespace android |
| 181 | |
| 182 | #endif // ANDROID_IOMX_H_ |