public SmcErr Unload()
{
NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
logEx.Info("Enter: T28181IvsVideoMonitor.Unload().");
SmcErr err = new CgwError();
//停止定时器
this.updateCameraTimer.Stop();
//copy 一份,防止长时间占用锁
Dictionary<string, uint> monitorChannelRelationDicTemp = null;
try
{
monitorChannelRelationDicTemp = new Dictionary<string, uint>(cameraVideoChannelDic);
}
catch (Exception e)
{
logEx.Error("Unload.Execption message:{0}", e.Message);
}
if (monitorChannelRelationDicTemp == null)
{
//记录日志,获取*监控平台的摄像头列表失败
logEx.Error("Unload failed.No any cameraVideoChannelDic.");
return err;
}
//遍历通道字典,停止流
foreach (KeyValuePair<string, uint> videoChannelRelation in monitorChannelRelationDicTemp)
{
string cameraNo = videoChannelRelation.Key.ToString();
string channel = videoChannelRelation.Value.ToString();
if (!string.IsNullOrEmpty(cameraNo))
{
SmcErr errs = this.StopReceiveVideo(cameraNo);
if (!errs.IsSuccess())
{
logEx.Error("@@Unload.StopReceiveVideo failed, cameraNo:{0},errNo={1}.", cameraNo, errs.ErrNo);
}
else
{
logEx.Trace("@@Unload.StopReceiveVideo success, cameraNo:{0} ", cameraNo);
}
}
else
{
logEx.Error("@@Unload.StopReceiveVideo failed, cameraNo is null.");
}
}
logEx.Trace("Leave: T28181IvsVideoMonitor.Unload().");
EM_SIP_RESULT iRet = sipStack.SIP_SDK_UNREGISTER();
//释放所有实况通道,释放NETSOURCE资源
IVS_NETSOURCE_RESULT iNet = sipStack.IVS_NETSOURCE_UnInit();
iRet += (int)sipStack.SIP_SDK_UnInit();
iNet += rtpAdapter.ESDK_RTP_UnInit();
logEx.Info("Unload T28181video.Monitor id:{0},iRet:{1} ,iNet:{2}", this.monitorId, iRet, iNet);
//if (iRet == EM_SIP_RESULT.RET_SUCCESS || iNet != IVS_NETSOURCE_RESULT.SUCCESS)
if (iRet == EM_SIP_RESULT.RET_SUCCESS && iNet == IVS_NETSOURCE_RESULT.SUCCESS)
{
logEx.Info("Unload T28181video monitor success.Monitor id:{0}.", this.monitorId);
}
else
{
err.SetErrorNo(CgwError.MONITOR_UDLOAD_FAILED);
logEx.Error("Unload T28181video monitor failed.Monitor id:{0}.", this.monitorId);
}
return err;
}