コード例 #1
0
        private void btnOpenCamere_Click(object sender, RoutedEventArgs e)
        {
            DoAction(() =>
            {
                IEnumerable <InDeviceInfo> videoDeviceInfos;
                IEnumerable <InDeviceInfo> audioDeviceInfos;

                ApiProvider.Default.GetFreeDeviceInfos(out videoDeviceInfos, out audioDeviceInfos);

                if (videoDeviceInfos.Count() > 0)
                {
                    var param = new VideoInParam();

                    param.Type                = VideoInType.Camera;
                    param.CaptureFps          = 20;
                    param.Camera              = new CameraParam();
                    param.Camera.DevicePath   = videoDeviceInfos.First().Path;
                    param.Camera.QualityLevel = VideoQualityLevel.Middle;

                    if (_cameraOpened = _camera.Open(param))
                    {
                        var text = $"fps:{param.CaptureFps}{Environment.NewLine}";
                        text    += $"devicePath:{param.Camera.DevicePath}{Environment.NewLine}";
                        text    += $"qualityLevel:{param.Camera.QualityLevel}{Environment.NewLine}";

                        MessageBox.Show(text, "Open Success");

                        // 测试只能设置为Left=0,Top=0 ???
                        var rect = new RectScreenParam
                        {
                            Left   = 0,
                            Top    = 0,
                            Right  = 200,
                            Bottom = 150
                        };

                        _camera.SetDisplayRect(rect);
                        _camera.AdjustLayer(false);

                        if (_cameraStarted = _camera.StartCapture())
                        {
                            _camera.SwitchSoloPreview(true);
                        }
                    }
                }
            });
        }
コード例 #2
0
        private void btnOpenDesktop_Click(object sender, RoutedEventArgs e)
        {
            DoAction(() =>
            {
                var param = new VideoInParam();

                param.Type       = VideoInType.FullScreen;
                param.CaptureFps = 6;

                if (_desktopOpened = _desktop.Open(param))
                {
                    MessageBox.Show("Opened!", "Open Success");

                    _desktop.SetBackLayer();
                }
            });
        }
コード例 #3
0
        /// <summary>
        /// 打开子视频实例,用于推流直播
        /// </summary>
        /// <param name="param">子视频采集参数</param>
        /// <returns></returns>
        public bool Open(VideoInParam param)
        {
            ApiProvider.Default.ThrowIfServiceException();

            if (param == null)
            {
                throw new ArgumentNullException("param");
            }

            var p = (_VideoInParam)param;

            try
            {
                ChildService = ChildVideoApi.Open(ApiProvider.Default.Service, ref p);

                return(ChildService != IntPtr.Zero);
            }
            finally
            {
                p.Dispose();
            }
        }