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

Commit a66243a7 authored by Pawin Vongmasa's avatar Pawin Vongmasa
Browse files

Allow customized registration of codec services

Test: adb bugreport

Bug: 78206546
Change-Id: Id42d57b8b647570e68de228de856a39b2755862d
parent 67f280ee
Loading
Loading
Loading
Loading
+23 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef CODEC_SERVICE_REGISTRANT_H_

#define CODEC_SERVICE_REGISTRANT_H_

typedef void (*RegisterCodecServicesFunc)();

#endif  // CODEC_SERVICE_REGISTRANT_H_
+33 −13
Original line number Original line Diff line number Diff line
@@ -25,6 +25,9 @@
#include <media/stagefright/omx/1.0/Omx.h>
#include <media/stagefright/omx/1.0/Omx.h>
#include <media/stagefright/omx/1.0/OmxStore.h>
#include <media/stagefright/omx/1.0/OmxStore.h>


#include <media/CodecServiceRegistrant.h>
#include <dlfcn.h>

using namespace android;
using namespace android;


// Must match location in Android.mk.
// Must match location in Android.mk.
@@ -45,6 +48,22 @@ int main(int argc __unused, char** argv)


    ::android::hardware::configureRpcThreadpool(64, false);
    ::android::hardware::configureRpcThreadpool(64, false);


    // Registration of customized codec services
    void *registrantLib = dlopen(
            "libmedia_codecserviceregistrant.so",
            RTLD_NOW | RTLD_LOCAL);
    if (registrantLib) {
        RegisterCodecServicesFunc registerCodecServices =
                reinterpret_cast<RegisterCodecServicesFunc>(
                dlsym(registrantLib, "RegisterCodecServices"));
        if (registerCodecServices) {
            registerCodecServices();
        } else {
            LOG(WARNING) << "Cannot register additional services "
                    "-- corrupted library.";
        }
    } else {
        // Default codec services
        using namespace ::android::hardware::media::omx::V1_0;
        using namespace ::android::hardware::media::omx::V1_0;
        sp<IOmxStore> omxStore = new implementation::OmxStore();
        sp<IOmxStore> omxStore = new implementation::OmxStore();
        if (omxStore == nullptr) {
        if (omxStore == nullptr) {
@@ -60,6 +79,7 @@ int main(int argc __unused, char** argv)
        } else {
        } else {
            LOG(INFO) << "IOmx HAL service created.";
            LOG(INFO) << "IOmx HAL service created.";
        }
        }
    }


    ::android::hardware::joinRpcThreadpool();
    ::android::hardware::joinRpcThreadpool();
}
}