コード例 #1
0
        /// <summary>
        /// 停止预览摄像头视频,并清理命名管道
        /// </summary>
        /// <param name="cameraNo"></param>
        /// <returns></returns>
        public SmcErr StopReceiveVideoByPipe(string cameraNo)
        {
            SmcErr err = new CgwError();

            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);

            err = CheckSession(currentSessionID);
            //调任何接口前 需要判断监控平台是否加载成功
            if (err.IsSuccess())
            {
                err = VideoMonitorManage.Instance().StopReceiveVideo(cameraNo);
                VideoPipe videoPipe = VideoPipeManage.Instance().DeleteVideoPipe(cameraNo);
                if (videoPipe == null)
                {
                    logEx.Error("MonitorManageService StopReceiveVideoByPipe failed,VideoPipe is null,cameraNo = {0}", cameraNo);
                    err.SetErrorNo(CgwError.STOP_RECEIVE_VIDEO_FAILED);
                }
                else
                {
                    videoPipe.Stop();
                }
            }
            if (err.IsSuccess())
            {
                logEx.Info("MonitorManageService StopReceiveVideoByPipe  Successful,Current Cgw IP is : {0}", CgwConst.ClientIp);
            }
            else
            {
                logEx.Error("MonitorManageService StopReceiveVideoByPipe failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
コード例 #2
0
        /// <summary>
        /// 刷新监控摄像头列表
        /// </summary>
        /// <returns></returns>
        public SmcErr RefreshMonitorCamera()
        {
            SmcErr err = new CgwError();

            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);

            err = CheckSession(currentSessionID);
            //调任何接口前 需要判断监控平台是否加载成功
            if (err.IsSuccess())
            {
                Thread th = new Thread(new ThreadStart(() =>
                {
                    VideoMonitorManage.Instance().RefreshMonitorCamera();
                }));
                th.Start();
            }

            if (err.IsSuccess())
            {
                logEx.Info("MonitorManageService RefreshMonitorCamera  Successful,Current Cgw IP is : {0}", CgwConst.ClientIp);
            }
            else
            {
                logEx.Error("MonitorManageService RefreshMonitorCamera failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
コード例 #3
0
        /// <summary>
        /// 获取监控摄像头列表刷新状态,返回结果为0是表示刷新完毕,为1是刷新操作中。当查询刷新状态为0时,可调用获取监控摄像头列表接口,获取刷新后监控摄像头列表
        /// </summary>
        /// <param name="refreshStatus"></param>
        /// <returns></returns>
        public SmcErr GetRefreshStatus(out SmcErr refreshStatus)
        {
            SmcErr err = new CgwError();

            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            refreshStatus       = new SmcErr();
            refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END;
            err = CheckSession(currentSessionID);
            //调任何接口前 需要判断监控平台是否加载成功
            if (err.IsSuccess())
            {
                err = VideoMonitorManage.Instance().GetRefreshStatus(out refreshStatus);
            }
            else
            {
                refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_FAILED;
            }
            if (err.IsSuccess())
            {
                logEx.Info("MonitorManageService GetRefreshStatus  Successful,Current Cgw IP is : {0}", CgwConst.ClientIp);
            }
            else
            {
                logEx.Error("MonitorManageService GetRefreshStatus failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
コード例 #4
0
ファイル: IvsVideoMonitor.cs プロジェクト: wgyswqs/esdk_Cgw
        /// <summary>
        /// 设置麦克风状态,非物理状态,通过软件控制,该状态只针对该融合网关。软件重启,状态丢失
        /// </summary>
        /// <param name="cameraNo"></param>
        /// <param name="isOn">麦克风是否开启</param>
        /// <returns></returns>
        public SmcErr SetMic(string cameraNo, bool isOn)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: IvsVideoMonitor.SetMic({0},{1}).", cameraNo, isOn);
            SmcErr err = new CgwError();

            if (this.micOperateLock.TryEnterWriteLock(CgwConst.ENTER_LOCK_WAIT_TIME))
            {
                try
                {
                    if (this.cameraMicStatusDic.ContainsKey(cameraNo))
                    {
                        this.cameraMicStatusDic[cameraNo] = isOn;
                    }
                    else
                    {
                        this.cameraMicStatusDic.Add(cameraNo, isOn);
                    }
                }
                finally
                {
                    this.micOperateLock.ExitWriteLock();
                }
            }
            logEx.Info("Set Mic status success.Camera no:{0},isOn:{1}).", cameraNo, isOn);
            return(err);
        }
コード例 #5
0
        /// <summary>
        /// 获取摄像头列表及分组信息
        /// </summary>
        /// <param name="fromMonitorSys">如果该值为true,则实时从监控平台获取,否则从融合网关缓存获取</param>
        /// <param name="cameraList">摄像头列表</param>
        /// <param name="groupList">组信息</param>
        /// <param name="nodeRelationList">分组关系</param>
        /// <returns></returns>
        public SmcErr GetAllCameras(PlatformType platformType, PagesParam pageParam, out List <Camera> cameraList, out List <CameraGroup> groupList, out List <NodeRelation> nodeRelationList, out PageInfo pagesInfo, PlatformLicenseInfo licenseInfo = null)
        {
            SmcErr err = new CgwError();

            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            cameraList       = null;
            groupList        = null;
            nodeRelationList = null;
            pagesInfo        = null;

            err = CheckSession(currentSessionID);
            //调任何接口前 需要判断监控平台是否加载成功
            if (err.IsSuccess())
            {
                err = VideoMonitorManage.Instance().GetAllCameras(pageParam, out cameraList, out groupList, out nodeRelationList, out pagesInfo, licenseInfo);
            }
            if (err.IsSuccess())
            {
                logEx.Info("MonitorManageService QueryMonitorCamera  Successful,Current Cgw IP is : {0}", CgwConst.ClientIp);
            }
            else
            {
                logEx.Error("MonitorManageService QueryMonitorCamera failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
コード例 #6
0
 /// <summary>
 /// 指定码流回调函数
 /// </summary>
 /// <param name="dataCallBack">回调函数</param>
 public void SetDataCallBackFunc(Common.DataCallBack dataCallBack)
 {
     NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
     logEx.Trace("Enter: CgwMonitorManageAdapter.SetVideoDataCallBackFunc({0})", dataCallBack);
     //向上回调,平台管理接到码流后,对摄像头编号加上平台标识,再执行回调转发码流
     this.dataCallBack = dataCallBack;
 }
コード例 #7
0
ファイル: IvsVideoMonitor.cs プロジェクト: wgyswqs/esdk_Cgw
        /// <summary>
        /// 获取监控摄像头列表刷新状态,返回结果为0是表示刷新完毕,为1是刷新操作中。当查询刷新状态为0时,可调用获取监控摄像头列表接口,获取刷新后监控摄像头列表
        /// </summary>
        /// <param name="refreshStatus">刷新状态</param>
        /// <returns></returns>
        public SmcErr GetRefreshStatus(out SmcErr refreshStatus)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: IvsVideoMonitor.GetRefreshStatus");
            SmcErr err = new CgwError();

            refreshStatus       = new SmcErr();
            refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END;

            if (refreshMonitorCameraOperateLock.TryEnterWriteLock(CgwConst.EFRESH_MONITOR_CAMERA_WAIT_TIME))
            {
                try
                {
                    if (loadResult)
                    {
                        refreshStatus.ErrNo = isRefreshSucess ? CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END : CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_FAILED;
                    }
                    else
                    {
                        refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_EXECUTING;
                    }
                }
                finally
                {
                    refreshMonitorCameraOperateLock.ExitWriteLock();
                }
            }
            else
            {
                refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_EXECUTING;
            }
            logEx.Info("GetRefreshStatus success.");
            return(err);
        }
コード例 #8
0
        /// <summary>
        /// 获取设备树
        /// </summary>
        /// <param name="requestUrl"></param>
        /// <returns>成功返回对象列表,失败返回null</returns>
        private List <Resource> GetResourceTree(String requestUrl)
        {
            NLogEx.LoggerEx logEx     = new NLogEx.LoggerEx(log);
            List <Resource> resources = null;

            //调用HTTP接口获取json字符串
            string resourceString = CallHttpInterface(requestUrl);

            if (!string.IsNullOrEmpty(resourceString))
            {
                resources = JsonUtil.ParseResource(resourceString);
                if (resources == null)
                {
                    logEx.Error("Call function GetResourceTree() failed.");
                }
                else
                {
                    logEx.Info("Call function GetResourceTree() success.");
                }
            }
            else
            {
                //如果字符串为空,说明调用不成功
                resources = null;
                logEx.Error("Call function GetResourceTree() failed.");
            }

            return(resources);
        }
コード例 #9
0
        /// <summary>
        /// 调用天地伟业http接口
        /// </summary>
        /// <param name="requestUrl"></param>
        /// <returns>成功返回json字符串,失败返回null</returns>
        private string CallHttpInterface(string requestUrl)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: TiandyHttpClient.CallHttpInterface().");
            Stream stream = null;
            string result = null;

            try
            {
                //调用http接口
                WebClient webClient = new WebClient();

                stream = webClient.OpenRead(requestUrl);
                StreamReader streamReader = new StreamReader(stream);

                //调用HTTP接口返回json字符串
                result = streamReader.ReadToEnd();
            }
            catch (Exception e)
            {
                result = null;
                logEx.Error("Call http function failed.Exception message:{0}.", e.Message);
            }
            finally
            {
                //记录日志,待日志模块合入后补充日志信息
                if (stream != null)
                {
                    stream.Close();
                }
            }
            return(result);
        }
コード例 #10
0
        /// <summary>
        /// 获取监控摄像头列表刷新状态,返回结果为0是表示刷新完毕,为1是刷新操作中。当查询刷新状态为0时,可调用获取监控摄像头列表接口,获取刷新后监控摄像头列表
        /// </summary>
        /// <param name="refreshStatus"></param>
        /// <returns></returns>
        public SmcErr GetRefreshStatus(out SmcErr refreshStatus)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            SmcErr          err   = new CgwError();

            refreshStatus       = new SmcErr();
            refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END;
            if (serviceControl.MonitorServiceRun())
            {
                err = CgwMonitorManageAdapter.Instance().GetRefreshStatus(out refreshStatus);
            }
            else
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
            }
            //日志记录
            if (err.IsSuccess())
            {
                logEx.Trace("GetRefreshStatus Successful");
            }
            else
            {
                logEx.Error("GetRefreshStatus failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
コード例 #11
0
        /// <summary>
        /// 获取设备树接口
        /// </summary>
        /// <returns>成功返回对象列表,失败返回null</returns>
        public List <Resource> GetResourceTree()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: TiandyHttpClient.GetResourceTree().");

            //设置访问天地伟业登陆接口的uri
            string requestUrl = string.Format(
                "{0}/GetResourceTree.jsp?CurrentUserId={1}&UserId={2}&Password={3}",
                this.serverUrl,
                this.user,
                this.user,
                this.pwd);

            //日志不能记密码,单独处理
            string logString = string.Format(
                "{0}/GetResourceTree.jsp?CurrentUserId={1}&UserId={2}&Password=******",
                this.serverUrl,
                this.user,
                this.user);

            logEx.Trace("Call function TiandyHttpClient.GetResourceTree({0}).", logString);
            List <Resource> resources = GetResourceTree(requestUrl);

            return(resources);
        }
コード例 #12
0
        /// <summary>
        /// 开启PTZ控制
        /// </summary>
        /// <param name="cameraNo">摄像头NO</param>
        /// <param name="ptzCommand">操作类型</param>
        /// <param name="param">命令参数</param>
        /// <returns></returns>
        public SmcErr StartControlPtz(string cameraNo, Common.PtzCommandType ptzCommand, int param)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            SmcErr          err   = new CgwError();

            if (serviceControl.MonitorServiceRun())
            {
                err = CgwMonitorManageAdapter.Instance().StartControlPtz(cameraNo, ptzCommand, param);
            }
            else
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
            }


            //日志记录
            if (err.IsSuccess())
            {
                logEx.Trace("StartControlPtz Successful");
            }
            else
            {
                logEx.Error("StartControlPtz failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
コード例 #13
0
        /// <summary>
        /// 设置监控通道视频源
        /// </summary>
        /// <param name="channelLabel">通道label</param>
        /// <param name="cameraNo">摄像头NO</param>
        /// <returns></returns>
        public SmcErr SwitchChannelVideoSource(string channelLabel, string cameraNo)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            SmcErr          err   = new SmcErr();

            if (serviceControl.MonitorServiceRun())
            {
                if (!string.IsNullOrEmpty(channelLabel))
                {
                    //切换通道关联
                    err = manageChannel.SwitchChannelRelation(channelLabel, cameraNo);
                }
                else
                {
                    //监控通道号不能为空
                    err.SetErrorNo(CgwError.ERR_CGW_BUSINESS_CHANNELNO_NULL);
                }
            }
            else
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
            }

            //日志记录
            if (err.IsSuccess())
            {
                logEx.Trace("SwitchChannelVideoSource Successful");
            }
            else
            {
                logEx.Error("SwitchChannelVideoSource failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
コード例 #14
0
ファイル: RtpAdapter.cs プロジェクト: eSDK/esdk_Cgw
        /// <summary>
        /// 初始化rtp模块
        /// </summary>
        public void ESDK_RTP_Init()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: RtpAdapter.ESDK_RTP_Init().");

            try
            {
                int iRet = 0;
                if (!isInited)
                {
                    iRet = SdkRtpInterface.ESDK_RTP_Init();
                    logEx.Trace("Enter: RtpAdapter.ESDK_RTP_Init(). This is first init!");
                }
                if (iRet != 0)
                {
                    logEx.Error("RtpAdapter.ESDK_RTP_Init ,error:{0}", iRet);
                    isInited = false;
                }
                else
                {
                    logEx.Trace("Enter: RtpAdapter.ESDK_RTP_Init().Success");
                    isInited = true;
                }
                logEx.Trace("Enter: RtpAdapter.ESDK_RTP_Init(). inited is {0}!", isInited);
            }
            catch (System.Exception ex)
            {
                logEx.Error("RtpAdapter.ESDK_RTP_Init ,Exception:{0}", ex.ToString());
                isInited = false;
            }
        }
コード例 #15
0
        /// <summary>
        /// 断开监控平台管理服务
        /// </summary>
        /// <returns></returns>
        public Cgw.SmcError.SmcErr Disconnect()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: CgwMonitorManageAdapter.Disconnect");
            Cgw.SmcError.SmcErr err = new Cgw.SmcError.SmcErr();

            try
            {
                //判断Monitor服务是否在线,在线调用DisConnect方法
                if (serviceControl.MonitorServiceRun())
                {
                    client = new MonitorManageServiceClient();
                    CgwMonitorManageServiceReference.SmcErr serviceErr = client.Disconnect();
                    client.Close();
                    if (serviceErr.ErrNo != Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_SUCCESS)
                    {
                        logEx.Error("CgwMonitorManageAdapter.Disconnect failed. ErrNo = {0} ", serviceErr.ErrNo);
                        err = SetCgwErrNo(serviceErr);
                    }
                }
                else //不在线,无需调用DisConnect方法
                {
                    logEx.Info("CgwMonitorManageAdapter.Disconnect,MonitorManage Stopped");
                }
            }
            catch (System.Exception ex)
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                logEx.Error("CgwMonitorManageServiceReference.Disconnect failed. Exception is {0} ", ex.ToString());
            }
            return(err);
        }
コード例 #16
0
 /// <summary>
 /// 指定码流回调函数
 /// </summary>
 /// <param name="videoDataCallBack"></param>
 /// <param name="sender"></param>
 public void SetDataCallBackFunc(DataCallBack dataCallBack, string sender)
 {
     NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
     logEx.Trace("Enter: TiandyVideoMonitor.SetDataCallBackFunc().");
     this.dataCallBack = dataCallBack;
     this.sender       = sender;
 }
コード例 #17
0
        /// <summary>
        /// 停止云台控制,摄像头控制
        /// </summary>
        /// <param name="cameraNo">摄像头编号</param>
        /// <param name="ptzCommandType">命令类型</param>
        /// <returns></returns>
        public SmcErr StopControlPtz(string cameraNo, PtzCommandType ptzCommandType)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: VideoMonitorManage.StopControlPtz({0}).", cameraNo);
            IVideoMonitor videoMonitor;
            string        decodedCameraNo;

            SmcErr err = DecoderCameraNo(cameraNo, out decodedCameraNo, out videoMonitor);

            if (err.IsSuccess())
            {
                err = videoMonitor.StopControlPtz(decodedCameraNo, ptzCommandType);
                if (err.IsSuccess())
                {
                    logEx.Info("Stop control ptz success.Camera no:{0},ptzCommandType:{1}.", cameraNo, ptzCommandType);
                }
                else
                {
                    logEx.Error("Stop control ptz failed.Camera no:{0},ptzCommandType:{1},Error Code:{1} ", cameraNo, ptzCommandType, err.ErrNo);
                }
            }
            else
            {
                logEx.Error("Stop control ptz failed. Camera no is not found.Camera no:{0}.", cameraNo);
            }
            return(err);
        }
コード例 #18
0
ファイル: GatewayExternal.cs プロジェクト: eSDK/esdk_Cgw
        /// <summary>
        /// 分配监控通道
        /// </summary>
        public SmcErr AssignMonitorChannel(List<ChannelInfo> ChannelInfoList)
        {
            SmcErr err = new CgwError();
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            err = CheckSession();
            if (err.IsSuccess())
            {
                if (ChannelInfoList != null)
                {
                    err = MonitorChannelBll.Instance().AssignMonitorChannel(ChannelInfoList);

                }
                else
                {
                    err.SetErrorNo(CgwError.ERR_CGW_BUSINESS_CHANNELLIST_NULL);
                }

            }
            if (err.IsSuccess())
            {
                logEx.Trace("AssignMonitorChannel Successful");
            }
            else
            {
                logEx.Error("AssignMonitorChannel failed,ErrNo :{0}", err.ErrNo);
            }
            return err;
        }
コード例 #19
0
        /// <summary>
        /// 连接监控平台管理服务
        /// </summary>
        /// <param name="monitorPwd">加密后的密码字符串</param>
        /// <returns></returns>
        public Cgw.SmcError.SmcErr Connect(string monitorPwd)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Info("Enter: CgwMonitorManageAdapter.Connect");
            Cgw.SmcError.SmcErr err = new Cgw.SmcError.SmcErr();
            try
            {
                if (serviceControl.MonitorServiceRun())
                {
                    logEx.Info("CgwMonitorManageAdapter.Connect Opened");
                    client = new MonitorManageServiceClient();
                    CgwMonitorManageServiceReference.SmcErr serviceErr = client.Connect(out monitorPwd);

                    sessionID = monitorPwd;
                    client.Close();
                    if (serviceErr.ErrNo != Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_SUCCESS)
                    {
                        logEx.Error("CgwMonitorManageAdapter.Connect failed. ErrNo = {0} ", serviceErr.ErrNo);
                        err = SetCgwErrNo(serviceErr);
                    }
                }
                else
                {
                    logEx.Info("CgwMonitorManageAdapter.Connect MonitorServiceStart");
                    err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                    serviceControl.MonitorServiceStart();//自动重连监控服务
                }
            }
            catch (System.Exception ex)
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                logEx.Error("CgwMonitorManageServiceReference.Connect failed. Exception is {0} ", ex.ToString());
            }
            return(err);
        }
コード例 #20
0
        /// <summary>
        /// 断开监控管理连接
        /// </summary>
        /// <returns></returns>
        public SmcErr Disconnect()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            SmcErr          err   = new CgwError();

            if (OperationContext.Current != null)
            {
                //string strSessionId = OperationContext.Current.SessionId;
                string strSessionId = currentSessionID;
                if (!string.IsNullOrEmpty(strSessionId))
                {
                    err = SessionManage.Instance().RemoveSessionBySessionId(strSessionId);
                    logEx.Info("Client DisConnect MonitorManageService Successful,Current.Cgw IP is : {0}", CgwConst.ClientIp);
                }
                else
                {
                    err.SetErrorNo(CgwError.ERR_CGW_BUSINESS_CURRENTSESSION_NULL);
                    logEx.Warn("Current SessionId is null ! ");
                }
            }
            else
            {
                err.SetErrorNo(CgwError.ERR_CGW_BUSINESS_CURRENTSESSION_NULL);
                logEx.Warn("Current SessionId is null ! ");
            }

            return(err);
        }
コード例 #21
0
ファイル: IvsVideoMonitor.cs プロジェクト: wgyswqs/esdk_Cgw
        /// <summary>
        /// 注销IVS监控平台资源
        /// </summary>
        /// <returns></returns>
        public SmcErr Unload()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Info("Enter: IvsVideoMonitor.Unload().");
            SmcErr err = new CgwError();

            loadResult = true;
            //停止定时器
            this.updateCameraTimer.Stop();
            logEx.Trace("Call ivsSdkClient.Logout().");
            int result = this.ivsSdkClient.Logout();

            logEx.Trace("Call ivsSdkClient.Cleanup().");
            result = this.ivsSdkClient.Cleanup();

            if (result == CgwConst.IVS_SDK_SUCCESS_TAG)
            {
                logEx.Info("Unload video monitor success.Monitor id:{0}.", this.monitorId);
            }
            else
            {
                err.SetErrorNo(CgwError.MONITOR_UDLOAD_FAILED);
                logEx.Error("Unload video monitor failed.Monitor id:{0}.", this.monitorId);
            }
            return(err);
        }
コード例 #22
0
        /// <summary>
        /// 刷新监控摄像头列表
        /// </summary>
        /// <returns></returns>
        public Cgw.SmcError.SmcErr RefreshMonitorCamera()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: CgwMonitorManageAdapter.RefreshMonitorCamera");
            Cgw.SmcError.SmcErr err = new Cgw.SmcError.SmcErr();

            try
            {
                //if (serviceControl.MonitorServiceRun() && client.State == CommunicationState.Opened)
                if (serviceControl.MonitorServiceRun())
                {
                    client = new MonitorManageServiceClient();
                    CgwMonitorManageServiceReference.SmcErr serviceErr = client.RefreshMonitorCamera();
                    client.Close();
                    if (serviceErr.ErrNo != Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_SUCCESS)
                    {
                        logEx.Error("CgwMonitorManageAdapter.RefreshMonitorCamera failed. ErrNo = {0} ", serviceErr.ErrNo);
                        err = SetCgwErrNo(serviceErr);
                    }
                }
                else
                {
                    err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                }
            }
            catch (System.Exception ex)
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                logEx.Error("CgwMonitorManageServiceReference.RefreshMonitorCamera failed. Exception is {0} ", ex.ToString());
            }
            return(err);
        }
