blob: d1f5be33067e0760a4549c8cfaec08fd6d86fbdb [file] [log] [blame]
Andreas Huberb0caf942009-12-03 11:39:54 -08001/*
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
23namespace android {
24
25OMXPVCodecsPlugin::OMXPVCodecsPlugin() {
26 OMX_MasterInit();
27}
28
29OMXPVCodecsPlugin::~OMXPVCodecsPlugin() {
30 OMX_MasterDeinit();
31}
32
33OMX_ERRORTYPE OMXPVCodecsPlugin::makeComponentInstance(
34 const char *name,
35 const OMX_CALLBACKTYPE *callbacks,
36 OMX_PTR appData,
37 OMX_COMPONENTTYPE **component) {
Andreas Huberfef64352009-12-04 12:52:40 -080038 return OMX_MasterGetHandle(
Andreas Huberb0caf942009-12-03 11:39:54 -080039 reinterpret_cast<OMX_HANDLETYPE *>(component),
40 const_cast<char *>(name),
41 appData,
42 const_cast<OMX_CALLBACKTYPE *>(callbacks));
Andreas Huberfef64352009-12-04 12:52:40 -080043}
Andreas Huberb0caf942009-12-03 11:39:54 -080044
Andreas Huberfef64352009-12-04 12:52:40 -080045OMX_ERRORTYPE OMXPVCodecsPlugin::destroyComponentInstance(
46 OMX_COMPONENTTYPE *component) {
47 return OMX_MasterFreeHandle(component);
Andreas Huberb0caf942009-12-03 11:39:54 -080048}
49
50OMX_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 Huberc7e91ee2009-12-15 15:22:08 -080057OMX_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 Huberb0caf942009-12-03 11:39:54 -0800101} // namespace android