Exemplo n.º 1
0
        private ObsData CreateWebcamSettings()
        {
            ObsData webcamSettings = new ObsData();

            webcamSettings.SetString(VideoCapture.VIDEO_DEVICE_ID, selectedWebcam.value);

            int buffering = 2;

            webcamSettings.SetInt(VideoCapture.BUFFERING, buffering); // 0 = Auto, 1 = Enable, 2 = Disable

            // need to check webcam whitelist
            if (Store.Data.Webcam.WebcamSettings.ShouldUseCustomSettings)
            {
                webcamSettings.SetString(VideoCapture.RESOLUTION, Store.Data.Webcam.WebcamSettings.Resolution);
                webcamSettings.SetInt(VideoCapture.RESOLUTION_TYPE, 1);
                webcamSettings.SetInt(VideoCapture.VIDEO_FORMAT, (int)Store.Data.Webcam.WebcamSettings.VideoFormat);
                webcamSettings.SetInt(VideoCapture.FRAME_INTERVAL, Store.Data.Webcam.WebcamSettings.Fps);
            }
            else
            {
                if (selectedWebcamResolution != null)
                {
                    webcamSettings.SetString(VideoCapture.RESOLUTION, selectedWebcamResolution.value);
                    webcamSettings.SetInt(VideoCapture.RESOLUTION_TYPE, 1);
                }
                else
                {
                    var preferredResolution = WebcamService.GetOptimalWebcamResolution(selectedWebcam.dsDeviceValue);

                    if (!string.IsNullOrEmpty(preferredResolution))
                    {
                        webcamSettings.SetString(VideoCapture.RESOLUTION, preferredResolution);
                        webcamSettings.SetInt(VideoCapture.RESOLUTION_TYPE, 1);
                    }
                    else
                    {
                        webcamSettings.Erase(VideoCapture.RESOLUTION);
                        webcamSettings.SetInt(VideoCapture.RESOLUTION_TYPE, 0);
                    }
                }
            }

            webcamSettings.SetBool(VideoCapture.ACTIVATE, true);

            return(webcamSettings);
        }