コード例 #23
0
        /// <summary>
        /// 停止预览
        /// </summary>
        /// <param name="cameraNo">摄像头编号</param>
        /// <returns>返回错误码</returns>
        public SmcErr StopReceiveVideo(string cameraNo)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: VideoMonitorManage.StopReceiveVideo({0}).", cameraNo);
            IVideoMonitor videoMonitor;
            string        decodedCameraNo;

            SmcErr err = DecoderCameraNo(cameraNo, out decodedCameraNo, out videoMonitor);

            if (err.IsSuccess())
            {
                err = videoMonitor.StopReceiveVideo(decodedCameraNo);
                if (err.IsSuccess())
                {
                    logEx.Info("Stop receive camera video data success.Camera no:{0}.", cameraNo);
                }
                else
                {
                    logEx.Error("Stop receive camera video data failed.Camera no:{0},Error Code:{1} ", cameraNo, err.ErrNo);
                }
            }
            else
            {
                logEx.Error("Stop receive camera video data failed.Camera no is not found.Camera no:{0}.", cameraNo);
            }
            return(err);
        }
コード例 #24
0
ファイル: VideoPipe.cs プロジェクト: wgyswqs/esdk_Cgw
        /// <summary>
        /// 运行管道
        /// </summary>
        public void Run()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);

            logEx.Trace("VideoPipe.Connect.pipeName = {0} ", pipeName);
            pipedStream.Connect(CgwConst.ENTER_PIPE_LOCK_WAIT_TIME);
        }
