public async Task AvailableDevices(object[] devices)
        {
            // Called by JavaScript when we get the list of devices
            await Task.Delay(1);

            AudioInputDevices.Clear();

            foreach (var device in devices)
            {
                string deviceString = device.ToString();
                var    dev          = JsonSerializer.Deserialize <BrowserMediaDevice>(deviceString);
                if (dev.kind == "audioinput")
                {
                    if (dev.label.Trim() != "" && dev.deviceId.Trim() != "")
                    {
                        AudioInputDevices.Add(dev);
                    }
                }
                else if (dev.kind == "audiooutput")
                {
                    if (dev.label.Trim() != "" && dev.deviceId.Trim() != "")
                    {
                        AudioOutputDevices.Add(dev);
                    }
                }
                else if (dev.kind == "videoinput")
                {
                    if (dev.label.Trim() != "" && dev.deviceId.Trim() != "")
                    {
                        VideoInputDevices.Add(dev);
                    }
                }
                else
                {
                    var kind = dev.kind;
                }
            }

            if (AudioInputDevices.Count > 0)
            {
                AudioInputDevices = AudioInputDevices.OrderBy(o => o.label).ToList();
            }
            if (AudioOutputDevices.Count > 0)
            {
                AudioOutputDevices = AudioOutputDevices.OrderBy(o => o.label).ToList();
            }
            if (VideoInputDevices.Count > 0)
            {
                VideoInputDevices = VideoInputDevices.OrderBy(o => o.label).ToList();
            }

            await RecordingStatus("Devices");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes this Client instance.
        /// If the client is already initialized, it will do nothing.
        /// <param name="config">Optional: config to set on initialize</param>
        /// </summary>
        public void Initialize(VivoxConfig config = null)
        {
            if (Initialized)
            {
                return;
            }

            VxClient.Instance.Start(config);

            // Refresh audio devices to ensure they are up to date when the client is initialized.
            AudioInputDevices.BeginRefresh(null);
            AudioOutputDevices.BeginRefresh(null);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes this Client instance.
        /// If the client is already initialized, it will do nothing.
        /// <param name="config">Optional: config to set on initialize</param>
        /// </summary>
        public void Initialize(VivoxConfig config = null)
        {
            if (_initialized)
            {
                return;
            }

            VxClient.Instance.Start(config != null? config.ToVx_Sdk_Config() : new VivoxConfig().ToVx_Sdk_Config());
            _initialized = true;

            // Refresh audio devices to ensure they are up to date when the client is initialized.
            AudioInputDevices.BeginRefresh(null);
            AudioOutputDevices.BeginRefresh(null);
        }
        private void MainWindow_Activated(object sender, EventArgs e)
        {
            if (_initialized)
            {
                return;
            }

            Closing += Window_Closing;

            _initialized = true;

            CreateEngine();

            Title += $" (SDK v{VideoCapture1.SDK_Version()})";
            VideoCapture1.Debug_Dir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "VisioForge");

            tmRecording.Elapsed += (senderx, args) => { UpdateRecordingTime(); };

            cbOutputFormat.SelectedIndex = 2;

            foreach (var device in VideoCapture1.Video_CaptureDevices())
            {
                VideoInputDevices.Add(device.Name);
            }

            if (VideoInputDevices.Count > 0)
            {
                cbVideoInputDevice.SelectedIndex = 0;
            }

            cbVideoInputDevice_SelectionChanged(null, null);

            foreach (var device in VideoCapture1.Audio_CaptureDevices())
            {
                AudioInputDevices.Add(device.Name);
            }

            if (AudioInputDevices.Count > 0)
            {
                cbAudioInputDevice.SelectedIndex = 0;
                cbAudioInputDevice_SelectionChanged(null, null);
            }

            AudioInputLines.Clear();

            if (!string.IsNullOrEmpty(cbAudioInputDevice.SelectedItem.ToString()))
            {
                var deviceItem =
                    VideoCapture1.Audio_CaptureDevices().FirstOrDefault(device => device.Name == cbAudioInputDevice.SelectedItem.ToString());
                if (deviceItem != null)
                {
                    foreach (var line in deviceItem.Lines)
                    {
                        AudioInputLines.Add(line);
                    }

                    if (AudioInputLines.Count > 0)
                    {
                        cbAudioInputLine.SelectedIndex = 0;
                    }
                }
            }

            string defaultAudioRenderer = string.Empty;

            foreach (string audioOutputDevice in VideoCapture1.Audio_OutputDevices())
            {
                AudioOutputDevices.Add(audioOutputDevice);

                if (audioOutputDevice.Contains("Default DirectSound Device"))
                {
                    defaultAudioRenderer = audioOutputDevice;
                }
            }

            if (AudioOutputDevices.Count > 0)
            {
                if (string.IsNullOrEmpty(defaultAudioRenderer))
                {
                    cbAudioOutputDevice.SelectedIndex = 0;
                }
                else
                {
                    cbAudioOutputDevice.SelectedItem = defaultAudioRenderer;
                }
            }

            edOutput.Text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "VisioForge", "output.mp4");
        }
