Beispiel #1
0
        public void TestIsMissingPackets()
        {
            //Create a frame
            using (Media.Rtp.RtpFrame frame = new Media.Rtp.RtpFrame(0))
            {
                //Add packets to the frame
                for (int i = 0; i < 15; ++i)
                {
                    frame.Add(new Media.Rtp.RtpPacket(2, false, false,
                                                      Media.Common.MemorySegment.EmptyBytes)
                    {
                        SequenceNumber = i,
                        Marker         = i == 14
                    });
                }

                if (frame.IsMissingPackets)
                {
                    throw new Exception("Frame is missing packets");
                }

                if (false == frame.IsComplete)
                {
                    throw new Exception("Frame is not complete");
                }

                if (false == frame.HasMarker)
                {
                    throw new Exception("Frame does not have marker");
                }

                //Remove the marker packet
                frame.Remove(14);

                if (frame.IsComplete)
                {
                    throw new Exception("Frame is complete");
                }

                if (frame.HasMarker)
                {
                    throw new Exception("Frame has marker");
                }

                if (frame.IsMissingPackets)
                {
                    throw new Exception("Frame is missing packets");
                }

                //Remove the first packet
                frame.Remove(1);

                if (false == frame.IsMissingPackets)
                {
                    throw new Exception("Frame is not missing packets");
                }
            }
        }
Beispiel #2
0
        private void RTSPClient_RtpFrameChanged(object sender, Media.Rtp.RtpFrame frame = null, Media.Rtp.RtpClient.TransportContext tc = null, bool final = false)
        {
            if (InvokeRequired)
            {
                MethodInvoker del = delegate { RTSPClient_RtpFrameChanged(sender, frame, tc, final); };
                Invoke(del);
            }
            else
            {
                RTSPMessagesTextBox.AppendText("RTSPClient_RtpFrameChanged" + Environment.NewLine);
                RTSPMessagesTextBox.AppendText("@" + frame.Created.ToUniversalTime().ToString() + " - " + frame.ToString() + Environment.NewLine);

                frame.Depacketize();

                //If the frame has depacketize data
                if (frame.HasDepacketized)
                {
                    RTSPMessagesTextBox.AppendText("BufferSize = " + frame.Buffer.Length.ToString() + Environment.NewLine);
                    RTSPMessagesTextBox.AppendText("Packets = " + frame.Count.ToString() + Environment.NewLine);

                    System.IO.Stream buffer = frame.Buffer;

                    /*
                     * //Check for the expected length
                     * if (buffer.Length != frameCount) throw new Exception("More data in buffer than expected");
                     *
                     * //Read the buffer
                     * while (buffer.Position < frameCount)
                     * {
                     *      //If the byte is out of order then throw an exception
                     *      if (buffer.ReadByte() != expected++) throw new Exception("Data at wrong position");
                     * }
                     */
                }
                else
                {
                    RTSPMessagesTextBox.AppendText("Not DEPACKETIZED" + Environment.NewLine);
                }
            }
        }