コード例 #25
0
        /// <summary>
        /// 指定码流回调函数
        /// </summary>
        /// <param name="dataCallBack">回调函数</param>
        public void SetDataCallBackFunc(DataCallBack dataCallBack)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: VideoMonitorManage.SetVideoDataCallBackFunc({0})", dataCallBack);
            //向上回调,平台管理接到码流后,对摄像头编号加上平台标识,再执行回调转发码流
            this.dataCallBack = dataCallBack;

            //向下注册回调,在该回调函数VideoDataCallBackFunc内要先对摄像头编号加上平台标识
            DataCallBack callBack = this.DataCallBackFunc;

            if (this.monitorsOperateLock.TryEnterReadLock(CgwConst.ENTER_LOCK_WAIT_TIME))
            {
                try
                {
                    foreach (KeyValuePair <string, IVideoMonitor> monitor in monitorsDictionary)
                    {
                        IVideoMonitor videoMonitor = monitor.Value;
                        videoMonitor.SetDataCallBackFunc(callBack, monitor.Key);
                    }
                }
                catch (Exception e)
                {
                    logEx.Error("Set VideoDataCallBackFunc failed.Execption message:{0}", e.Message);
                }
                finally
                {
                    this.monitorsOperateLock.ExitReadLock();
                }
            }
            logEx.Trace("Set VideoDataCallBackFunc success.");
        }
コード例 #26
0
        /// <summary>
        /// 获取监控平台配置
        /// </summary>
        /// <param name="monitorElement"></param>
        /// <returns></returns>
        private SmcErr GetMonitorConfig(XmlElement monitorElement, out string monitorId, out string className)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: VideoMonitorManage.GetMonitorConfig().");
            SmcErr err = new CgwError();

            monitorId = CommonFunction.GetSingleNodeValue(monitorElement, CgwConst.ID_TAG);

            className = CommonFunction.GetSingleNodeValue(monitorElement, CgwConst.CLASS_TAG);

            if (string.IsNullOrEmpty(monitorId))
            {
                //监控平台id不能为空
                err.SetErrorNo(CgwError.MONITOR_CONFIG_FILE_INVALID_ID_NULL);

                logEx.Error("Monitor id can not be null.");
                return(err);
            }

            if (string.IsNullOrEmpty(className))
            {
                //监控平台 {0}的class不能为空
                err.SetErrorNo(CgwError.MONITOR_CONFIG_FILE_INVALID_CLASS_NULL);

                logEx.Error("The class of Monitor is null. Monitor id:{0}.", monitorId);
                return(err);
            }

            return(err);
        }
コード例 #27
0
        /// <summary>
        /// 重发关键帧
        /// </summary>
        /// <param name="cameraNo">摄像头编号</param>
        /// <returns></returns>
        public SmcErr MakeIFrame(string cameraNo)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: VideoMonitorManage.MakeIFrame({0}).", cameraNo);
            IVideoMonitor videoMonitor;
            string        decodedCameraNo;

            SmcErr err = DecoderCameraNo(cameraNo, out decodedCameraNo, out videoMonitor);

            if (err.IsSuccess())
            {
                err = videoMonitor.MakeIFrame(decodedCameraNo);
                if (err.IsSuccess())
                {
                    logEx.Info("Make I Frame success.Camera no:{0}.", cameraNo);
                }
                else
                {
                    logEx.Error("Make I Frame failed.Camera no:{0},Error Code:{1}.", cameraNo, err.ErrNo);
                }
            }
            else
            {
                logEx.Error("Make I Frame failed. Camera no is not found.Camera no:{0}.", cameraNo);
            }

            return(err);
        }
コード例 #28
0
        /// <summary>
        /// 设置摄像头麦克风状态
        /// </summary>
        /// <param name="cameraNo">摄像头编号</param>
        /// <param name="isOn">麦克风是否开启</param>
        /// <returns></returns>
        public SmcErr SetMic(string cameraNo, bool isOn)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: VideoMonitorManage.SetMic({0},{1}).", cameraNo, isOn);
            IVideoMonitor videoMonitor;
            string        decodedCameraNo;

            SmcErr err = DecoderCameraNo(cameraNo, out decodedCameraNo, out videoMonitor);

            if (err.IsSuccess())
            {
                err = videoMonitor.SetMic(decodedCameraNo, isOn);
                if (err.IsSuccess())
                {
                    logEx.Info("Set camera Mic status success.Camera no:{0}, isOn:{1}.", cameraNo, isOn);
                }
                else
                {
                    logEx.Error("Set camera Mic status failed. Camera no:{0}, isOn:{1}, Error Code:{2} ", cameraNo, isOn, err.ErrNo);
                }
            }
            else
            {
                logEx.Error("Set camera Mic status failed.Camera no is not found.Camera no:{0}, isOn:{1}.", cameraNo, isOn);
            }

            return(err);
        }
コード例 #29
0
        /// <summary>
        /// 添加通道到软终端
        /// </summary>
        /// <param name="channelNo">通道号码</param>
        /// <param name="confNo">会议号</param>
        public bool AddSotChannel(string channelLabel, string confAccessCode)
        {
            NLogEx.LoggerEx logEx     = new NLogEx.LoggerEx(log);
            bool            isSuccess = false;

            logEx.Trace("AddSotChannel channelLabel:{0} confAccessCode:{1}.", channelLabel, confAccessCode);
            string channelCode = CommonFunction.ConvertChannelLabel(channelLabel);


            try
            {
                isSuccess = this.softTerminalAdapter.AddChannel(channelCode, confAccessCode);
                if (isSuccess)
                {
                    logEx.Trace("AddSotChannel channelCode:{0} confAccessCode:{1} successfully.", channelCode, confAccessCode);
                }
                else
                {
                    logEx.Trace("AddSotChannel channelCode:{0} confAccessCode{1} failed.", channelCode, confAccessCode);
                }
            }
            catch (System.Exception ex)
            {
                logEx.Error(ex, "AddSotChannel Exception.");
            }

            return(isSuccess);
        }
コード例 #30
0
        /// <summary>
        /// 软终端删除通道
        /// </summary>
        /// <param name="channelNo">通道号码</param>
        /// <returns>删除结果</returns>
        public bool RemoveSotChannel(string channelLabel)
        {
            bool isSuccess = false;

            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("RemoveSotChannel channelLabel:{0}.", channelLabel);
            string channelCode = CommonFunction.ConvertChannelLabel(channelLabel);

            try
            {
                isSuccess = this.softTerminalAdapter.RemoveChannel(channelCode);
                if (isSuccess)
                {
                    logEx.Trace("RemoveSotChannel channelCode:{0} successfully.", channelCode);
                }
                else
                {
                    logEx.Trace("RemoveSotChannel channelCode:{0} failed.", channelCode);
                }
            }
            catch (System.Exception ex)
            {
                logEx.Error(ex, "RemoveSotChannel Exception.");
            }


            return(isSuccess);
        }
コード例 #31
0
        /// <summary>
        /// 分发码流
        /// </summary>
        /// <param name="channelNo">通道号码</param>
        /// <param name="data">码流</param>
        public void SendMediaData(string channelLabel, MediaData data)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);

            try
            {
                bool successed = this.channelDicLocker.TryEnterReadLock(CgwConst.ENTER_LOCK_WAIT_TIME);
                // 申请互斥
                if (successed)
                {
                    try
                    {
                        if (this.monitorChannelDic.ContainsKey(channelLabel))
                        {
                            this.monitorChannelDic[channelLabel].AddMediaData(data);
                        }
                    }
                    finally
                    {
                        // 释放互斥量
                        this.channelDicLocker.ExitReadLock();
                    }
                }
                else
                {
                    // 日志
                    logEx.Error("SendRtpData: Enert Write Lock Failed.WaitingReadCount:{0};WaitingWriteCount:{1}.", this.channelDicLocker.WaitingReadCount, this.channelDicLocker.WaitingWriteCount);
                }
            }
            catch (Exception ex)
            {
                // 日志
                logEx.Error(ex, "SendRtpData: Enert Write Lock Exception.");
            }
        }
コード例 #32
0
ファイル: Program.cs プロジェクト: silingling/esdk_Cgw
        /// <summary>
        /// 线程加载监控平台
        /// </summary>
        private static void LoadMonitorTimer_Elapsed()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            System.Threading.Thread.Sleep(1000);
            SmcErr smcErr = new SmcErr();

            try
            {
                smcErr = CgwService.Instance().Load();
                if (false == smcErr.IsSuccess())
                {
                    logEx.Error("CGW service Start failed! Errno :{0}", smcErr.ErrNo);
                    NLog.LogManager.Flush();
                    System.Diagnostics.Process.GetCurrentProcess().Kill();
                }
                else
                {
                    logEx.Info("CGW service Start Success");
                }
            }
            catch (Exception ex)
            {
                logEx.Fatal(ex, "CGW service LoadMonitor Failed!");
                NLog.LogManager.Flush();
            }
        }
コード例 #33
0
ファイル: Program.cs プロジェクト: eSDK/esdk_Cgw
        /// <summary>
        /// 停止服务
        /// </summary>
        public override void StopService()
        {
            if (serviceHost != null)
            {
                NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
                NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);

                CgwService.Instance().StopAllStream();//stop all stream.
                SmcErr err = CgwService.Instance().DisconnectMonitor();
                logEx.Info("CGW service.StopService DisconnectMonitor.ErrNo ={0}!", err.ErrNo);

                serviceHost.Close();
                logEx.Info("CGW service.StopService Close Success.");
            }
        }
コード例 #34
0
ファイル: RtpAdapter.cs プロジェクト: eSDK/esdk_Cgw
        /// <summary>
        /// 关闭通道
        /// </summary>
        /// <param name="uiChannel"></param>
        public void ESDK_RTP_CloseChannel(uint uiChannel)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: RtpAdapter.ESDK_RTP_CloseChannel().");

            try
            {
                int iRet = SdkRtpInterface.ESDK_RTP_CloseChannel(uiChannel);

                if (iRet != 0)
                {
                    logEx.Error("RtpAdapter.ESDK_RTP_CloseChannel ,error:{0}", iRet);
                }
            }
            catch (System.Exception ex)
            {
                logEx.Error("RtpAdapter.ESDK_RTP_CloseChannel ,Exception:{0}", ex.ToString());
            }
        }
コード例 #35
0
ファイル: Program.cs プロジェクト: eSDK/esdk_Cgw
        /// <summary>
        /// 线程加载监控平台
        /// </summary>
        private static void LoadMonitorTimer_Elapsed()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            System.Threading.Thread.Sleep(CgwConst.Thread_Sleep_Time);
            SmcErr smcErr = new SmcErr();
            try
            {

                smcErr = MonitorManageService.Instance().Load();
                if (false == smcErr.IsSuccess())
                {
                    logEx.Error("MonitorManageService Start failed! Errno :{0}", smcErr.ErrNo);
                    NLog.LogManager.Flush();
                    System.Diagnostics.Process.GetCurrentProcess().Kill();
                }
            }
            catch (Exception ex)
            {
                logEx.Fatal(ex, "MonitorManageService LoadMonitor Failed!");
                NLog.LogManager.Flush();
            }
        }
