示例#1
0
        private void StartSinglePreview()
        {
            if (m_iPlaybackID >= 0)
            {
                Log.Info("", "Please stop plaback first");
                ShowFancyMessage(GetApplicationContext(), "Please stop playback first", Color: Resource.Color.error_color_material_light);
                return;
            }

            Log.Info("", "m_iStartChan: " + m_iStartChan);

            NET_DVR_PREVIEWINFO previewinfo = new NET_DVR_PREVIEWINFO()
            {
                LChannel     = m_iStartChan,
                DwStreamType = 0,
                BBlocked     = 1,
                HHwnd        = playView[0].Holder
            };

            m_iPlaybackID = HCNetSDK.Instance.NET_DVR_RealPlay_V40(m_iLogID, previewinfo, null);
            if (m_iPlaybackID < 0)
            {
                Log.Error("", "NET_DVR_RealPlay is failed!Err: " + HCNetSDK.Instance.NET_DVR_GetLastError());
                return;
            }

            Log.Info("", "NetSdk Play sucess ***********************3***************************");
            m_oPreviewBtn.Text = "Stop";
        }
示例#2
0
        public bool StartStream(IntPtr streamingHandle)
        {
            if (playId >= 0)
            {
                StopStream();
            }

            var previewInfo = new NET_DVR_PREVIEWINFO();

            previewInfo.WindowHandle  = streamingHandle;
            previewInfo.ChannelNumber = 1;
            previewInfo.StreamType    = 0;
            previewInfo.LinkMode      = 0;
            previewInfo.Blocked       = true;
            previewInfo.DisplayBufNum = 1;
            previewInfo.ProtoType     = 0;
            previewInfo.PreviewMode   = 0;

            playId = NET_DVR_RealPlay_V40(userId, ref previewInfo, null, IntPtr.Zero);

            if (playId >= 0)
            {
                return(true);
            }

            return(false);
        }
示例#3
0
        /// <summary>
        /// 预览
        /// </summary>
        /// <param name="CH">通道</param>
        /// <param name="Handle">句柄</param>
        /// <param name="StreamType">码流类型:0-主码流,1-子码流,2-码流3,3-码流4,以此类推</param>
        /// <param name="Mode">连接方式:0- TCP方式,1- UDP方式,2- 多播方式,3- RTP方式,4-RTP/RTSP,5-RSTP/HTTP </param>
        /// <param name="Blocked">0- 非阻塞取流,1- 阻塞取流</param>
        public void RealPlay(int CH, IntPtr Handle, Action <int, int, IntPtr, uint, IntPtr> RealDataCallBack = null, Action <int, int, IntPtr, uint, IntPtr> StdDataEvent = null, Action <int, int, IntPtr, uint, IntPtr> RealDataEvent = null, int StreamType = 0, LinkMode Mode = LinkMode.TCP, bool Blocked = true)
        {
            NET_DVR_PREVIEWINFO lpPreviewInfo = new NET_DVR_PREVIEWINFO();

            lpPreviewInfo.hPlayWnd        = Handle;
            lpPreviewInfo.lChannel        = CH;
            lpPreviewInfo.dwStreamType    = (uint)StreamType;
            lpPreviewInfo.dwLinkMode      = (uint)Mode;
            lpPreviewInfo.bBlocked        = Blocked;
            lpPreviewInfo.dwDisplayBufNum = (uint)this.BufferFrame;
            IntPtr           pUser    = new IntPtr();
            REALDATACALLBACK RealData = null;

            if (RealDataCallBack != null)
            {
                RealData = new REALDATACALLBACK(RealDataCallBack);
            }
            System.Threading.Thread.Sleep(1000);
            if (Environment.Is64BitProcess)
            {
                m_lRealHandle = HCNetSDKia64.NET_DVR_RealPlay_V40(this.lUserID, ref lpPreviewInfo, RealData, pUser);
            }
            else
            {
                m_lRealHandle = HCNetSDK.NET_DVR_RealPlay_V40(this.lUserID, ref lpPreviewInfo, RealData, pUser);
            }
            if (m_lRealHandle < 0)
            {
                Error();
            }
            if (StdDataEvent != null)
            {
                if (Environment.Is64BitProcess)
                {
                    HCNetSDKia64.NET_DVR_SetStandardDataCallBack(this.lUserID, new StdDataCallBack(StdDataEvent), pUser);
                }
                else
                {
                    HCNetSDK.NET_DVR_SetStandardDataCallBack(this.lUserID, new StdDataCallBack(StdDataEvent), pUser);
                }
            }
            if (RealDataEvent != null)
            {
                if (Environment.Is64BitProcess)
                {
                    HCNetSDKia64.NET_DVR_SetRealDataCallBack(this.lUserID, new RealDataCallBack(RealDataEvent), pUser);
                }
                else
                {
                    HCNetSDK.NET_DVR_SetRealDataCallBack(this.lUserID, new RealDataCallBack(RealDataEvent), pUser);
                }
            }
        }
