Merge change Ic7e91eee into eclair-mr2
* changes: Add a new API to support determining the roles of an OMX component specified by name. Remove unneeded OMXSoftwareCodecsPlugin.
This commit is contained in:
@@ -22,6 +22,9 @@
|
||||
|
||||
#include <OMX_Component.h>
|
||||
|
||||
#include <utils/String8.h>
|
||||
#include <utils/Vector.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
struct OMXComponentBase;
|
||||
@@ -44,6 +47,10 @@ struct OMXPluginBase {
|
||||
size_t size,
|
||||
OMX_U32 index) = 0;
|
||||
|
||||
virtual OMX_ERRORTYPE getRolesOfComponent(
|
||||
const char *name,
|
||||
Vector<String8> *roles) = 0;
|
||||
|
||||
private:
|
||||
OMXPluginBase(const OMXPluginBase &);
|
||||
OMXPluginBase &operator=(const OMXPluginBase &);
|
||||
|
||||
@@ -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 += \
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 &);
|
||||
|
||||
@@ -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
|
||||
@@ -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_
|
||||
|
||||
Reference in New Issue
Block a user