コード例 #36
0
ファイル: TiandyHttpClient.cs プロジェクト: eSDK/esdk_Cgw
        /// <summary>
        /// 获取自定义设备列表
        /// </summary>
        /// <returns>成功返回对象列表,失败返回null</returns>
        public List<Resource> GetCustomTree()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: TiandyHttpClient.GetCustomTree().");

            //设置访问天地伟业登陆接口的uri
            string requestUrl = string.Format(
                                "{0}/GetCustomTree.jsp?CurrentUserId={1}&UserId={2}&Password={3}",
                                this.serverUrl,
                                this.user,
                                this.user,
                                pwd);
            //日志不能记密码,单独处理
            string logString = string.Format(
                                "{0}/GetCustomTree.jsp?CurrentUserId={1}&UserId={2}&Password=******",
                                this.serverUrl,
                                this.user,
                                this.user);

            logEx.Trace("Call function TiandyHttpClient.GetResourceTree({0}).", logString);
            List<Resource> resources = GetResourceTree(requestUrl);

            return resources;
        }
コード例 #37
0
ファイル: TiandyVideoMonitor.cs プロジェクト: eSDK/esdk_Cgw
        /// <summary>
        /// 获取监控摄像头列表刷新状态,返回结果为0是表示刷新完毕,为1是刷新操作中。当查询刷新状态为0时,可调用获取监控摄像头列表接口,获取刷新后监控摄像头列表
        /// </summary>
        /// <param name="refreshStatus">刷新状态</param>
        /// <returns></returns>
        public SmcErr GetRefreshStatus(out SmcErr refreshStatus)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: TiandyVideoMonitor.GetRefreshStatus");
            SmcErr err = new CgwError();
            refreshStatus = new SmcErr();
            refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END;

            if (refreshMonitorCameraOperateLock.TryEnterWriteLock(CgwConst.EFRESH_MONITOR_CAMERA_WAIT_TIME))
            {
                try
                {
                    refreshStatus.ErrNo = isRefreshSucess ? CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END : CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_FAILED;
                }
                finally
                {
                    refreshMonitorCameraOperateLock.ExitWriteLock();
                }
            }
            else
            {
                refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_EXECUTING;
            }
            logEx.Info("GetRefreshStatus success.");
            return err;
        }
コード例 #38
0
ファイル: TiandyVideoMonitor.cs プロジェクト: eSDK/esdk_Cgw
        /// <summary>
        /// 码流回调处理,用于中转
        /// </summary>
        /// <param name="playfd">预览句柄</param>
        /// <param name="datatype">视频流类型</param>
        /// <param name="buf">码流</param>
        /// <param name="size">码流大小</param>
        /// <param name="usr">用户标识数据</param>
        private void TiandyRealDataCallbackFunc(int playfd, int datatype, byte[] buf, uint size, int usr)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);

            string cameraNo = null;
            try
            {

                StreamType streamType = StreamType.VIDEO_H264;
                //判断码流类型,因为码流回调访问频频非常高,不单独抽成一个方法,减少方法访问开销
                //对于支持的码流类型,用break退出switch,对于不支持的码流类型直接舍弃,用return返回
                switch (datatype)
                {
                    case (int)TiandyStreamType.STREAM_TYPE_VIDEO_FRAME_I:
                        streamType = StreamType.VIDEO_H264;
                        break;
                    case (int)TiandyStreamType.STREAM_TYPE_VIDEO_FRAME_P:
                        streamType = StreamType.VIDEO_H264;
                        break;
                    case (int)TiandyStreamType.STREAM_TYPE_VIDEO_FRAME_B:
                        streamType = StreamType.VIDEO_H264;
                        break;

                    //音频只接收G711A和G711U,其他舍弃
                    case (int)TiandyStreamType.STREAM_TYPE_AUDIO_G711A:
                        streamType = StreamType.AUDIO_G711A;
                        break;
                    case (int)TiandyStreamType.STREAM_TYPE_AUDIO_G711U:
                        streamType = StreamType.AUDIO_G711U;
                        break;
                    default:
                        //不支持的类型直接舍弃,返回
                        //logEx.Warn("This stream type is not support. Chuck the data.StreamType:{0};Camera no:{1}", datatype, cameraNo);
                        return;
                }

                if (this.handelOperateLock.TryEnterReadLock(CgwConst.ENTER_LOCK_WAIT_TIME))
                {
                    try
                    {
                        if (!this.videoHandleCameraDic.ContainsKey(playfd))
                        {
                            logEx.Error("The video data handle is not found.Handle:{0}", playfd);
                            return;
                        }
                        cameraNo = this.videoHandleCameraDic[playfd];
                        if (string.IsNullOrEmpty(cameraNo))
                        {
                            return;
                        }
                    }
                    finally
                    {
                        this.handelOperateLock.ExitReadLock();
                    }
                }

                if (streamType == StreamType.AUDIO_G711A || streamType == StreamType.AUDIO_G711U)
                {
                    //如果是音频流,需要判断mic的状态,开启时才发送音频流
                    if (this.micOperateLock.TryEnterReadLock(CgwConst.ENTER_LOCK_WAIT_TIME))
                    {
                        try
                        {
                            if (this.cameraMicStatusDic.ContainsKey(cameraNo))
                            {
                                //如果mic为非开启状态,则不发送音频码流,
                                if (!this.cameraMicStatusDic[cameraNo])
                                {
                                    //logEx.Warn("This data is audio,but the mic is off.Chuck the data.Camera no:{0}", cameraNo);
                                    return;
                                }
                            }
                            else
                            {
                                //默认为关闭状态,因此如果cameraMicStatusDic不包含该摄像头,则认为处于关闭状态,舍弃音频码流
                                //logEx.Warn("This data is audio,but the mic is off.Chuck the data.Camera no:{0}", cameraNo);
                                return;
                            }
                        }
                        finally
                        {
                            this.micOperateLock.ExitReadLock();
                        }
                    }

                }

                MediaData mediaData = new MediaData();
                mediaData.Data = buf;
                mediaData.DataType = MediaDataType.FRAME_DATA;
                mediaData.StreamType = streamType;
                mediaData.Size = size;

                //向回调函数转发码流
                this.dataCallBack(cameraNo, mediaData, sender);
            }
            catch (Exception e)
            {
                logEx.Error("Send the media data failed.The camera No is {0}.Execption message:{1}", cameraNo, e.Message);
            }
        }
コード例 #39
0
ファイル: TiandyVideoMonitor.cs プロジェクト: eSDK/esdk_Cgw
        /// <summary>
        /// 获取摄像头列表及分组信息
        /// </summary>
        /// <param name="fromMonitorSys">如果该值为true,则实时从监控平台获取,否则从融合网关缓存获取</param>
        /// <param name="cameraList">摄像头列表</param>
        /// <param name="groupList">组信息</param>
        /// <param name="nodeRelationListT">分组关系</param>
        /// <returns></returns>
        public SmcErr GetAllCameras(out List<Camera> cameraList, out List<CameraGroup> groupList, out List<NodeRelation> nodeRelationListT)
        {
            monitorManageServiceGetCameraList.Stop();
            isGetDevicesFinish = false;

            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: TiandyVideoMonitor.GetAllCameras().");
            SmcErr err = new CgwError();
            cameraList = new List<Camera>();
            groupList = new List<CameraGroup>();
            nodeRelationListT = new List<NodeRelation>();

            if (this.cameraOperateLock.TryEnterReadLock(CgwConst.ENTER_LOCK_WAIT_TIME))
            {
                try
                {
                    #region 深度克隆数据
                    foreach (KeyValuePair<string, TiandyCamera> tiandyCameraKeyValue in this.tiandyCameraDictionary)
                    {
                        TiandyCamera tiandyCamera = tiandyCameraKeyValue.Value;
                        //从缓存获取
                        Camera camera = new Camera(tiandyCamera.No, tiandyCamera.Name);
                        cameraList.Add(camera);
                    }
                    foreach (KeyValuePair<string, CameraGroup> groupDicKeyValue in this.groupDic)
                    {
                        CameraGroup cameraGroupTemp = new CameraGroup(groupDicKeyValue.Value.No, groupDicKeyValue.Value.Name);
                        groupList.Add(cameraGroupTemp);
                    }

                    foreach (NodeRelation nodeRelation in this.nodeRelationList)
                    {
                        NodeRelation nodeRelationTemp = new NodeRelation(nodeRelation.No,
                                                                          nodeRelation.Path,
                                                                          nodeRelation.Type);
                        nodeRelationListT.Add(nodeRelationTemp);
                    }
                    #endregion
                }
                catch (Exception e)
                {
                    err.SetErrorNo(CgwError.GET_ALL_CAMERAS_FAILED);
                    logEx.Error("Get all cameras failed.Execption message:{0}", e.Message);
                    return err;
                }
                finally
                {
                    this.cameraOperateLock.ExitReadLock();
                }
            }
            monitorManageServiceGetCameraList.Start();
            logEx.Info("Get all cameras success.");
            return err;
        }
コード例 #40
0
ファイル: TiandyVideoMonitor.cs プロジェクト: eSDK/esdk_Cgw
        /// <summary>
        /// 递归天地伟业返回的设备树,获取所有通道(一个通道对应一个摄像头)、主机、流媒体(中间件)服务器
        /// </summary>
        /// <param name="resourceTree">天地伟业返回的设备树</param>
        /// <param name="tiandyCameraDictionary">摄像头键值对,key为摄像头编号</param>
        /// <param name="hostDictionary">主机键值对,key为主机编号</param>
        /// <param name="mediaServerDictionary">流媒体(中间件)服务键值对,key为编号</param>
        private void RecursionCamera(List<Resource> resourceTree, Dictionary<string, TiandyCamera> tiandyCameraDictionary, Dictionary<string, Host> hostDictionary, Dictionary<string, MediaServer> mediaServerDictionary)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);

            if (resourceTree == null)
            {
                logEx.Error("Recursion camera failed.ResourceTree is null.");
                return;
            }
            if (tiandyCameraDictionary == null)
            {
                tiandyCameraDictionary = new Dictionary<string, TiandyCamera>();
            }
            if (hostDictionary == null)
            {
                hostDictionary = new Dictionary<string, Host>();
            }
            if (mediaServerDictionary == null)
            {
                mediaServerDictionary = new Dictionary<string, MediaServer>();
            }
            foreach (Resource resource in resourceTree)
            {
                //TypeId为5时,表示该节点为通道,对应一个摄像头
                if (((int)NodeType.CAMERA).ToString().Equals(resource.TypeId))
                {
                    TiandyCamera camera = new TiandyCamera(resource.Id, resource.Caption);
                    camera.Channel = resource.Ch;
                    //摄像头的父节点为主机
                    camera.HostNo = resource.ParentId;
                    tiandyCameraDictionary.Add(camera.No, camera);

                    //如果是摄像头节点,不需要递归
                    continue;
                }
                else if (((int)NodeType.HOST).ToString().Equals(resource.TypeId))
                {
                    //将主机加入缓存,主机的父节点为流媒体(中间件)服务器
                    Host host = new Host(
                                resource.Id,
                                resource.Username,
                                resource.Pwd,
                                resource.ParentId);

                    hostDictionary.Add(host.No, host);
                }
                else if (((int)NodeType.MEDIASERVER).ToString().Equals(resource.TypeId))
                {
                    //将流媒体(中间件)服务器加入缓存
                    MediaServer mediaServer = new MediaServer(
                                                resource.Id,
                                                resource.Ip,
                                                resource.Port,
                                                resource.Username,
                                                resource.Pwd);

                    mediaServerDictionary.Add(mediaServer.No, mediaServer);
                }

                //递归处理
                RecursionCamera(resource.items, tiandyCameraDictionary, hostDictionary, mediaServerDictionary);
            }
        }
