Loading media/libstagefright/MediaCodec.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -479,6 +479,13 @@ sp<MediaCodec> MediaCodec::CreateByComponentName( // static sp<PersistentSurface> MediaCodec::CreatePersistentInputSurface() { // allow plugin to create surface sp<PersistentSurface> pluginSurface = StagefrightPluginLoader::GetCCodecInstance()->createInputSurface(); if (pluginSurface != nullptr) { return pluginSurface; } OMXClient client; if (client.connect() != OK) { ALOGE("Failed to connect to OMX to create persistent input surface."); Loading media/libstagefright/MediaCodecList.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -92,7 +92,14 @@ MediaCodecListBuilderBase *GetCodec2InfoBuilder() { } std::vector<MediaCodecListBuilderBase *> GetBuilders() { std::vector<MediaCodecListBuilderBase *> builders {&sOmxInfoBuilder}; std::vector<MediaCodecListBuilderBase *> builders; // if plugin provides the input surface, we cannot use OMX video encoders. // In this case, rely on plugin to provide list of OMX codecs that are usable. sp<PersistentSurface> surfaceTest = StagefrightPluginLoader::GetCCodecInstance()->createInputSurface(); if (surfaceTest == nullptr) { builders.push_back(&sOmxInfoBuilder); } builders.push_back(GetCodec2InfoBuilder()); return builders; } Loading media/libstagefright/StagefrightPluginLoader.cpp +13 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,11 @@ StagefrightPluginLoader::StagefrightPluginLoader(const char *libPath) if (mCreateBuilder == nullptr) { ALOGD("Failed to find symbol: CreateBuilder (%s)", dlerror()); } mCreateInputSurface = (CodecBase::CreateInputSurfaceFunc)dlsym( mLibHandle, "CreateInputSurface"); if (mCreateBuilder == nullptr) { ALOGD("Failed to find symbol: CreateInputSurface (%s)", dlerror()); } } StagefrightPluginLoader::~StagefrightPluginLoader() { Loading @@ -69,6 +74,14 @@ MediaCodecListBuilderBase *StagefrightPluginLoader::createBuilder() { return mCreateBuilder(); } PersistentSurface *StagefrightPluginLoader::createInputSurface() { if (mLibHandle == nullptr || mCreateInputSurface == nullptr) { ALOGD("Handle or CreateInputSurface symbol is null"); return nullptr; } return mCreateInputSurface(); } //static const std::unique_ptr<StagefrightPluginLoader> &StagefrightPluginLoader::GetCCodecInstance() { Mutex::Autolock _l(sMutex); Loading media/libstagefright/StagefrightPluginLoader.h +4 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include <media/stagefright/CodecBase.h> #include <media/stagefright/MediaCodecListWriter.h> #include <media/stagefright/PersistentSurface.h> #include <utils/Mutex.h> namespace android { Loading @@ -31,6 +32,8 @@ public: CodecBase *createCodec(); MediaCodecListBuilderBase *createBuilder(); PersistentSurface *createInputSurface(); private: explicit StagefrightPluginLoader(const char *libPath); Loading @@ -40,6 +43,7 @@ private: void *mLibHandle; CodecBase::CreateCodecFunc mCreateCodec; MediaCodecListBuilderBase::CreateBuilderFunc mCreateBuilder; CodecBase::CreateInputSurfaceFunc mCreateInputSurface; }; } // namespace android Loading media/libstagefright/include/media/stagefright/CodecBase.h +1 −0 Original line number Diff line number Diff line Loading @@ -223,6 +223,7 @@ struct CodecBase : public AHandler, /* static */ ColorUtils { virtual void signalEndOfInputStream() = 0; typedef CodecBase *(*CreateCodecFunc)(void); typedef PersistentSurface *(*CreateInputSurfaceFunc)(void); protected: CodecBase() = default; Loading Loading
media/libstagefright/MediaCodec.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -479,6 +479,13 @@ sp<MediaCodec> MediaCodec::CreateByComponentName( // static sp<PersistentSurface> MediaCodec::CreatePersistentInputSurface() { // allow plugin to create surface sp<PersistentSurface> pluginSurface = StagefrightPluginLoader::GetCCodecInstance()->createInputSurface(); if (pluginSurface != nullptr) { return pluginSurface; } OMXClient client; if (client.connect() != OK) { ALOGE("Failed to connect to OMX to create persistent input surface."); Loading
media/libstagefright/MediaCodecList.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -92,7 +92,14 @@ MediaCodecListBuilderBase *GetCodec2InfoBuilder() { } std::vector<MediaCodecListBuilderBase *> GetBuilders() { std::vector<MediaCodecListBuilderBase *> builders {&sOmxInfoBuilder}; std::vector<MediaCodecListBuilderBase *> builders; // if plugin provides the input surface, we cannot use OMX video encoders. // In this case, rely on plugin to provide list of OMX codecs that are usable. sp<PersistentSurface> surfaceTest = StagefrightPluginLoader::GetCCodecInstance()->createInputSurface(); if (surfaceTest == nullptr) { builders.push_back(&sOmxInfoBuilder); } builders.push_back(GetCodec2InfoBuilder()); return builders; } Loading
media/libstagefright/StagefrightPluginLoader.cpp +13 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,11 @@ StagefrightPluginLoader::StagefrightPluginLoader(const char *libPath) if (mCreateBuilder == nullptr) { ALOGD("Failed to find symbol: CreateBuilder (%s)", dlerror()); } mCreateInputSurface = (CodecBase::CreateInputSurfaceFunc)dlsym( mLibHandle, "CreateInputSurface"); if (mCreateBuilder == nullptr) { ALOGD("Failed to find symbol: CreateInputSurface (%s)", dlerror()); } } StagefrightPluginLoader::~StagefrightPluginLoader() { Loading @@ -69,6 +74,14 @@ MediaCodecListBuilderBase *StagefrightPluginLoader::createBuilder() { return mCreateBuilder(); } PersistentSurface *StagefrightPluginLoader::createInputSurface() { if (mLibHandle == nullptr || mCreateInputSurface == nullptr) { ALOGD("Handle or CreateInputSurface symbol is null"); return nullptr; } return mCreateInputSurface(); } //static const std::unique_ptr<StagefrightPluginLoader> &StagefrightPluginLoader::GetCCodecInstance() { Mutex::Autolock _l(sMutex); Loading
media/libstagefright/StagefrightPluginLoader.h +4 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include <media/stagefright/CodecBase.h> #include <media/stagefright/MediaCodecListWriter.h> #include <media/stagefright/PersistentSurface.h> #include <utils/Mutex.h> namespace android { Loading @@ -31,6 +32,8 @@ public: CodecBase *createCodec(); MediaCodecListBuilderBase *createBuilder(); PersistentSurface *createInputSurface(); private: explicit StagefrightPluginLoader(const char *libPath); Loading @@ -40,6 +43,7 @@ private: void *mLibHandle; CodecBase::CreateCodecFunc mCreateCodec; MediaCodecListBuilderBase::CreateBuilderFunc mCreateBuilder; CodecBase::CreateInputSurfaceFunc mCreateInputSurface; }; } // namespace android Loading
media/libstagefright/include/media/stagefright/CodecBase.h +1 −0 Original line number Diff line number Diff line Loading @@ -223,6 +223,7 @@ struct CodecBase : public AHandler, /* static */ ColorUtils { virtual void signalEndOfInputStream() = 0; typedef CodecBase *(*CreateCodecFunc)(void); typedef PersistentSurface *(*CreateInputSurfaceFunc)(void); protected: CodecBase() = default; Loading