135 lines
4.1 KiB
C++
135 lines
4.1 KiB
C++
/*
|
|
*******************************************************************************
|
|
* INCLUDE
|
|
*******************************************************************************
|
|
*/
|
|
#include "MPPChannel.h"
|
|
#include "Logger.h"
|
|
#include <hi_common.h>
|
|
#include <hi_mpi_sys.h>
|
|
#include <Poco/Format.h>
|
|
|
|
/*
|
|
*******************************************************************************
|
|
* MACROS
|
|
*******************************************************************************
|
|
*/
|
|
#define HI_MPP_CHN_DECLARE(name, ref) \
|
|
hi_mpp_chn name \
|
|
{ \
|
|
(hi_mod_id)(ref).moduleID(), (hi_s32)(ref).deviceID(), (hi_s32)(ref).channelID(), \
|
|
}
|
|
|
|
namespace Video
|
|
{
|
|
namespace MPP5
|
|
{
|
|
/*
|
|
*******************************************************************************
|
|
* CLASS DEFINE
|
|
*******************************************************************************
|
|
*/
|
|
static const char* moduleNames[] = {
|
|
"CMPI", "VB", "SYS",
|
|
"RGN", "CHNL", "VDEC",
|
|
"AVS", "VPSS", "VENC",
|
|
"SVP", "H264E", "JPEGE",
|
|
"UNKNOWN", "H265E", "JPEGD",
|
|
"VO", "VI", "DIS",
|
|
"VALG", "RC", "AIO",
|
|
"AI", "AO", "AENC",
|
|
"ADEC", "VPU", "PCIV",
|
|
"PCIVFMW", "ISP", "IVE",
|
|
"USER", "UNKNOWN", "UNKNOWN",
|
|
"PROC", "LOG", "VFMW",
|
|
"UNKNOWN", "GDC", "PHOTO",
|
|
"FB", "HDMI", "VOIE",
|
|
"TDE", "HDR", "PRORES",
|
|
"VGS", "UNKNOWN", "FD",
|
|
"OD", "UNKNOWN", "LPR",
|
|
"SVP_NNIE", "SVP_DSP", "DPU_RECT",
|
|
"DPU_MATCH", "MOTIONSENSOR", "MOTIONFUSION",
|
|
"GYRODIS", "PM", "SVP_ALG",
|
|
"IVP", "MCF", "SVP_MAU",
|
|
"VDA", "VPP", "KCF",
|
|
"PQP", "NPUDEV", "AICPU",
|
|
"NPUDFX", "TSFW", "CIPHER",
|
|
"KLAD", "KEYSLOT", "OTP",
|
|
"VDEC_ADAPT", "DCC", "VDEC_SERVER",
|
|
"VFMW_MDC", "VB_LOG", "MCF_CALIBRATION",
|
|
"SVP_NPU", "HNR", "SNAP",
|
|
"LOG_MDC", "UVC", "FISHEYE_CALIBRATION",
|
|
};
|
|
|
|
MPPChannel::MPPChannel(uint32_t moduleID, uint32_t deviceID, uint32_t channelID)
|
|
: _moduleID(moduleID), _deviceID(deviceID), _channelID(channelID)
|
|
{
|
|
}
|
|
|
|
std::string MPPChannel::toString() const
|
|
{
|
|
const char* name = "UNKNOWN";
|
|
if (moduleID() < HI_ID_FISHEYE_CALIBRATION)
|
|
name = moduleNames[moduleID()];
|
|
|
|
return Poco::format("%s(%u:%u)", std::string(name), deviceID(), channelID());
|
|
}
|
|
|
|
void MPPChannel::bind(const MPPChannel& next)
|
|
{
|
|
HI_MPP_CHN_DECLARE(from, *this);
|
|
HI_MPP_CHN_DECLARE(to, next);
|
|
|
|
int rc = hi_mpi_sys_bind(&from, &to);
|
|
if (rc < 0)
|
|
logger().error("Bind: %s -> %s: %#x", this->toString(), next.toString(), (uint32_t)rc);
|
|
else
|
|
logger().debug("Bind: %s -> %s SUCCESS", this->toString(), next.toString());
|
|
}
|
|
|
|
void MPPChannel::unbind(const MPPChannel& next)
|
|
{
|
|
HI_MPP_CHN_DECLARE(from, *this);
|
|
HI_MPP_CHN_DECLARE(to, next);
|
|
|
|
int rc = hi_mpi_sys_unbind(&from, &to);
|
|
if (rc < 0)
|
|
logger().error("Unbind: %s -> %s: %#x", this->toString(), next.toString(), (uint32_t)rc);
|
|
else
|
|
logger().debug("Unbind: %s -> %s SUCCESS", this->toString(), next.toString());
|
|
}
|
|
|
|
void MPPChannel::doLink(Core::Component::Ptr pPrevious)
|
|
{
|
|
auto pFrom = dynamic_cast<MPPChannel*>(pPrevious.get());
|
|
if (pFrom)
|
|
{
|
|
pFrom->bind(*this);
|
|
return;
|
|
}
|
|
|
|
logger().error("MPPChannel: dolink FAIL: %s is not 'MPPChannel'", pPrevious->name());
|
|
}
|
|
|
|
void MPPChannel::doUnlink(Core::Component::Ptr pPrevious)
|
|
{
|
|
auto pFrom = dynamic_cast<MPPChannel*>(pPrevious.get());
|
|
if (pFrom)
|
|
{
|
|
pFrom->unbind(*this);
|
|
return;
|
|
}
|
|
|
|
logger().error("MPPChannel: doUnlink FAIL: %s is not 'MPPChannel'", pPrevious->name());
|
|
}
|
|
|
|
hi_mpp_chn MPPChannel::raw()
|
|
{
|
|
return hi_mpp_chn{
|
|
(hi_mod_id)moduleID(),
|
|
(hi_s32)deviceID(),
|
|
(hi_s32)channelID(),
|
|
};
|
|
}
|
|
}
|
|
}
|