/// <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(Robot1 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; } m_pRtpPacket = new RTP_Packet(); m_pRtpPacket.Data = new byte[400]; }
/// <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> /// 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; this.Closed = null; this.Timeout = null; this.SenderReport = null; this.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; this.Closed = null; this.Disposing = null; this.StateChanged = null; }
/// <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; }
/// <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(Robot1 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(); })); }
private bool HandleNAT(SDP_MediaDescription mediaStream, RTP_Session rtpSession) { if (mediaStream == null) { throw new ArgumentNullException("mediaStream"); } if (rtpSession == null) { throw new ArgumentNullException("rtpSession"); } IPEndPoint rtpPublicEP = null; IPEndPoint rtcpPublicEP = null; // We have public IP. if (!Net_Utils.IsPrivateIP(rtpSession.LocalEP.IP)) { rtpPublicEP = rtpSession.LocalEP.RtpEP; rtcpPublicEP = rtpSession.LocalEP.RtcpEP; } // No NAT handling. else if (m_NatHandlingType == "no_nat") { rtpPublicEP = rtpSession.LocalEP.RtpEP; rtcpPublicEP = rtpSession.LocalEP.RtcpEP; } // Use STUN. else if (m_NatHandlingType == "stun") { rtpSession.StunPublicEndPoints(m_StunServer, 3478, out rtpPublicEP, out rtcpPublicEP); } // Use UPnP. else if (m_NatHandlingType == "upnp") { // Try to open UPnP ports. if (m_pUPnP.IsSupported) { int rtpPublicPort = rtpSession.LocalEP.RtpEP.Port; int rtcpPublicPort = rtpSession.LocalEP.RtcpEP.Port; try { UPnP_NAT_Map[] maps = m_pUPnP.GetPortMappings(); while (true) { bool conficts = false; // Check that some other application doesn't use that port. foreach (UPnP_NAT_Map map in maps) { // Existing map entry conflicts. if (Convert.ToInt32(map.ExternalPort) == rtpPublicPort || Convert.ToInt32(map.ExternalPort) == rtcpPublicPort) { rtpPublicPort += 2; rtcpPublicPort += 2; conficts = true; break; } } if (!conficts) { break; } } m_pUPnP.AddPortMapping(true, "LS RTP", "UDP", null, rtpPublicPort, rtpSession.LocalEP.RtpEP, 0); m_pUPnP.AddPortMapping(true, "LS RTCP", "UDP", null, rtcpPublicPort, rtpSession.LocalEP.RtcpEP, 0); IPAddress publicIP = m_pUPnP.GetExternalIPAddress(); rtpPublicEP = new IPEndPoint(publicIP, rtpPublicPort); rtcpPublicEP = new IPEndPoint(publicIP, rtcpPublicPort); mediaStream.Tags.Add("upnp_rtp_map", new UPnP_NAT_Map(true, "UDP", "", rtpPublicPort.ToString(), rtpSession.LocalEP.IP.ToString(), rtpSession.LocalEP.RtpEP.Port, "LS RTP", 0)); mediaStream.Tags.Add("upnp_rtcp_map", new UPnP_NAT_Map(true, "UDP", "", rtcpPublicPort.ToString(), rtpSession.LocalEP.IP.ToString(), rtpSession.LocalEP.RtcpEP.Port, "LS RTCP", 0)); } catch { } } } if (rtpPublicEP != null && rtcpPublicEP != null) { mediaStream.Port = rtpPublicEP.Port; if ((rtpPublicEP.Port + 1) != rtcpPublicEP.Port) { // Remove old rport attribute, if any. for (int i = 0; i < mediaStream.Attributes.Count; i++) { if (string.Equals(mediaStream.Attributes[i].Name, "rport", StringComparison.InvariantCultureIgnoreCase)) { mediaStream.Attributes.RemoveAt(i); i--; } } mediaStream.Attributes.Add(new SDP_Attribute("rport", rtcpPublicEP.Port.ToString())); } mediaStream.Connection = new SDP_Connection("IN", "IP4", rtpPublicEP.Address.ToString()); return true; } return false; }
/// <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; }
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> /// 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> /// 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; }