Exemple #1
0
        public static StreamPacket Decode(MemoryStream ms)
        {
            DateTime time   = PacketBase.ReadTime(ms);
            DataType type   = (DataType)PacketBase.ReadInt(ms);
            int      length = PacketBase.ReadInt(ms);

            byte[] buf = PacketBase.ReadByteArray(ms, length);
            return(new StreamPacket(time, type, buf));
        }
        public static VideoBasePacket Decode(Stream ms)
        {
            DateTime time    = PacketBase.ReadTime(ms);
            int      headLen = PacketBase.ReadInt(ms);

            byte[] header = PacketBase.ReadByteArray(ms, headLen);
            long   length = PacketBase.ReadLong(ms);

            return(new VideoBasePacket(header, time, length));
        }
Exemple #3
0
        public static HikHeaderPacket Decode(MemoryStream ms)
        {
            int videoType = PacketBase.ReadInt(ms);

            if (videoType != (int)VideoType.Hik)
            {
                return(null);
            }
            int    streamId   = PacketBase.ReadInt(ms);
            string streamName = PacketBase.ReadString(ms);
            string streamUrl  = PacketBase.ReadString(ms);
            int    type       = PacketBase.ReadInt(ms);
            int    length     = PacketBase.ReadInt(ms);

            byte[] buffer = PacketBase.ReadByteArray(ms, length);
            return(new HikHeaderPacket(streamId, streamName, streamUrl, type, buffer));
        }
        private void readPacket(Stream ms)
        {
            int length = PacketBase.ReadInt(ms);
            int code   = PacketBase.ReadInt(ms);

            byte[] buffer = PacketBase.ReadByteArray(ms, length - 4);
            switch ((ParamCode)code)
            {
            case ParamCode.VideoBaseInfo:
                if (buffer.Length > 20 && (VideoBase == null || VideoBase.Length == 0))
                {
                    VideoBase = VideoBasePacket.Decode(buffer);
                }
                break;

            case ParamCode.TimePeriods:
                TimePeriods = VideoTimePeriodsPacket.Decode(buffer);
                break;

            case ParamCode.DownloadBase:
                DownloadInfo = DownloadInfoParam.Decode(buffer);
                break;
            }
        }
Exemple #5
0
        private static byte[] readStream(Stream ms)
        {
            int length = readInt(ms);

            return(PacketBase.ReadByteArray(ms, length - 4));
        }