public SmcErr Load(XmlElement monitorConfigElement)
{
NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
logEx.Info("Enter: IvsVideoMonitor.Load().");
SmcErr err = new CgwError();
try
{
//解析xml节点,获取所需参数
this.monitorId = CommonFunction.GetSingleNodeValue(monitorConfigElement, CgwConst.ID_TAG);
ip = CommonFunction.GetSingleNodeValue(monitorConfigElement, CgwConst.IP_TAG);
port = CommonFunction.GetSingleNodeValue(monitorConfigElement, CgwConst.PORT_TAG);
user = CommonFunction.GetSingleNodeValue(monitorConfigElement, CgwConst.USER_TAG);
//password = CommonFunction.GetSingleNodeValue(monitorConfigElement, CgwConst.PASSWORD_TAG);
pwdByte = CommonFunction.EncryptStr2Byte(CommonFunction.GetSingleNodeValue(monitorConfigElement, CgwConst.PASSWORD_TAG),CgwConst.PASSWORD_TAG);
//从配置文件读取的参数要简单判断一下合法性
//初始化之前设置日志路径
logEx.Trace("Call SetLogPath:{0}", ivsLogPath);
this.ivsSdkClient.SetLogPath(ivsLogPath);
logEx.Trace("Call ivsSdkClient.Init().");
//初始化
int result = this.ivsSdkClient.Init();
if (result != CgwConst.IVS_SDK_SUCCESS_TAG)
{
//直接将IVS的错误码返回
err.SetErrorNo(CgwError.MONITOR_LOAD_FAILED);
logEx.Error("Init ivs monitor failed.Monitor id:{0}.ivs sdk error code:{1}.", this.monitorId, result);
return err;
}
else
{
logEx.Info("Init ivs sdk success.Monitor id:{0}", this.monitorId);
}
//设置监控平台id
this.ivsSdkClient.SetId(this.monitorId);
this.sdkCallbackFunc = IvsRealPlayCallBackRaw;
this.ivsSdkClient.SetRealPlayCBRawCallBackFunc(this.sdkCallbackFunc);
//sdk事件回调
this.ivsEventCallBackFunc = IvsEventCallBackFunc;
this.ivsSdkClient.SetEventCallBackFunc(this.ivsEventCallBackFunc);
IvsLoginInfo loginInfo = new IvsLoginInfo();
loginInfo.Ip = ip;
loginInfo.Port = int.Parse(port);
loginInfo.User = user;
//loginInfo.Pwd = password;
loginInfo.Pwd = CommonFunction.DecryptByte2Str(pwdByte,CgwConst.PASSWORD_TAG);
loadResult = false;
//使用线程轮询加载监控平台
Thread loaderThread = new Thread(LoginThread);
loaderThread.IsBackground = true;
loaderThread.Start(loginInfo);
}
catch (Exception e)
{
err.SetErrorNo(CgwError.MONITOR_CONFIG_FILE_INVALID);
logEx.Error("Load ivs monitor failed.Execption message:{0}.", e.Message);
return err;
}
logEx.Info("Load video monitor success.Monitor id:{0}.", this.monitorId);
return err;
}