Andreas Huber | b0caf94 | 2009-12-03 11:39:54 -0800 | [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 | #include "OMXPVCodecsPlugin.h" |
| 18 | |
| 19 | #include "pv_omxcore.h" |
| 20 | |
| 21 | #include <media/stagefright/MediaDebug.h> |
| 22 | |
| 23 | namespace android { |
| 24 | |
| 25 | OMXPVCodecsPlugin::OMXPVCodecsPlugin() { |
| 26 | OMX_MasterInit(); |
| 27 | } |
| 28 | |
| 29 | OMXPVCodecsPlugin::~OMXPVCodecsPlugin() { |
| 30 | OMX_MasterDeinit(); |
| 31 | } |
| 32 | |
| 33 | OMX_ERRORTYPE OMXPVCodecsPlugin::makeComponentInstance( |
| 34 | const char *name, |
| 35 | const OMX_CALLBACKTYPE *callbacks, |
| 36 | OMX_PTR appData, |
| 37 | OMX_COMPONENTTYPE **component) { |
Andreas Huber | fef6435 | 2009-12-04 12:52:40 -0800 | [diff] [blame] | 38 | return OMX_MasterGetHandle( |
Andreas Huber | b0caf94 | 2009-12-03 11:39:54 -0800 | [diff] [blame] | 39 | reinterpret_cast<OMX_HANDLETYPE *>(component), |
| 40 | const_cast<char *>(name), |
| 41 | appData, |
| 42 | const_cast<OMX_CALLBACKTYPE *>(callbacks)); |
Andreas Huber | fef6435 | 2009-12-04 12:52:40 -0800 | [diff] [blame] | 43 | } |
Andreas Huber | b0caf94 | 2009-12-03 11:39:54 -0800 | [diff] [blame] | 44 | |
Andreas Huber | fef6435 | 2009-12-04 12:52:40 -0800 | [diff] [blame] | 45 | OMX_ERRORTYPE OMXPVCodecsPlugin::destroyComponentInstance( |
| 46 | OMX_COMPONENTTYPE *component) { |
| 47 | return OMX_MasterFreeHandle(component); |
Andreas Huber | b0caf94 | 2009-12-03 11:39:54 -0800 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | OMX_ERRORTYPE OMXPVCodecsPlugin::enumerateComponents( |
| 51 | OMX_STRING name, |
| 52 | size_t size, |
| 53 | OMX_U32 index) { |
| 54 | return OMX_MasterComponentNameEnum(name, size, index); |
| 55 | } |
| 56 | |
Andreas Huber | c7e91ee | 2009-12-15 15:22:08 -0800 | [diff] [blame] | 57 | OMX_ERRORTYPE OMXPVCodecsPlugin::getRolesOfComponent( |
| 58 | const char *name, |
| 59 | Vector<String8> *roles) { |
| 60 | roles->clear(); |
| 61 | |
| 62 | OMX_U32 numRoles; |
| 63 | OMX_ERRORTYPE err = |
| 64 | OMX_MasterGetRolesOfComponent( |
| 65 | const_cast<char *>(name), |
| 66 | &numRoles, |
| 67 | NULL); |
| 68 | |
| 69 | if (err != OMX_ErrorNone) { |
| 70 | return err; |
| 71 | } |
| 72 | |
| 73 | if (numRoles > 0) { |
| 74 | OMX_U8 **array = new OMX_U8 *[numRoles]; |
| 75 | for (OMX_U32 i = 0; i < numRoles; ++i) { |
| 76 | array[i] = new OMX_U8[OMX_MAX_STRINGNAME_SIZE]; |
| 77 | } |
| 78 | |
| 79 | OMX_U32 numRoles2; |
| 80 | err = OMX_MasterGetRolesOfComponent( |
| 81 | const_cast<char *>(name), &numRoles2, array); |
| 82 | |
| 83 | CHECK_EQ(err, OMX_ErrorNone); |
| 84 | CHECK_EQ(numRoles, numRoles2); |
| 85 | |
| 86 | for (OMX_U32 i = 0; i < numRoles; ++i) { |
| 87 | String8 s((const char *)array[i]); |
| 88 | roles->push(s); |
| 89 | |
| 90 | delete[] array[i]; |
| 91 | array[i] = NULL; |
| 92 | } |
| 93 | |
| 94 | delete[] array; |
| 95 | array = NULL; |
| 96 | } |
| 97 | |
| 98 | return OMX_ErrorNone; |
| 99 | } |
| 100 | |
Andreas Huber | b0caf94 | 2009-12-03 11:39:54 -0800 | [diff] [blame] | 101 | } // namespace android |