Пример #1
0
        /// <summary>
        /// 连接视频
        /// </summary>
        /// <param name="strId">连接视频的id</param>
        /// <param name="strIp">连接视频的ip</param>
        /// <param name="strName">摄像机名称</param>
        /// <param name="itype">api类型 1.自己api 2.海康api</param>
        /// <param name="iLoginHandle">海康摄像机的登录句柄</param>
        /// <param name="iChannel">播放通道(海康摄像机)</param>
        public void ConnectVideo(string strId, string strIp, string strName, int iType,
                                 int iChannel, int iLoginHandle = -1)
        {
            //ucSingleVideo sOldVideo = GetSingleFormByCamId(strId);
            ////说明没有找到id对应的窗口
            //if (sOldVideo == null)
            //{
            //返回窗口的信息(空白的窗口)
            ucSingleVideo svideo = GetNextNullWin();

            if (svideo != null)
            {
                switch (iType)
                {
                case 1:    //自己api
                    svideo.ConnectVideo(strId, strIp, strName);
                    svideo.SetCamType(iType, iChannel);
                    svideo.ShowVideoCaption(true);
                    break;

                case 2:    //海康api
                    svideo.ConnectVideoHik(iLoginHandle, iChannel, strName);
                    svideo.SetCamType(iType, iChannel);
                    svideo.ShowVideoCaption(true);
                    break;
                }
            }
            //}
            //else
            //{
            //    setActiveWin(Convert.ToInt32(sOldVideo.Tag));
            //}
        }
Пример #2
0
        /// <summary>
        /// 连接视频
        /// </summary>
        /// <param name="strId">连接视频的id</param>
        /// <param name="strIp">连接视频的ip</param>
        /// <param name="strName">摄像机名称</param>
        /// <param name="itype">api类型 1.自己api 2.海康api</param>
        /// <param name="iLoginHandle">海康摄像机的登录句柄</param>
        /// <param name="iChannel">播放通道(海康摄像机)</param>
        public void ConnectVideoSwitch(string strId, string strIp, string strName, int iType,
                                       int iChannel, int iLoginHandle = -1)
        {
            ucSingleVideo oSelfCamVideo = GetSingleFormByCamId(strId);
            /*\ 根据海康 /*/
            ucSingleVideo oHikCamVideo = GetSingleByHikCamIp(strIp);

            switch (iType)
            {
            case 1:    //自己api
                if (oSelfCamVideo == null)
                {
                    ucSingleVideo oVideo = GetNextNullWin();
                    if (oVideo != null)
                    {
                        oVideo.ConnectVideo(strId, strIp, strName);
                        oVideo.SetCamType(iType, iChannel);
                        oVideo.ShowVideoCaption(true);
                    }
                }
                else
                {
                    /*\ 判断当先显示的视频是否和要在活动窗口显示的视频id相等 /*/
                    if (m_arrVideos[Convert.ToInt32(oSelfCamVideo.Tag)].m_strCamId == strId)
                    {
                        setActiveWin(Convert.ToInt32(oSelfCamVideo.Tag));
                    }
                    else
                    {
                        /*\ 断开当前连接的视频 /*/
                        m_arrVideos[Convert.ToInt32(oSelfCamVideo.Tag)].DisConnectVideo();
                        /*\ 连接新id的视频 /*/
                        m_arrVideos[Convert.ToInt32(oSelfCamVideo.Tag)].ConnectVideo(strId, strIp, strName);
                        m_arrVideos[Convert.ToInt32(oSelfCamVideo.Tag)].SetCamType(iType, iChannel);
                        m_arrVideos[Convert.ToInt32(oSelfCamVideo.Tag)].ShowVideoCaption(true);
                    }
                }
                break;

            case 2:    //海康api
                       /*\ 判断当前选中窗口是否连接视频,连接视频断开,替换 /*/
                if (oHikCamVideo == null)
                {
                    if (m_iCurScreens == 1)
                    {
                        setActiveWin(0);
                        if (m_arrVideos[m_iActiveWin].m_bConnected)
                        {
                            m_arrVideos[m_iActiveWin].DisConnectVideoHik();
                        }
                    }
                    ucSingleVideo oVideo = GetNextNullWinSwitch();
                    if (oVideo != null)
                    {
                        oVideo.ConnectVideoHik(iLoginHandle, iChannel, strName);
                        oVideo.SetHikCamIp(strIp);
                        oVideo.SetCamType(iType, iChannel);
                        oVideo.ShowVideoCaption(true);
                    }
                }
                else
                {
                    /*\ 判断当先显示的视频是否和要在活动窗口显示的视频Ip相等 /*/
                    int iWinNo = GetWinNoByHikCamIp(strIp);
                    if (iWinNo != -1)
                    {
                        setActiveWin(iWinNo);
                    }
                    else
                    {
                        /*\ 断开当前连接的视频 /*/
                        m_arrVideos[m_iActiveWin].DisConnectVideo();
                        /*\ 连接新id的视频 /*/
                        m_arrVideos[m_iActiveWin].ConnectVideoHik(iLoginHandle, iChannel, strName);
                        m_arrVideos[m_iActiveWin].SetHikCamIp(strIp);
                        m_arrVideos[m_iActiveWin].SetCamType(iType, iChannel);
                        m_arrVideos[m_iActiveWin].ShowVideoCaption(true);
                    }
                    //if (m_arrVideos[m_iActiveWin].m_strHikCamIp == strIp)
                    //{
                    //    setActiveWin(m_iActiveWin);
                    //}
                    //else
                    //{
                    //    /*\ 断开当前连接的视频 /*/
                    //    m_arrVideos[m_iActiveWin].DisConnectVideo();
                    //    /*\ 连接新id的视频 /*/
                    //    m_arrVideos[m_iActiveWin].ConnectVideoHik(iLoginHandle, iChannel, strName);
                    //    m_arrVideos[m_iActiveWin].SetHikCamIp(strIp);
                    //    m_arrVideos[m_iActiveWin].SetCamType(iType, iChannel);
                    //    m_arrVideos[m_iActiveWin].ShowVideoCaption(true);
                    //}
                }
                break;
            }
        }