示例#4
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;
            }
        }
        public void StartPreview(int IUserID, int IChan)
        {
            Console.WriteLine(TAG, "Preview channel:" + IChan);

            while (!BCreate)
            {
                try
                {
                    Task.Delay(100);
                    Console.WriteLine("Wait for the surface create");
                }
                catch (Java.Lang.InterruptedException e)
                {
                    e.PrintStackTrace();
                }
            }

            NET_DVR_PREVIEWINFO previewinfo = new NET_DVR_PREVIEWINFO()
            {
                LChannel     = IChan,
                DwStreamType = 0, //Substream
                BBlocked     = 1,
                HHwnd        = M_hHolder
            };

            M_iPreviewHandle = HCNetSDK.Instance.NET_DVR_RealPlay_V40(IUserID, previewinfo, null);

            if (M_iPreviewHandle < 0)
            {
                Console.WriteLine(TAG, "NET_DVR_RealPlay is failed!Err: " + HCNetSDK.Instance.NET_DVR_GetLastError());
                using (var h = new Handler(Looper.MainLooper))
                {
                    h.Post(() =>
                    {
                        MainActivity.ShowFancyMessage(MainActivity.GetApplicationContext(), "Preview has failed", message: $"Error code: {HCNetSDK.Instance.NET_DVR_GetLastError()} ");
                    });
                }
                MainActivity.ShowFancyMessage(MainActivity.GetApplicationContext(), "Preview has failed", message: $"Error code: {HCNetSDK.Instance.NET_DVR_GetLastError()} ");
            }
        }
示例#6
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);
示例#7
0
文件: HKSDK.cs 项目: nodreamnolove/-
 public static extern int NET_DVR_RealPlay_V40(int iUserID, ref NET_DVR_PREVIEWINFO lpPreviewInfo, REALDATACALLBACK fRealDataCallBack_V30, IntPtr pUser);
        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);
        }
示例#9
0
        public string DisplayDVR()
        {
            string message = "";

            if (m_UserID < 0)
            {
                message = "Please login the device firstly";
            }

            if (m_RealHandle < 0)
            {
                NET_DVR_PREVIEWINFO lpPreviewInfo = new NET_DVR_PREVIEWINFO();
                lpPreviewInfo.hPlayWnd        = dvrPtr; //预览窗口
                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- 阻塞取流
                lpPreviewInfo.dwDisplayBufNum = 1;      //播放库播放缓冲区最大缓冲帧数
                lpPreviewInfo.byProtoType     = 0;
                lpPreviewInfo.byPreviewMode   = 0;

                //流ID摄制
                //if (textBoxID.Text != "")
                //{
                //    lpPreviewInfo.lChannel = -1;
                //    byte[] byStreamID = System.Text.Encoding.Default.GetBytes(textBoxID.Text);
                //    lpPreviewInfo.byStreamID = new byte[32];
                //    byStreamID.CopyTo(lpPreviewInfo.byStreamID, 0);
                //}


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

                IntPtr pUser = new IntPtr();//用户数据

                //打开预览 Start live view
                m_RealHandle = realPlay(m_UserID, ref lpPreviewInfo, null /*RealData*/, pUser);
                if (m_RealHandle < 0)
                {
                    iLastErr = lastError();
                    message  = "NET_DVR_RealPlay_V40 failed, error code= " + iLastErr; //预览失败,输出错误号
                }
                else
                {
                    message = "Stop Live View";
                }
            }
            else
            {
                //停止预览 Stop live view
                if (!stopPlay(m_RealHandle))
                {
                    iLastErr = lastError();
                    message  = "NET_DVR_StopRealPlay failed, error code= " + iLastErr;
                }
                m_RealHandle = -1;
            }

            return(message);
        }