private void m_pToggleSend_Click(object sender,EventArgs e) { if(m_pAudioInRTP == null){ m_pSendStream = m_pSession.CreateSendStream(); m_pAudioInRTP = new AudioIn_RTP(AudioIn.Devices[m_pInDevices.SelectedIndex],20,m_pMainUI.AudioCodecs,m_pSendStream); m_pAudioInRTP.Start(); m_pTimer = new Timer(); m_pTimer.Interval = 500; m_pTimer.Tick += delegate(object s1,EventArgs e1){ m_pCodec.Text = m_pAudioInRTP.AudioCodec.Name; m_pPacketsSent.Text = m_pSendStream.RtpPacketsSent.ToString(); m_pKBSent.Text = Convert.ToString(m_pSendStream.RtpBytesSent / 1000); }; m_pTimer.Start(); m_pToggleSend.Text = "Stop"; } else{ m_pTimer.Dispose(); m_pTimer = null; m_pAudioInRTP.Dispose(); m_pAudioInRTP = null; m_pSendStream.Close(); m_pSendStream = null; m_pToggleSend.Text = "Send"; } }
/// <summary> /// This method is called when RTP session creates new send stream. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">Event data.</param> private void m_pRtpSession_NewSendStream(object sender, RTP_SendStreamEventArgs e) { d_SendStream = Dispatcher.BeginInvoke(new Action(delegate() { var selectedInDevice = cbAudioInDevices.SelectedItem as AudioInDevice; m_pAudioInRTP = new AudioIn_RTP(selectedInDevice, 20, m_pAudioCodecs, m_pSendStream); m_pAudioInRTP.Start(); })); }
private void StartRtpSession(IPAddress remoteIp, IPAddress localIp, int rtpPort, int rtcpPort) { Dictionary <int, AudioCodec> m_pAudioCodecs = new Dictionary <int, AudioCodec> { { 0, new PCMU() } }; RTP_MultimediaSession rtpMultimediaSession = new RTP_MultimediaSession(RTP_Utils.GenerateCNAME()); sessionRtp = rtpMultimediaSession.CreateSession(new RTP_Address(localIp, rtpPort, rtcpPort), new RTP_Clock(1, 8000)); sessionRtp.AddTarget(new RTP_Address(remoteIp, rtpPort, rtcpPort)); sessionRtp.Payload = 0; sessionRtp.StreamMode = RTP_StreamMode.SendReceive; sessionRtp.NewReceiveStream += delegate(object s, RTP_ReceiveStreamEventArgs e2) { if (audioOut != null) { audioOutRtp = new AudioOut_RTP(audioOut, e2.Stream, m_pAudioCodecs); if (speakerMute == false) { audioOutRtp.Start(); } } }; if (audioIn != null) { audioInRtp = new AudioIn_RTP(audioIn, 10, m_pAudioCodecs, sessionRtp.CreateSendStream()); if (micMute == false) { audioInRtp.Start(); } } sessionRtp.Start(); }
private void BtnSpeakerMic_ButtonClick(object sender, EventArgs e) { if (sender == btnMic) { micMute = !micMute; btnMic.Image = micMute ? Resources.MicrophoneOff : Resources.MicrophoneOn; if (audioInRtp != null) { if (micMute) { audioInRtp.Stop(); } else { audioInRtp.Start(); } } } if (sender == btnSpeaker) { speakerMute = !speakerMute; btnSpeaker.Image = speakerMute ? Resources.SpeakerOff : Resources.SpeakerOn; if (audioOutRtp != null) { if (speakerMute) { audioOutRtp.Stop(); } else { audioOutRtp.Start(); } } } }