Beispiel #1
0
 /// <summary>
 /// Save the device's current settings to the registry
 /// </summary>
 protected void SaveDeviceSettings()
 {
     if (cg.Source.HasPhysConns)
     {
         AVReg.WriteValue(DeviceKey(), AVReg.PhysicalConnectorIndex, cg.Source.PhysicalConnectorIndex);
     }
 }
Beispiel #2
0
        private void cboMicrophones_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            try
            {
                if (acg != null)
                {
                    AVReg.DeleteValue(AVReg.SelectedMicrophone, acg.Source.Moniker);
                    DeactivateAudioCapability();
                }

                if (cboMicrophones.SelectedIndex != 0)
                {
                    FilterInfo fi = (FilterInfo)cboMicrophones.SelectedItem;
                    ActivateAudioCapability(fi);

                    AVReg.WriteValue(AVReg.SelectedMicrophone, fi.Moniker, fi.Name);
                }

                btnAdvancedAudioSettings.Enabled = cboMicrophones.SelectedIndex > 0;
                ckPlayAudio.Enabled  = cboMicrophones.SelectedIndex > 0;
                lblTestAudio.Enabled = cboMicrophones.SelectedIndex > 0;
            }
            catch (COMException ex)
            {
                Log(DShowError._AMGetErrorText(ex.ErrorCode));
                Log(ex.ToString());
            }
            catch (Exception ex)
            {
                Log(ex.ToString());
            }
        }
Beispiel #3
0
        private void clbCameras_ItemCheck(object sender, System.Windows.Forms.ItemCheckEventArgs e)
        {
            try
            {
                if (e.NewValue == CheckState.Checked)
                {
                    ActivateVideoCapability((FilterInfo)clbCameras.Items[e.Index]);

                    // Only save the camera after we were able to successfully activate it
                    AVReg.WriteValue(AVReg.SelectedCameras, vcg.Source.Moniker,
                                     vcg.Source.FriendlyName);
                }
                else if (e.NewValue == CheckState.Unchecked)
                {
                    // Remove the camera from the registry, even if we can't shut it down
                    AVReg.DeleteValue(AVReg.SelectedCameras, vcg.Source.Moniker);

                    DeactivateVideoCapability((FilterInfo)clbCameras.SelectedItem);
                }
            }
            catch (COMException ex)
            {
                Log(DShowError._AMGetErrorText(ex.ErrorCode));
                Log(ex.ToString());
            }
            catch (Exception ex)
            {
                Log(ex.ToString());
            }
        }
Beispiel #4
0
        public void SaveVideoCompressorSettings()
        {
            VideoCompressorQualityInfo vcqi = vcg.VideoCompressor.QualityInfo;

            // Cast to int, otherwise it gets stored as a string
            AVReg.WriteValue(DeviceKey(), AVReg.CompressorBitRate, (int)vcqi.BitRate);
            AVReg.WriteValue(DeviceKey(), AVReg.CompressorKeyFrameRate, vcqi.KeyFrameRate);
        }
Beispiel #5
0
        /// <summary>
        /// Save the camera's current settings to the registry
        /// </summary>
        public void SaveCameraSettings()
        {
            if (vcg.VideoSource.HasVideoStandards)
            {
                AVReg.WriteValue(DeviceKey(), AVReg.VideoStandardIndex, vcg.VideoSource.VideoStandardIndex);
            }

            SaveDeviceSettings();
        }
        /// <summary>
        /// Save the microphone's current settings to the registry.  This only applies to
        /// audio sources, not DV sources
        /// </summary>
        public void SaveMicrophoneSettings()
        {
            AudioCaptureGraph acg = cg as AudioCaptureGraph;

            if (acg != null)
            {
                AVReg.WriteValue(DeviceKey(), AVReg.MicrophoneSourceIndex,
                                 acg.Source.InputPinIndex);

                SaveDeviceSettings();
            }
        }
Beispiel #7
0
        public void SaveLinkedCamera(FilterInfo fi)
        {
            // Delete previous link value
            string[] linkedCamera = AVReg.ValueNames(AVReg.LinkedCamera);
            if (linkedCamera != null && linkedCamera.Length > 0)
            {
                Debug.Assert(linkedCamera.Length == 1);
                AVReg.DeleteValue(AVReg.LinkedCamera, linkedCamera[0]);
            }

            // Set the new value
            AVReg.WriteValue(AVReg.LinkedCamera, fi.Moniker, fi.Name);
        }
