Merge "Allow customized registration of codec services" into pi-dev am: d549c0835a

am: 38ca1a3c28

Change-Id: Id6a3c8e218845d49d33e9661a960458490bdc2e6
gugelfrei
Pawin Vongmasa 6 years ago committed by android-build-merger
commit 82a8d3aa9e

@ -0,0 +1,23 @@
/*
* 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_

@ -25,6 +25,9 @@
#include <media/stagefright/omx/1.0/Omx.h>
#include <media/stagefright/omx/1.0/OmxStore.h>
#include <media/CodecServiceRegistrant.h>
#include <dlfcn.h>
using namespace android;
// Must match location in Android.mk.
@ -45,20 +48,37 @@ int main(int argc __unused, char** argv)
::android::hardware::configureRpcThreadpool(64, false);
using namespace ::android::hardware::media::omx::V1_0;
sp<IOmxStore> omxStore = new implementation::OmxStore();
if (omxStore == nullptr) {
LOG(ERROR) << "Cannot create IOmxStore HAL service.";
} else if (omxStore->registerAsService() != OK) {
LOG(ERROR) << "Cannot register IOmxStore HAL service.";
}
sp<IOmx> omx = new implementation::Omx();
if (omx == nullptr) {
LOG(ERROR) << "Cannot create IOmx HAL service.";
} else if (omx->registerAsService() != OK) {
LOG(ERROR) << "Cannot register IOmx HAL service.";
// 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 {
LOG(INFO) << "IOmx HAL service created.";
// Default codec services
using namespace ::android::hardware::media::omx::V1_0;
sp<IOmxStore> omxStore = new implementation::OmxStore();
if (omxStore == nullptr) {
LOG(ERROR) << "Cannot create IOmxStore HAL service.";
} else if (omxStore->registerAsService() != OK) {
LOG(ERROR) << "Cannot register IOmxStore HAL service.";
}
sp<IOmx> omx = new implementation::Omx();
if (omx == nullptr) {
LOG(ERROR) << "Cannot create IOmx HAL service.";
} else if (omx->registerAsService() != OK) {
LOG(ERROR) << "Cannot register IOmx HAL service.";
} else {
LOG(INFO) << "IOmx HAL service created.";
}
}
::android::hardware::joinRpcThreadpool();

Loading…
Cancel
Save