/// <summary> /// This method is called when output device has changed. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">Event data.</param> private void m_pOutputDevice_SelectedIndexChanged(object sender, EventArgs e) { // Release old audio player, if exists. if (m_pAudioOut != null) { m_pAudioOut.Dispose(); } m_pAudioOut = new AudioOut_RTP(AudioOut.Devices[m_pOutputDevice.SelectedIndex], m_pRTP_Stream, m_AudioCodecs); m_pAudioOut.Start(); }
/// <summary> /// This method is called when RTP session gets new receive stream. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">Event data.</param> private void m_pRtpSession_NewReceiveStream(object sender, RTP_ReceiveStreamEventArgs e) { d_RecieveStream = Dispatcher.BeginInvoke(new Action(delegate() { /*wfrm_Receive frm = new wfrm_Receive(e.Stream, m_pAudioCodecs); * frm.Show();*/ var selectedOutDevice = cbAudioOutDevices.SelectedItem as AudioOutDevice; m_pAudioOut = new AudioOut_RTP(selectedOutDevice, e.Stream, m_pAudioCodecs); m_pAudioOut.Start(); })); }
static public void Stop() { if (session != null) { ao.Stop(); ao.Dispose(); ao = null; session.Close("Closed."); session.Dispose(); session = null; execute = null; } }
private void wfrm_Receive_FormClosing(object sender, FormClosingEventArgs e) { if (m_pTimer != null) { m_pTimer.Dispose(); m_pTimer = null; } if (m_pAudioOut != null) { m_pAudioOut.Dispose(); m_pAudioOut = null; } }
static int payload = 0;//8; static private void m_pRtpSession_NewReceiveStream(object sender, RTP_ReceiveStreamEventArgs e) { //if(e.Stream.Session.StunPublicEndPoints) //e.Stream.Session.Stop(); foreach (AudioOutDevice device in AudioOut.Devices) { //WavePlayer wp = new WavePlayer(device); //wp.Play(,) ao = new AudioOut_RTP( device, e.Stream, new Dictionary <int, AudioCodec> { { payload, new PCMA() } } ); ao.Start(); break; } }
static private void m_pRtpSession_NewReceiveStream(object sender, RTP_ReceiveStreamEventArgs e) { try { //for unicast make sure that the stream is from the expected source ip if (!multicast && !e.Stream.SSRC.RtpEP.Address.Equals(source_ip)) { return; } session.Sessions[0].NewReceiveStream -= NewReceiveStream; AudioOutDevice device = AudioOut.Devices.Where(d => d.Name == Settings.Default.AudioDeviceName).FirstOrDefault(); if (device == null) { Message.Error("Could not find audio device: " + Settings.Default.AudioDeviceName); return; } AudioCodec ac = new PCMU(); ao = new AudioOut_RTP( device, e.Stream, new Dictionary <int, AudioCodec> { { payload, ac } } ); Dictionary <AudioCodec, string> acs2of = new Dictionary <AudioCodec, string>(); if (Settings.Default.RecordIncomingRtpStreams) { string wav_file = PathRoutines.CreateDirectory(Settings.Default.RtpStreamStorageFolder) + "\\" + e.Stream.SSRC.RtpEP.Address.ToString() + DateTime.Now.ToString("_yyyy-MM-dd_HH-mm-ss") + ".wav"; acs2of[ac] = wav_file; if (execute != null) { execute.Record = wav_file; } } ao.Start(volume100, acs2of); } catch (Exception ex) { Message.Error(ex); } }
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(); }