Ejemplo n.º 1
0
        public void RenderAndRunAudio(AudioCaptureGraph acg, bool playIt)
        {
            if (acg == null)
            {
                throw new ArgumentNullException("Can't render an audio graph without an audio capture device");
            }

            if (playIt)
            {
                Log("Playing audio (render and run graph) - " + acg.Source.FriendlyName);

                // Re-add the renderer in case they changed it since the last
                // time they played the audio
                acg.AddRenderer((FilterInfo)cboSpeakers.SelectedItem);

                acg.Run();
            }
            else
            {
                Log("Stop audio (stop and unrender graph) - " + acg.Source.FriendlyName);

                acg.Stop();
                acg.RemoveRenderer();
            }

            Log(FilterGraph.Debug(acg.IFilterGraph));
        }
Ejemplo n.º 2
0
        private void DeactivateAudioCapability()
        {
            RenderAndRunAudio(acg, false);
            acg = null;

            ac.DeactivateMicrophone();
        }
Ejemplo n.º 3
0
        private void ActivateAudioCapability(FilterInfo fi)
        {
            ac = new AudioCapability(fi);
            ac.SetLogger(new AVLogger(Log));
            ac.ActivateMicrophone();
            acg = ac.AudioCaptureGraph;

            RenderAndRunAudio(acg, ckPlayAudio.Checked);
        }
        /// <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();
            }
        }
        /// <summary>
        /// Restore the audio device input pin setting from the registry.  Not applicable to DV sources
        /// </summary>
        private void RestoreMicrophoneSettings()
        {
            AudioCaptureGraph acg = cg as AudioCaptureGraph;

            if (acg != null)
            {
                object setting = AVReg.ReadValue(DeviceKey(), AVReg.MicrophoneSourceIndex);
                if (setting != null)
                {
                    if ((int)setting < cg.Source.InputPins.Count)
                    {
                        acg.AudioSource.InputPinIndex = (int)setting;
                    }
                }
            }
        }
        /// <summary>
        /// Creates the actual FilgraphManager with the chosen microphone
        /// </summary>
        private void CreateAudioGraph(FilterInfo fi)
        {
            Debug.Assert(cg == null);

            if (DVSource.IsDVSourceWithAudio(fi))
            {
                cg = DVCaptureGraph.GetInstance(fi);
                Log(((DVCaptureGraph)cg).DVSource.Dump());
            }
            else
            {
                // Create the graph, which creates the source filter
                cg = new AudioCaptureGraph(fi);
                Log(((AudioCaptureGraph)cg).AudioSource.Dump());
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Input pin change.  Not applicable to DV sources
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cboMicrophonePins_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            AudioCaptureGraph acg = ac.CaptureGraph as AudioCaptureGraph;

            if (acg == null)
            {
                return;
            }

            if (ckTestAudio.Checked)
            {
                ckTestAudio.Checked = false;
            }

            acg.AudioSource.InputPinIndex = cboMicrophonePins.SelectedIndex;
            ac.SaveMicrophoneSettings();
        }
        /// <summary>
        /// Restore custom buffer settings from the registry, if any.  This doesn't seem to work with DV Sources.
        /// It is also not relevant for the Opus Encoder since the settings will be overridden later in that case.
        /// </summary>
        private void RestoreBufferSettings()
        {
            if (cg is AudioCaptureGraph)
            {
                AudioCaptureGraph acg   = (AudioCaptureGraph)cg;
                object            bufSz = AVReg.ReadValue(DeviceKey(), AVReg.AudioBufferSize);
                if (bufSz != null)
                {
                    acg.AudioSource.BufferSize = (int)bufSz;
                }

                object bufCnt = AVReg.ReadValue(DeviceKey(), AVReg.AudioBufferCount);
                if (bufCnt != null)
                {
                    acg.AudioSource.BufferCount = (int)bufCnt;
                }
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Restore the selected audio input.  If it is a DV source, we have no choices.
        /// </summary>
        private void RestoreInputPin()
        {
            if (ac.CaptureGraph is AudioCaptureGraph)
            {
                AudioCaptureGraph acg = ac.CaptureGraph as AudioCaptureGraph;
                foreach (IPin pin in acg.AudioSource.InputPins)
                {
                    cboMicrophonePins.Items.Add(Pin.Name(pin));
                }
                cboMicrophonePins.Enabled = acg.AudioSource.InputPins.Count > 1;

                if (cboMicrophonePins.Items.Count > 0)
                {
                    cboMicrophonePins.SelectedIndex = acg.AudioSource.InputPinIndex;
                }
            }
            else if (ac.CaptureGraph is DVCaptureGraph)
            {
                cboMicrophonePins.Items.Add("DV Audio");
                cboMicrophonePins.Enabled       = false;
                cboMicrophonePins.SelectedIndex = 0;
            }
        }
Ejemplo n.º 10
0
 public void RenderAndRunAudio(AudioCaptureGraph acg)
 {
     RenderAndRunAudio(acg, ckPlayAudio.Checked);
 }