protected override void frmAudioSettings_Load(object sender, EventArgs e) { base.frmAudioSettings_Load(sender, e); this.btnAudio.Font = UIFont.StringFont; this.cbBufferSize.Font = UIFont.StringFont; this.cbBufferCount.Font = UIFont.StringFont; this.lblBufferSize.Font = UIFont.StringFont; this.lblBufferCount.Font = UIFont.StringFont; this.btnAudio.Text = Strings.AudioFormat; this.lblBufferSize.Text = Strings.AudioBufferSize; this.lblBufferCount.Text = Strings.AudioBufferCount; this.Controls.Remove(this.btnAudio); this.gbMicAndAudio.Controls.Add(this.btnAudio); // Reduce the height of the form this.ClientSize = new System.Drawing.Size(this.ClientSize.Width, this.ClientSize.Height - 30); try { this.Text += " - Uncompressed"; RestoreBufferSettings(); } catch (COMException ex) { Log(DShowError._AMGetErrorText(ex.ErrorCode)); Log(ex.ToString()); } catch (Exception ex) { Log(ex.ToString()); } }
/// <summary> /// Show Video source filter format dialog /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnVideo_Click(object sender, System.EventArgs e) { try { if (vc.CaptureGraph.Source.HasFormatDialog) { frmAV.RenderAndRunVideo(vc.CaptureGraph, false); vc.CaptureGraph.RemoveFiltersDownstreamFromSource(MSR.LST.Net.Rtp.PayloadType.dynamicVideo); vc.CaptureGraph.Source.ShowFormatDialog(this.Handle); vc.AddVideoCompressor(); frmAV.RenderAndRunVideo(vc.CaptureGraph); vc.SaveVideoSettings(); UpdateCurrentSettings(); } } catch (COMException ex) { Log(DShowError._AMGetErrorText(ex.ErrorCode)); Log(ex.ToString()); } catch (Exception ex) { Log(ex.ToString()); } }
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()); } }
private void btnCamera_Click(object sender, System.EventArgs e) { try { if (vcg.VideoSource.HasSourceDialog) { // Vfw is not as flexible as WDM, need to stop the graph first if (vcg.VideoSource.IsVfw) { frmAV.RenderAndRunVideo(vcg, false); vcg.RemoveFiltersDownstreamFrom(vcg.Source); } vcg.VideoSource.ShowSourceDialog(this.Handle); if (vcg.VideoSource.IsVfw) { vc.AddVideoCompressor(); frmAV.RenderAndRunVideo(vcg); } vc.SaveCameraSettings(); UpdateCurrentSettings(); } } catch (COMException ex) { Log(DShowError._AMGetErrorText(ex.ErrorCode)); Log(ex.ToString()); } catch (Exception ex) { Log(ex.ToString()); } }
private void btnVideo_Click(object sender, System.EventArgs e) { try { if (vcg.VideoSource.HasFormatDialog) { frmAV.RenderAndRunVideo(vcg, false); vcg.RemoveFiltersDownstreamFrom(vcg.Source); vcg.VideoSource.ShowFormatDialog(this.Handle); vc.AddVideoCompressor(); frmAV.RenderAndRunVideo(vcg); vc.SaveVideoSettings(); UpdateCurrentSettings(); } } catch (COMException ex) { Log(DShowError._AMGetErrorText(ex.ErrorCode)); Log(ex.ToString()); } catch (Exception ex) { Log(ex.ToString()); } }
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()); } }
private void btnApplyCompression_Click(object sender, System.EventArgs e) { try { frmAV.RenderAndRunVideo(vcg, false); // Create the custom settings and set them VideoCompressorQualityInfo vcqi = VideoCompressor.DefaultQualityInfo; vcqi.BitRate = (uint)BitRateValue; vcqi.KeyFrameRate = KeyFrameRateValue; vcg.VideoCompressor.QualityInfo = vcqi; frmAV.RenderAndRunVideo(vcg); // Save them vc.SaveVideoCompressorSettings(); vc.RegCustomCompression = true; UpdateCurrentSettings(); } catch (COMException ex) { Log(DShowError._AMGetErrorText(ex.ErrorCode)); Log(ex.ToString()); } catch (Exception ex) { Log(ex.ToString()); } }
/// <summary> /// Show the uncompressed audio format form /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAudio_Click(object sender, System.EventArgs e) { try { // Show the form frmAudioFormat af = new frmAudioFormat(ac.CaptureGraph); if (af.ShowDialog(this) == DialogResult.OK) { if (ckTestAudio.Checked) { ckTestAudio.Checked = false; } // Get the media type they selected and set it _AMMediaType mt; object fb; af.GetMediaType(out mt, out fb); #region Log Log("Setting media type to..."); Log(MediaType.Dump(mt) + MediaType.FormatType.Dump(fb)); #endregion Log frmAV.RenderAndRunAudio(ac.CaptureGraph, false); ac.CaptureGraph.RemoveFiltersDownstreamFromSource(MSR.LST.Net.Rtp.PayloadType.dynamicAudio); try { ac.CaptureGraph.Source.SetMediaType(mt, fb); } catch (COMException ex) { Log(DShowError._AMGetErrorText(ex.ErrorCode)); Log(ex.ToString()); } catch (Exception ex) { Log(ex.ToString()); } ac.SaveAudioSettings(); ac.AddAudioCompressor(); frmAV.RenderAndRunAudio(ac.CaptureGraph); UpdateCurrentSettings(); } } catch (COMException ex) { Log(DShowError._AMGetErrorText(ex.ErrorCode)); Log(ex.ToString()); } catch (Exception ex) { Log(ex.ToString()); } }
private void frmAudioSettings_Load(object sender, System.EventArgs e) { this.btnOK.Font = UIFont.StringFont; this.gbCurrentSettings.Font = UIFont.StringFont; this.btnAudio.Font = UIFont.StringFont; this.ckUncompressedAudio.Font = UIFont.StringFont; this.label1.Font = UIFont.StringFont; this.cboLinkedCamera.Font = UIFont.StringFont; this.gbMicAndAudio.Font = UIFont.StringFont; this.ckDisableFec.Font = UIFont.StringFont; this.cbBufferSize.Font = UIFont.StringFont; this.cbBufferCount.Font = UIFont.StringFont; this.lblBufferSize.Font = UIFont.StringFont; this.lblBufferCount.Font = UIFont.StringFont; this.ckTestAudio.Font = UIFont.StringFont; this.btnOK.Text = Strings.Close; this.gbCurrentSettings.Text = Strings.CurrentSettings; this.lblCurrentSettings.Text = Strings.CurrentSettings; this.lblInputSource.Text = Strings.MicrophoneInputSource; this.btnAudio.Text = Strings.AudioFormat; this.ckUncompressedAudio.Text = Strings.UseUncompressedAudio; this.label1.Text = Strings.SelectCamera; this.gbMicAndAudio.Text = Strings.ConfigureMicrophone; this.label2.Text = Strings.SelectAudioCompressionFormat; this.cbCompressionFormat.Text = Strings.SelectAudioCompressionFormat; this.ckDisableFec.Text = Strings.DisableAudioForwardErrorCorrection; this.lblBufferSize.Text = Strings.AudioBufferSize; this.lblBufferCount.Text = Strings.AudioBufferCount; this.ckTestAudio.Text = Strings.TestAudio; try { lblCurrentSettings.Text = null; this.Text = string.Format(CultureInfo.CurrentCulture, Strings.AdvancedAudioSettings, ac.CaptureGraph.Source.FriendlyName); RestoreLinkedCamera(); RestoreInputPin(); RestoreCompressionFormat(); RestoreCompression(); RestoreBufferSettings(); RestoreFec(); UpdateCurrentSettings(); } catch (COMException ex) { Log(DShowError._AMGetErrorText(ex.ErrorCode)); Log(ex.ToString()); } catch (Exception ex) { Log(ex.ToString()); } }
private void InitializeUI() { try { this.Text = string.Format(CultureInfo.CurrentCulture, Strings.AdvancedVideoSettings, vc.CaptureGraph.Source.FriendlyName); IBaseFilter[] upstreamFilters = vc.CaptureGraph.Source.UpstreamFilters; if (upstreamFilters != null && upstreamFilters.Length > 0) { ArrayList propPages = new ArrayList(); foreach (IBaseFilter iBF in upstreamFilters) { if (Filter.HasDialog(iBF)) { propPages.Add(new PropertyPage((ISpecifyPropertyPages)iBF, Filter.Name(iBF))); } } // Populate the property page configuration combo box cboUpstreamPropPages.DataSource = propPages; cboUpstreamPropPages.DisplayMember = Strings.Name; cboUpstreamPropPages.SelectedIndex = 0; cboUpstreamPropPages.Enabled = true; } // Enable the appropriate buttons btnCamera.Enabled = vc.CaptureGraph.Source.HasSourceDialog; btnVideo.Enabled = vc.CaptureGraph.Source.HasFormatDialog; // Update compressor settings ckEnableCompression.Enabled = false; ckEnableCompression.Checked = vc.RegVideoCompressorEnabled; ckEnableCompression.Enabled = true; ckDisableVideoFec.Checked = !FMain.EnableVideoFec; // Get these setup correctly whether there is a compressor or not UpdateKeyFrameRateLabel(); UpdateBitRateLabel(); UpdateCurrentSettings(); } catch (COMException ex) { Log(DShowError._AMGetErrorText(ex.ErrorCode)); Log(ex.ToString()); } catch (Exception ex) { Log(ex.ToString()); } }
private void ckPlayAudio_CheckedChanged(object sender, System.EventArgs e) { try { ckPlayAudio.Text = ckPlayAudio.Checked ? "Stop Audio" : "Test Audio"; RenderAndRunAudio(acg, ckPlayAudio.Checked); } catch (COMException ex) { Log(DShowError._AMGetErrorText(ex.ErrorCode)); Log(ex.ToString()); } catch (Exception ex) { Log(ex.ToString()); } }
protected override void frmAudioSettings_Load(object sender, System.EventArgs e) { base.frmAudioSettings_Load(sender, e); this.cbBufferSize.Font = UIFont.StringFont; this.cbBufferCount.Font = UIFont.StringFont; this.lblBufferSize.Font = UIFont.StringFont; this.lblBufferCount.Font = UIFont.StringFont; this.lblACompressionFmt.Font = UIFont.StringFont; this.cbCompressionFormat.Font = UIFont.StringFont; this.lblACompressionFmt.Text = Strings.SelectAudioCompressionFormat; this.cbCompressionFormat.Text = Strings.SelectAudioCompressionFormat; this.lblBufferSize.Text = Strings.AudioBufferSize; this.lblBufferCount.Text = Strings.AudioBufferCount; // Put some controls into a groupbox of the base class. // Do it here so that the forms designer still works. this.Controls.Remove(this.lblACompressionFmt); this.Controls.Remove(this.cbCompressionFormat); this.gbMicAndAudio.Controls.Add(this.cbCompressionFormat); this.gbMicAndAudio.Controls.Add(this.lblACompressionFmt); // Increase the height of the form to fit more controls. this.ClientSize = new System.Drawing.Size(this.ClientSize.Width, this.ClientSize.Height - 30); try { this.Text += " - WM Audio V2"; RestoreCompressionFormat(); RestoreBufferSettings(); UpdateCurrentSettings(); } catch (COMException ex) { Log(DShowError._AMGetErrorText(ex.ErrorCode)); Log(ex.ToString()); } catch (Exception ex) { Log(ex.ToString()); } }
/// <summary> /// Restore the video stream's last settings from the registry /// </summary> private void RestoreVideoSettings() { // Read media type from registry byte[] bytes = (byte[])AVReg.ReadValue(DeviceKey(), AVReg.MediaType); if (bytes != null) { AVReg.ms.Position = 0; AVReg.ms.Write(bytes, 0, bytes.Length); AVReg.ms.Position = 0; _AMMediaType mt = (_AMMediaType)AVReg.bf.Deserialize(AVReg.ms); // Read format block from registry if (mt.cbFormat != 0) { bytes = (byte[])AVReg.ReadValue(DeviceKey(), AVReg.FormatBlock); Debug.Assert(bytes.Length == mt.cbFormat); mt.pbFormat = Marshal.AllocCoTaskMem((int)mt.cbFormat); Marshal.Copy(bytes, 0, mt.pbFormat, (int)mt.cbFormat); Log("Restoring stream settings..."); Log(MediaType.Dump(mt)); try { // Set and free cg.Source.SetMediaType(ref mt); } catch (COMException ex) { Log(DShowError._AMGetErrorText(ex.ErrorCode)); Log(ex.ToString()); } catch (Exception ex) { Log(ex.ToString()); } } } }
private void ckPlayVideo_CheckedChanged(object sender, System.EventArgs e) { foreach (VideoCapability vc in vcs.Values) { try { ckPlayVideo.Text = ckPlayVideo.Checked ? "Stop Video" : "Test Video"; RenderAndRunVideo(vc.VideoCaptureGraph); } catch (COMException ex) { Log(DShowError._AMGetErrorText(ex.ErrorCode)); Log(ex.ToString()); } catch (Exception ex) { Log(ex.ToString()); } } }
private void ckTestAudio_CheckedChanged(object sender, EventArgs e) { SaveSettings(); try { ckTestAudio.Text = ckTestAudio.Checked ? Strings.StopAudio : Strings.TestAudio; if (ckTestAudio.Checked) { RefreshAudioCapability(); } frmAV.RenderAndRunAudio(ac.CaptureGraph, ckTestAudio.Checked); } catch (COMException ex) { frmAV.Log(DShowError._AMGetErrorText(ex.ErrorCode)); frmAV.Log(ex.ToString()); } catch (Exception ex) { frmAV.Log(ex.ToString()); } }
protected virtual void frmAudioSettings_Load(object sender, System.EventArgs e) { this.btnOK.Font = UIFont.StringFont; this.gbCurrentSettings.Font = UIFont.StringFont; this.label1.Font = UIFont.StringFont; this.cboLinkedCamera.Font = UIFont.StringFont; this.gbMicAndAudio.Font = UIFont.StringFont; this.ckDisableFec.Font = UIFont.StringFont; this.ckTestAudio.Font = UIFont.StringFont; this.btnOK.Text = Strings.Close; this.gbCurrentSettings.Text = Strings.CurrentSettings; this.lblInputSource.Text = Strings.MicrophoneInputSource; this.label1.Text = Strings.SelectCamera; this.gbMicAndAudio.Text = Strings.ConfigureMicrophone; this.ckDisableFec.Text = Strings.DisableAudioForwardErrorCorrection; this.ckTestAudio.Text = Strings.TestAudio; this.lblCurrentSettings.Text = null; try { this.Text = string.Format(CultureInfo.CurrentCulture, Strings.AdvancedAudioSettings, this.sourceFilter.Name); RestoreLinkedCamera(); RestoreInputPin(); RestoreFec(); UpdateCurrentSettings(); } catch (COMException ex) { Log(DShowError._AMGetErrorText(ex.ErrorCode)); Log(ex.ToString()); } catch (Exception ex) { Log(ex.ToString()); } }
/// <summary> /// Checked means "Use uncompressed audio" /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ckAudioCompression_CheckedChanged(object sender, System.EventArgs e) { try { if (ckTestAudio.Checked) { ckTestAudio.Checked = false; } btnAudio.Enabled = ckUncompressedAudio.Checked; cbCompressionFormat.Enabled = !ckUncompressedAudio.Checked; if (ckUncompressedAudio.Enabled) { ac.RegAudioCompressorEnabled = !ckUncompressedAudio.Checked; frmAV.RenderAndRunAudio(ac.CaptureGraph, false); ac.CaptureGraph.RemoveFiltersDownstreamFromSource(MSR.LST.Net.Rtp.PayloadType.dynamicAudio); if (!ckUncompressedAudio.Checked) { ac.AddAudioCompressor(); } frmAV.RenderAndRunAudio(ac.CaptureGraph); UpdateCurrentSettings(); } } catch (COMException ex) { Log(DShowError._AMGetErrorText(ex.ErrorCode)); Log(ex.ToString()); } catch (Exception ex) { Log(ex.ToString()); } }
private void btnDefault_Click(object sender, System.EventArgs e) { try { frmAV.RenderAndRunVideo(vcg, false); vc.RegCustomCompression = false; vc.AddVideoCompressor(); frmAV.RenderAndRunVideo(vcg); UpdateCurrentSettings(); } catch (COMException ex) { Log(DShowError._AMGetErrorText(ex.ErrorCode)); Log(ex.ToString()); } catch (Exception ex) { Log(ex.ToString()); } }
private void ckEnableCompression_CheckedChanged(object sender, System.EventArgs e) { try { gbCustomCompression.Enabled = ckEnableCompression.Checked; if (ckEnableCompression.Enabled) // Flag for programmatic / user { frmAV.RenderAndRunVideo(vcg, false); // Must come before vc.AddVideoCompressor vc.RegCompressorEnabled = ckEnableCompression.Checked; if (ckEnableCompression.Checked) { vc.AddVideoCompressor(); } else { vcg.RemoveCompressor(); } frmAV.RenderAndRunVideo(vcg); UpdateCurrentSettings(); } } catch (COMException ex) { Log(DShowError._AMGetErrorText(ex.ErrorCode)); Log(ex.ToString()); } catch (Exception ex) { Log(ex.ToString()); } }
private void cboUpstreamPropPages_SelectedIndexChanged(object sender, System.EventArgs e) { try { if (cboUpstreamPropPages.Enabled) // Flag for programmatic vs. user input { PropertyPage pp = (PropertyPage)cboUpstreamPropPages.SelectedItem; pp.Show(this.Handle); // To save Crossbar info vc.SaveCameraSettings(); UpdateCurrentSettings(); } } catch (COMException ex) { Log(DShowError._AMGetErrorText(ex.ErrorCode)); Log(ex.ToString()); } catch (Exception ex) { Log(ex.ToString()); } }
private void clbCameras_SelectedIndexChanged(object sender, System.EventArgs e) { try { ClearVideoBox(); vc = (VideoCapability)vcs[(FilterInfo)clbCameras.SelectedItem]; vcg = vc != null ? vc.VideoCaptureGraph : null; if (clbCameras.GetItemChecked(clbCameras.SelectedIndex)) { UpdateVideoBox(); } } catch (COMException ex) { Log(DShowError._AMGetErrorText(ex.ErrorCode)); Log(ex.ToString()); } catch (Exception ex) { Log(ex.ToString()); } }
protected override void frmAudioSettings_Load(object sender, EventArgs e) { base.frmAudioSettings_Load(sender, e); // Put some controls into a groupbox of the base class. // Do it here so that the forms designer still works. this.Controls.Remove(this.lblACompressionFmt); this.Controls.Remove(this.cbCompressionFormat); this.gbMicAndAudio.Controls.Add(this.cbCompressionFormat); this.gbMicAndAudio.Controls.Add(this.lblACompressionFmt); // Hide the current settings display since all the settings are exposed in controls this.gbCurrentSettings.Visible = false; // Increase the height of the form to fit more controls. this.ClientSize = new System.Drawing.Size(this.ClientSize.Width, this.ClientSize.Height + 60); // Tool tips this.ttASettings.SetToolTip(this.cbApplication, Strings.OpusTTApplication); this.ttASettings.SetToolTip(this.cbBufferMS, Strings.OpusTTBufferMS); this.ttASettings.SetToolTip(this.cbComplexity, Strings.OpusTTComplexity); this.ttASettings.SetToolTip(this.cbDTX, Strings.OpusTTDTX); this.ttASettings.SetToolTip(this.cbForcedChannels, Strings.OpusTTForcedChannels); this.ttASettings.SetToolTip(this.cbInbandFec, Strings.OpusTTInbandFEC); this.ttASettings.SetToolTip(this.cbLSBDepth, Strings.OpusTTLSBDepth); this.ttASettings.SetToolTip(this.cbMaxBandwidth, Strings.OpusTTMaxBandwidth); this.ttASettings.SetToolTip(this.cbSignal, Strings.OpusTTSignal); this.ttASettings.SetToolTip(this.cbVBR, Strings.OpusTTVBR); this.ttASettings.SetToolTip(this.cbVBRConstraint, Strings.OpusTTVBRConstraint); this.ttASettings.SetToolTip(this.tbPacketLossPerc, Strings.OpusTTPacketLossPerc); this.ttASettings.SetToolTip(this.btnRestoreDefaults, Strings.RestoreCompressorDefaultValues); // Establish data sources for the ComboBox controls this.cbSignal.DataSource = Enum.GetValues(typeof(OpusAudioCompressor.EnumSignal)); this.cbBitRate.DataSource = Enum.GetValues(typeof(OpusAudioCompressor.EnumBitRate)); this.cbBufferMS.DataSource = OpusAudioCompressor.ValuesBufferMS; this.cbComplexity.DataSource = OpusAudioCompressor.ValuesComplexity; this.cbDTX.DataSource = Enum.GetValues(typeof(OpusAudioCompressor.EnumDTX)); this.cbForcedChannels.DataSource = Enum.GetValues(typeof(OpusAudioCompressor.EnumForcedChannels)); this.cbLSBDepth.DataSource = OpusAudioCompressor.ValuesLSBDepth; this.cbMaxBandwidth.DataSource = Enum.GetValues(typeof(OpusAudioCompressor.EnumMaxBandwidth)); this.cbVBR.DataSource = Enum.GetValues(typeof(OpusAudioCompressor.EnumVBR)); this.cbVBRConstraint.DataSource = Enum.GetValues(typeof(OpusAudioCompressor.EnumVBRConstraint)); this.cbApplication.DataSource = Enum.GetValues(typeof(OpusAudioCompressor.EnumApplication)); this.cbInbandFec.DataSource = Enum.GetValues(typeof(OpusAudioCompressor.EnumInbandFec)); try { this.Text += " - Opus Encoder"; // Load OpusEncoder static properties from the registry and put them in the form RestoreComboBoxValues(); // Load compression format combo box and validate compatibility with selected hardware RestoreCompressionFormat(); } catch (COMException ex) { Log(DShowError._AMGetErrorText(ex.ErrorCode)); Log(ex.ToString()); } catch (Exception ex) { Log(ex.ToString()); } }