Exemplo n.º 1
0
 public LivePlayer(IntPtr playWndHandle, NvrPreviewSettings previewSettings)
 {
     PreviewSettings      = previewSettings ?? throw new ArgumentNullException(nameof(previewSettings));
     PlayWndHandlePtr     = playWndHandle;
     RealPlayHandle       = RealPlayPort = -1;
     RealDataCallBackFunc = null;
     DrawCallBackFunc     = null;
 }
Exemplo n.º 2
0
        /// <summary>
        ///		Start Preview in realtime.
        ///		<para><paramref name="playWndHandle"/> - window handle, on fitch will be drawing.</para>
        ///		<para><paramref name="previewSettings"/> - preview settings.</para>
        /// </summary>
        public void StartPreview(IntPtr playWndHandle, NvrPreviewSettings previewSettings)
        {
            if (livePlayer_.RealPlayHandle != -1)
            {
                throw new NvrBadLogicException("Call StopPreview before calling StartPreview");
            }

            if (!NvrUserSession.IsSessionValid())
            {
                throw new NvrBadLogicException("Call StartPreview when NvrUserSession is invalid");
            }

            livePlayer_ = new LivePlayer(playWndHandle, previewSettings);

            CHCNetSDK.NET_DVR_PREVIEWINFO previewInfo = new CHCNetSDK.NET_DVR_PREVIEWINFO()
            {
                lChannel        = NvrUserSession.UserSessionState.SelectedChannelNum,
                dwStreamType    = livePlayer_.PreviewSettings.StreamType,
                dwLinkMode      = (uint)livePlayer_.PreviewSettings.LinkMode,
                bBlocked        = livePlayer_.PreviewSettings.IsBlocked,
                dwDisplayBufNum = livePlayer_.PreviewSettings.DisplayBufNum,
                byPreviewMode   = (byte)livePlayer_.PreviewSettings.PreviewMode
            };

            switch (previewSettings.PreviewHandleMode)
            {
            case PreviewHandleType.Direct:
                livePlayer_.RealDataCallBackFunc = null;
                previewInfo.hPlayWnd             = livePlayer_.PlayWndHandlePtr;
                break;

            case PreviewHandleType.CallBack:
                livePlayer_.RealDataCallBackFunc = new CHCNetSDK.REALDATACALLBACK(realDataCallBack);                        // Real-time stream callback function
                previewInfo.hPlayWnd             = IntPtr.Zero;
                break;
            }

            livePlayer_.RealPlayHandle = CHCNetSDK.NET_DVR_RealPlay_V40(NvrUserSession.UserSessionState.UserId, ref previewInfo, livePlayer_.RealDataCallBackFunc, IntPtr.Zero);

            if (livePlayer_.RealPlayHandle == -1)
            {
                throw new NvrSdkException(CHCNetSDK.NET_DVR_GetLastError(), "NET_DVR_RealPlay_V40 failed: " + livePlayer_.RealPlayHandle);
            }

            if (previewSettings.PreviewHandleMode == PreviewHandleType.Direct)
            {
                livePlayer_.DrawCallBackFunc = new CHCNetSDK.DRAWFUN(drawCallBack);
                if (!CHCNetSDK.NET_DVR_RigisterDrawFun(livePlayer_.RealPlayHandle, livePlayer_.DrawCallBackFunc, 0))
                {
                    invokeOnPreviewErrorEvent(PlayCtrl.PlayM4_GetLastError(livePlayer_.RealPlayPort), "NET_DVR_RigisterDrawFun failed");
                }
            }

            debugInfo("NET_DVR_RealPlay_V40 succ!");
        }
Exemplo n.º 3
0
        public MainWindow()
        {
            InitializeComponent();

            textBox4.Text = getAppConfiguration("NvrIp");
            textBox3.Text = getAppConfiguration("NvrPort");
            textBox1.Text = getAppConfiguration("NvrUserName");
            textBox2.Text = getAppConfiguration("NvrUserPassword");

            liveViewService_.OnException += appendLogOnUiThread;

            NvrPreviewSettings previewSettings = liveViewService_.NvrPreviewSettings;

            numericUpDown1.Value = previewSettings.StreamType;
            numericUpDown2.Value = previewSettings.DisplayBufNum;
            checkBox1.Checked    = previewSettings.IsPassbackRecord;
            checkBox2.Checked    = previewSettings.IsBlocked;

            comboBox2.Items.AddRange(Enum.GetNames(typeof(PreviewLinkModeType)));
            comboBox2.SelectedIndex = (int)previewSettings.LinkMode;

            comboBox3.Items.AddRange(Enum.GetNames(typeof(PreviewQualityType)));
            comboBox3.SelectedIndex = (int)previewSettings.PreviewQuality;

            comboBox4.Items.AddRange(Enum.GetNames(typeof(PreviewModeType)));
            comboBox4.SelectedIndex = (int)previewSettings.PreviewMode;

            comboBox5.Items.AddRange(Enum.GetNames(typeof(PreviewHandleType)));
            comboBox5.SelectedIndexChanged += (object sender, EventArgs e) => {
                if (comboBox5.SelectedIndex == (int)PreviewHandleType.Direct)
                {
                    subtleSettingsGB.Enabled = false;
                }
                else
                {
                    subtleSettingsGB.Enabled = true;
                }
            };
            comboBox5.SelectedIndex = (int)previewSettings.PreviewHandleMode;

            previewPanel.Enabled = isLogedIn_;
        }