예제 #1
0
        /// <summary>
        /// 海康视频播放
        /// </summary>
        public void HikDVR_VideoPlay()
        {
            NET_DVR_DEVICEINFO_V30 dev = new NET_DVR_DEVICEINFO_V30();

            _intDVRHwd = NET_DVR_Login_V30(CurrentVideoInfo.DVSAddress, CurrentVideoInfo.DVSConnectPort, CurrentVideoInfo.UserName, CurrentVideoInfo.Password, ref dev);
            if (_intDVRHwd < 0)
            {
                //登陆失败
                return;
            }
            return;

            NET_DVR_PREVIEWINFO lpPreviewInfo = new NET_DVR_PREVIEWINFO();

            lpPreviewInfo.hPlayWnd     = pictureBox1.Handle; //预览窗口
            lpPreviewInfo.lChannel     = CurrentCameraInfo.Channel;
            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- 阻塞取流


            //NET_DVR_CLIENTINFO cli = new NET_DVR_CLIENTINFO();
            //cli.lLinkMode = 0;// 设置连接方式  /*  最高位(31)为 0 表示主码流,为 1 表示子码流,0-30 位表示码流连接方式:0:TCP方式,1:UDP 方式,2:多播方式,3 - RTP方式,4—音视频分开 */
            //cli.lChannel = channel + 32;
            //cli.hPlayWnd = playHandle;

            // 开始播放视频
            //Thread.Sleep(50);
            IntPtr           pUser    = new IntPtr();
            REALDATACALLBACK RealData = new REALDATACALLBACK(RealDataCallBack);//预览实时流回调函数

            //intRet = NET_DVR_RealPlay_V30(_intDVRHwd, ref cli, null, pUser, 1);//130814
            intRet = NET_DVR_RealPlay_V40(_intDVRHwd, ref lpPreviewInfo, null, pUser); //140521
            //intRet = NET_DVR_RealPlay(_intDVRHwd, ref cli);//130814
            NET_DVR_OpenSound(intRet);                                                 //140609
            if (intRet < 0)
            {
                return;
            }
        }
예제 #2
0
        public void StartPreview(IntPtr realPlayWndHandle)
        {
            if (UserID < 0)
            {
                throw new Exception("Please login the device firstly");
            }

            CHCNetSDK.NET_DVR_PREVIEWINFO previewInfo = new CHCNetSDK.NET_DVR_PREVIEWINFO();
            previewInfo.hPlayWnd        = realPlayWndHandle; //预览窗口
            previewInfo.lChannel        = 1;                 //预览的设备通道
            previewInfo.dwStreamType    = 0;                 //码流类型:0-主码流,1-子码流,2-码流3,3-码流4,以此类推
            previewInfo.dwLinkMode      = 0;                 //连接方式:0- TCP方式,1- UDP方式,2- 多播方式,3- RTP方式,4-RTP/RTSP,5-RSTP/HTTP
            previewInfo.bBlocked        = true;              //0- 非阻塞取流,1- 阻塞取流
            previewInfo.dwDisplayBufNum = 15;                //播放库播放缓冲区最大缓冲帧数

            if (RealData == null)
            {
                RealData = RealDataCallBack;//预览实时流回调函数
            }

            RealPlayHandle = NET_DVR_RealPlay_V40(UserID, ref previewInfo, null, User);
        }
예제 #3
0
 public static extern int NET_DVR_RealPlay_V40(int iUserId, ref NetDvrPreviewInfo lpPreviewInfo,
                                               REALDATACALLBACK fRealDataCallBackV30, IntPtr pUser);
예제 #4
0
파일: HKSDK.cs 프로젝트: dusong7/--1
 public static extern int NET_DVR_RealPlay_V40(int iUserID, ref NET_DVR_PREVIEWINFO lpPreviewInfo, REALDATACALLBACK fRealDataCallBack_V30, IntPtr pUser);
예제 #5
0
파일: HKSDK.cs 프로젝트: nodreamnolove/-
 public static extern int NET_DVR_RealPlay_V40(int iUserID, ref NET_DVR_PREVIEWINFO lpPreviewInfo, REALDATACALLBACK fRealDataCallBack_V30, IntPtr pUser);
예제 #6
0
 /*********************************************************
 Function:	NET_DVR_RealPlay_V30
 Desc:		实时预览。
 Input:	lUserID [in] NET_DVR_Login()或NET_DVR_Login_V30()的返回值 
         lpClientInfo [in] 预览参数 
         cbRealDataCallBack [in] 码流数据回调函数 
         pUser [in] 用户数据 
         bBlocked [in] 请求码流过程是否阻塞:0-否;1-是 
 Output:	
 Return:	1表示失败,其他值作为NET_DVR_StopRealPlay等函数的句柄参数
 **********************************************************/
 public static extern int NET_DVR_RealPlay_V30(int iUserID, ref NET_DVR_CLIENTINFO lpClientInfo, REALDATACALLBACK fRealDataCallBack_V30, IntPtr pUser, UInt32 bBlocked);
