예제 #1
0
        private void InitAudioCapability(ICapability capability)
        {
            if (audioCapability == null)
            {
                audioCapability = (AudioCapability)capability;

                // We want always to have the name of the video capability
                // if the form is shared with a video capability
                // => If the audio capability come after the video capability,
                // we want to overwrite with the name of the video capability.
                if (videoCapability != null)
                {
                    this.Text = videoCapability.Name;
                }

                // TODO: Add a condition to not call InitVideoUI() if isFormLoaded is false to prevent
                // the form to show to early
                InitAudioUI();

                // Set the UI borders so the audio capability can calculate the
                // AV form size given some constrains due to the video ratio
                //audioCapability.UIBorderWidth = UIBorderWidth;
                //audioCapability.UIBorderHeight = UIBorderHeight;
            }
        }
        /// <summary>
        /// Adds an audio compressor if needed (by checking the registry)
        /// </summary>
        public void AddAudioCompressor()
        {
            FilterInfo compressor = AudioCapability.SelectedCompressor();

            if (compressor.Moniker != "Uncompressed")
            {
                try
                {
                    cg.AddCompressor(SelectedCompressor());
                    Log(cg.Compressor.Dump());

                    IAudioCaptureGraph          iacg = cg as IAudioCaptureGraph;
                    Dictionary <string, Object> args = new Dictionary <string, object>();
                    args.Add("CaptureGraph", cg);
                    args.Add("CompressionMediaTypeIndex", this.CompressionMediaTypeIndex);
                    iacg.AudioCompressor.PostConnectConfig(args);
                }
                catch (Exception e)
                {
                    // If we encounter an error trying to add or configure the
                    // compressor, just disable compressor and log it
                    //RegAudioCompressorEnabled = false;
                    Log(e.ToString());
                }
            }
        }
예제 #3
0
 protected void RefreshAudioCapability()
 {
     //Rebuild graph.  AFAIK the only reason we need to do this is to apply changes to the buffer settings.
     ac.Dispose();
     ac = new AudioCapability(this.sourceFilter);
     ac.SetLogger(new AVLogger(Log));
     ac.ActivateMicrophone();
 }
예제 #4
0
        private void ActivateAudioCapability(FilterInfo fi)
        {
            ac = new AudioCapability(fi);
            ac.SetLogger(new AVLogger(Log));
            ac.ActivateMicrophone();
            acg = ac.AudioCaptureGraph;

            RenderAndRunAudio(acg, ckPlayAudio.Checked);
        }
예제 #5
0
        public frmAudioSettingsBase(FilterInfo fi, frmAVDevices frmAV)
        {
            InitializeComponent();

            Debug.Assert(frmAV != null);
            this.frmAV        = frmAV;
            this.sourceFilter = fi;

            ac = new AudioCapability(fi);
            ac.SetLogger(new AVLogger(Log));
            ac.ActivateMicrophone();
        }
예제 #6
0
        public frmAudioSettings(FilterInfo fi, frmAVDevices frmAV)
        {
            InitializeComponent();

            Debug.Assert(frmAV != null);
            this.frmAV = frmAV;
            this.sourceFilter = fi;

            ac = new AudioCapability(fi);
            ac.SetLogger(new AVLogger(Log));
            ac.ActivateMicrophone();
        }
예제 #7
0
        public frmAudioSettings(AudioCapability ac, frmAVDevices frmAV)
        {
            InitializeComponent();

            Debug.Assert(ac != null);
            Debug.Assert(ac.AudioCaptureGraph != null);
            Debug.Assert(frmAV != null);

            this.ac = ac;
            this.acg = ac.AudioCaptureGraph;
            this.frmAV = frmAV;
        }
예제 #8
0
        private void RestoreAudio()
        {
            foreach (FilterInfo fi in AudioCapability.SelectedMicrophones())
            {
                cboMicrophones.SelectedIndex = cboMicrophones.Items.IndexOf(fi);
            }

            if (cboMicrophones.SelectedIndex == -1)
            {
                cboMicrophones.SelectedIndex = 0;
            }

            cboSpeakers.SelectedIndex = cboSpeakers.Items.IndexOf(AudioCapability.SelectedSpeaker());
        }
