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

Commit d3663c97 authored by Lajos Molnar's avatar Lajos Molnar
Browse files

stagefright: allow plugin to create persistent input surface

Bug: 67591367
Change-Id: Iad90113513a19ecaefeb33c891a94265c93f59e9
parent df1ecbf2
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -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.");
+8 −1
Original line number Diff line number Diff line
@@ -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;
}
+13 −0
Original line number Diff line number Diff line
@@ -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() {
@@ -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);
+4 −0
Original line number Diff line number Diff line
@@ -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 {
@@ -31,6 +32,8 @@ public:

    CodecBase *createCodec();
    MediaCodecListBuilderBase *createBuilder();
    PersistentSurface *createInputSurface();

private:
    explicit StagefrightPluginLoader(const char *libPath);

@@ -40,6 +43,7 @@ private:
    void *mLibHandle;
    CodecBase::CreateCodecFunc mCreateCodec;
    MediaCodecListBuilderBase::CreateBuilderFunc mCreateBuilder;
    CodecBase::CreateInputSurfaceFunc mCreateInputSurface;
};

}  // namespace android
+1 −0
Original line number Diff line number Diff line
@@ -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