Ejemplo n.º 1
0
        public void Dispose()
        {
            EventsHelper.CanRaiseEvent = false;

            CompositionTarget.Rendering -= CompositionTargetRendering;

            Dispatcher.BeginInvoke(
                new Action(
                    delegate
            {
                FreeEvents();
                if (IsPlaying)
                {
                    Stop();
                }
                AudioProperties.Dispose();
                VideoProperties.Dispose();
                LogProperties.Dispose();
                AudioOutputDevices.Dispose();
                VlcContext.InteropManager.MediaPlayerInterops.ReleaseInstance.Invoke(VlcContext.HandleManager.MediaPlayerHandles[this]);
                VlcContext.HandleManager.MediaPlayerHandles.Remove(this);

                myVideoLockCallbackHandle.Free();
                myVideoSetFormatHandle.Free();
                myVideoCleanupHandle.Free();
            }));
        }
Ejemplo n.º 2
0
 internal AudioOutputDescription(string name, string description, VlcManager manager, VlcMediaPlayerInstance mediaPlayerInstance)
 {
     Name = name;
     Description = description;
     myManager = manager;
     myMediaPlayerInstance = mediaPlayerInstance;
     Devices = new AudioOutputDevices(this, manager, myMediaPlayerInstance);
 }
        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");
        }
Ejemplo n.º 4
0
 protected void Dispose(bool disposing)
 {
     if (disposing)
     {
         AudioProperties.Dispose();
         VideoProperties.Dispose();
         LogProperties.Dispose();
         AudioOutputDevices.Dispose();
         FreeEvents();
         VlcContext.InteropManager.MediaPlayerInterops.ReleaseInstance.Invoke(VlcContext.HandleManager.MediaPlayerHandles[this]);
         VlcContext.HandleManager.MediaPlayerHandles.Remove(this);
     }
 }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
 public HotkeyAudioDevice GetDevice(string deviceName, AudioDeviceType deviceType = AudioDeviceType.Output)
 {
     if (deviceType == AudioDeviceType.Output)
     {
         return(AudioOutputDevices.FirstOrDefault(audioDevice => audioDevice.AudioDeviceName.Equals(deviceName)));
     }
     else if (deviceType == AudioDeviceType.Input)
     {
         return(AudioInputDevices.FirstOrDefault(audioDevice => audioDevice.AudioDeviceName.Equals(deviceName)));
     }
     else if (deviceType == AudioDeviceType.Both)
     {
         throw new Exception("Cannot use device type of both to get one device");
     }
     return(null);
 }
Ejemplo n.º 8
0
        public SetupViewModel()
        {
            using (var devices = new MMDeviceEnumerator())
            {
                AudioOutputDevices = devices.EnumerateAudioEndPoints(DataFlow.Render, DeviceState.Active)
                                     .Select(x => x.FriendlyName).ToArray();

                SelectedAudioOutput = AudioOutputDevices.First();
            }

            Start = ReactiveCommand.Create(() =>
            {
                ObsSettings obsSettings = null;
                if (!String.IsNullOrWhiteSpace(ObsAddress) && !string.IsNullOrWhiteSpace(ObsPassword))
                {
                    obsSettings = new ObsSettings(ObsAddress, ObsPassword);
                }

                return(new Settings(Team1Starts? 0 : 1, WordSize, TimeOut, Rounds, _excludedBallNumbersEven, _excludedBallNumbersOdd, GetAudioDevice(SelectedAudioOutput), obsSettings));
            });
        }
        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");
        }
Ejemplo n.º 10
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(); };
        }