Пример #1
0
        public Common.SegmentStream GetSample(Container.Track track, out TimeSpan duration)
        {
            Rtp.RtpFrame result = new Rtp.RtpFrame(0);

            while (HasNext)
            {
                Rtp.RtpPacket next = new Rtp.RtpPacket(ReadNext().Data.ToArray(), 0);
                if (result.Count > 0 && next.Timestamp != result.Timestamp)
                {
                    break;
                }
                result.Add(next);
                if (next.Marker)
                {
                    break;
                }
            }

            duration = TimeSpan.FromMilliseconds(90 * result.Count);

            //return result.Assemble().ToArray();

            result.Depacketize();

            return(result.Buffer);
        }
Пример #2
0
 /// <summary>
 /// Creates a new JpegFrame from an existing RtpFrame which has the JpegFrame PayloadType
 /// </summary>
 /// <param name="f">The existing frame</param>
 public RFC2435Frame(Rtp.RtpFrame f) : base(f)
 {
     if (PayloadTypeByte != RFC2435Frame.RtpJpegPayloadType)
     {
         throw new ArgumentException("Expected the payload type 26, Found type: " + f.PayloadTypeByte);
     }
 }
Пример #3
0
            public virtual void Depacketize(Rtp.RtpFrame rtpFrame)
            {
                DisposeBuffer();

                this.Buffer = new MemoryStream();

                //Get all packets in the frame
                foreach (Rtp.RtpPacket packet in rtpFrame)
                {
                    ProcessPacket(packet);
                }

                //Order by DON?
                this.Buffer.Position = 0;
            }
Пример #4
0
 public RFC3640Frame(Rtp.RtpFrame existing) : base(existing)
 {
 }
Пример #5
0
 public RFC5577Frame(Rtp.RtpFrame existing) : base(existing)
 {
 }
Пример #6
0
 public RFC5404Frame(Rtp.RtpFrame existing) : base(existing)
 {
 }
Пример #7
0
 public RFC4629Frame(Rtp.RtpFrame existing) : base(existing)
 {
 }
Пример #8
0
 public RFC6416Frame(Rtp.RtpFrame existing) : base(existing)
 {
 }
Пример #9
0
 public RFC2190Frame(Rtp.RtpFrame existing) : base(existing)
 {
 }
Пример #10
0
 /// <summary>
 /// Add a frame of existing packetized data
 /// </summary>
 /// <param name="frame">The frame with packets to send</param>
 public void AddFrame(Rtp.RtpFrame frame)
 {
     try { m_Frames.Enqueue(frame); }
     catch { throw; }
 }
Пример #11
0
 public RFC6184Frame(Rtp.RtpFrame existing)
     : base(existing)
 {
     m_ContainedNalTypes = new List <byte>();
 }
Пример #12
0
 public RFC6184Frame(Rtp.RtpFrame existing) : base(existing)
 {
 }
Пример #13
0
 public RFC4867Frame(Rtp.RtpFrame existing) : base(existing)
 {
 }
Пример #14
0
 public RFC4734Frame(Rtp.RtpFrame existing) : base(existing)
 {
 }
Пример #15
0
        //Needs to only send packets and not worry about updating the frame, that should be done by ImageSource

        internal override void SendPackets()
        {
            m_RtpClient.FrameChangedEventsEnabled = false;

            while (State == StreamState.Started)
            {
                try
                {
                    if (m_Frames.Count == 0)
                    {
                        m_RtpClient.m_WorkerThread.Priority = System.Threading.ThreadPriority.Lowest;

                        System.Threading.Thread.Sleep(clockRate);

                        continue;
                    }

                    int period = (clockRate * 1000 / m_Frames.Count);

                    //Dequeue a frame or die
                    Rtp.RtpFrame frame = m_Frames.Dequeue();

                    if (frame == null || frame.IsDisposed)
                    {
                        continue;
                    }

                    //Get the transportChannel for the packet
                    Rtp.RtpClient.TransportContext transportContext = RtpClient.GetContextBySourceId(frame.SynchronizationSourceIdentifier);

                    //If there is a context
                    if (transportContext != null)
                    {
                        //Increase priority
                        m_RtpClient.m_WorkerThread.Priority = System.Threading.ThreadPriority.AboveNormal;

                        transportContext.RtpTimestamp += period;

                        foreach (Rtp.RtpPacket packet in frame)
                        {
                            //Copy the values before we signal the server
                            //packet.Channel = transportContext.DataChannel;
                            packet.SynchronizationSourceIdentifier = (int)sourceId;
                            packet.Timestamp = (int)transportContext.RtpTimestamp;

                            //Increment the sequence number on the transportChannel and assign the result to the packet
                            packet.SequenceNumber = ++transportContext.SequenceNumber;

                            //Fire an event so the server sends a packet to all clients connected to this source
                            if (false == m_RtpClient.FrameChangedEventsEnabled)
                            {
                                RtpClient.OnRtpPacketReceieved(packet);
                            }
                        }

                        //Modified packet is no longer complete because SequenceNumbers were modified

                        //Fire a frame changed event manually
                        if (m_RtpClient.FrameChangedEventsEnabled)
                        {
                            RtpClient.OnRtpFrameChanged(frame);
                        }

                        unchecked { ++m_FramesPerSecondCounter; }
                    }

                    //If we are to loop images then add it back at the end
                    if (Loop)
                    {
                        m_Frames.Enqueue(frame);
                    }

                    System.Threading.Thread.Sleep(clockRate);
                }
                catch (Exception ex)
                {
                    if (ex is System.Threading.ThreadAbortException)
                    {
                        //Handle the abort
                        System.Threading.Thread.ResetAbort();

                        Stop();

                        return;
                    }
                    continue;
                }
            }
        }
Пример #16
0
 public RFC3952Frame(Rtp.RtpFrame existing) : base(existing)
 {
 }
Пример #17
0
 public RFC5215Frame(Rtp.RtpFrame existing) : base(existing)
 {
 }
Пример #18
0
 public RFC5391Frame(Rtp.RtpFrame existing) : base(existing)
 {
 }
Пример #19
0
 public RFC6295Frame(Rtp.RtpFrame existing) : base(existing)
 {
 }
Пример #20
0
 public RFC5993Frame(Rtp.RtpFrame existing) : base(existing)
 {
 }
Пример #21
0
 public RFC4421Frame(Rtp.RtpFrame existing) : base(existing)
 {
 }