コード例 #41
0
ファイル: TiandyVideoMonitor.cs プロジェクト: eSDK/esdk_Cgw
        /// <summary>
        /// 递归天地伟业返回的自定义设备列表,只获取分组节点(TypeId为1000)和通道(摄像头)节点(TypeId为5),舍弃其他节点(如主机,中间件服务器等)
        /// </summary>
        /// <param name="customTree">天地伟业返回的自定义设备列表树</param>
        /// <param name="pathList">节点路径,如果为跟节点,传null即可,主要是用于递归函数处理</param>
        /// <param name="groupDic">组列表</param>
        /// <param name="nodeRelationDic">组、摄像头关系列表Dic,不能重复</param>
        /// <param name="nodeRelationListT">组、摄像头关系列表,可以重复,解决同一摄像头在不同分组下,融合网关报错的问题</param>
        /// 
        private void RecursionCameraGroup(List<Resource> customTree, List<string> pathList, Dictionary<string, CameraGroup> groupDic, Dictionary<string, NodeRelation> nodeRelationDic, List<NodeRelation> nodeRelationListT)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);

            if (customTree == null)
            {
                logEx.Error("RecursionCameraGroup failed.CustomTree is null.");
                return;
            }

            if (pathList == null)
            {
                pathList = new List<string>();
            }

            if (groupDic == null)
            {
                groupDic = new Dictionary<string, CameraGroup>();
            }

            if (nodeRelationDic == null)
            {
                nodeRelationDic = new Dictionary<string, NodeRelation>();
            }

            if (nodeRelationListT == null)
            {
                nodeRelationListT = new List<NodeRelation>();
            }

            foreach (Resource custom in customTree)
            {
                //TypeId为5时,表示该节点为通道,对应一个摄像头
                if (((int)NodeType.CAMERA).ToString().Equals(custom.TypeId))
                {
                    //pathList.Add(custom.Id);
                    NodeRelation nodeRelation = new NodeRelation(custom.Id, new List<string>(pathList), CgwMonitorManage.Common.NodeType.CAMERA);
                    if (!nodeRelationDic.ContainsKey(custom.Id))
                    {
                        nodeRelationDic.Add(custom.Id, nodeRelation);
                    }
                    nodeRelationListT.Add(nodeRelation);

                    //获取完路径后,要返回上一级路径
                    //pathList.Remove(custom.Id);
                }
                //TypeId为1000时,表示该节点为分组
                else if (((int)NodeType.GROUP).ToString().Equals(custom.TypeId))
                {
                    //添加组信息
                    CameraGroup cameraGroup = new CameraGroup(custom.Id, custom.Caption);
                    groupDic.Add(custom.Id, cameraGroup);

                    NodeRelation nodeRelation = new NodeRelation(custom.Id, new List<string>(pathList), CgwMonitorManage.Common.NodeType.GROUP);
                    if (!nodeRelationDic.ContainsKey(custom.Id))
                    {
                        nodeRelationDic.Add(custom.Id, nodeRelation);
                    }
                    nodeRelationListT.Add(nodeRelation);

                    //添加分组关系
                    pathList.Add(custom.Id);

                    //如果是组,还需要递归处理,遍历子节点
                    RecursionCameraGroup(custom.items, pathList, groupDic, nodeRelationDic, nodeRelationListT);

                    //获取完路径后,要返回上一级路径
                    pathList.Remove(custom.Id);

                }
                else
                {
                    //其他类型节点不做处理
                }
            }
        }
コード例 #42
0
ファイル: TiandyVideoMonitor.cs プロジェクト: eSDK/esdk_Cgw
 /// <summary>
 /// 指定码流回调函数
 /// </summary>
 /// <param name="videoDataCallBack"></param>
 /// <param name="sender"></param>
 public void SetDataCallBackFunc(DataCallBack dataCallBack, string sender)
 {
     NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
     logEx.Trace("Enter: TiandyVideoMonitor.SetDataCallBackFunc().");
     this.dataCallBack = dataCallBack;
     this.sender = sender;
 }
コード例 #43
0
ファイル: TiandyVideoMonitor.cs プロジェクト: eSDK/esdk_Cgw
        /// <summary>
        /// 初始化天地伟业监控平台
        /// </summary>
        /// <param name="monitorConfigElement">监控平台配置节点</param>
        /// <returns></returns>
        public SmcErr Load(XmlElement monitorConfigElement)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: TiandyVideoMonitor.Load().");
            SmcErr err = new CgwError();

            string userLevel = "";
            //解析xml节点,获取所需参数
            try
            {
                #region Tiandy视频监控平台(Easy7)连接信息
                this.monitorId = CommonFunction.GetSingleNodeValue(monitorConfigElement, CgwConst.ID_TAG);

                userLevel = CommonFunction.GetSingleNodeValue(monitorConfigElement, CgwConst.PTZCONTROLLEVEL_TAG);

                string httpUser = CommonFunction.GetSingleNodeValue(monitorConfigElement, CgwConst.PLATFORM_USER_TAG);

                string httpPassword = CommonFunction.GetSingleNodeValue(monitorConfigElement, CgwConst.PLATFORM_PASSWORD_TAG);

                string httpUrl = CommonFunction.GetSingleNodeValue(monitorConfigElement, CgwConst.PLATFORM_URL_TAG);

                string mediaServerId = CommonFunction.GetSingleNodeValue(monitorConfigElement, CgwConst.MEDIASERVER_SERVERID_TAG);
                #endregion
                this.httpClient = new TiandyHttpClient(httpUrl, httpUser, httpPassword);

                //使用线程轮询加载监控平台
                Thread loaderThread = new Thread(LoaderThread);
                loaderThread.Start(mediaServerId);

            }
            catch (Exception e)
            {
                err.SetErrorNo(CgwError.MONITOR_CONFIG_FILE_INVALID);
                logEx.Error("Load Tiandy monitor failed.Execption message:{0}.", e.Message);
                return err;
            }

            this.sdkClient = new TiandySdkClient();
            //如果控制级别配置错误,只记录错误日志,不向外报错
            try
            {
                this.sdkClient.PtzControlLevel = int.Parse(userLevel);
            }
            catch (Exception e)
            {
                logEx.Error("Ptz Control Level is invalid.Execption message:{0}.", e.Message);
                this.sdkClient.PtzControlLevel = CgwConst.PTZ_CONTROL_LEVEL;
            }
            logEx.Info("Load video monitor success.Monitor id:{0}.", this.monitorId);
            return err;
        }
コード例 #44
0
ファイル: TiandyVideoMonitor.cs プロジェクト: eSDK/esdk_Cgw
        /// <summary>
        /// 启动摄像头预览
        /// </summary>
        /// <param name="cameraNo">摄像头编号</param>
        /// <returns></returns>
        public SmcErr StartReceiveVideo(string cameraNo)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: TiandyVideoMonitor.StartReceiveVideo({0}).", cameraNo);
            SmcErr err = new CgwError();

            TiandyCamera camera = null;
            Host host = null;

            //摄像头所连接的流媒体服务器
            MediaServer cameraMediaServer = null;
            if (this.cameraOperateLock.TryEnterReadLock(CgwConst.ENTER_LOCK_WAIT_TIME))
            {
                try
                {
                    if (!this.tiandyCameraDictionary.ContainsKey(cameraNo))
                    {
                        err.SetErrorNo(CgwError.CAMERA_NOT_FOUND);
                        logEx.Error("Start Receive camera video data failed.Camera No is not found.Camera No:{0}", cameraNo);
                        return err;
                    }
                    camera = this.tiandyCameraDictionary[cameraNo];
                    host = this.hostDictionary[camera.HostNo];
                    cameraMediaServer = this.mediaServerDictionary[host.MediaServerNo];
                }
                catch (Exception e)
                {
                    err.SetErrorNo(CgwError.START_RECEIVE_VIDEO_FAILED);
                    logEx.Error("Start Receive camera video data failed.Camera No:{0},Execption message:{1}", cameraNo, e.Message);
                    return err;
                }
                finally
                {
                    this.cameraOperateLock.ExitReadLock();
                }
            }

            if (camera == null)
            {
                err.SetErrorNo(CgwError.START_RECEIVE_VIDEO_FAILED);
                logEx.Error("Start Receive camera video data failed.Camera No is not found.Camera No:{0}", cameraNo);
                return err;
            }

            RealPlayInfo real = new RealPlayInfo();
            real.ch = camera.Channel;
            real.data_type = (int)TiandyDateType.PRIMARY;
            real.hPlayWnd = null;

            int result = this.sdkClient.StartReceiveVideo(host.No, cameraMediaServer, ref real);

            //如果为负数,表示预览失败
            if (result < 0)
            {
                err.SetErrorNo(CgwError.START_RECEIVE_VIDEO_FAILED);
                logEx.Error("Start Receive camera video data failed.Camera No:{0}.", cameraNo);
                return err;
            }
            else
            {
                //需要停止的预览句柄
                int needToStopHandel = CgwConst.START_RECEIVE_VIDEO_DATA_FAILED;
                if (this.handelOperateLock.TryEnterWriteLock(CgwConst.ENTER_LOCK_WAIT_TIME))
                {
                    try
                    {
                        //如果预览句柄已经存在,删除掉原来的句柄,用新的句柄替换
                        if (this.cameraVideoHandeDic.ContainsKey(cameraNo))
                        {
                            needToStopHandel = this.cameraVideoHandeDic[cameraNo];
                            this.videoHandleCameraDic.Remove(needToStopHandel);
                            this.cameraVideoHandeDic.Remove(cameraNo);
                        }
                        this.cameraVideoHandeDic.Add(cameraNo, result);
                        this.videoHandleCameraDic.Add(result, cameraNo);
                    }
                    finally
                    {
                        this.handelOperateLock.ExitWriteLock();
                    }
                }
                logEx.Info("Start Receive camera video data success.Camera No:{0},Handle:{1}.", cameraNo, result);
                //重新预览后,更新了预览句柄,需要将原来的预览停止,放在handelOperateLock外面,防止长时间占用锁
                if (needToStopHandel != CgwConst.START_RECEIVE_VIDEO_DATA_FAILED)
                {
                    this.sdkClient.StopReceiveVideo(needToStopHandel);
                }
            }

            return err;
        }
コード例 #45
0
ファイル: TiandyVideoMonitor.cs プロジェクト: eSDK/esdk_Cgw
        /// <summary>
        /// 停止预览
        /// </summary>
        /// <param name="cameraNo">摄像头编号</param>
        /// <returns>成功返回0,失败返回错误码</returns>
        public SmcErr StopReceiveVideo(string cameraNo)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: TiandyVideoMonitor.StopReceiveVideo({0}).", cameraNo);
            SmcErr err = new CgwError();

            //需要停止的预览句柄
            int needToStopHandel = CgwConst.START_RECEIVE_VIDEO_DATA_FAILED;
            if (this.handelOperateLock.TryEnterWriteLock(CgwConst.ENTER_LOCK_WAIT_TIME))
            {
                try
                {
                    if (this.cameraVideoHandeDic.ContainsKey(cameraNo))
                    {
                        needToStopHandel = this.cameraVideoHandeDic[cameraNo];
                        this.videoHandleCameraDic.Remove(needToStopHandel);
                        this.cameraVideoHandeDic.Remove(cameraNo);
                    }
                    else
                    {
                        //不存在,表示已经删除,不返回错误
                        //err.SetErrorNo(CgwError.STOP_RECEIVE_VIDEO_FAILED);
                        logEx.Warn("Stop Receive camera video data failed. Don't need to end the preview.Camera No:{0}.", cameraNo);
                    }
                }
                finally
                {
                    this.handelOperateLock.ExitWriteLock();
                }
            }

            //调用sdk的停止方法,放在handelOperateLock外面,防止长时间占用锁
            if (needToStopHandel != CgwConst.START_RECEIVE_VIDEO_DATA_FAILED)
            {
                this.sdkClient.StopReceiveVideo(needToStopHandel);
            }

            logEx.Info("Stop Receive camera video data success.Camera No:{0},Handle:{1}.", cameraNo, needToStopHandel);
            return err;
        }
