/// <summary> /// Creates new RTP session. /// </summary> /// <param name="localEP">Local RTP end point.</param> /// <param name="clock">RTP media clock.</param> /// <returns>Returns created session.</returns> /// <exception cref="ObjectDisposedException">Is raised when this class is Disposed and this method is accessed.</exception> /// <exception cref="ArgumentNullException">Is raised when <b>localEP</b> or <b>clock</b> is null reference.</exception> public RTP_Session CreateSession(RTP_Address localEP, RTP_Clock clock) { if (m_IsDisposed) { throw new ObjectDisposedException(this.GetType().Name); } if (localEP == null) { throw new ArgumentNullException("localEP"); } if (clock == null) { throw new ArgumentNullException("clock"); } RTP_Session session = new RTP_Session(this, localEP, clock); session.Disposed += new EventHandler(delegate(object s, EventArgs e) { m_pSessions.Remove((RTP_Session)s); }); m_pSessions.Add(session); OnSessionCreated(session); return(session); }
public void Start() { if (IsDisposed) { throw new ObjectDisposedException(this.GetType().Name); } if (!Started) { _hTrigger.Init(); _multiSession = new RTP_MultimediaSession(RTP_Utils.GenerateCNAME()); RTP_Session session = _multiSession.CreateSession(new RTP_Address(IPAddress.Parse(_localIP), _localPort, _localPort + 1), new RTP_Clock(0, VideoRate)); session.Payload = RTP_PayloadTypes.H264; session.Start(); _sendStream = session.CreateSendStream(); _vSoure = VideoSourceCreator.Instance.GetVideoSource(_videoId); if (_targets.Count > 0) { foreach (string key in _targets.Keys) { TargetItem ti = _targets[key]; session.AddTarget(new RTP_Address(ti.IP, ti.Port, ti.Port + 1)); } startPlay(); } Started = true; } }
/// <summary> /// Default constructor. /// </summary> /// <param name="owner">Main UI.</param> /// <param name="session">RTP session.</param> /// <param name="sendFile">File which data to send.</param> /// <exception cref="ArgumentNullException">Is raised when <b>owner</b>, <b>session</b> or <b>sendFile</b> is null reference.</exception> public wfrm_SendAudio(wfrm_Main owner, RTP_Session session, string sendFile) { if (owner == null) { throw new ArgumentNullException("owner"); } if (session == null) { throw new ArgumentNullException("session"); } if (sendFile == null) { throw new ArgumentNullException("sendFile"); } m_pMainUI = owner; m_pSession = session; m_SendFile = sendFile; InitUI(); ThreadPool.QueueUserWorkItem(new WaitCallback(delegate(object state){ SendAudio(); })); }
/// <summary> /// Default constructor. /// </summary> /// <param name="session">RTP session.</param> /// <exception cref="ArgumentNullException">Is raised when <b>session</b></exception> public RTP_SessionStatistics(RTP_Session session) { if (session == null) { throw new ArgumentNullException("session"); } m_pSession = session; }
/// <summary> /// Default constructor. /// </summary> /// <param name="session">Owner RTP session.</param> /// <param name="ssrc">Synchronization source ID.</param> /// <exception cref="ArgumentNullException">Is raised when <b>session</b> is null reference.</exception> internal RTP_Source(RTP_Session session, uint ssrc) { if (session == null) { throw new ArgumentNullException("session"); } m_pSession = session; m_SSRC = ssrc; }
/// <summary> /// Raises <b>SessionCreated</b> event. /// </summary> /// <param name="session">RTP session.</param> private void OnSessionCreated(RTP_Session session) { if (session == null) { throw new ArgumentNullException("session"); } if (this.SessionCreated != null) { this.SessionCreated(this, new EventArgs <RTP_Session>(session)); } }
/// <summary> /// Default constructor. /// </summary> /// <param name="session">Owner RTP session.</param> /// <param name="ssrc">Synchronization source ID.</param> /// <param name="rtcpEP">RTCP end point.</param> /// <param name="rtpEP">RTP end point.</param> /// <exception cref="ArgumentNullException">Is raised when <b>session</b>,<b>rtcpEP</b> or <b>rtpEP</b> is null reference.</exception> internal RTP_Source_Local(RTP_Session session, uint ssrc, IPEndPoint rtcpEP, IPEndPoint rtpEP) : base(session, ssrc) { if (rtcpEP == null) { throw new ArgumentNullException("rtcpEP"); } if (rtpEP == null) { throw new ArgumentNullException("rtpEP"); } this.SetRtcpEP(rtcpEP); this.SetRtpEP(rtpEP); }
/// <summary> /// Cleans up any resources being used. /// </summary> internal void Dispose() { if (m_IsDisposed) { return; } m_IsDisposed = true; m_pSession = null; m_pParticipant = null; Closed = null; Timeout = null; SenderReport = null; PacketReceived = null; }
/// <summary> /// Cleans up any resources being used. /// </summary> internal virtual void Dispose() { if (m_State == RTP_SourceState.Disposed) { return; } OnDisposing(); SetState(RTP_SourceState.Disposed); m_pSession = null; m_pRtcpEP = null; m_pRtpEP = null; Closed = null; Disposing = null; StateChanged = 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(); }
/// <summary> /// Default constructor. /// </summary> /// <param name="session">Owner RTP session.</param> /// <param name="ssrc">Onwer synchronization source.</param> /// <param name="packetSeqNo">RTP packet <b>SeqNo</b> value.</param> /// <exception cref="ArgumentNullException">Is riased when <b>session</b> or <b>ssrc</b> is null reference.</exception> internal RTP_ReceiveStream(RTP_Session session, RTP_Source ssrc, ushort packetSeqNo) { if (session == null) { throw new ArgumentNullException("session"); } if (ssrc == null) { throw new ArgumentNullException("ssrc"); } m_pSession = session; m_pSSRC = ssrc; // RFC 3550 A.1. InitSeq(packetSeqNo); m_MaxSeqNo = (ushort)(packetSeqNo - 1); m_Probation = MIN_SEQUENTIAL; }
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(); }
/// <summary> /// Default constructor. /// </summary> /// <param name="owner">Main UI.</param> /// <param name="session">RTP session.</param> /// <exception cref="ArgumentNullException">Is raised when <b>owner</b> or <b>session</b> is null reference.</exception> public wfrm_SendMic(wfrm_Main owner,RTP_Session session) { if(owner == null){ throw new ArgumentNullException("owner"); } if(session == null){ throw new ArgumentNullException("session"); } m_pMainUI = owner; m_pSession = session; InitUI(); // Load input devices. m_pInDevices.Items.Clear(); foreach(AudioInDevice device in AudioIn.Devices){ m_pInDevices.Items.Add(device.Name); } if(m_pInDevices.Items.Count > 0){ m_pInDevices.SelectedIndex = 0; } }
private void m_pToggleRun_Click(object sender, EventArgs e) { if (m_IsRunning) { m_IsRunning = false; m_IsSendingTest = false; m_pRtpSession.Dispose(); m_pRtpSession = null; m_pWaveOut.Dispose(); m_pWaveOut = null; if (m_pRecordStream != null) { m_pRecordStream.Dispose(); m_pRecordStream = null; } m_pOutDevices.Enabled = true; m_pToggleRun.Text = "Start"; m_pRecord.Enabled = true; m_pRecordFile.Enabled = true; m_pRecordFileBrowse.Enabled = true; m_pRemoteIP.Enabled = false; m_pRemotePort.Enabled = false; m_pCodec.Enabled = false; m_pToggleMic.Text = "Send"; m_pToggleMic.Enabled = false; m_pSendTestSound.Enabled = false; m_pSendTestSound.Text = "Send"; m_pPlayTestSound.Enabled = false; m_pPlayTestSound.Text = "Play"; } else { if (m_pOutDevices.SelectedIndex == -1) { MessageBox.Show(this, "Please select output device !", "Error:", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (m_pRecord.Checked && m_pRecordFile.Text == "") { MessageBox.Show(this, "Please specify record file !", "Error:", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (m_pRecord.Checked) { m_pRecordStream = File.Create(m_pRecordFile.Text); } m_IsRunning = true; m_pWaveOut = new AudioOut(AudioOut.Devices[m_pOutDevices.SelectedIndex], 8000, 16, 1); m_pRtpSession = new RTP_MultimediaSession(RTP_Utils.GenerateCNAME()); // --- Debug ----- wfrm_RTP_Debug frmRtpDebug = new wfrm_RTP_Debug(m_pRtpSession); frmRtpDebug.Show(); //----------------- // m_pRtpSession.CreateSession(new RTP_Address(IPAddress.Parse(m_pLocalIP.Text),(int)m_pLocalPort.Value,(int)m_pLocalPort.Value + 1),new RTP_Clock(0,8000)); string ip = "127.0.0.1"; int port = 1100; int remote_port = 20700; //RTP_Session session = m_pRtpSession.CreateSession(new RTP_Address(IPAddress.Parse(ip), port, port + 1), new RTP_Clock(0, 8000)); //session.AddTarget(new RTP_Address(IPAddress.Parse("127.0.0.1"), remote_port, remote_port + 1)); RTP_Session session = m_pRtpSession.CreateMulticastSession(new RTP_Address(IPAddress.Parse(ip), port, port + 1), new RTP_Clock(0, 8000), null); session.AddTarget(new RTP_Address(IPAddress.Parse("224.0.0.1"), remote_port, remote_port + 1)); session.Payload = 0; session.Start(); m_pOutDevices.Enabled = false; m_pToggleRun.Text = "Stop"; m_pRecord.Enabled = false; m_pRecordFile.Enabled = false; m_pRecordFileBrowse.Enabled = false; m_pRemoteIP.Enabled = true; m_pRemotePort.Enabled = true; m_pCodec.Enabled = true; m_pToggleMic.Enabled = true; m_pSendTestSound.Enabled = true; m_pSendTestSound.Text = "Send"; m_pPlayTestSound.Enabled = true; m_pPlayTestSound.Text = "Play"; } wfrm_SendAudio frm = new wfrm_SendAudio(this, m_pRtpSession.Sessions[0], @"D:\_d\_PROJECTS\CisteraDesktopNotificationService\Lumisoft.Net.Rtp\Rtp Audio Demo\Rtp Audio Demo\bin\Debug\audio\futurama.raw"); frm.Show(); }
/// <summary> /// Default constructor. /// </summary> /// <param name="session">Owner RTP session.</param> /// <param name="ssrc">Synchronization source ID.</param> /// <exception cref="ArgumentNullException">Is raised when <b>session</b> is null reference.</exception> internal RTP_Source_Remote(RTP_Session session, uint ssrc) : base(session, ssrc) { }
/// <summary> /// Default constructor. /// </summary> /// <param name="session">RTP session.</param> /// <exception cref="ArgumentNullException">Is raised when <b>session</b></exception> public RTP_SessionStatistics(RTP_Session session) { if (session == null) { throw new ArgumentNullException("session"); } m_pSession = session; }