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

Commit 033975f9 authored by Pawin Vongmasa's avatar Pawin Vongmasa
Browse files

Add the Treble version of OMX to the service.

To enable the Treble version of IOmx in mediacodec process, use "setprop
debug.treble_omx 1".

Test: Compiles
Bug: 31399200
Change-Id: I0935dc7943e25067f5d8e75264cf2b088498a862
parent 94e36c56
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -17,7 +17,8 @@ include $(CLEAR_VARS)
LOCAL_REQUIRED_MODULES_arm := mediacodec-seccomp.policy
LOCAL_REQUIRED_MODULES_arm := mediacodec-seccomp.policy
LOCAL_SRC_FILES := main_codecservice.cpp minijail/minijail.cpp
LOCAL_SRC_FILES := main_codecservice.cpp minijail/minijail.cpp
LOCAL_SHARED_LIBRARIES := libmedia libmediacodecservice libbinder libutils \
LOCAL_SHARED_LIBRARIES := libmedia libmediacodecservice libbinder libutils \
	liblog libminijail
    liblog libminijail libcutils \
    android.hardware.media.omx@1.0
LOCAL_C_INCLUDES := \
LOCAL_C_INCLUDES := \
    $(TOP)/frameworks/av/media/libstagefright \
    $(TOP)/frameworks/av/media/libstagefright \
    $(TOP)/frameworks/native/include/media/openmax
    $(TOP)/frameworks/native/include/media/openmax
+18 −0
Original line number Original line Diff line number Diff line
@@ -25,11 +25,14 @@
#include <binder/ProcessState.h>
#include <binder/ProcessState.h>
#include <binder/IServiceManager.h>
#include <binder/IServiceManager.h>
#include <utils/Log.h>
#include <utils/Log.h>
#include <cutils/properties.h>


// from LOCAL_C_INCLUDES
// from LOCAL_C_INCLUDES
#include "MediaCodecService.h"
#include "MediaCodecService.h"
#include "minijail/minijail.h"
#include "minijail/minijail.h"


#include <android/hardware/media/omx/1.0/IOmx.h>

using namespace android;
using namespace android;


int main(int argc __unused, char** argv)
int main(int argc __unused, char** argv)
@@ -42,6 +45,21 @@ int main(int argc __unused, char** argv)
    sp<ProcessState> proc(ProcessState::self());
    sp<ProcessState> proc(ProcessState::self());
    sp<IServiceManager> sm = defaultServiceManager();
    sp<IServiceManager> sm = defaultServiceManager();
    MediaCodecService::instantiate();
    MediaCodecService::instantiate();

    // Treble
    bool useTrebleOmx = bool(property_get_bool("debug.treble_omx", 0));
    if (useTrebleOmx) {
        using namespace ::android::hardware::media::omx::V1_0;
        sp<IOmx> omx = IOmx::getService(true);
        if (omx == nullptr) {
            ALOGE("Cannot create a Treble IOmx service.");
        } else if (omx->registerAsService("default") != OK) {
            ALOGE("Cannot register a Treble IOmx service.");
        } else {
            ALOGV("Treble IOmx service created.");
        }
    }

    ProcessState::self()->startThreadPool();
    ProcessState::self()->startThreadPool();
    IPCThreadState::self()->joinThreadPool();
    IPCThreadState::self()->joinThreadPool();
}
}