コード例 #46
0
ファイル: TiandyVideoMonitor.cs プロジェクト: eSDK/esdk_Cgw
        /// <summary>
        /// 清除缓存数据
        /// </summary>
        private void ClearCamera()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: TiandyVideoMonitor.ClearCamera().");
            if (this.cameraOperateLock.TryEnterWriteLock(CgwConst.ENTER_LOCK_WAIT_TIME))
            {
                try
                {
                    this.tiandyCameraDictionary = new Dictionary<string, TiandyCamera>();
                    this.hostDictionary = new Dictionary<string, Host>();
                    this.mediaServerDictionary = new Dictionary<string, MediaServer>();

                    this.groupDic = new Dictionary<string, CameraGroup>();
                    this.nodeRelationList = new List<NodeRelation>();
                }
                finally
                {
                    this.cameraOperateLock.ExitWriteLock();
                }
            }
            logEx.Trace("Clear Camera which in the cache success.");
        }
コード例 #47
0
ファイル: TiandyVideoMonitor.cs プロジェクト: eSDK/esdk_Cgw
        /// <summary>
        /// 获取摄像头列表及分组信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GetAllCamerasTimer(object sender, System.Timers.ElapsedEventArgs e)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: TiandyVideoMonitor.GetAllCamerasTimer().");

            if (refreshMonitorCameraOperateLock.TryEnterWriteLock(CgwConst.EFRESH_MONITOR_CAMERA_WAIT_TIME))
            {
                try
                {
                    GetAllCamerasMethod();
                }
                finally
                {
                    refreshMonitorCameraOperateLock.ExitWriteLock();
                }
            }
        }
コード例 #48
0
ファイル: IvsVideoMonitor.cs プロジェクト: eSDK/esdk_Cgw
        /// <summary>
        /// 码流回调函数,
        /// 1、根据预览句柄handle从videoHandleCameraDic中获取摄像头编号,
        /// 2、根据摄像头编号,获取mic状态
        /// 3、判断码流是否是音频,如果是音频,根据mic状态判断是否需要转发
        /// </summary>
        /// <param name="handle">播放句柄</param>
        /// <param name="pRawFrameInfo">实况参数</param>
        /// <param name="pBuf">码流</param>
        /// <param name="uiBufSize">大小</param>
        /// <param name="cameraNo">摄像头编号</param>
        private void IvsRealPlayCallBackRaw(int handle, IvsRawFrameInfo pRawFrameInfo, byte[] pBuf, UInt32 uiBufSize, string pUserData)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            //logEx.Trace("Enter:IvsRealPlayCallBackRaw(),{0}", pUserData);

            MediaDataSender mediaDataSender = null;
            try
            {
                if (this.handelOperateLock.TryEnterReadLock(CgwConst.ENTER_LOCK_WAIT_TIME))
                {
                    try
                    {
                        if (!this.videoHandleCameraDic.ContainsKey(handle))
                        {
                            logEx.Error("The video data handle is not found.Handle:{0}", handle);
                            return;
                        }
                        mediaDataSender = this.videoHandleCameraDic[handle];
                    }
                    finally
                    {
                        this.handelOperateLock.ExitReadLock();
                    }
                }

                if (mediaDataSender == null)
                {
                    return;
                }

                StreamType streamType = StreamType.VIDEO_H264;
                //判断码流类型,因为码流回调访问频频非常高,不单独抽成一个方法,减少方法访问开销
                //对于支持的码流类型,用break退出switch,对于不支持的码流类型直接舍弃,用return返回
                switch (pRawFrameInfo.StreamType)
                {
                    //对于音频只接收G711A和G711U,其他舍弃
                    case (int)IvsStreamType.PAY_LOAD_TYPE_PCMU:
                        streamType = StreamType.AUDIO_G711U;
                        break;
                    case (int)IvsStreamType.PAY_LOAD_TYPE_PCMA:
                        streamType = StreamType.AUDIO_G711A;
                        break;

                    //只接收H264的视频码流
                    case (int)IvsStreamType.PAY_LOAD_TYPE_H264:
                        //H264的标准视频流,作为视频流处理
                        streamType = StreamType.VIDEO_H264;
                        break;
                    default:
                        //不支持的类型,直接舍弃,返回
                        //logEx.Warn("This stream type is not support. Chuck the data.StreamType:{0};Camera no:{1}",
                        //            Enum.GetName(typeof(IvsStreamType), pRawFrameInfo.StreamType),
                        //            cameraNo);
                        return;
                }

                if (streamType == StreamType.AUDIO_G711A || streamType == StreamType.AUDIO_G711U)
                {
                    //如果是音频流,需要判断mic的状态,开启时才发送音频流
                    if (this.micOperateLock.TryEnterReadLock(CgwConst.ENTER_LOCK_WAIT_TIME))
                    {
                        try
                        {
                            if (this.cameraMicStatusDic.ContainsKey(mediaDataSender.CameraNo))
                            {
                                //如果mic为非开启状态,则不发送音频码流,
                                if (!this.cameraMicStatusDic[mediaDataSender.CameraNo])
                                {
                                    //logEx.Warn("This data is audio,but the mic is off.Chuck the data.Camera no:{0}", mediaDataSender.CameraNo);
                                    return;
                                }
                            }
                            else
                            {
                                //默认为关闭状态,因此如果cameraMicStatusDic不包含该摄像头,则认为处于关闭状态,舍弃音频码流
                                //logEx.Warn("This data is audio,but the mic is off.Chuck the data.Camera no:{0}", mediaDataSender.CameraNo);
                                return;
                            }
                        }
                        finally
                        {
                            this.micOperateLock.ExitReadLock();
                        }
                    }

                }

                MediaData mediaData = new MediaData();
                mediaData.Data = pBuf;
                //IVS 目前为裸码流
                mediaData.DataType = MediaDataType.FRAME_DATA;
                mediaData.StreamType = streamType;
                mediaData.Size = uiBufSize;

                //将Ivs帧类型转换成各融合网关统一的帧类型
                string name = Enum.GetName(typeof(IvsH264NaluType), pRawFrameInfo.FrameType);

                //帧类型判断,偶现IVS返回的帧类型,在融合网关中未记录,返回值为null
                if (string.IsNullOrEmpty(name))
                {
                    logEx.Warn("IvsRealPlayCallBackRaw FrameType Is Not Defined ,FrameType:{0}", pRawFrameInfo.FrameType);
                    mediaData.FrameType = FrameDataType.H264_NALU_TYPE_UNDEFINED;
                }
                else
                {
                    if (Enum.IsDefined(typeof(FrameDataType), name))
                    {
                        FrameDataType frameDataType = (FrameDataType)Enum.Parse(typeof(FrameDataType), name);
                        mediaData.FrameType = frameDataType;
                    }
                    else
                    {
                        mediaData.FrameType = FrameDataType.H264_NALU_TYPE_UNDEFINED;
                    }
                }

                //向回调函数转发码流
                //this.videoDataCallBack(cameraNo, mediaData, this.sender);

                //logEx.Debug("FrameDataCallBackFun.mediaData.DataType={0},FrameType = {1},StreamType = {2},Size = {3}", Enum.GetName(typeof(MediaDataType), mediaData.DataType),
                //         Enum.GetName(typeof(FrameDataType), mediaData.FrameType), Enum.GetName(typeof(StreamType), mediaData.StreamType), mediaData.Size);
                mediaDataSender.SendData(mediaData, this.sender);
            }
            catch (Exception e)
            {
                logEx.Error("Send the media data failed.Execption message:{0}", e.ToString());
            }
        }
コード例 #49
0
ファイル: TiandyVideoMonitor.cs プロジェクト: eSDK/esdk_Cgw
        /// <summary>
        /// 刷新监控摄像头列表
        /// </summary>
        /// <returns></returns>
        public SmcErr RefreshMonitorCamera()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: TiandyVideoMonitor.RefreshMonitorCamera");
            SmcErr err = new CgwError();

            if (refreshMonitorCameraOperateLock.TryEnterWriteLock(CgwConst.EFRESH_MONITOR_CAMERA_WAIT_TIME))
            {
                try
                {
                    GetAllCamerasMethod();
                    //重新开始计时
                    updateCameraTimer.Stop();
                    updateCameraTimer.Start();
                }
                finally
                {
                    refreshMonitorCameraOperateLock.ExitWriteLock();
                }
            }
            logEx.Info("RefreshMonitorCamera success.");
            return err;
        }
コード例 #50
0
ファイル: IvsVideoMonitor.cs プロジェクト: eSDK/esdk_Cgw
        /// <summary>
        /// 启动摄像头预览
        /// </summary>
        /// <param name="cameraNo">摄像头编号</param>
        /// <returns></returns>
        public SmcErr StartReceiveVideo(string cameraNo)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: IvsVideoMonitor.StartReceiveVideo({0}).", cameraNo);
            SmcErr err = new CgwError();
            int handle;
            logEx.Trace("Call ivsSdkClient.StartRealPlayCBRaw({0}).", cameraNo);
            int result = this.ivsSdkClient.StartRealPlayCBRaw(cameraNo, out handle);

            //如果不为0,表示预览失败
            if (result != CgwConst.IVS_SDK_SUCCESS_TAG)
            {
                err.SetErrorNo(CgwError.START_RECEIVE_VIDEO_FAILED);
                logEx.Error("Start Receive camera video data failed.Camera No:{0}.Ivs sdk error code:{1}", cameraNo, result);
                return err;
            }
            else
            {
                logEx.Info("Start Receive camera video data success.Camera No:{0},Handle:{1}.", cameraNo, handle);
            }

            //预览成功,需要停止原来的预览,并将预览句柄添加到缓存
            //需要停止的预览句柄
            int needToStopHandel = CgwConst.START_RECEIVE_VIDEO_DATA_FAILED;
            if (this.handelOperateLock.TryEnterWriteLock(CgwConst.ENTER_LOCK_WAIT_TIME))
            {
                try
                {
                    //如果预览句柄已经存在,删除掉原来的句柄,用新的句柄替换
                    if (this.cameraVideoHandeDic.ContainsKey(cameraNo))
                    {
                        needToStopHandel = this.cameraVideoHandeDic[cameraNo];
                        this.videoHandleCameraDic.Remove(needToStopHandel);
                        this.cameraVideoHandeDic.Remove(cameraNo);
                    }
                    this.cameraVideoHandeDic.Add(cameraNo, handle);
                    MediaDataSender mediaDataSender = new MediaDataSender(cameraNo, this.dataCallBack);
                    this.videoHandleCameraDic.Add(handle, mediaDataSender);
                }
                finally
                {
                    this.handelOperateLock.ExitWriteLock();
                }
            }

            //重新预览后,更新了预览句柄,需要将原来的预览停止,放在handelOperateLock外面,防止长时间占用锁
            if (needToStopHandel != CgwConst.START_RECEIVE_VIDEO_DATA_FAILED)
            {
                result = this.ivsSdkClient.StopRealPlay(needToStopHandel);
                //如果不为0,表示停止原来的预览失败,只记录日志,不返回错误,不设置错误码
                if (result != CgwConst.IVS_SDK_SUCCESS_TAG)
                {
                    logEx.Error("Get a new preview success. But stop old preview failed.CameraNo:{0},Ivs sdk error code:{0}", cameraNo, result);
                    return err;
                }
            }

            return err;
        }
コード例 #51
0
ファイル: TiandyVideoMonitor.cs プロジェクト: eSDK/esdk_Cgw
        /// <summary>
        /// 设置麦克风状态
        /// </summary>
        /// <param name="cameraNo"></param>
        /// <param name="isOn">麦克风是否开启</param>
        /// <returns></returns>
        public SmcErr SetMic(string cameraNo, bool isOn)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: TiandyVideoMonitor.SetMic({0},{1}).", cameraNo, isOn);
            SmcErr err = new CgwError();

            if (this.micOperateLock.TryEnterWriteLock(CgwConst.ENTER_LOCK_WAIT_TIME))
            {
                try
                {
                    if (this.cameraMicStatusDic.ContainsKey(cameraNo))
                    {
                        this.cameraMicStatusDic[cameraNo] = isOn;
                    }
                    else
                    {
                        this.cameraMicStatusDic.Add(cameraNo, isOn);
                    }
                }
                finally
                {
                    this.micOperateLock.ExitWriteLock();
                }
            }
            logEx.Info("Set Mic status success.Camera no:{0},isOn:{1}).", cameraNo, isOn);
            return err;
        }
