Exemplo n.º 1
0
        public void OnNetSDKMsg(IntPtr wParam, IntPtr lParam)
        {
            //wParam的低16位是消息的类型;
            int iMsgType = wParam.ToInt32() & 0xFFFF;

            switch (iMsgType)
            {
            case NetSDKMsg.WCM_LOGON_NOTIFY:
            {
                Int32 iStatus = wParam.ToInt32() >> 16;
                if (NetSDKMsg.LOGON_SUCCESS == iStatus)
                {
                    MessageBox.Show("logon success!");
                    m_iLogonId = (Int32)lParam;

                    //初始化通道列表
                    Int32 iChanNum = 0;
                    SDK_TDWYSDK.NetClient_GetChannelNum(m_iLogonId, ref iChanNum);
                    //cboChanList.Items.Clear();
                    //for (Int32 i = 0; i < iChanNum; ++i)
                    //{
                    //    cboChanList.Items.Add((i + 1).ToString());
                    //}
                    //if (cboChanList.Items.Count > 0)
                    //{
                    //    cboChanList.SelectedIndex = 0;
                    //}
                    //btnLogon.Text = "Logoff";

                    ////登录成功后获取NTP信息
                    GetNtpInfo();
                }
                else
                {
                    MessageBox.Show("logon failed, reason " + iStatus);
                }
            }
            break;

            case NetSDKMsg.WCM_VIDEO_HEAD_EX:
            {
                //视频头消息来了,开始播放视频
                SDK_TDWYSDK.NetClient_StopPlay(m_iConnectId);
                SDK_TDWYSDK.RECT rect = new SDK_TDWYSDK.RECT();
                SDK_TDWYSDK.NetClient_StartPlay(m_iConnectId, pictureBox1.Handle, rect, 0);
            }
            break;

            default:
                break;
            }
        }
Exemplo n.º 2
0
        private void VideoEnvironment_TDWY_MAIN_NOTIFYEvent(uint _ulLogonID, IntPtr _iWparam, IntPtr _iLParam, int _iUser)
        {
            if (_ulLogonID == m_iLogonId)
            {
                //表示属于当前信息登录信息
                switch (_iWparam.ToInt32())
                {
                //登陆状态消息
                //param1 登陆IP
                //param2 登陆ID
                //param3 登陆状态
                case NetSDKMsg.WCM_LOGON_NOTIFY:
                    Int32 iStatus = _iLParam.ToInt32();
                    if (iStatus == NetSDKMsg.LOGON_SUCCESS)
                    {
                        Console.WriteLine("登录成功");
                    }
                    else
                    {
                        //触发相关时间进行提示
                        Console.WriteLine("登录失败,Status:" + iStatus);
                    }
                    break;

                case NetSDKMsg.WCM_VIDEO_HEAD:
                    break;

                case NetSDKMsg.WCM_VIDEO_HEAD_EX:

                    SDK_TDWYSDK.NetClient_StopPlay(m_iConnectId);
                    this.BeginInvoke(new EventHandler(delegate
                    {
                        SDK_TDWYSDK.RECT rect = new SDK_TDWYSDK.RECT()
                        {
                            bottom = 0, left = 0, right = 0, top = 0
                        };
                        SDK_TDWYSDK.NetClient_StartPlay(m_iConnectId, pictureBox1.Handle, rect, 0);
                    }));
                    break;

                default:
                    Console.WriteLine("TDWY- MyMAIN_NOTIFY_V4: " + _iWparam.ToInt32());
                    break;
                }
            }
        }
Exemplo n.º 3
0
        private void VideoEnvironment_TDWY_MAIN_NOTIFYEvent(Int32 _ulLogonID, Int32 _iWparam, IntPtr _iLParam, IntPtr _iUser)
        {
            if (_ulLogonID == _iLogonID)
            {
                int iMsg = _iWparam & 0xffff;
                //表示属于当前信息登录信息
                switch (iMsg)
                {
                //登陆状态消息
                //param1 登陆IP
                //param2 登陆ID
                //param3 登陆状态
                case NetSDKMsg.WCM_LOGON_NOTIFY:
                    Int32 iStatus = _iLParam.ToInt32();
                    if (iStatus == NetSDKMsg.LOGON_SUCCESS)
                    {
                        VideoPlayCallback(new VideoPlayCallbackValue {
                            evType = Enum_VideoPlayEventType.LoginSuccess
                        });
                        //初始化通道列表
                        //Int32 iChanNum = 0;
                        //SDK_TDWY.NetClient_GetChannelNum(_iLogonID, ref iChanNum);
                        CLIENTINFO channel = new CLIENTINFO
                        {
                            m_iServerID  = _iLogonID,
                            m_iTimeout   = 20,
                            m_iNetMode   = 1,
                            m_iChannelNo = CurrentCameraInfo.Channel - 1,
                            m_iStreamNO  = (CurrentVideoPlaySet.PlayStream == Enum.Enum_VideoStream.SubStream) ? 1 : 0,
                            m_cNetFile   = new char[255],
                            m_cRemoteIP  = new char[16],
                        };
                        Array.Copy(CurrentVideoInfo.DVSAddress.ToArray(), channel.m_cRemoteIP, CurrentVideoInfo.DVSAddress.Length);
                        //开始接收一路视频数据
                        UInt32 uiConID = 0;
                        int    iRet    = SDK_TDWYSDK.NetClient_StartRecv(ref uiConID, ref channel, null);

                        VideoPlayCallback(new VideoPlayCallbackValue {
                            evType = Enum_VideoPlayEventType.RequestConn
                        });
                        if (iRet < 0)
                        {
                            //操作失败
                            VideoPlayCallback(new VideoPlayCallbackValue {
                                evType = Enum_VideoPlayEventType.RequestVideoTimeout
                            });
                        }
                        m_iConnectId = Convert.ToInt32(uiConID);
                    }
                    else
                    {
                        //触发相关时间进行提示
                        VideoPlayCallback(new VideoPlayCallbackValue {
                            evType = Enum_VideoPlayEventType.DevLoginException
                        });
                        Console.WriteLine("登录失败,Status:" + iStatus);
                    }
                    break;

                case NetSDKMsg.WCM_VIDEO_HEAD_EX:
                    RECT rect = new RECT();
                    SDK_TDWYSDK.NetClient_StartPlay(m_iConnectId, intptrPlayMain, rect, 0);
                    VideoPlayCallback(new VideoPlayCallbackValue {
                        evType = Enum_VideoPlayEventType.VideoPlay
                    });
                    break;

                case NetSDKMsg.WCM_ERR_DIGITCHANNEL_NOT_ENABLED:
                    VideoPlayCallback(new VideoPlayCallbackValue {
                        evType = Enum_VideoPlayEventType.RequestVideoTimeout
                    });
                    break;

                default:
                    Console.WriteLine("TDWY- MyMAIN_NOTIFY_V4: " + iMsg);
                    break;
                }
            }
        }