diff options
author | Andreas Huber <andih@google.com> | 2009-12-15 15:22:08 -0800 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2009-12-15 15:22:08 -0800 |
commit | 8ae1d0bdcef22f2bdd8d283e0e615f3ba6c3f4cd (patch) | |
tree | d2ac9d7dbbd665bda5f3019ad27db3a925158061 /media | |
parent | 1af80bc3fefb999756ef4847e72b2dcfd0b88a4a (diff) | |
download | frameworks_av-8ae1d0bdcef22f2bdd8d283e0e615f3ba6c3f4cd.zip frameworks_av-8ae1d0bdcef22f2bdd8d283e0e615f3ba6c3f4cd.tar.gz frameworks_av-8ae1d0bdcef22f2bdd8d283e0e615f3ba6c3f4cd.tar.bz2 |
Add a new API to support determining the roles of an OMX component specified by name. Remove unneeded OMXSoftwareCodecsPlugin.
Diffstat (limited to 'media')
-rw-r--r-- | media/libstagefright/omx/Android.mk | 3 | ||||
-rw-r--r-- | media/libstagefright/omx/OMX.cpp | 25 | ||||
-rw-r--r-- | media/libstagefright/omx/OMXMaster.cpp | 21 | ||||
-rw-r--r-- | media/libstagefright/omx/OMXMaster.h | 4 | ||||
-rw-r--r-- | media/libstagefright/omx/OMXPVCodecsPlugin.cpp | 44 | ||||
-rw-r--r-- | media/libstagefright/omx/OMXPVCodecsPlugin.h | 4 | ||||
-rw-r--r-- | media/libstagefright/omx/OMXSoftwareCodecsPlugin.cpp | 78 | ||||
-rw-r--r-- | media/libstagefright/omx/OMXSoftwareCodecsPlugin.h | 50 |
8 files changed, 95 insertions, 134 deletions
diff --git a/media/libstagefright/omx/Android.mk b/media/libstagefright/omx/Android.mk index 965852b..4f88d99 100644 --- a/media/libstagefright/omx/Android.mk +++ b/media/libstagefright/omx/Android.mk @@ -12,8 +12,7 @@ LOCAL_SRC_FILES:= \ OMX.cpp \ OMXComponentBase.cpp \ OMXNodeInstance.cpp \ - OMXMaster.cpp \ - OMXSoftwareCodecsPlugin.cpp \ + OMXMaster.cpp ifneq ($(BUILD_WITHOUT_PV),true) LOCAL_SRC_FILES += \ diff --git a/media/libstagefright/omx/OMX.cpp b/media/libstagefright/omx/OMX.cpp index 61be8f7..94dbb6d 100644 --- a/media/libstagefright/omx/OMX.cpp +++ b/media/libstagefright/omx/OMX.cpp @@ -208,6 +208,29 @@ void OMX::binderDied(const wp<IBinder> &the_late_who) { instance->onObserverDied(mMaster); } +#if 0 +static void dumpRoles(OMXMaster *master, const char *name) { + Vector<String8> roles; + OMX_ERRORTYPE err = master->getRolesOfComponent(name, &roles); + + if (err != OMX_ErrorNone) { + LOGE("Could not get roles for component '%s'.", name); + return; + } + + if (roles.isEmpty()) { + LOGE("Component '%s' has NO roles!", name); + return; + } + + LOGI("Component '%s' has the following roles:", name); + + for (size_t i = 0; i < roles.size(); ++i) { + LOGI("%d) %s", i + 1, roles[i].string()); + } +} +#endif + status_t OMX::listNodes(List<String8> *list) { list->clear(); @@ -217,6 +240,8 @@ status_t OMX::listNodes(List<String8> *list) { componentName, sizeof(componentName), index) == OMX_ErrorNone) { list->push_back(String8(componentName)); + // dumpRoles(mMaster, componentName); + ++index; } diff --git a/media/libstagefright/omx/OMXMaster.cpp b/media/libstagefright/omx/OMXMaster.cpp index 12302f3..9a45bea 100644 --- a/media/libstagefright/omx/OMXMaster.cpp +++ b/media/libstagefright/omx/OMXMaster.cpp @@ -24,14 +24,10 @@ #include "OMXPVCodecsPlugin.h" #endif -#include "OMXSoftwareCodecsPlugin.h" - namespace android { OMXMaster::OMXMaster() : mVendorLibHandle(NULL) { - addPlugin(new OMXSoftwareCodecsPlugin); - addVendorPlugin(); #ifndef NO_OPENCORE @@ -168,4 +164,21 @@ OMX_ERRORTYPE OMXMaster::enumerateComponents( return OMX_ErrorNone; } +OMX_ERRORTYPE OMXMaster::getRolesOfComponent( + const char *name, + Vector<String8> *roles) { + Mutex::Autolock autoLock(mLock); + + roles->clear(); + + ssize_t index = mPluginByComponentName.indexOfKey(String8(name)); + + if (index < 0) { + return OMX_ErrorInvalidComponentName; + } + + OMXPluginBase *plugin = mPluginByComponentName.valueAt(index); + return plugin->getRolesOfComponent(name, roles); +} + } // namespace android diff --git a/media/libstagefright/omx/OMXMaster.h b/media/libstagefright/omx/OMXMaster.h index e944c4a..7ba8d18 100644 --- a/media/libstagefright/omx/OMXMaster.h +++ b/media/libstagefright/omx/OMXMaster.h @@ -45,6 +45,10 @@ struct OMXMaster : public OMXPluginBase { size_t size, OMX_U32 index); + virtual OMX_ERRORTYPE getRolesOfComponent( + const char *name, + Vector<String8> *roles); + private: Mutex mLock; List<OMXPluginBase *> mPlugins; diff --git a/media/libstagefright/omx/OMXPVCodecsPlugin.cpp b/media/libstagefright/omx/OMXPVCodecsPlugin.cpp index 2bd8094..d1f5be3 100644 --- a/media/libstagefright/omx/OMXPVCodecsPlugin.cpp +++ b/media/libstagefright/omx/OMXPVCodecsPlugin.cpp @@ -54,4 +54,48 @@ OMX_ERRORTYPE OMXPVCodecsPlugin::enumerateComponents( return OMX_MasterComponentNameEnum(name, size, index); } +OMX_ERRORTYPE OMXPVCodecsPlugin::getRolesOfComponent( + const char *name, + Vector<String8> *roles) { + roles->clear(); + + OMX_U32 numRoles; + OMX_ERRORTYPE err = + OMX_MasterGetRolesOfComponent( + const_cast<char *>(name), + &numRoles, + NULL); + + if (err != OMX_ErrorNone) { + return err; + } + + if (numRoles > 0) { + OMX_U8 **array = new OMX_U8 *[numRoles]; + for (OMX_U32 i = 0; i < numRoles; ++i) { + array[i] = new OMX_U8[OMX_MAX_STRINGNAME_SIZE]; + } + + OMX_U32 numRoles2; + err = OMX_MasterGetRolesOfComponent( + const_cast<char *>(name), &numRoles2, array); + + CHECK_EQ(err, OMX_ErrorNone); + CHECK_EQ(numRoles, numRoles2); + + for (OMX_U32 i = 0; i < numRoles; ++i) { + String8 s((const char *)array[i]); + roles->push(s); + + delete[] array[i]; + array[i] = NULL; + } + + delete[] array; + array = NULL; + } + + return OMX_ErrorNone; +} + } // namespace android diff --git a/media/libstagefright/omx/OMXPVCodecsPlugin.h b/media/libstagefright/omx/OMXPVCodecsPlugin.h index f32eede..c133232 100644 --- a/media/libstagefright/omx/OMXPVCodecsPlugin.h +++ b/media/libstagefright/omx/OMXPVCodecsPlugin.h @@ -40,6 +40,10 @@ struct OMXPVCodecsPlugin : public OMXPluginBase { size_t size, OMX_U32 index); + virtual OMX_ERRORTYPE getRolesOfComponent( + const char *name, + Vector<String8> *roles); + private: OMXPVCodecsPlugin(const OMXPVCodecsPlugin &); OMXPVCodecsPlugin &operator=(const OMXPVCodecsPlugin &); diff --git a/media/libstagefright/omx/OMXSoftwareCodecsPlugin.cpp b/media/libstagefright/omx/OMXSoftwareCodecsPlugin.cpp deleted file mode 100644 index 51c7029..0000000 --- a/media/libstagefright/omx/OMXSoftwareCodecsPlugin.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "OMXSoftwareCodecsPlugin.h" - -#include <string.h> - -namespace android { - -typedef OMX_ERRORTYPE (*ComponentFactory)( - const OMX_CALLBACKTYPE *callbacks, OMX_PTR appData, - OMX_COMPONENTTYPE **component); - -static const struct ComponentInfo { - const char *mName; - ComponentFactory mFactory; -} kComponentInfos[] = { -}; - -OMXSoftwareCodecsPlugin::OMXSoftwareCodecsPlugin() { -} - -OMX_ERRORTYPE OMXSoftwareCodecsPlugin::makeComponentInstance( - const char *name, - const OMX_CALLBACKTYPE *callbacks, - OMX_PTR appData, - OMX_COMPONENTTYPE **component) { - *component = NULL; - - const size_t kNumComponentInfos = - sizeof(kComponentInfos) / sizeof(kComponentInfos[0]); - - for (size_t i = 0; i < kNumComponentInfos; ++i) { - if (!strcmp(kComponentInfos[i].mName, name)) { - return (*kComponentInfos[i].mFactory)( - callbacks, appData, component); - } - } - - return OMX_ErrorInvalidComponentName; -} - -OMX_ERRORTYPE OMXSoftwareCodecsPlugin::destroyComponentInstance( - OMX_COMPONENTTYPE *component) { - return (*component->ComponentDeInit)(component); -} - -OMX_ERRORTYPE OMXSoftwareCodecsPlugin::enumerateComponents( - OMX_STRING name, - size_t size, - OMX_U32 index) { - const size_t kNumComponentInfos = - sizeof(kComponentInfos) / sizeof(kComponentInfos[0]); - - if (index >= kNumComponentInfos) { - return OMX_ErrorNoMore; - } - - strncpy(name, kComponentInfos[index].mName, size - 1); - name[size - 1] = '\0'; - - return OMX_ErrorNone; -} - -} // namespace android diff --git a/media/libstagefright/omx/OMXSoftwareCodecsPlugin.h b/media/libstagefright/omx/OMXSoftwareCodecsPlugin.h deleted file mode 100644 index 5beeb26..0000000 --- a/media/libstagefright/omx/OMXSoftwareCodecsPlugin.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OMX_SOFTWARE_CODECS_PLUGIN_H_ - -#define OMX_SOFTWARE_CODECS_PLUGIN_H_ - -#include <media/stagefright/OMXPluginBase.h> - -namespace android { - -struct OMXSoftwareCodecsPlugin : public OMXPluginBase { - OMXSoftwareCodecsPlugin(); - - virtual OMX_ERRORTYPE makeComponentInstance( - const char *name, - const OMX_CALLBACKTYPE *callbacks, - OMX_PTR appData, - OMX_COMPONENTTYPE **component); - - virtual OMX_ERRORTYPE destroyComponentInstance( - OMX_COMPONENTTYPE *component); - - virtual OMX_ERRORTYPE enumerateComponents( - OMX_STRING name, - size_t size, - OMX_U32 index); - -private: - OMXSoftwareCodecsPlugin(const OMXSoftwareCodecsPlugin &); - OMXSoftwareCodecsPlugin &operator=(const OMXSoftwareCodecsPlugin &); -}; - -} // namespace android - -#endif // OMX_SOFTWARE_CODECS_PLUGIN_H_ - |