コード例 #52
0
ファイル: IvsVideoMonitor.cs プロジェクト: eSDK/esdk_Cgw
 /// <summary>
 /// 停止云台控制,摄像头控制
 /// </summary>
 /// <param name="cameraNo">摄像头编号</param>
 /// <param name="ptzCommand">命令类型</param>
 /// <returns></returns>
 public SmcErr StopControlPtz(string cameraNo, PtzCommandType ptzCommand)
 {
     NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
     logEx.Trace("Enter: IvsVideoMonitor.StopControlPtz({0}).", cameraNo);
     SmcErr err = new CgwError();
     logEx.Trace("Call ivsSdkClient.StopPtzControl({0}).", cameraNo);
     int result = this.ivsSdkClient.StopPtzControl(cameraNo);
     //如果为0,表示成功
     if (result == CgwConst.IVS_SDK_SUCCESS_TAG)
     {
         logEx.Info("Stop control ptz success.Camera No:{0}.", cameraNo);
     }
     else
     {
         //直接将IVS的错误码返回
         err.SetErrorNo(CgwError.STOP_CONTROL_PTZ_FAILED);
         logEx.Error("Stop control ptz failed.Camera No:{0}.Ivs sdk error code:{1}.", cameraNo, result);
         return err;
     }
     return err;
 }
コード例 #53
0
ファイル: TiandyVideoMonitor.cs プロジェクト: eSDK/esdk_Cgw
        /// <summary>
        /// 停止云台控制,摄像头控制
        /// </summary>
        /// <param name="cameraNo">摄像头编号</param>
        /// <param name="ptzCommand">命令类型</param>
        /// <returns></returns>
        public SmcErr StopControlPtz(string cameraNo, PtzCommandType ptzCommand)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: TiandyVideoMonitor.StopControlPtz({0}).", cameraNo);
            SmcErr err = new CgwError();

            int handel = CgwConst.START_RECEIVE_VIDEO_DATA_FAILED;
            if (this.handelOperateLock.TryEnterReadLock(CgwConst.ENTER_LOCK_WAIT_TIME))
            {
                try
                {
                    if (this.cameraVideoHandeDic.ContainsKey(cameraNo))
                    {
                        handel = this.cameraVideoHandeDic[cameraNo];
                    }
                    else
                    {
                        logEx.Warn("The camera was not Preview.Don't need to end the control.Camera No:{0}.", cameraNo);
                    }
                }
                finally
                {
                    this.handelOperateLock.ExitReadLock();
                }

            }

            if (handel != CgwConst.START_RECEIVE_VIDEO_DATA_FAILED)
            {
                Client_PTZ_Command client_ptz_command = new Client_PTZ_Command();
                client_ptz_command.start = false;

                //将ptz命令转换成天地伟业的命令
                string name = Enum.GetName(typeof(PtzCommandType), ptzCommand);
                if (Enum.IsDefined(typeof(TiandyPtzCommandType), name))
                {
                    TiandyPtzCommandType tiandyPtzCommandType = (TiandyPtzCommandType)Enum.Parse(typeof(TiandyPtzCommandType), name);
                    client_ptz_command.cmd = (int)tiandyPtzCommandType;
                }
                else
                {
                    err.SetErrorNo(CgwError.STOP_CONTROL_PTZ_FAILED);
                    logEx.Error("The tiandy monitor is not support the command.ptzCommand:{0}.", ptzCommand);
                    return err;
                }

                bool result = this.sdkClient.ControlPtz(handel, client_ptz_command);
                if (result)
                {
                    logEx.Info("Stop control camera ptz success.Camera No:{0}.", cameraNo);
                }
                else
                {
                    err.SetErrorNo(CgwError.STOP_CONTROL_PTZ_FAILED);
                    logEx.Error("Stop control camera ptz failed.Camera No:{0}.", cameraNo);
                }
            }
            else
            {
                err.SetErrorNo(CgwError.STOP_CONTROL_PTZ_FAILED);
                logEx.Error("Handel is not found. Stop control camera ptz failed. Camera No:{0}.", cameraNo);
                return err;
            }

            return err;
        }
コード例 #54
0
ファイル: IvsVideoMonitor.cs プロジェクト: eSDK/esdk_Cgw
        /// <summary>
        /// 停止预览
        /// </summary>
        /// <param name="cameraNo">摄像头编号</param>
        /// <returns>成功返回0,失败返回错误码</returns>
        public SmcErr StopReceiveVideo(string cameraNo)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: IvsVideoMonitor.StopReceiveVideo({0}).", cameraNo);
            SmcErr err = new CgwError();
            //需要停止的预览句柄
            int needToStopHandel = CgwConst.START_RECEIVE_VIDEO_DATA_FAILED;
            if (this.handelOperateLock.TryEnterWriteLock(CgwConst.ENTER_LOCK_WAIT_TIME))
            {
                try
                {
                    if (this.cameraVideoHandeDic.ContainsKey(cameraNo))
                    {
                        needToStopHandel = this.cameraVideoHandeDic[cameraNo];
                        this.videoHandleCameraDic.Remove(needToStopHandel);
                        this.cameraVideoHandeDic.Remove(cameraNo);
                    }
                    else
                    {
                        logEx.Warn("Stop Receive camera video data failed. Don't need to end the preview.Camera No:{0}.", cameraNo);
                        //如果预览句柄不存在,不需要处理,直接返回
                        return err;
                    }
                }
                catch (Exception ex)
                {
                    err.SetErrorNo(CgwError.STOP_RECEIVE_VIDEO_FAILED);
                    logEx.Error("Stop Receive camera video data failed.Execption message:{0}", ex.Message);
                    return err;
                }
                finally
                {
                    this.handelOperateLock.ExitWriteLock();
                }
            }

            //调用sdk的停止方法,放在handelOperateLock外面,防止长时间占用锁
            if (needToStopHandel != CgwConst.START_RECEIVE_VIDEO_DATA_FAILED)
            {
                int result = this.ivsSdkClient.StopRealPlay(needToStopHandel);
                //如果不为0,表示预览失败
                if (result != CgwConst.IVS_SDK_SUCCESS_TAG)
                {
                    err.SetErrorNo(CgwError.STOP_RECEIVE_VIDEO_FAILED);
                    logEx.Error("Stop Receive camera video data failed.Ivs sdk error code:{0}", result);
                    return err;
                }
                logEx.Info("Stop Receive camera video data success.Camera No:{0},Handle:{1}.", cameraNo, needToStopHandel);
            }

            return err;
        }
コード例 #55
0
ファイル: TiandyVideoMonitor.cs プロジェクト: eSDK/esdk_Cgw
 /// <summary>
 /// 注销天地伟业监控平台资源
 /// </summary>
 /// <returns></returns>
 public SmcErr Unload()
 {
     NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
     logEx.Trace("Enter: TiandyVideoMonitor.Unload().");
     SmcErr err = new CgwError();
     //停止定时器
     this.updateCameraTimer.Stop();
     if (this.sdkClient.Unload())
     {
         logEx.Info("Unload video monitor success.Monitor id:{0}.", this.monitorId);
     }
     else
     {
         err.SetErrorNo(CgwError.UNLOAD_MONITOR_FAILED);
         logEx.Error("Unload video monitor failed.Monitor id:{0}.", this.monitorId);
     }
     return err;
 }
コード例 #56
0
ファイル: IvsVideoMonitor.cs プロジェクト: eSDK/esdk_Cgw
        /// <summary>
        /// 注销IVS监控平台资源
        /// </summary>
        /// <returns></returns>
        public SmcErr Unload()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Info("Enter: IvsVideoMonitor.Unload().");
            SmcErr err = new CgwError();

            loadResult = true;
            //停止定时器
            this.updateCameraTimer.Stop();
            logEx.Trace("Call ivsSdkClient.Logout().");
            int result = this.ivsSdkClient.Logout();
            logEx.Trace("Call ivsSdkClient.Cleanup().");
            result = this.ivsSdkClient.Cleanup();

            if (result == CgwConst.IVS_SDK_SUCCESS_TAG)
            {
                logEx.Info("Unload video monitor success.Monitor id:{0}.", this.monitorId);
            }
            else
            {
                err.SetErrorNo(CgwError.MONITOR_UDLOAD_FAILED);
                logEx.Error("Unload video monitor failed.Monitor id:{0}.", this.monitorId);
            }
            return err;
        }
コード例 #57
0
ファイル: TiandyVideoMonitor.cs プロジェクト: eSDK/esdk_Cgw
        /// <summary>
        /// 获取摄像头列表及分组信息
        /// </summary>
        private void GetAllCamerasMethod()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: TiandyVideoMonitor.GetAllCamerasTimer().");

            try
            {

                //调用天地伟业http接口获取天地伟业设备管理树列表
                List<Resource> resourceTree = this.httpClient.GetResourceTree();
                if (resourceTree == null)
                {
                    logEx.Error("GetResourceTree failed.");
                    ClearCamera();
                    isRefreshSucess = false;
                    return;
                }

                //调用天地伟业http接口获取自定义设备树列表
                List<Resource> customTree = this.httpClient.GetCustomTree();

                if (customTree == null)
                {
                    logEx.Error("GetCustomTree failed.");
                    ClearCamera();
                    isRefreshSucess = false;
                    return;
                }

                Dictionary<string, TiandyCamera> tiandyCameraDictionaryTemp = new Dictionary<string, TiandyCamera>();
                Dictionary<string, Host> hostDictionaryTemp = new Dictionary<string, Host>();
                Dictionary<string, MediaServer> mediaServerDictionaryTemp = new Dictionary<string, MediaServer>();
                //递归处理,将摄像头、主机、流媒体服务器遍历出来
                RecursionCamera(resourceTree, tiandyCameraDictionaryTemp, hostDictionaryTemp, mediaServerDictionaryTemp);

                Dictionary<string, CameraGroup> groupDicTemp = new Dictionary<string, CameraGroup>();
                Dictionary<string, NodeRelation> nodeRelationDicTemp = new Dictionary<string, NodeRelation>();
                List<NodeRelation> nodeRelationListTemp = new List<NodeRelation>();

                //递归处理,获取组,摄像头、分组关系
                RecursionCameraGroup(customTree, null, groupDicTemp, nodeRelationDicTemp, nodeRelationListTemp);

                //对于未分组的摄像头,父节点设置为空
                foreach (KeyValuePair<string, TiandyCamera> tiandyCameraKeyValue in tiandyCameraDictionaryTemp)
                {
                    if (!nodeRelationDicTemp.ContainsKey(tiandyCameraKeyValue.Key))
                    {
                        NodeRelation nodeRelation = new NodeRelation(tiandyCameraKeyValue.Key,
                                                                     new List<string>(),
                                                                     CgwMonitorManage.Common.NodeType.CAMERA);
                        nodeRelationListTemp.Add(nodeRelation);
                    }
                }

                DateTime dtStart = DateTime.Now;
                DateTime dtNow = new DateTime();
                while (!isGetDevicesFinish)
                {
                    dtNow = DateTime.Now;

                    if ((dtNow - dtStart).TotalSeconds > refreshDeviceListOverTime)
                    {
                        isRefreshSucess = false;
                        return;
                    }
                    Thread.Sleep(1);
                    continue;
                }

                if (this.cameraOperateLock.TryEnterWriteLock(CgwConst.ENTER_LOCK_WAIT_TIME))
                {
                    try
                    {
                        this.tiandyCameraDictionary = tiandyCameraDictionaryTemp;
                        this.hostDictionary = hostDictionaryTemp;
                        this.mediaServerDictionary = mediaServerDictionaryTemp;

                        this.groupDic = groupDicTemp;
                        this.nodeRelationList = nodeRelationListTemp;

                        isRefreshSucess = true;

                    }
                    catch (Exception ex)
                    {
                        isRefreshSucess = false;
                        logEx.Error("Recursion camera failed.Execption message:{0}", ex.Message);
                    }
                    finally
                    {
                        this.cameraOperateLock.ExitWriteLock();
                    }
                }
            }
            catch (System.Exception ex)
            {
                isRefreshSucess = false;
                logEx.Error("GetAllCamerasTimer catch Exception:{0}", ex.Message);
            }
        }
