Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3c3d1d26 authored by Lajos Molnar's avatar Lajos Molnar
Browse files

omx: only list existing OMX codecs in OmxStore

Bug: 129710438
Change-Id: Iaeba313ec94838880a8d20d775866f20454104be
parent 9f5591ac
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -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 omx {
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 @@ OmxStore::OmxStore(
        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 @@ OmxStore::OmxStore(
            nodeList[j] = std::move(node);
            ++j;
        }
        nodeList.resize(j);
        mRoleList[i] = std::move(role);
        ++i;
    }
+2 −0
Original line number Diff line number Diff line
@@ -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 @@ using ::android::wp;

struct OmxStore : public IOmxStore {
    OmxStore(
            const sp<IOmx> &omx = nullptr,
            const char* owner = "default",
            const char* const* searchDirs
                = MediaCodecsXmlParser::defaultSearchDirs,
+6 −6
Original line number Diff line number Diff line
@@ -49,12 +49,6 @@ int main(int argc __unused, char** argv)

    // 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 @@ int main(int argc __unused, char** argv)
    } 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();
}