/// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="stream">RTP send stream.</param>
        public RTP_SendStreamEventArgs(RTP_SendStream stream)
        {
            if(stream == null){
                throw new ArgumentNullException("stream");
            }

            m_pStream = stream;
        }
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="stream">RTP send stream.</param>
        public RTP_SendStreamEventArgs(RTP_SendStream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            m_pStream = stream;
        }
Beispiel #3
0
        /// <summary>
        /// Creates RTP send stream for this source.
        /// </summary>
        /// <exception cref="InvalidOperationException">Is raised when this method is called more than 1 times(source already created).</exception>
        internal void CreateStream()
        {
            if (m_pStream != null)
            {
                throw new InvalidOperationException("Stream is already created.");
            }

            m_pStream           = new RTP_SendStream(this);
            m_pStream.Disposed += new EventHandler(delegate(object s, EventArgs e){
                m_pStream = null;
                Dispose();
            });

            SetState(RTP_SourceState.Active);
        }
Beispiel #4
0
        /// <summary>
        /// Cleans up any resources being used.
        /// </summary>
        public void Dispose()
        {
            if(m_IsDisposed){
                return;
            }

            Stop();

            m_IsDisposed = true;

            this.Error        = null;
            m_pAudioInDevice  = null;
            m_pAudioCodecs    = null;
            m_pRTP_Stream.Session.PayloadChanged -= new EventHandler(m_pRTP_Stream_PayloadChanged);
            m_pRTP_Stream     = null;
            m_pActiveCodec    = null;
        }
Beispiel #5
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="audioInDevice">Audio-in device to capture.</param>
        /// <param name="audioFrameSize">Audio frame size in milliseconds.</param>
        /// <param name="codecs">Audio codecs with RTP payload number. For example: 0-PCMU,8-PCMA.</param>
        /// <param name="stream">RTP stream to use for audio sending.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>audioInDevice</b>,<b>codecs</b> or <b>stream</b> is null reference.</exception>
        public AudioIn_RTP(AudioInDevice audioInDevice,int audioFrameSize,Dictionary<int,AudioCodec> codecs,RTP_SendStream stream)
        {
            if(audioInDevice == null){
                throw new ArgumentNullException("audioInDevice");
            }
            if(codecs == null){
                throw new ArgumentNullException("codecs");
            }
            if(stream == null){
                throw new ArgumentNullException("stream");
            }

            m_pAudioInDevice = audioInDevice;
            m_AudioFrameSize = audioFrameSize;
            m_pAudioCodecs   = codecs;
            m_pRTP_Stream    = stream;

            m_pRTP_Stream.Session.PayloadChanged += new EventHandler(m_pRTP_Stream_PayloadChanged);
            m_pAudioCodecs.TryGetValue(m_pRTP_Stream.Session.Payload,out m_pActiveCodec);
        }
Beispiel #6
0
        //Start Send Voice
        public void m_pToggleSend_Click2(ComboBox m_pInDevices, Button m_pToggleSend)
        {
            if(m_pWaveIn == null){
                m_pSendStream = m_pSession.CreateSendStream();

                m_pWaveIn = new AudioIn(AudioIn.Devices[m_pInDevices.SelectedIndex],8000,16,1);
                //m_pWaveIn.Start();

                m_pToggleSend.Text = "Stop";
                m_Send = true;

                Thread tr = new Thread(this.SendMic);
                tr.Start();
            }
            else{
                m_pSendStream.Close();
                m_pSendStream = null;
                m_pWaveIn.Dispose();
                m_pWaveIn = null;

                m_pToggleSend.Text = "Send";
                m_Send = false;
            }
        }