예제 #9
0
        /// <summary>
        /// Remove a capability object to the list of capability objects referring to this shared form
        /// </summary>
        /// <param name="capability">The capability object to remove</param>
        /// <returns>true if there is no more capability of this type, false otherwise</returns>
        public override bool RemoveCapability(ICapability capability)
        {
            bool lastCapability = base.RemoveCapability(capability);

            if (lastCapability)
            {
                // TODO - we need to keep track of how many instances of a capability are in use
                // so that we shut down when the last instance goes away, not the first
                if (capability is VideoCapability)
                {
                    UninitVideoUI();
                    videoCapability = null;
                }
                else if (capability is AudioCapability)
                {
                    UninitAudioUI();
                    audioCapability = null;
                }
            }

            return(lastCapability);
        }
예제 #10
0
 private void ckPlayAudio_CheckedChanged(object sender, System.EventArgs e)
 {
     ckPlayAudio.Text = ckPlayAudio.Checked ? Strings.StopAudio : Strings.TestAudio;
     try {
         if (ckPlayAudio.Checked) {
             FilterInfo fi = (FilterInfo)cboMicrophones.SelectedItem;
             audioCapability = new AudioCapability(fi);
             audioCapability.SetLogger(new AVLogger(Log));
             audioCapability.ActivateMicrophone();
             RenderAndRunAudio(audioCapability.CaptureGraph, true);
         }
         else {
             RenderAndRunAudio(audioCapability.CaptureGraph, false);
             audioCapability.Dispose();
             audioCapability = null;
         }
     }
     catch (COMException ex) {
         Log(DShowError._AMGetErrorText(ex.ErrorCode));
         Log(ex.ToString());
     }
     catch (Exception ex) {
         Log(ex.ToString());
     }
 }
예제 #11
0
 private void frmAudioSettings_FormClosing(object sender, FormClosingEventArgs e)
 {
     ac.Dispose();
     ac = null;
 }
예제 #12
0
 private void frmAudioSettings_FormClosing(object sender, FormClosingEventArgs e) {
     ac.Dispose();
     ac = null;
 }        
예제 #13
0
        private void AutoSendAV()
        {
            // Determine if the form is shared
            string[] linkedCamera = AVReg.ValueNames(AVReg.LinkedCamera);
            if (linkedCamera != null)
            {
                Debug.Assert(linkedCamera.Length <= 1);
            }

            // Create the audio capability
            FilterInfo[] mics = AudioCapability.SelectedMicrophones();
            Debug.Assert(mics.Length <= 1);  // For now we only support 1

            AudioCapability ac = null;
            foreach (FilterInfo fi in mics)
            {
                ac = new AudioCapability(fi);
                ac.FecEnabled = enableAudioFec;
            }

            // Create the video capabilities and start sending their data
            foreach (FilterInfo fi in VideoCapability.SelectedCameras())
            {
                VideoCapability vc = new VideoCapability(fi);
                vc.FecEnabled = enableVideoFec;

                // Set the shared form ID
                if (ac != null && linkedCamera != null && linkedCamera.Length > 0)
                {
                    if (fi.Moniker == linkedCamera[0])
                    {
                        Guid sharedFormID = Guid.NewGuid();
                        ac.SharedFormID = sharedFormID;
                        vc.SharedFormID = sharedFormID;
                    }
                }

                try
                {
                    vc.ActivateCamera();
                    vc.Send();
                }
                catch (Exception)
                {
                    vc.Dispose();

                    RtlAwareMessageBox.Show(this, string.Format(CultureInfo.CurrentCulture,
                        Strings.SendVideoErrorText, vc.Name), Strings.SendVideoErrorTitle, MessageBoxButtons.OK,
                        MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0);
                }
            }

            // Start sending the audio data
            try
            {
                if (ac != null)
                {
                    ac.ActivateMicrophone();
                    ac.Send();
                }
            }
            catch (Exception)
            {
                ac.Dispose();

                RtlAwareMessageBox.Show(this, string.Format(CultureInfo.CurrentCulture, Strings.SendAudioErrorText,
                    ac.Name), Strings.SendAudioErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error,
                    MessageBoxDefaultButton.Button1, (MessageBoxOptions)0);
            }
        }
