Beispiel #1
0
        public static IEnumerable <byte> CreatePacketHeader(Common.IPacket packet, int offset)
        {
            //Only the packet and offset are really needed.

            //len (2)
            //plen (2)
            //offset (4)

            if (!BitConverter.IsLittleEndian)
            {
                return(BitConverter.GetBytes((ushort)(packet.Length + sizeOf_RD_packet_T)).
                       Concat
                           (packet is Rtcp.RtcpPacket ?
                           BitConverter.GetBytes((ushort)0)
                :
                           BitConverter.GetBytes((ushort)(packet.Length)).Concat(BitConverter.GetBytes(offset))));
            }

            return(BitConverter.GetBytes((ushort)(packet.Length + sizeOf_RD_packet_T)).Reverse().
                   Concat
                       (packet is Rtcp.RtcpPacket ?
                       BitConverter.GetBytes((ushort)0)
            :
                       BitConverter.GetBytes((ushort)(packet.Length)).Reverse()).Concat(BitConverter.GetBytes(offset).Reverse()));
        }
 void RtpClientPacketReceieved(object sender, Common.IPacket packet)
 {
     if (sender is Rtp.RtpClient)
     {
         WritePacket(Attached.Keys.FirstOrDefault(s => (s as RtpSource).RtpClient == sender as Rtp.RtpClient), packet);
     }
 }
 void RtpClientPacketReceieved(object sender, Common.IPacket packet = null, Media.Rtp.RtpClient.TransportContext tc = null)
 {
     if (sender is Rtp.RtpClient)
     {
         WritePacket(Attached.Keys.FirstOrDefault(s => (s as RtpSource).RtpClient == sender as Rtp.RtpClient), packet);
     }
 }
Beispiel #4
0
 public void EnquePacket(Common.IPacket packet)
 {
     if (RtpClient != null)
     {
         Packets.Enqueue(packet);
     }
 }
Beispiel #5
0
        internal virtual void SendPackets()
        {
            while (State == StreamState.Started)
            {
                try
                {
                    if (Packets.Count == 0)
                    {
                        System.Threading.Thread.Sleep(0);
                        continue;
                    }

                    //Dequeue a frame or die
                    Common.IPacket packet = Packets.Dequeue();

                    SendPacket(packet);

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

                    //Check for bandwidth and sleep if necessary
                }
                catch (Exception ex)
                {
                    if (ex is System.Threading.ThreadAbortException)
                    {
                        return;
                    }
                    continue;
                }
            }
        }
Beispiel #6
0
        public void EnquePacket(Common.IPacket packet)
        {
            if (Common.IDisposedExtensions.IsNullOrDisposed(RtpClient) ||
                Common.IDisposedExtensions.IsNullOrDisposed(packet))
            {
                return;
            }

            Packets.Enqueue(packet);
        }
Beispiel #7
0
        //

        public void SendPacket(Common.IPacket packet)
        {
            if (RtpClient != null)
            {
                if (packet is Rtp.RtpPacket)
                {
                    RtpClient.OnRtpPacketReceieved(packet as Rtp.RtpPacket);
                }
                else if (packet is Rtcp.RtcpPacket)
                {
                    RtpClient.OnRtcpPacketReceieved(packet as Rtcp.RtcpPacket);
                }
            }
        }
Beispiel #8
0
        public void SendPacket(Common.IPacket packet)
        {
            if (Common.IDisposedExtensions.IsNullOrDisposed(RtpClient) ||
                Common.IDisposedExtensions.IsNullOrDisposed(packet))
            {
                return;
            }

            if (packet is Rtp.RtpPacket)
            {
                RtpClient.OnRtpPacketReceieved(packet as Rtp.RtpPacket);
            }
            else if (packet is Rtcp.RtcpPacket)
            {
                RtpClient.OnRtcpPacketReceieved(packet as Rtcp.RtcpPacket);
            }
        }
        //Writes a RtpToolEntry for the packet
        public virtual void WritePacket(IMedia stream, Common.IPacket packet)
        {
            if (stream == null)
            {
                return;
            }

            RtpTools.RtpDump.Program program;
            if (!Attached.TryGetValue(stream, out program))
            {
                return;
            }

            if (packet is Rtp.RtpPacket)
            {
                program.Writer.WritePacket(packet as Rtp.RtpPacket);
            }
            program.Writer.WritePacket(packet as Rtcp.RtcpPacket);
        }
Beispiel #10
0
 public RtpToolEntry(DateTime timeBase, System.Net.IPEndPoint source, Common.IPacket packet, int?offset = null, long?fileOffset = null)
     : this(timeBase, source, FileFormat.Binary, CreatePacketHeader(packet, offset ?? 0).Concat(packet.Prepare()).ToArray(), offset, fileOffset)
 {
     BlobLength = (int)(sizeOf_RD_packet_T + packet.Length);
 }
Beispiel #11
0
        //http://net7mma.codeplex.com/workitem/17176
        //Text entries will need another constructor

        public RtpToolEntry(DateTime timeBase, System.Net.IPEndPoint source, Common.IPacket packet, int?offset = null, long?fileOffset = null, FileFormat format = FileFormat.Binary, bool shouldDispose = true)
            : this(timeBase, source, format, format >= FileFormat.Binary ? CreatePacketHeader(packet, offset ?? 0).Concat(packet.Prepare()).ToArray() : null, offset, fileOffset, shouldDispose)
        {
            BlobLength = format >= FileFormat.Binary ? (int)(sizeOf_RD_packet_T + packet.Length) : 0;
        }