コード例 #58
0
ファイル: IvsVideoMonitor.cs プロジェクト: eSDK/esdk_Cgw
 /// <summary>
 /// 清除缓存数据
 /// </summary>
 private void ClearCamera()
 {
     NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
     logEx.Trace("Enter: IvsVideoMonitor.ClearCamera().");
     if (this.cameraOperateLock.TryEnterWriteLock(CgwConst.ENTER_LOCK_WAIT_TIME))
     {
         try
         {
             this.cameraList = new List<Camera>();
             this.groupList = new List<CameraGroup>();
             this.nodeRelationList = new List<NodeRelation>();
         }
         finally
         {
             this.cameraOperateLock.ExitWriteLock();
         }
     }
     logEx.Trace("Clear Camera which in the cache success.");
 }
コード例 #59
0
ファイル: TiandyVideoMonitor.cs プロジェクト: eSDK/esdk_Cgw
        /// <summary>
        /// 监控平台加载器,轮询加载,直到成功
        /// </summary>
        /// <param name="mediaServerIdObj"></param>
        private void LoaderThread(Object mediaServerIdObj)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: TiandyVideoMonitor.LoadTiandyMonitorThread().");
            try
            {
                bool loadResult = false;
                string mediaServerId = mediaServerIdObj as string;
                while (!loadResult)
                {
                    this.GetAllCamerasTimer(null, null);
                    if (this.cameraOperateLock.TryEnterReadLock(CgwConst.ENTER_LOCK_WAIT_TIME))
                    {
                        try
                        {
                            loadResult = true;
                            this.sdkClient.SdkMediaServer = null;

                            //用户没有指定流媒体服务器,预览视频时,采用摄像头所连接的服务器。
                            if (!string.IsNullOrEmpty(mediaServerId))
                            {
                                if (this.mediaServerDictionary.ContainsKey(mediaServerId))
                                {
                                    this.sdkClient.SdkMediaServer = this.mediaServerDictionary[mediaServerId];
                                }
                                else
                                {
                                    //流媒体服务器id配置错误,Id不存在
                                    logEx.Error("Load Tiandy monitor failed.Media server id is not found.MediaServerId:{0}", mediaServerId);
                                    loadResult = false;
                                }
                            }

                            if (loadResult)
                            {
                                //设置回调函数到SDK
                                this.sdkClient.SetDataCallBackFunc(TiandyRealDataCallbackFunc);
                            }

                        }
                        finally
                        {
                            this.cameraOperateLock.ExitReadLock();
                        }
                    }

                    if (!loadResult)
                    {
                        loadResult = false;
                        Thread.Sleep(CgwConst.RELOAD_MONITOR_WAIT_TIME);
                        continue;
                    }

                    if (!this.sdkClient.Load(this.monitorId))
                    {
                        logEx.Error("Load video monitor failed.Monitor id:{0}.", this.monitorId);
                        loadResult = false;
                        Thread.Sleep(CgwConst.RELOAD_MONITOR_WAIT_TIME);
                        continue;
                    }

                    //启动定时器
                    this.updateCameraTimer.Start();
                    loadResult = true;
                }
            }
            catch (System.Exception ex)
            {
                logEx.Error("LoaderThread catch exception:{0}", ex.Message);
            }
            logEx.Trace("Exit: TiandyVideoMonitor.LoadTiandyMonitorThread().");
        }
コード例 #60
0
ファイル: IvsVideoMonitor.cs プロジェクト: eSDK/esdk_Cgw
        /// <summary>
        /// 获取摄像头列表及分组信息
        /// </summary>
        private void GetAllCamerasMethod()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: IvsVideoMonitor.GetAllCamerasMethod().");
            try
            {
                //1、获取系统中所有的域
                List<IvsDomainRoute> ivsDomainRouteList;

                logEx.Trace("Call ivsSdkClient.GetDomainRoute().");
                int result = this.ivsSdkClient.GetDomainRoute(out ivsDomainRouteList);

                if (result == CgwConst.IVS_SDK_SUCCESS_TAG)
                {
                    logEx.Info("GetDomainRoute success.List count:{0}", ivsDomainRouteList.Count);
                }
                else
                {
                    logEx.Error("GetDomainRoute failed.Ivs sdk error code:{0}", result);
                    ClearCamera();
                    isRefreshSucess = false;
                    return;
                }

                List<Camera> cameraListTemp = new List<Camera>();
                List<CameraGroup> groupListTemp = new List<CameraGroup>();
                List<NodeRelation> nodeRelationListTemp = new List<NodeRelation>();
                Dictionary<string, NodeRelation> nodeRelationDicTemp = new Dictionary<string, NodeRelation>();

                foreach (IvsDomainRoute route in ivsDomainRouteList)
                {
                    //加上此判断条件的话,子域将不会作查目录处理,不合理,故注释掉
                    //if (route.ParentDomain != "")
                    //{
                    //    continue;
                    //}
                    Dictionary<string, IvsCameraGroup> ivsCameraGroupDic;

                    logEx.Trace("Call ivsSdkClient.GetDeviceGroupList({0},{1},out groupCount, out ivsCameraGroupDic).",
                                route.DomainCode,
                                CgwConst.IVS_SDK_ROOTGROUP_TAG);

                    result = this.ivsSdkClient.GetDeviceGroupList(route.DomainCode,
                                                             CgwConst.IVS_SDK_ROOTGROUP_TAG,
                                                             out ivsCameraGroupDic);

                    if (result == CgwConst.IVS_SDK_SUCCESS_TAG)
                    {
                        logEx.Info("GetDeviceGroupList success.Current group count:{0}", ivsCameraGroupDic.Count);
                    }
                    else
                    {
                        logEx.Error("GetDeviceGroupList failed.Ivs sdk error code:{0}", result);
                        ClearCamera();
                        isRefreshSucess = false;
                        return;
                    }

                    //域也当做分组使用
                    string encodeDomainNo = CgwConst.IVS_SDK_ROOTGROUP_TAG + CgwConst.IVS_SDK_DOMAINCODE_SEPARATOR_TAG + route.DomainCode;
                    CameraGroup domainGroup = new CameraGroup(encodeDomainNo, route.DomainName);
                    groupListTemp.Add(domainGroup);

                    List<string> pathDomainList = new List<string>();
                    RecursionGroupPath(route.DomainCode, ivsDomainRouteList,ref pathDomainList);
                    NodeRelation nodeDomainRelation = new NodeRelation(encodeDomainNo, pathDomainList, CgwMonitorManage.Common.NodeType.GROUP);
                    nodeRelationDicTemp.Add(encodeDomainNo, nodeDomainRelation);

                    foreach (KeyValuePair<string, IvsCameraGroup> ivsCameraGroupKeyValue in ivsCameraGroupDic)
                    {
                        IvsCameraGroup group = ivsCameraGroupKeyValue.Value;
                        string encodeGroupNo = group.GroupNo + CgwConst.IVS_SDK_DOMAINCODE_SEPARATOR_TAG + group.DomainCode;
                        //添加组信息
                        CameraGroup cameraGroup = new CameraGroup(encodeGroupNo, group.GroupName);
                        groupListTemp.Add(cameraGroup);

                        List<string> pathList = new List<string>();
                        RecursionPath(group.GroupNo, ivsCameraGroupDic, ref pathList);

                        NodeRelation nodeRelation = new NodeRelation(encodeGroupNo, pathList, CgwMonitorManage.Common.NodeType.GROUP);
                        nodeRelationDicTemp.Add(encodeGroupNo, nodeRelation);
                    }
                }
                //添加所有组节点
                nodeRelationListTemp.AddRange(nodeRelationDicTemp.Values);

                List<IvsCamera> ivsCameraPageList = new List<IvsCamera>();
                int cameraCount = 0;
                logEx.Trace("Call ivsSdkClient.GetDeviceList");

                //查询第一页记录,同时获取摄像头个数
                result = this.ivsSdkClient.GetDeviceList(CgwConst.PAGE_FIRST_INDEX, CgwConst.PAGE_LAST_INDEX, out cameraCount, out ivsCameraPageList);

                List<IvsCamera> ivsCameraLeaveList = new List<IvsCamera>();
                //如果总记录大于一页的总记录数
                if (cameraCount > CgwConst.PAGE_LAST_INDEX)
                {
                    //一次将剩下所有记录查询出来
                    result = this.ivsSdkClient.GetDeviceList(CgwConst.PAGE_LAST_INDEX + 1, cameraCount, out cameraCount, out ivsCameraLeaveList);
                }

                if (result == CgwConst.IVS_SDK_SUCCESS_TAG)
                {
                    logEx.Info("GetDeviceList success.Current group count:{0}", cameraCount);
                    ivsCameraPageList.AddRange(ivsCameraLeaveList);
                }
                else
                {
                    logEx.Error("GetDeviceList failed.Ivs sdk error code:{0}", result);
                    ClearCamera();
                    isRefreshSucess = false;
                    return;
                }

                foreach (IvsCamera ivsCamera in ivsCameraPageList)
                {
                    Camera camera = new Camera(ivsCamera.No, ivsCamera.Name);
                    camera.Status = ivsCamera.Status;

                    List<string> cameraPathList = new List<string>();
                    //string encodeGroupNo = ivsCamera.GroupNo + CgwConst.IVS_SDK_DOMAINCODE_SEPARATOR_TAG + ivsCamera.DomainCode;//摄像头所属组号错误(与群组组号混淆了)。
                    string encodeGroupNo = ivsCamera.GroupNo;
                    if (nodeRelationDicTemp.ContainsKey(encodeGroupNo))
                    {
                        //如果自定义分组里面包含该摄像头的父节点,需要设置分组路径
                        cameraPathList.AddRange(nodeRelationDicTemp[encodeGroupNo].Path);
                        cameraPathList.Add(encodeGroupNo);
                    }

                    NodeRelation nodeRelation = new NodeRelation(camera.No, cameraPathList, CgwMonitorManage.Common.NodeType.CAMERA);

                    //解决问题单DTS2013080201001,规避因IVS服务器存在摄像头重复的bug导致融合网关异常的问题
                    if (!nodeRelationDicTemp.ContainsKey(camera.No))
                    {
                        cameraListTemp.Add(camera);
                        nodeRelationDicTemp.Add(camera.No, nodeRelation);
                    }

                    nodeRelationListTemp.Add(nodeRelation);
                }
                //nodeRelationListTemp.AddRange(nodeRelationDicTemp.Values);

                DateTime dtStart = DateTime.Now;
                DateTime dtNow = new DateTime();
                while (!isGetDevicesFinish)
                {
                    dtNow = DateTime.Now;

                    if ((dtNow - dtStart).TotalSeconds > refreshDeviceListOverTime)
                    {
                        isRefreshSucess = false;
                        return;
                    }
                    Thread.Sleep(1);
                    continue;
                }
                //将实时获取的值放到缓存
                if (this.cameraOperateLock.TryEnterWriteLock(CgwConst.ENTER_LOCK_WAIT_TIME))
                {
                    try
                    {
                        this.cameraList = cameraListTemp;
                        this.groupList = groupListTemp;
                        this.nodeRelationList = nodeRelationListTemp;
                        isRefreshSucess = true;
                    }
                    catch (Exception ex)
                    {
                        isRefreshSucess = false;
                        logEx.Error("Set the list to the buffer failed. ", ex.Message);
                    }
                    finally
                    {
                        this.cameraOperateLock.ExitWriteLock();
                    }
                }
                else
                {
                    isRefreshSucess = false;
                }
            }
            catch (System.Exception ex)
            {
                logEx.Error("GetAllCamerasMethod failed.Exception message:{0}", ex.Message);
                isRefreshSucess = false;
            }
        }