omx: only list existing OMX codecs in OmxStore
Bug: 129710438
Change-Id: Iaeba313ec94838880a8d20d775866f20454104be
diff --git a/media/libstagefright/omx/1.0/OmxStore.cpp b/media/libstagefright/omx/1.0/OmxStore.cpp
index 2e041e3..89292e8 100644
--- a/media/libstagefright/omx/1.0/OmxStore.cpp
+++ b/media/libstagefright/omx/1.0/OmxStore.cpp
@@ -17,6 +17,8 @@
#include <ios>
#include <list>
+#define LOG_TAG "OmxStore"
+
#include <android-base/logging.h>
#include <media/stagefright/omx/1.0/Conversion.h>
@@ -30,12 +32,29 @@
namespace V1_0 {
namespace implementation {
+using ::android::hardware::media::omx::V1_0::Status;
+using ::android::hardware::media::omx::V1_0::IOmx;
+
OmxStore::OmxStore(
+ const sp<IOmx> &omx,
const char* owner,
const char* const* searchDirs,
const char* mainXmlName,
const char* performanceXmlName,
const char* profilingResultsXmlPath) {
+ // retrieve list of omx nodes
+ std::set<std::string> nodes;
+ if (omx != nullptr) {
+ omx->listNodes([&nodes](const Status &status,
+ const hidl_vec<IOmx::ComponentInfo> &nodeList) {
+ if (status == Status::OK) {
+ for (const IOmx::ComponentInfo& info : nodeList) {
+ nodes.emplace(info.mName.c_str());
+ }
+ }
+ });
+ }
+
MediaCodecsXmlParser parser(searchDirs,
mainXmlName,
performanceXmlName,
@@ -66,6 +85,13 @@
nodeList.resize(rolePair.second.nodeList.size());
size_t j = 0;
for (const auto& nodePair : rolePair.second.nodeList) {
+ if (!nodes.count(nodePair.second.name)) {
+ // not supported by this OMX instance
+ if (!strncasecmp(nodePair.second.name.c_str(), "omx.", 4)) {
+ LOG(INFO) << "node [" << nodePair.second.name.c_str() << "] not found in IOmx";
+ }
+ continue;
+ }
NodeInfo node;
node.name = nodePair.second.name;
node.owner = owner;
@@ -82,6 +108,7 @@
nodeList[j] = std::move(node);
++j;
}
+ nodeList.resize(j);
mRoleList[i] = std::move(role);
++i;
}
diff --git a/media/libstagefright/omx/include/media/stagefright/omx/1.0/OmxStore.h b/media/libstagefright/omx/include/media/stagefright/omx/1.0/OmxStore.h
index 006d2d9..0fcea48 100644
--- a/media/libstagefright/omx/include/media/stagefright/omx/1.0/OmxStore.h
+++ b/media/libstagefright/omx/include/media/stagefright/omx/1.0/OmxStore.h
@@ -20,6 +20,7 @@
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
+#include <android/hardware/media/omx/1.0/IOmx.h>
#include <android/hardware/media/omx/1.0/IOmxStore.h>
#include <media/stagefright/xmlparser/MediaCodecsXmlParser.h>
@@ -43,6 +44,7 @@
struct OmxStore : public IOmxStore {
OmxStore(
+ const sp<IOmx> &omx = nullptr,
const char* owner = "default",
const char* const* searchDirs
= MediaCodecsXmlParser::defaultSearchDirs,
diff --git a/services/mediacodec/main_codecservice.cpp b/services/mediacodec/main_codecservice.cpp
index 6ffbd26..f668c33 100644
--- a/services/mediacodec/main_codecservice.cpp
+++ b/services/mediacodec/main_codecservice.cpp
@@ -49,12 +49,6 @@
// Default codec services
using namespace ::android::hardware::media::omx::V1_0;
- sp<IOmxStore> omxStore = new implementation::OmxStore();
- if (omxStore == nullptr) {
- LOG(ERROR) << "Cannot create IOmxStore HAL service.";
- } else if (omxStore->registerAsService() != OK) {
- LOG(ERROR) << "Cannot register IOmxStore HAL service.";
- }
sp<IOmx> omx = new implementation::Omx();
if (omx == nullptr) {
LOG(ERROR) << "Cannot create IOmx HAL service.";
@@ -63,6 +57,12 @@
} else {
LOG(INFO) << "IOmx HAL service created.";
}
+ sp<IOmxStore> omxStore = new implementation::OmxStore(omx);
+ if (omxStore == nullptr) {
+ LOG(ERROR) << "Cannot create IOmxStore HAL service.";
+ } else if (omxStore->registerAsService() != OK) {
+ LOG(ERROR) << "Cannot register IOmxStore HAL service.";
+ }
::android::hardware::joinRpcThreadpool();
}