Esempio n. 1
0
        /// <summary>
        /// Determines whether the specified Object is equal to the current Object.
        /// </summary>
        /// <param name="obj">The Object to compare with the current Object.</param>
        /// <returns>True if the specified Object is equal to the current Object; otherwise, false.</returns>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj is RTP_Address)
            {
                RTP_Address a = (RTP_Address)obj;
                if (!a.IP.Equals(IP))
                {
                    return(false);
                }
                if (a.DataPort != DataPort)
                {
                    return(false);
                }
                if (a.ControlPort != ControlPort)
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        /// <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(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 += delegate(object s, EventArgs e) { m_pSessions.Remove((RTP_Session)s); };
            m_pSessions.Add(session);

            OnSessionCreated(session);

            return(session);
        }
Esempio n. 3
0
        /// <summary>
        /// Removes specified target.
        /// </summary>
        /// <param name="target">Session remote target.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>target</b> is null reference.</exception>
        public void RemoveTarget(RTP_Address target)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            m_pTargets.Remove(target);
        }
Esempio n. 4
0
        /// <summary>
        /// Opens RTP session to the specified remote target.
        /// </summary>
        /// <remarks>Once RTP session opened, RTCP reports sent to that target and also each local sending stream data.</remarks>
        /// <param name="target">Session remote target.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>target</b> is null reference.</exception>
        /// <exception cref="ArgumentException">Is raised when any of the arguments has invalid values.</exception>
        public void AddTarget(RTP_Address target)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }
            if (m_pLocalEP.Equals(target))
            {
                throw new ArgumentException("Argument 'target' value collapses with property 'LocalEP'.",
                                            "target");
            }

            foreach (RTP_Address t in Targets)
            {
                if (t.Equals(target))
                {
                    throw new ArgumentException("Specified target already exists.", "target");
                }
            }

            m_pTargets.Add(target);
        }
Esempio n. 5
0
        /// <summary>
        /// Cleans up any resources being used.
        /// </summary>
        public void Dispose()
        {
            if (m_IsDisposed)
            {
                return;
            }
            m_IsDisposed = true;

            if (m_pRtcpTimer != null)
            {
                m_pRtcpTimer.Dispose();
                m_pRtcpTimer = null;
            }
            m_pSession = null;
            m_pLocalEP = null;
            m_pTargets = null;
            foreach (RTP_Source_Local source in m_pLocalSources.ToArray())
            {
                source.Dispose();
            }
            m_pLocalSources = null;
            m_pRtcpSource = null;
            foreach (RTP_Source source in m_pMembers.Values)
            {
                source.Dispose();
            }
            m_pMembers = null;
            m_pSenders = null;
            m_pConflictingEPs = null;
            m_pRtpReceiveBuffer = null;
            m_pRtcpReceiveBuffer = null;
            m_pRtpSocket.Close();
            m_pRtpSocket = null;
            m_pRtcpSocket.Close();
            m_pRtcpSocket = null;

            OnDisposed();

            Disposed = null;
            Closed = null;
            NewSendStream = null;
            NewReceiveStream = null;
        }
Esempio n. 6
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="session">Owner RTP multimedia session.</param>
        /// <param name="localEP">Local RTP end point.</param>
        /// <param name="clock">RTP media clock.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>localEP</b>, <b>localEP</b> or <b>clock</b> is null reference.</exception>
        internal RTP_Session(RTP_MultimediaSession session, RTP_Address localEP, RTP_Clock clock)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (localEP == null)
            {
                throw new ArgumentNullException("localEP");
            }
            if (clock == null)
            {
                throw new ArgumentNullException("clock");
            }

            m_pSession = session;
            m_pLocalEP = localEP;
            m_pRtpClock = clock;

            m_pRtpReceiveBuffer = new byte[Workaround.Definitions.MaxStreamLineLength];
            m_pRtcpReceiveBuffer = new byte[Workaround.Definitions.MaxStreamLineLength];

            m_pLocalSources = new List<RTP_Source_Local>();
            m_pTargets = new List<RTP_Address>();
            m_pMembers = new Dictionary<uint, RTP_Source>();
            m_pSenders = new Dictionary<uint, RTP_Source>();
            m_pConflictingEPs = new Dictionary<string, DateTime>();

            m_pRtpSocket = new Socket(localEP.IP.AddressFamily, SocketType.Dgram, ProtocolType.Udp);
            m_pRtpSocket.Bind(localEP.RtpEP);
            m_pRtcpSocket = new Socket(localEP.IP.AddressFamily, SocketType.Dgram, ProtocolType.Udp);
            m_pRtcpSocket.Bind(localEP.RtcpEP);

            m_pRtcpTimer = new TimerEx();
            m_pRtcpTimer.Elapsed += delegate { SendRtcp(); };
            m_pRtcpTimer.AutoReset = false;
        }
        /// <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(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 += delegate(object s, EventArgs e) { m_pSessions.Remove((RTP_Session) s); };
            m_pSessions.Add(session);

            OnSessionCreated(session);

            return session;
        }