예제 #1
0
 public JpegFrame(RtpFrame f) : base(f)
 {
     if (PayloadType != 26)
     {
         throw new ArgumentException("Expected the payload type 26, Found type: " + f.PayloadType);
     }
 }
예제 #2
0
        /// <summary>
        /// Adds a frame using the specified payloadType.
        /// </summary>
        /// <param name="payloadType"></param>
        /// <param name="frame"></param>
        public void Add(int payloadType, RtpFrame frame)
        {
            if (Common.IDisposedExtensions.IsNullOrDisposed(frame))
            {
                return;
            }

            Frames.Add(payloadType, frame);
        }
예제 #3
0
        /// <summary>
        /// Adds the given packet to the contained frames and provides the frame which was added to.
        /// </summary>
        /// <param name="payloadType">The payloadType to use for the add operation</param>
        /// <param name="packet">The packet to add</param>
        /// <param name="addedTo">The frame which the packet was added to.</param>
        /// <returns>True if <paramref name="addedTo"/> is complete (it is no longer contained), otherwise false.</returns>
        public bool Add(int payloadType, bool allowDuplicatePackets, bool allowPacketsAfterMarker, RtpPacket packet, out RtpFrame addedTo)
        {
            addedTo = null;

            if (Common.IDisposedExtensions.IsNullOrDisposed(packet))
            {
                return(false);
            }

            System.Collections.Generic.IList <RtpFrame> framesList;

            //Use the given payloadType to get frames
            if (Frames.TryGetValueList(ref payloadType, out framesList))
            {
                //loop the frames found
                foreach (RtpFrame frame in framesList)
                {
                    //if the timestamp is eqaul try to add the packet
                    if (frame.Timestamp == packet.Timestamp)
                    {
                        //Try to add the packet and if added return.
                        if (frame.TryAdd(packet, allowDuplicatePackets, allowPacketsAfterMarker))
                        {
                            addedTo = frame;

                            //If the add results in completion
                            if (frame.IsComplete)
                            {
                                //Remove the frame
                                framesList.Remove(frame);

                                //Return true
                                return(true);
                            }
                        }
                    }
                }

                //Must add a new frame to frames.
                addedTo = new RtpFrame(packet);

                if (addedTo.IsComplete)
                {
                    return(true);
                }

                Frames.Add(ref payloadType, ref addedTo);
            }

            return(false);
        }
예제 #4
0
        /// <summary>
        /// Clone and existing RtpFrame
        /// </summary>
        /// <param name="f">The frame to clonse</param>
        /// <param name="referencePackets">Indicate if contained packets should be referenced</param>
        public RtpFrame(RtpFrame f, bool referencePackets = false)
            : this(f.PayloadTypeByte)
        {
            m_Ssrc = f.m_Ssrc; m_Timestamp = f.m_Timestamp;

            //If this is a shallow clone then just use the reference
            if (!referencePackets)
            {
                m_Packets = f.m_Packets;
            }
            else
            {
                foreach (RtpPacket p in f)
                {
                    m_Packets.Add(p.SequenceNumber, p);                         //Otherwise make a new reference to each RtpPacket
                }
            }
        }
예제 #5
0
 public RtpFrame(RtpFrame f) : this(f.PayloadType)
 {
     m_Ssrc = f.m_Ssrc; m_TimeStamp = f.m_TimeStamp; m_Packets = f.m_Packets;
 }
예제 #6
0
 /// <summary>
 /// Adds the given frame using the PayloadType specified by the frame.
 /// </summary>
 /// <param name="frame"></param>
 public void Add(RtpFrame frame)
 {
     Add(frame.PayloadType, frame);
 }