Esempio n. 1
0
        public static int GetVideoStreamValue(Enum_VideoStream vs)
        {
            int intValue = 0;

            switch (vs)
            {
            case Enum_VideoStream.MainStream:
                intValue = 1;
                break;

            case Enum_VideoStream.SubStream:
                intValue = 0;
                break;
            }
            return(intValue);
        }
Esempio n. 2
0
        /// <summary>
        /// 大华视频播放
        /// </summary>
        /// <returns></returns>
        public bool VideoPlay()
        {
            bool bolResult = false;

            if (SDKState.DHVideoSDKState != Enum_SDKState.SDK_Init)
            {
                SDKState.DHVideoSDK_Init();
            }
            SDK_DaHua.NET_DEVICEINFO deviceInfo = new SDK_DaHua.NET_DEVICEINFO();
            int intError;

            intLoginID = SDK_DaHua.CLIENT_Login(CurrentVideoInfo.DVSAddress, Convert.ToUInt16(CurrentVideoInfo.DVSConnectPort), CurrentVideoInfo.UserName, CurrentVideoInfo.Password, out deviceInfo, out intError);
            if (intLoginID != 0)
            {
                VideoPlayCallback(new VideoPlayCallbackValue {
                    evType = Enum_VideoPlayEventType.LoginSuccess
                });
                if (CurrentVideoPlaySet.PlayStream == Enum_VideoStream.MainStream)
                {
                    intPlayID   = SDK_DaHua.CLIENT_RealPlayEx(intLoginID, CurrentCameraInfo.Channel - 1, intptrPlayMain, SDK_DaHua.REALPLAY_TYPE.DH_RType_RealPlay);
                    videoStream = Enum_VideoStream.MainStream;
                }
                else
                {
                    intPlayID   = SDK_DaHua.CLIENT_RealPlayEx(intLoginID, CurrentCameraInfo.Channel - 1, intptrPlayMain, SDK_DaHua.REALPLAY_TYPE.DH_RType_RealPlay_1);
                    videoStream = Enum_VideoStream.SubStream;
                }

                if (intPlayID != 0)
                {
                    if (CurrentVideoPlaySet.VideoMonitorEnable)
                    {
                        OpenSound();
                    }
                    if (CurrentVideoPlaySet.VideoRecordEnable)
                    {
                        string Temp_strVideoRecord = GetLocalSavePath(CurrentVideoPlaySet.VideoRecordFilePath, CurrentVideoPlaySet.VideoRecordFileName);
                        SDK_DaHua.CLIENT_SaveRealData(intPlayID, Temp_strVideoRecord);
                        VideoRecordStatus = true;
                    }

                    VideoPlayCallback(new VideoPlayCallbackValue {
                        evType = Enum_VideoPlayEventType.VideoPlay
                    });
                    VideoPlayState = Enum_VideoPlayState.InPlayState;
                }
                else
                {
                    VideoPlayCallback(new VideoPlayCallbackValue {
                        evType = Enum_VideoPlayEventType.VideoPlayException
                    });
                }
            }
            else
            {
                VideoPlayState = Enum_VideoPlayState.NotInPlayState;
                VideoPlayCallback(new VideoPlayCallbackValue {
                    evType = Enum_VideoPlayEventType.DevLoginException
                });
            }
            return(bolResult);
        }
 public virtual void SetVideoStream(Enum_VideoStream vs)
 {
     videoStream = vs;
 }
        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);
        }