大华解码器学习

//参数获取
int deviceType; //设备类型
deviceType = atoi(argv[1]); //生产模式
//deviceType = 0; //开发模式,测试设备是大华。

int decodeChannelID; //对应解码通道号
decodeChannelID = atoi(argv[2]);
//decodeChannelID = 17;

char cameraIP[64] = {0};
strcpy(cameraIP, argv[3]);
//strcpy(cameraIP, "172.20.51.215");
//cout << "摄像机IP:" << cameraIP << endl;

char cameraUsr[64] = {0};
strcpy(cameraUsr, argv[4]);
//strcpy(cameraUsr, "admin");

char cameraPwd[64] = {0};
strcpy(cameraPwd, argv[5]);
//strcpy(cameraPwd, "admin12345");

int tvID;
tvID = atoi(argv[6]);
//tvID = 1;

int splitNum;
splitNum = atoi(argv[7]);
//splitNum = 16;

//SDK初始化
CLIENT_Init(DisConnectFunc, 0);
//cout << "初始化SDK成功!" << endl;

//读取解码器设备配置信息
read_xml_config();

/*
定义解码器配置:
*/
char szDevIp[64] = {0}; //解码器IP
//strcpy(szDevIp ,"172.20.40.98"); //设置解码器IP地址
strcpy(szDevIp ,configServerInfo.ip); //设置解码器IP地址

//睡眠时间
int sleep_time=configServerInfo.sleep_time;
NET_DEVICEINFO stDevInfo = {0}; //设备信息
int nErrorCode = 0; //返回错误码
LLONG lLoginHandle = 0; //登录句柄

int nPort; //端口
//nPort = 37777;
nPort = configServerInfo.port;

int nChannelID = 0; // 通道号

//登录解码器
lLoginHandle = CLIENT_Login(szDevIp, nPort, configServerInfo.usr,
configServerInfo.pwd, &stDevInfo, &nErrorCode);