Beispiel #8
0
        /// <summary>
        /// Save the camera's current settings to the registry
        /// </summary>
        public void SaveCameraSettings()
        {
            if (cg is VideoCaptureGraph)
            {
                VideoCaptureGraph vcg = (VideoCaptureGraph)cg;
                if (vcg.VideoSource.HasVideoStandards)
                {
                    AVReg.WriteValue(DeviceKey(), AVReg.VideoStandardIndex, vcg.VideoSource.VideoStandardIndex);
                }
            }
            else if (cg is DVCaptureGraph)
            {
                DVCaptureGraph dvcg = (DVCaptureGraph)cg;
                if (dvcg.VideoSource.HasVideoStandards)    //Always false for DV devices?
                {
                    AVReg.WriteValue(DeviceKey(), AVReg.VideoStandardIndex, dvcg.VideoSource.VideoStandardIndex);
                }
            }

            SaveDeviceSettings();
        }
Beispiel #9
0
        /// <summary>
        /// Save the stream's current settings to the registry.
        /// </summary>
        protected void SaveStreamSettings()
        {
            _AMMediaType mt = cg.Source.GetMediaType();

            // Copy the pbFormat block into a byte array
            if (mt.pbFormat != IntPtr.Zero && mt.cbFormat > 0)
            {
                byte[] pbFormat = new byte[mt.cbFormat];
                Marshal.Copy(mt.pbFormat, pbFormat, 0, (int)mt.cbFormat);

                Marshal.FreeCoTaskMem(mt.pbFormat);
                mt.pbFormat = IntPtr.Zero;
                // Don't adjust cbFormat, will use on restore

                AVReg.WriteValue(DeviceKey(), AVReg.FormatBlock, pbFormat);
            }

            AVReg.ms.Position = 0;
            AVReg.bf.Serialize(AVReg.ms, mt);
            AVReg.WriteValue(DeviceKey(), AVReg.MediaType, AVReg.ms.ToArray());
        }
Beispiel #10
0
        private void cboSpeakers_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            // Delete previous value
            string[] selectedSpeaker = AVReg.ValueNames(AVReg.SelectedSpeaker);
            if (selectedSpeaker != null)
            {
                Debug.Assert(selectedSpeaker.Length == 1);
                AVReg.DeleteValue(AVReg.SelectedSpeaker, selectedSpeaker[0]);
            }

            // Store current value
            FilterInfo fi = (FilterInfo)cboSpeakers.SelectedItem;

            AVReg.WriteValue(AVReg.SelectedSpeaker, fi.Moniker, fi.Name);

            if (acg != null)
            {
                RenderAndRunAudio(acg, false);
                RenderAndRunAudio(acg);
            }
        }
        /// <summary>
        /// Save compressor settings from the form back into the static properties and persist to the registry.
        /// </summary>
        protected override void SaveSettings()
        {
            // Compressor format
            OpusAudioCompressor.Frequency = (int)((CompressorFmt)this.cbCompressionFormat.SelectedItem).WFEX.SamplesPerSec;
            OpusAudioCompressor.Channels  = (int)((CompressorFmt)this.cbCompressionFormat.SelectedItem).WFEX.Channels;

            Type compressorType = typeof(OpusAudioCompressor);

            FieldInfo[] fields = compressorType.GetFields(BindingFlags.Public | BindingFlags.Static);
            foreach (FieldInfo field in fields)
            {
                if (field.IsLiteral || field.IsInitOnly)
                {
                    continue;
                }

                Type  enumType;
                int[] valuesArray;
                bool  validated    = false;
                int   checkedValue = 0;

                // Look for the enum type first
                if ((enumType = findEnumType(field.Name)) != null)
                {
                    object   saveValue;
                    ComboBox cb = findComboBox(field.Name);
                    if (cb == null)
                    {
                        continue;
                    }
                    if (enumTryParse(enumType, cb.SelectedValue.ToString(), out saveValue))
                    {
                        checkedValue = (int)saveValue;
                        validated    = true;
                    }
                }
                else if ((valuesArray = findValuesArray(field.Name)) != null)
                {
                    // Use a int[] of legal values
                    int      uncheckedValue = (int)field.GetValue(null);
                    ComboBox cb             = findComboBox(field.Name);
                    if ((cb == null) ||
                        ((cb != null) && (int.TryParse(cb.SelectedValue.ToString(), out uncheckedValue))))
                    {
                        foreach (int j in valuesArray)
                        {
                            if (uncheckedValue == j)
                            {
                                checkedValue = uncheckedValue;
                                validated    = true;
                                break;
                            }
                        }
                    }
                }
                else if ((valuesArray = findMinMaxArray(field.Name)) != null)
                {
                    // Use a int[] with min/max values.
                    TextBox tb = findTextBox(field.Name);
                    if (tb == null)
                    {
                        continue;
                    }
                    if (int.TryParse(tb.Text, out checkedValue))
                    {
                        if (checkedValue >= valuesArray[0] && checkedValue <= valuesArray[1])
                        {
                            validated = true;
                        }
                    }
                }

                if (!validated)
                {
                    checkedValue = (int)findDefaultValue(field.Name);
                }
                field.SetValue(null, checkedValue);
                AVReg.WriteValue(AVReg.OpusCompressorKey, field.Name, checkedValue);
            }
        }