示例#1
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;
        }
示例#2
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;
        }