Esempio n. 1
0
 public static byte[] Encode(StandardHeaderPacket packet)
 {
     using (MemoryStream ms = new MemoryStream())
     {
         PacketBase.WriteBytes(ms, packet.CodecID);
         PacketBase.WriteBytes(ms, packet.Buffer.Length);
         PacketBase.WriteBytes(ms, packet.Buffer);
         return(ms.ToArray());
     }
 }
Esempio n. 2
0
        public static IHeaderPacket Decode(MemoryStream ms)
        {
            VideoPacketType type   = (VideoPacketType)PacketBase.ReadInt(ms);
            IHeaderPacket   packet = null;

            switch (type)
            {
            case VideoPacketType.HikvisionHeader:
                packet = HikHeaderPacket.Decode(ms);
                break;

            case VideoPacketType.FfmpegHeader:
                packet = StandardHeaderPacket.Decode(ms);
                break;
            }
            return(packet);
        }
Esempio n. 3
0
 public static byte[] Encoder(IHeaderPacket packet)
 {
     using (MemoryStream ms = new MemoryStream())
     {
         if (packet is HikHeaderPacket)
         {
             PacketBase.WriteBytes(ms, (int)VideoPacketType.HikvisionHeader);
             PacketBase.WriteBytes(ms, HikHeaderPacket.Encode(packet as HikHeaderPacket));
         }
         else if (packet is StandardHeaderPacket)
         {
             PacketBase.WriteBytes(ms, (int)VideoPacketType.FfmpegHeader);
             PacketBase.WriteBytes(ms, StandardHeaderPacket.Encode(packet as StandardHeaderPacket));
         }
         return(ms.ToArray());
     }
 }