if (lLoginHandle != 0)
{
//设置异步回调函数
CLIENT_SetOperateCallBack(lLoginHandle, MessDataCallBackFunc, (LDWORD)0);

//查询解码器信息
DEV_DECODER_INFO stDecoderInfo = {0};
BOOL bRet = CLIENT_QueryDecoderInfo(lLoginHandle, &stDecoderInfo, 2000 /*超时时间*/);
if (bRet)
{
//cout << "查询解码器信息如下:" << endl;
//得到解码器信息,包括TV个数,解码通道个数,各个TV的画面分割数,各个TV使能
//用于界面状态显示
//cout << "类型:" << stDecoderInfo.szDecType << endl;
//cout << "TV个数:" << stDecoderInfo.nMonitorNum << endl;
//cout << "解码通道个数:" << stDecoderInfo.nEncoderNum << endl;
}

//使解码器解码前端设备的数据,以指定的分割画面tv输出。
int nDecoderID = decodeChannelID; //解码器ID
DEV_ENCODER_INFO stuEncoderInfo = {0}; //编码器信息
strcpy(stuEncoderInfo.szDevIpEx , cameraIP); //szDevIp扩展,前端DVR的IP地址(可以输入域名)
strcpy(stuEncoderInfo.szDevUser , cameraUsr);
strcpy(stuEncoderInfo.szDevPwd , cameraPwd);
//stuEncoderInfo.wDevPort = 37777;
stuEncoderInfo.dwHttpPort = 80; //Http端口号,0-65535
stuEncoderInfo.byManuFactory = DH_IPC_ONVIF; //目标设备的生产厂商,0:Private(私有),1: AEBell(美电)
stuEncoderInfo.nDevChannel = 0; //通道 号
stuEncoderInfo.nStreamType = 0; //码流类型,0:主码流;1:子码流
stuEncoderInfo.bDevChnEnable = 1; //解码通道使能
/*
byConnType参数说明:
-1: auto
0:TCP
1:UDP
2:组播
*/
stuEncoderInfo.byConnType = 0; //TCP
/*
byWorkMode参数说明:
0:直连
1:转发
*/
stuEncoderInfo.byWorkMode = 0; //直连
//对应解码通道号,一号电视机,就是0-15,二号就是16-31,以此类推。
//要与上面的nDecoderID保持一致。
stuEncoderInfo.byDecoderID = decodeChannelID;

//由于CLIENT_SwitchDecTVEncoder接口为异步方式,
//因此要自定义一个操作参数 pSwitchTvParam,以便在异步回调函数处理界面的变化。
//控制解码器TV画面切换
LLONG lOperateHandle = CLIENT_SwitchDecTVEncoder(lLoginHandle,
nDecoderID,
&stuEncoderInfo,
0/*pSwitchTvParam用户数据*/);

if (lOperateHandle == 0)
{
printf("Switch failed!, error = %d\n", CLIENT_GetLastError());
}

int nMonitorID = tvID; //TV的ID,电视机屏幕的编号,从0开始,四个就是0-3
int nSplitNum = splitNum; //一画面 切割方式,1,4,9,16 中一值

BYTE bEncoderChannel[16] = {0}; //编码器通道
switch (nSplitNum)
{
case 1:
//BYTE bEncoderChannel[4] = {0};
bEncoderChannel[0] = 0;//编码器通道
break;
case 4:
//BYTE bEncoderChannel[4] = {0};
bEncoderChannel[0] = 0;//编码器通道
bEncoderChannel[1] = 1; //编码器通道
bEncoderChannel[2] = 2; //编码器通道
bEncoderChannel[3] = 3; //编码器通道
break;
case 9:
bEncoderChannel[0] = 0;//编码器通道
bEncoderChannel[1] = 1; //编码器通道
bEncoderChannel[2] = 2; //编码器通道
bEncoderChannel[3] = 3; //编码器通道
bEncoderChannel[4] = 5;//编码器通道
bEncoderChannel[5] = 6; //编码器通道
bEncoderChannel[6] = 7; //编码器通道
bEncoderChannel[7] = 8; //编码器通道
bEncoderChannel[8] = 9;//编码器通道
case 16:
bEncoderChannel[0] = 0;//编码器通道
bEncoderChannel[1] = 1; //编码器通道
bEncoderChannel[2] = 2; //编码器通道
bEncoderChannel[3] = 3; //编码器通道
bEncoderChannel[4] = 4;//编码器通道
bEncoderChannel[5] = 5; //编码器通道
bEncoderChannel[6] = 6; //编码器通道
bEncoderChannel[7] = 7; //编码器通道
bEncoderChannel[8] = 8;//编码器通道
bEncoderChannel[9] = 9;//编码器通道
bEncoderChannel[10] = 10; //编码器通道
bEncoderChannel[11] = 11; //编码器通道
bEncoderChannel[12] = 12; //编码器通道
bEncoderChannel[13] = 13;//编码器通道
bEncoderChannel[14] = 14; //编码器通道
bEncoderChannel[15] = 15; //编码器通道
default:
break;
}

//由于CLIENT_CtrlDecTVScreen接口为异步方式,因此要自定义一个操作参数pCtrlTVParam,以便在异步回调函数处理界面的变化。
//控制解码器TV画面切割
lOperateHandle = CLIENT_CtrlDecTVScreen(lLoginHandle, nMonitorID, TRUE/*TV通道使能标志*/, nSplitNum, bEncoderChannel, nSplitNum/*pEncoderChannel的长度*/, 0/*pCtrlTVParam用户数据*/);
if (lOperateHandle == 0)
{
printf("CLIENT_CtrlDecTVScreen failed!, error = %d\n", CLIENT_GetLastError());
}
}

Sleep(sleep_time);
//注销用户
CLIENT_Logout(lLoginHandle);

//释放SDK资源
CLIENT_Cleanup();

你可能感兴趣的:(解码器)