예제 #14
0
        private void InitAudioCapability(ICapability capability)
        {
            if (audioCapability == null)
            {
                audioCapability = (AudioCapability)capability;

                // We want always to have the name of the video capability
                // if the form is shared with a video capability
                // => If the audio capability come after the video capability,
                // we want to overwrite with the name of the video capability.
                if (videoCapability != null)
                {
                    this.Text = videoCapability.Name;
                }

                // TODO: Add a condition to not call InitVideoUI() if isFormLoaded is false to prevent
                // the form to show to early
                InitAudioUI();

                // Set the UI borders so the audio capability can calculate the
                // AV form size given some constrains due to the video ratio
                audioCapability.UIBorderWidth = UIBorderWidth;
                audioCapability.UIBorderHeight = UIBorderHeight;
            }
        }
예제 #15
0
        /// <summary>
        /// Remove a capability object to the list of capability objects referring to this shared form
        /// </summary>
        /// <param name="capability">The capability object to remove</param>
        /// <returns>true if there is no more capability of this type, false otherwise</returns>
        public override bool RemoveCapability(ICapability capability)
        {
            bool lastCapability = base.RemoveCapability(capability);

            if(lastCapability)
            {

                // TODO - we need to keep track of how many instances of a capability are in use
                // so that we shut down when the last instance goes away, not the first
                if (capability is VideoCapability)
                {
                    UninitVideoUI();
                    videoCapability = null;
                }
                else if (capability is AudioCapability)
                {
                    UninitAudioUI();
                    audioCapability = null;
                }
            }

            return lastCapability;
        }
예제 #16
0
        private void ActivateAudioCapability(FilterInfo fi)
        {
            ac = new AudioCapability(fi);
            ac.SetLogger(new AVLogger(Log));
            ac.ActivateMicrophone();
            acg = ac.AudioCaptureGraph;

            RenderAndRunAudio(acg, ckPlayAudio.Checked);
        }
예제 #17
0
        private void AutoSendAV()
        {
            // Determine if the form is shared
            string[] linkedCamera = AVReg.ValueNames(AVReg.LinkedCamera);
            if (linkedCamera != null)
            {
                Debug.Assert(linkedCamera.Length <= 1);
            }

            // Create the audio capability
            FilterInfo[] mics = AudioCapability.SelectedMicrophones();
            Debug.Assert(mics.Length <= 1);  // For now we only support 1

            AudioCapability ac = null;
            foreach (FilterInfo fi in mics)
            {
                ac = new AudioCapability(fi);
            }

            // Create the video capabilities and start sending their data
            foreach (FilterInfo fi in VideoCapability.SelectedCameras())
            {
                VideoCapability vc = new VideoCapability(fi);

                // Set the shared form ID
                if (ac != null && linkedCamera != null && linkedCamera.Length > 0)
                {
                    if (fi.Moniker == linkedCamera[0])
                    {
                        Guid sharedFormID = Guid.NewGuid();
                        ac.SharedFormID = sharedFormID;
                        vc.SharedFormID = sharedFormID;
                    }
                }

                try
                {
                    vc.ActivateCamera();
                    vc.Send();
                }
                catch (Exception)
                {
                    vc.Dispose();

                    MessageBox.Show(string.Format("ConferenceXP was unable to send video from " +
                        "the device - {0}.  See the ConferenceAPI Event Log for details.", vc.Name),
                        "Unable to send video", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            // Start sending the audio data
            try
            {
                if (ac != null)
                {
                    ac.ActivateMicrophone();
                    ac.Send();
                }
            }
            catch (Exception)
            {
                ac.Dispose();

                MessageBox.Show(string.Format("ConferenceXP was unable to send audio from " +
                    "the device - {0}.  See the ConferenceAPI Event Log for details.", ac.Name),
                    "Unable to send audio", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #18
0
 protected void RefreshAudioCapability() {
     //Rebuild graph.  AFAIK the only reason we need to do this is to apply changes to the buffer settings.
     ac.Dispose();
     ac = new AudioCapability(this.sourceFilter);
     ac.SetLogger(new AVLogger(Log));
     ac.ActivateMicrophone();
 }