Beispiel #7
0
        /// <summary>
        /// Sends specified RTP packet to the session remote party.
        /// </summary>
        /// <param name="stream">RTP packet sending stream.</param>
        /// <param name="packet">RTP packet.</param>
        /// <returns>Returns packet size in bytes.</returns>
        /// <exception cref="ObjectDisposedException">Is raised when this class is Disposed and this method is accessed.</exception>
        /// <exception cref="ArgumentNullException">Is raised when <b>stream</b> or <b>packet</b> is null reference.</exception>
        internal int SendRtpPacket(RTP_SendStream stream,RTP_Packet packet)
        {
            if(m_IsDisposed){
                throw new ObjectDisposedException(this.GetType().Name);
            }
            if(stream == null){
                throw new ArgumentNullException("stream");
            }
            if(packet == null){
                throw new ArgumentNullException("packet");
            }

            // Check that we are in members table (because SSRC has timed out), add itself to senders table.
            lock(m_pMembers){
                if(!m_pMembers.ContainsKey(stream.Source.SSRC)){
                    m_pMembers.Add(stream.Source.SSRC,stream.Source);
                }
            }

            // If we are not in sender table (because SSRC has timed out), add itself to senders table.
            lock(m_pSenders){
                if(!m_pSenders.ContainsKey(stream.Source.SSRC)){
                    m_pSenders.Add(stream.Source.SSRC,stream.Source);
                }
            }
                        
            byte[] packetBytes = new byte[m_MTU];
            int count = 0;
            packet.ToByte(packetBytes,ref count);

            // Send packet to each remote target.
            foreach(RTP_Address target in this.Targets){
                try{
                    m_pRtpSocket.BeginSendTo(packetBytes,0,count,SocketFlags.None,target.RtpEP,this.RtpAsyncSocketSendCompleted,null);
                }
                catch{
                    m_RtpFailedTransmissions++;
                }
            }
                        
            return count;
        }
Beispiel #8
0
 /// <summary>
 /// Raises <b>NewSendStream</b> event.
 /// </summary>
 /// <param name="stream">New send stream.</param>
 private void OnNewSendStream(RTP_SendStream stream)
 {
     if(this.NewSendStream != null){
         this.NewSendStream(this,new RTP_SendStreamEventArgs(stream));
     }
 }
Beispiel #9
0
        /// <summary>
        /// Creates RTP send stream for this source.
        /// </summary>
        /// <exception cref="InvalidOperationException">Is raised when this method is called more than 1 times(source already created).</exception>
        internal void CreateStream()
        {
            if(m_pStream != null){
                throw new InvalidOperationException("Stream is already created.");
            }

            m_pStream = new RTP_SendStream(this);
            m_pStream.Disposed += new EventHandler(delegate(object s,EventArgs e){
                m_pStream = null;
                Dispose();
            });

            SetState(RTP_SourceState.Active);
        }
Beispiel #10
0
 //Dispose Send Audio
 public void wfrm_SendMic_FormClosing()
 {
     m_Send = false;
     if(m_pWaveIn != null){
         m_pWaveIn.Dispose();
         m_pWaveIn = null;
     }
     if(m_pSendStream != null){
         m_pSendStream.Close();
         m_pSendStream = null;
     }
 }
        private void btnCall_Click_1(object sender, RoutedEventArgs e)
        {
            IsConnected = false;
            m_pSession = m_pRtpSession.Sessions[0];
            if (m_pAudioInRTP == null)
            {
                m_pSendStream = m_pSession.CreateSendStream();
            }
            else
            {
                m_pAudioInRTP.Dispose();
                m_pAudioInRTP = null;
                m_pSendStream.Close();
                m_pSendStream = null;

            }
               // _soundSender.Start();
               // _soundReceiver.Start();
        }
Beispiel #12
0
 private void wfrm_SendMic_FormClosing(object sender, FormClosingEventArgs e)
 {
     m_Send = false;
     if(m_pWaveIn != null){
         m_pWaveIn.Dispose();
         m_pWaveIn = null;
     }
     if(m_pSendStream != null){
         m_pSendStream.Close();
         m_pSendStream = null;
     }
 }
Beispiel #13
0
        private void m_pToggleSend_Click(object sender,EventArgs e)
        {
            if(m_pWaveIn == null){
                m_pSendStream = m_pSession.CreateSendStream();

                m_pWaveIn = new AudioIn(AudioIn.Devices[m_pInDevices.SelectedIndex],8000,16,1);
                //m_pWaveIn.Start();

                m_pToggleSend.Text = "Stop";
                m_Send = true;

                Thread tr = new Thread(this.SendMic);
                tr.Start();
            }
            else{
                m_pSendStream.Close();
                m_pSendStream = null;
                m_pWaveIn.Dispose();
                m_pWaveIn = null;

                m_pToggleSend.Text = "Send";
                m_Send = false;
            }
        }