Exemplo n.º 1
0
 //预览开启
 private void previewOpenClick(object sender, EventArgs e)
 {
     if (m_lUserID >= 0)
     {
         if (button2.Text == @"开启预览")
         {
             HKSDK.NET_DVR_PREVIEWINFO lpPreviewInfo = new HKSDK.NET_DVR_PREVIEWINFO();
             lpPreviewInfo.hPlayWnd     = panel1.Handle; //预览窗口
             lpPreviewInfo.lChannel     = 1;             //预te览的设备通道
             lpPreviewInfo.dwStreamType = 0;             //码流类型:0-主码流,1-子码流,2-码流3,3-码流4,以此类推
             lpPreviewInfo.dwLinkMode   = 0;             //连接方式:0- TCP方式,1- UDP方式,2- 多播方式,3- RTP方式,4-RTP/RTSP,5-RSTP/HTTP
             lpPreviewInfo.bBlocked     = true;          //0- 非阻塞取流,1- 阻塞取流
             IntPtr pUser = new IntPtr();                //用户数据
             m_lRealHandle = HKSDK.NET_DVR_RealPlay_V40(m_lUserID, ref lpPreviewInfo, null /*RealData*/, pUser);
             if (m_lRealHandle < 0)
             {
                 textBox1.AppendText("\r\n开启预览失败");
                 //  MessageBox.Show("error " + HKSDK.NET_DVR_GetLastError());
                 return;
             }
             //    savepic = new Thread(new ThreadStart(savePicThread));
             m_call = new HKSDK.MSGCallBack(MsgCallback);
             if (HKSDK.NET_DVR_SetDVRMessageCallBack_V30(m_call, IntPtr.Zero))
             {
                 textBox1.AppendText("\r\n开启预览成功");
             }
             button2.Text = @"关闭预览";
         }
         else
         {
             HKSDK.NET_DVR_StopRealPlay(m_lRealHandle);
             button2.Text = @"关闭预览";
             textBox1.AppendText("\r\n关闭预览");
         }
     }
 }
Exemplo n.º 2
0
        //预览开启
        private void previewOpenClick(object sender, EventArgs e)
        {
            if (m_lUserID >= 0)
            {
                if (button2.Text == @"开启预览")
                {
                    HKSDK.NET_DVR_PREVIEWINFO lpPreviewInfo = new HKSDK.NET_DVR_PREVIEWINFO();
                    lpPreviewInfo.hPlayWnd = panel1.Handle;//预览窗口
                    lpPreviewInfo.lChannel = 1;//预te览的设备通道
                    lpPreviewInfo.dwStreamType = 0;//码流类型:0-主码流,1-子码流,2-码流3,3-码流4,以此类推
                    lpPreviewInfo.dwLinkMode = 0;//连接方式:0- TCP方式,1- UDP方式,2- 多播方式,3- RTP方式,4-RTP/RTSP,5-RSTP/HTTP
                    lpPreviewInfo.bBlocked = true; //0- 非阻塞取流,1- 阻塞取流
                    IntPtr pUser = new IntPtr();//用户数据
                    m_lRealHandle = HKSDK.NET_DVR_RealPlay_V40(m_lUserID, ref lpPreviewInfo, null/*RealData*/, pUser);
                    if (m_lRealHandle < 0)
                    {
                        textBox1.AppendText("\r\n开启预览失败");
                      //  MessageBox.Show("error " + HKSDK.NET_DVR_GetLastError());
                        return;
                    }
                    //    savepic = new Thread(new ThreadStart(savePicThread));
                    m_call = new HKSDK.MSGCallBack(MsgCallback);
                    if (HKSDK.NET_DVR_SetDVRMessageCallBack_V30(m_call, IntPtr.Zero))
                        textBox1.AppendText("\r\n开启预览成功");
                    button2.Text = @"关闭预览";
                }
                else
                {
                    HKSDK.NET_DVR_StopRealPlay(m_lRealHandle);
                    button2.Text = @"关闭预览";
                    textBox1.AppendText("\r\n关闭预览");
                }

            }
        }