Skip to content

Instantly share code, notes, and snippets.

@droogie
Forked from phhusson/omx-store.cpp
Last active March 19, 2022 01:17
Show Gist options
  • Save droogie/84a9c788c185d418be4b54b589785037 to your computer and use it in GitHub Desktop.
Save droogie/84a9c788c185d418be4b54b589785037 to your computer and use it in GitHub Desktop.
List OMX codecs through treble HAL
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := omx-store.cpp
LOCAL_SHARED_LIBRARIES := libutils liblog [email protected] [email protected] libcutils \
[email protected] \
[email protected] \
libhidlbase libbase
LOCAL_CFLAGS += -Wno-multichar -Werror -Wall
LOCAL_MODULE:= omx-store
include $(BUILD_EXECUTABLE)
#include <iostream>
#include <unistd.h>
#include <android/hardware/media/omx/1.0/IOmxStore.h>
using ::android::hardware::media::omx::V1_0::IOmxStore;
using ::android::sp;
int main(int argc, char **argv) {
auto svc = IOmxStore::getService();
{
auto res = svc->getNodePrefix([](const auto& prefix) {
std::cout << "Got prefix " << prefix << std::endl;
});
if(!res.isOk()) exit(1);
}
auto res = svc->listRoles([](const auto& roles) {
for(auto role : roles) {
std::cout << "Role " << role.role << std::endl;
std::cout << "\tType: " << role.type << std::endl;
std::cout << "\tNodes:" << std::endl;
for(auto node : role.nodes) {
std::cout << "\t\t" << node.name << std::endl;
std::cout << "\t\t\t" << node.owner << std::endl;
for(auto attribute: node.attributes) {
std::cout << "\t\t\t" << attribute.key << "=" << attribute.value << std::endl;
}
}
}
} );
if(!res.isOk()) exit(2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment