コード例 #1
0
        /// <summary>
        /// Stops capturing from audio-in device and sending it to RTP stream.
        /// </summary>
        /// <exception cref="ObjectDisposedException">Is raised when this object is disposed and this method is accessed.</exception>
        public void Stop()
        {
            if (this.IsDisposed)
            {
                throw new ObjectDisposedException(this.GetType().Name);
            }
            if (!m_IsRunning)
            {
                return;
            }

            if (m_pWaveIn != null)
            {
                m_pWaveIn.Dispose();
                m_pWaveIn = null;
            }
        }
コード例 #2
0
        /// <summary>
        /// Starts capturing from audio-in device and sending it to RTP stream.
        /// </summary>
        /// <exception cref="ObjectDisposedException">Is raised when this object is disposed and this method is accessed.</exception>
        public void Start()
        {
            if (this.IsDisposed)
            {
                throw new ObjectDisposedException(this.GetType().Name);
            }
            if (m_IsRunning)
            {
                return;
            }

            m_IsRunning = true;

            if (m_pActiveCodec != null)
            {
                // Calculate buffer size.
                int bufferSize = (m_pActiveCodec.AudioFormat.SamplesPerSecond / (1000 / m_AudioFrameSize)) * (m_pActiveCodec.AudioFormat.BitsPerSample / 8);

                m_pWaveIn = new _WaveIn(m_pAudioInDevice, m_pActiveCodec.AudioFormat.SamplesPerSecond, m_pActiveCodec.AudioFormat.BitsPerSample, 1, bufferSize);
                m_pWaveIn.AudioFrameReceived += new EventHandler <EventArgs <byte[]> >(m_pWaveIn_AudioFrameReceived);
                m_pWaveIn.Start();
            }
        }