예제 #7
0
 public static extern bool NET_DVR_SetRealDataCallBack(int lRealHandle, REALDATACALLBACK fRealDataCallBack, IntPtr dwUser);
예제 #8
0
        public bool VideoPlay()
        {
            if (VideoPlayState == Enum_VideoPlayState.InPlayState)
            {
                VideoClose();
            }
            bool bolResult             = false;
            NET_DVR_DEVICEINFO_V30 dev = new NET_DVR_DEVICEINFO_V30();

            _intDVRHwd = NET_DVR_Login_V30(CurrentVideoInfo.DVSAddress, CurrentVideoInfo.DVSConnectPort, CurrentVideoInfo.UserName, CurrentVideoInfo.Password, ref dev);

            if (_intDVRHwd >= 0)
            {
                DebugRelevant.DebugLog(this, "Hik:设备登陆成功:" + CurrentVideoInfo.DVSAddress);
                DebugRelevant.DebugLog(this, "Hik:设备信息:" + JsonConvert.SerializeObject(dev));
                dwAChanTotalNum = (uint)dev.byChanNum;
                if (dev.byIPChanNum > 0)
                {
                    InfoIPChannel();
                }
                else
                {
                    for (iip = 0; iip < dwAChanTotalNum; iip++)
                    {
                        iChannelNum[iip] = iip + (int)dev.byStartChan;
                    }
                }

                for (int i = 0; i < iChannelNum.Length; i++)
                {
                    DebugRelevant.DebugLog(this, "Hik:设备通道信息:" + "Index[" + i + "]" + iChannelNum[i]);
                }

                NET_DVR_PREVIEWINFO lpPreviewInfo = new NET_DVR_PREVIEWINFO();
                lpPreviewInfo.hPlayWnd = intptrPlayMain;//预览窗口
                if (dev.byIPChanNum == 0)
                {
                    lpPreviewInfo.lChannel = CurrentCameraInfo.Channel;
                    //SaveNetLog("播放通道" + channel.ToString());
                }
                else
                {
                    lpPreviewInfo.lChannel = iChannelNum[CurrentCameraInfo.Channel - 1];
                }
                if (CurrentVideoPlaySet.PlayStream == Enum_VideoStream.MainStream)
                {
                    lpPreviewInfo.dwStreamType = 0;//码流类型:0-主码流,1-子码流,2-码流3,3-码流4,以此类推
                    videoStream = Enum_VideoStream.MainStream;
                }
                else
                {
                    lpPreviewInfo.dwStreamType = 1;//码流类型:0-主码流,1-子码流,2-码流3,3-码流4,以此类推
                    videoStream = Enum_VideoStream.SubStream;
                }
                lpPreviewInfo.dwLinkMode = 0;    //连接方式:0- TCP方式,1- UDP方式,2- 多播方式,3- RTP方式,4-RTP/RTSP,5-RSTP/HTTP
                lpPreviewInfo.bBlocked   = true; //0- 非阻塞取流,1- 阻塞取流


                //NET_DVR_CLIENTINFO cli = new NET_DVR_CLIENTINFO();
                //cli.lLinkMode = 0;// 设置连接方式  /*  最高位(31)为 0 表示主码流,为 1 表示子码流,0-30 位表示码流连接方式:0:TCP方式,1:UDP 方式,2:多播方式,3 - RTP方式,4—音视频分开 */
                //cli.lChannel = channel + 32;
                //cli.hPlayWnd = playHandle;

                // 开始播放视频
                //Thread.Sleep(50);



                DebugRelevant.DebugLog(this, "Hik:真实播放通道号:" + lpPreviewInfo.lChannel);
                IntPtr           pUser    = new IntPtr();
                REALDATACALLBACK RealData = new REALDATACALLBACK(RealDataCallBack);//预览实时流回调函数

                //intRet = NET_DVR_RealPlay_V30(_intDVRHwd, ref cli, null, pUser, 1);//130814
                intRet = NET_DVR_RealPlay_V40(_intDVRHwd, ref lpPreviewInfo, null, pUser);//140521


                if (intRet != -1)
                {
                    if (CurrentVideoPlaySet.VideoMonitorEnable)
                    {
                        OpenSound();
                    }
                    VideoPlayCallback(new VideoPlayCallbackValue {
                        evType = Enum_VideoPlayEventType.VideoPlay
                    });
                    VideoPlayState = Enum_VideoPlayState.InPlayState;
                    if (CurrentVideoPlaySet.VideoRecordEnable)
                    {
                        StartVideoRecord(CurrentVideoPlaySet.VideoRecordFilePath);
                    }
                }
                else
                {
                    VideoPlayCallback(new VideoPlayCallbackValue {
                        evType = Enum_VideoPlayEventType.VideoPlayException
                    });
                }
            }
            else
            {
                VideoPlayCallback(new VideoPlayCallbackValue {
                    evType = Enum_VideoPlayEventType.DevLoginException
                });
                //登陆失败
                bolResult = false;
            }



            return(bolResult);
        }