コード例 #1
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="stream">RTP send stream.</param>
        public RTP_SendStreamEventArgs(RTP_SendStream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            m_pStream = stream;
        }
コード例 #2
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="stream">RTP send stream.</param>
        public RTP_SendStreamEventArgs(RTP_SendStream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            m_pStream = stream;
        }
コード例 #3
0
        /// <summary>
        /// Creates RTP send stream for this source.
        /// </summary>
        /// <exception cref="InvalidOperationException">Is raised when this method is called more than 1 times(source already created).</exception>
        internal void CreateStream()
        {
            if (m_pStream != null)
            {
                throw new InvalidOperationException("Stream is already created.");
            }

            m_pStream           = new RTP_SendStream(this);
            m_pStream.Disposed += delegate
            {
                m_pStream = null;
                Dispose();
            };

            SetState(RTP_SourceState.Active);
        }
コード例 #4
0
        /// <summary>
        /// Sends specified RTP packet to the session remote party.
        /// </summary>
        /// <param name="stream">RTP packet sending stream.</param>
        /// <param name="packet">RTP packet.</param>
        /// <returns>Returns packet size in bytes.</returns>
        /// <exception cref="ObjectDisposedException">Is raised when this class is Disposed and this method is accessed.</exception>
        /// <exception cref="ArgumentNullException">Is raised when <b>stream</b> or <b>packet</b> is null reference.</exception>
        internal int SendRtpPacket(RTP_SendStream stream, RTP_Packet packet)
        {
            if (m_IsDisposed)
            {
                throw new ObjectDisposedException(GetType().Name);
            }
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }
            if (packet == null)
            {
                throw new ArgumentNullException("packet");
            }

            // Check that we are in members table (because SSRC has timed out), add itself to senders table.
            lock (m_pMembers)
            {
                if (!m_pMembers.ContainsKey(stream.Source.SSRC))
                {
                    m_pMembers.Add(stream.Source.SSRC, stream.Source);
                }
            }

            // If we are not in sender table (because SSRC has timed out), add itself to senders table.
            lock (m_pSenders)
            {
                if (!m_pSenders.ContainsKey(stream.Source.SSRC))
                {
                    m_pSenders.Add(stream.Source.SSRC, stream.Source);
                }
            }

            byte[] packetBytes = new byte[m_MTU];
            int count = 0;
            packet.ToByte(packetBytes, ref count);

            // Send packet to each remote target.
            foreach (RTP_Address target in Targets)
            {
                try
                {
                    m_pRtpSocket.SendTo(packetBytes, count, SocketFlags.None, target.RtpEP);

                    m_RtpPacketsSent++;
                    m_RtpBytesSent += packetBytes.Length;
                }
                catch
                {
                    m_RtpFailedTransmissions++;
                }
            }

            return count;
        }
コード例 #5
0
 /// <summary>
 /// Raises <b>NewSendStream</b> event.
 /// </summary>
 /// <param name="stream">New send stream.</param>
 private void OnNewSendStream(RTP_SendStream stream)
 {
     if (NewSendStream != null)
     {
         NewSendStream(this, new RTP_SendStreamEventArgs(stream));
     }
 }
コード例 #6
0
        /// <summary>
        /// Creates RTP send stream for this source.
        /// </summary>
        /// <exception cref="InvalidOperationException">Is raised when this method is called more than 1 times(source already created).</exception>
        internal void CreateStream()
        {
            if (m_pStream != null)
            {
                throw new InvalidOperationException("Stream is already created.");
            }

            m_pStream = new RTP_SendStream(this);
            m_pStream.Disposed += delegate
                                      {
                                          m_pStream = null;
                                          Dispose();
                                      };

            SetState(RTP_SourceState.Active);
        }