Exemplo n.º 5
0
        public MainWindowViewModel(IVideoCaptureAccessor videoCaptureAccessor)
        {
            this.videoCaptureAccessor          = videoCaptureAccessor;
            this.videoCaptureAccessor.OnError += VideoCaptureAccessorOnError;

            Title = "Simple Video Capture Demo - Video Capture SDK .Net" +
                    " (SDK v" + videoCaptureAccessor.SDK_Version + ")";

            SelectedVideoInputDevice  = VideoInputDevices.FirstOrDefault();
            SelectedAudioInputDevice  = AudioInputDevices.FirstOrDefault();
            SelectedAudioOutputDevice =
                AudioOutputDevices.FirstOrDefault(_ => _.Contains("Default DirectSound Device")) ??
                AudioOutputDevices.FirstOrDefault();

            RecordAudio = true;

            MinVolumeValue     = 20;
            MaxVolumeValue     = 100;
            CurrentVolumeValue = 80;

            MinBalanceValue     = -100;
            MaxBalanceValue     = 100;
            CurrentBalanceValue = 0;

            ConfigureAudioInputDeviceCommand = new DelegateCommand(ConfigureAudioInputDevice);
            ConfigureVideoInputDeviceCommand = new DelegateCommand(ConfigureVideoInputDevice);

            OutputFileName       = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "VisioForge", "output.mp4");
            SelectedOutputFormat =
                OutputFormats.FirstOrDefault(_ => _.Description == "MP4") ??
                OutputFormats.FirstOrDefault();
            BrowseForOutputFileCommand   = new DelegateCommand(BrowseForOutputFile);
            ConfigureOutputFormatCommand = new DelegateCommand(ConfigureOutputFormat);

            MinLightnessValue     = 0;
            MaxLightnessValue     = 255;
            CurrentLightnessValue = 0;

            MinSaturationValue     = 0;
            MaxSaturationValue     = 255;
            CurrentSaturationValue = 255;

            MinContrastValue     = 0;
            MaxContrastValue     = 255;
            CurrentContrastValue = 0;

            MinDarknessValue     = 0;
            MaxDarknessValue     = 255;
            CurrentContrastValue = 0;

            AddImageLogoCommand = new DelegateCommand(AddImageLogo);
            AddTextLogoCommand  = new DelegateCommand(AddTextLogo);
            EditLogoCommand     = new DelegateCommand(EditLogo, CanEditLogo);
            RemoveLogoCommand   = new DelegateCommand(RemoveLogo, CanRemoveLogo);

            PreviewMode               = true;
            RecordingTimeText         = "Recording time: 00:00:00";
            StartCommand              = new DelegateCommand(Start);
            StopCommand               = new DelegateCommand(Stop);
            PauseCommand              = new DelegateCommand(Pause);
            ResumeCommand             = new DelegateCommand(Resume);
            SaveSnapshotCommand       = new DelegateCommand(SaveSnapshot);
            ViewVideoTutorialsCommand = new DelegateCommand(ViewVideoTutorials);

            tmRecording.Interval = TimeSpan.FromSeconds(1);
            tmRecording.Tick    += (senderx, args) => { UpdateRecordingTime(); };
        }