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.
103 lines
2.3 KiB
103 lines
2.3 KiB
/*
|
|
* Copyright (c) Hisilicon Technologies Co., Ltd.. 2019-2020. All rights reserved.
|
|
* Description: bootvideo api
|
|
*/
|
|
|
|
#include "BootvideoApi.h"
|
|
#include "BootvideoManager.h"
|
|
#include "BootvideoPlayer.h"
|
|
|
|
#undef LOG_TAG
|
|
#define LOG_TAG "BootVideo_Api"
|
|
|
|
namespace android {
|
|
using namespace std;
|
|
|
|
UserRegisterFunc g_userCallbackFunc;
|
|
const void *g_userCallbackArgs = nullptr;
|
|
int g_userCallbackInterval = 0;
|
|
|
|
int RegisterFirstFrameCallback(lpfnBootVideoCallback cb)
|
|
{
|
|
if (cb != nullptr) {
|
|
g_userCallbackFunc.firstFrameCb = cb;
|
|
return 0;
|
|
} else {
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
int RegisterLastFrameCallback(lpfnBootVideoCallback cb)
|
|
{
|
|
if (cb != nullptr) {
|
|
g_userCallbackFunc.lastFrameCb = cb;
|
|
return 0;
|
|
} else {
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
int RegisterVideoCallback(lpfnBootVideoCallback cb)
|
|
{
|
|
if (cb != nullptr) {
|
|
g_userCallbackFunc.runIntervalCb = cb;
|
|
return 0;
|
|
} else {
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
int StartBootVideo(const char *path, int callbackInterval, const void *arg)
|
|
{
|
|
// if you are using the API, you must call this function to set path
|
|
// else you must not call this function and the path of config.xml
|
|
BootvideoSetPath(path);
|
|
|
|
g_userCallbackArgs = arg;
|
|
g_userCallbackInterval = callbackInterval;
|
|
|
|
if (!StartPlayBootvideo()) {
|
|
return -1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
void StopBootVideo()
|
|
{
|
|
StopPlayBootVideo();
|
|
return;
|
|
}
|
|
|
|
int DoUserRegisterCallback(UserCallBackEnum type)
|
|
{
|
|
const void* usrParas = g_userCallbackArgs;
|
|
|
|
if (type == VIDEO_CB_FIRSTFRAME && g_userCallbackFunc.firstFrameCb != nullptr) {
|
|
return g_userCallbackFunc.firstFrameCb(usrParas, 0, nullptr);
|
|
}
|
|
|
|
if (type == VIDEO_CB_LASTFRAME && g_userCallbackFunc.lastFrameCb != nullptr) {
|
|
return g_userCallbackFunc.lastFrameCb(usrParas, 0, nullptr);
|
|
}
|
|
|
|
if (type == VIDEO_CB_RUNNING && g_userCallbackFunc.runIntervalCb != nullptr) {
|
|
int remainTime = GetPlayTimeInfo();
|
|
if (remainTime == -1) {
|
|
ALOGE("GetPlayTimeInfo err in DoUserRegisterCallback");
|
|
} else {
|
|
return g_userCallbackFunc.runIntervalCb(usrParas, remainTime, nullptr);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int GetUserCallBackInterval()
|
|
{
|
|
if (g_userCallbackInterval != 0) {
|
|
return g_userCallbackInterval;
|
|
}
|
|
return -1;
|
|
}
|
|
}
|