frameworks/av
Revisión | 25360cdb78caafbaac5241d9de4f4b9291cde9d2 (tree) |
---|---|
Tiempo | 2020-04-14 22:49:59 |
Autor | Steve Kondik <steve@cyng...> |
Commiter | Chih-Wei Huang |
stagefright: Add support for loading a custom OMXPlugin
Change-Id: I27d7e16ad56baa17754d8ea47a8c608a0d73d6f1
@@ -27,6 +27,8 @@ | ||
27 | 27 | #include <dlfcn.h> |
28 | 28 | #include <fcntl.h> |
29 | 29 | |
30 | +#include <cutils/properties.h> | |
31 | + | |
30 | 32 | namespace android { |
31 | 33 | |
32 | 34 | OMXMaster::OMXMaster() { |
@@ -52,6 +54,7 @@ OMXMaster::OMXMaster() { | ||
52 | 54 | |
53 | 55 | addVendorPlugin(); |
54 | 56 | addPlatformPlugin(); |
57 | + addUserPlugin(); | |
55 | 58 | } |
56 | 59 | |
57 | 60 | OMXMaster::~OMXMaster() { |
@@ -66,6 +69,13 @@ void OMXMaster::addPlatformPlugin() { | ||
66 | 69 | addPlugin("libstagefright_softomx_plugin.so"); |
67 | 70 | } |
68 | 71 | |
72 | +void OMXMaster::addUserPlugin() { | |
73 | + char plugin[PROPERTY_VALUE_MAX]; | |
74 | + if (property_get("media.sf.omx-plugin", plugin, NULL)) { | |
75 | + addPlugin(plugin); | |
76 | + } | |
77 | +} | |
78 | + | |
69 | 79 | void OMXMaster::addPlugin(const char *libname) { |
70 | 80 | void *libHandle = android_load_sphal_library(libname, RTLD_NOW); |
71 | 81 |
@@ -91,6 +91,7 @@ OMX_ERRORTYPE SoftOMXPlugin::makeComponentInstance( | ||
91 | 91 | OMX_COMPONENTTYPE **component) { |
92 | 92 | ALOGV("makeComponentInstance '%s'", name); |
93 | 93 | |
94 | + dlerror(); // clear any existing error | |
94 | 95 | for (size_t i = 0; i < kNumComponents; ++i) { |
95 | 96 | if (strcmp(name, kComponents[i].mName)) { |
96 | 97 | continue; |
@@ -122,6 +123,8 @@ OMX_ERRORTYPE SoftOMXPlugin::makeComponentInstance( | ||
122 | 123 | return OMX_ErrorComponentNotFound; |
123 | 124 | } |
124 | 125 | |
126 | + ALOGV("load component %s for %s", libName.c_str(), name); | |
127 | + | |
125 | 128 | typedef SoftOMXComponent *(*CreateSoftOMXComponentFunc)( |
126 | 129 | const char *, const OMX_CALLBACKTYPE *, |
127 | 130 | OMX_PTR, OMX_COMPONENTTYPE **); |
@@ -132,7 +135,8 @@ OMX_ERRORTYPE SoftOMXPlugin::makeComponentInstance( | ||
132 | 135 | "_Z22createSoftOMXComponentPKcPK16OMX_CALLBACKTYPE" |
133 | 136 | "PvPP17OMX_COMPONENTTYPE"); |
134 | 137 | |
135 | - if (createSoftOMXComponent == NULL) { | |
138 | + if (const char *error = dlerror()) { | |
139 | + ALOGE("unable to dlsym %s: %s", libName.c_str(), error); | |
136 | 140 | dlclose(libHandle); |
137 | 141 | libHandle = NULL; |
138 | 142 |
@@ -62,6 +62,7 @@ private: | ||
62 | 62 | |
63 | 63 | void addVendorPlugin(); |
64 | 64 | void addPlatformPlugin(); |
65 | + void addUserPlugin(); | |
65 | 66 | void addPlugin(const char *libname); |
66 | 67 | void addPlugin(OMXPluginBase *plugin); |
67 | 68 | void clearPlugins(); |