You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
3.4 KiB
101 lines
3.4 KiB
/*
|
|
* Copyright (c) Hisilicon Technologies Co., Ltd. 2016-2019. All rights reserved.
|
|
* Description: libnx_mediaplayer_wrapper implement
|
|
* Author: NxPlayer software group
|
|
* Create: 2019-11-21
|
|
*/
|
|
|
|
#ifndef MEDIAPLAYERSERVICE_EX_H
|
|
#define MEDIAPLAYERSERVICE_EX_H
|
|
|
|
#include <utils/List.h>
|
|
#include <utils/RefBase.h>
|
|
#include <utils/String16.h>
|
|
#include <dlfcn.h>
|
|
|
|
#include <MediaPlayerFactory.h>
|
|
#include <media/Metadata.h>
|
|
#include <media/MediaMetadataRetrieverInterface.h>
|
|
#include <media/MediaPlayerInterface.h>
|
|
|
|
namespace android {
|
|
/*
|
|
* Common delegate to the classes in libmediaplayerservice
|
|
*/
|
|
struct NxMediaPlayerServiceUtils {
|
|
// create NxMediaPlayerFactory.
|
|
static MediaPlayerFactory::IFactory* GetNxMediaPlayerFactory()
|
|
{
|
|
const char* factoryLib = "libnx_mediaplayer_wrapper.so";
|
|
const char* factoryCreateFn = "createNxMediaPlayerFactoryInstance";
|
|
|
|
ALOGI("Calling dlopen on nxmediaplayer lib.");
|
|
void* pFactoryLib = ::dlopen(factoryLib, RTLD_LAZY);
|
|
if (pFactoryLib == nullptr) {
|
|
ALOGI("Failed to open nxmediaplayer lib : %s", ::dlerror());
|
|
return nullptr;
|
|
}
|
|
|
|
ALOGI("Calling dlsym on nxmediaplayer lib for factoryCreateFn.");
|
|
typedef MediaPlayerFactory::IFactory* (*NxMediaPlayerFactoryInstanceCreate)();
|
|
NxMediaPlayerFactoryInstanceCreate pCreateFnPtr =
|
|
(NxMediaPlayerFactoryInstanceCreate) dlsym(pFactoryLib, factoryCreateFn);
|
|
if (pCreateFnPtr == nullptr) {
|
|
ALOGE("Could not locate nxmediaplayer pCreateFnPtr.");
|
|
dlclose(pFactoryLib);
|
|
pFactoryLib = nullptr;
|
|
return nullptr;
|
|
}
|
|
|
|
MediaPlayerFactory::IFactory* pFactory = pCreateFnPtr();
|
|
if (pFactory == nullptr) {
|
|
ALOGE("Failed to invoke NxMediaPlayerFactory.");
|
|
dlclose(pFactoryLib);
|
|
pFactoryLib = nullptr;
|
|
return nullptr;
|
|
}
|
|
|
|
ALOGI("Registering NxMediaPlayerFactory success.");
|
|
return pFactory;
|
|
}
|
|
|
|
// create nxmedia metadata retriever.
|
|
static sp<MediaMetadataRetrieverBase> GetNxPlayerMetaData()
|
|
{
|
|
const char* factoryLib = "libnx_mediaplayer_wrapper.so";
|
|
const char* factoryCreateFn = "createNxPlayerMetaDataInstance";
|
|
|
|
ALOGI("Calling dlopen on nxmediaplayer lib, metadata.");
|
|
void* pFactoryLib = ::dlopen(factoryLib, RTLD_LAZY);
|
|
if (pFactoryLib == nullptr) {
|
|
ALOGI("Failed to open nxmediaplayer lib : %s", ::dlerror());
|
|
return nullptr;
|
|
}
|
|
|
|
ALOGI("Calling dlsym on nxmediaplayer lib for factoryCreateFn.");
|
|
typedef MediaMetadataRetrieverBase* (*NxPlayerMetaDataInstanceCreate)();
|
|
NxPlayerMetaDataInstanceCreate pCreateFnPtr =
|
|
(NxPlayerMetaDataInstanceCreate) dlsym(pFactoryLib, factoryCreateFn);
|
|
if (pCreateFnPtr == nullptr) {
|
|
ALOGE("Could not locate NxPlayerMetaDataInstance pCreateFnPtr.");
|
|
dlclose(pFactoryLib);
|
|
pFactoryLib = nullptr;
|
|
return nullptr;
|
|
}
|
|
|
|
MediaMetadataRetrieverBase* pFactory = pCreateFnPtr();
|
|
if (pFactory == nullptr) {
|
|
ALOGE("Failed to invoke createNxPlayerMetaData.");
|
|
dlclose(pFactoryLib);
|
|
pFactoryLib = nullptr;
|
|
return nullptr;
|
|
}
|
|
|
|
ALOGI("CreateNxPlayerMetaData success.");
|
|
return pFactory;
|
|
}
|
|
};
|
|
}
|
|
|
|
#endif // MEDIAPLAYERSERVICE_EX_H
|