예제 #1
0
파일: ToxCall.cs 프로젝트: TimBo93/Toxy
        public void ToggleVideo(bool enableVideo, string videoDevice)
        {
            if (enableVideo && videoSource != null)
            {
                return;
            }

            if (!enableVideo && videoSource == null)
            {
                return;
            }

            if (!enableVideo)
            {
                videoSource.SignalToStop();
                videoSource.NewFrame -= video_source_NewFrame;
                videoSource           = null;

                var settings = ToxAv.DefaultCodecSettings;
                settings.CallType = ToxAvCallType.Audio;

                toxav.ChangeSettings(CallIndex, settings);
            }
            else
            {
                var videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                foreach (FilterInfo device in videoDevices)
                {
                    if (device.Name == videoDevice)
                    {
                        videoSource           = new VideoCaptureDevice(device.MonikerString);
                        videoSource.NewFrame += video_source_NewFrame;
                        videoSource.Start();

                        var settings = ToxAv.DefaultCodecSettings;
                        settings.CallType = ToxAvCallType.Video;

                        toxav.ChangeSettings(CallIndex, settings);
                        break;
                    }
                }
            }
        }