示例#1
0
        public static VideoInfo Decode(Stream sm)
        {
            string videoId   = PacketBase.ReadString(sm);
            int    streamId  = PacketBase.ReadInt(sm);
            string videoName = PacketBase.ReadString(sm);

            return(new VideoInfo(videoId, streamId, videoName));
        }
示例#2
0
        public static MessagePacket Decode(Stream ms)
        {
            MessageType type    = (MessageType)PacketBase.ReadInt(ms);
            string      message = PacketBase.ReadString(ms);
            string      operate = PacketBase.ReadString(ms);

            return(new MessagePacket(type, message, operate));
        }
示例#3
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));
        }
示例#4
0
        public static new DownloadInfoParam Decode(Stream stream)
        {
            string sourceIp     = PacketBase.ReadString(stream);
            int    sourcePort   = PacketBase.ReadInt(stream);
            string downloadPath = PacketBase.ReadString(stream);
            var    param        = VideoBaseInfomParam.Decode(stream);

            return(new DownloadInfoParam(sourceIp, sourcePort, param, downloadPath));
        }
示例#5
0
        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));
        }
示例#6
0
        public static new IDownloadInfo[] DecodeArray(Stream stream)
        {
            int len = PacketBase.ReadInt(stream);

            IDownloadInfo[] infos = new IDownloadInfo[len];
            for (int i = 0; i < len; i++)
            {
                infos[i] = Decode(stream);
            }
            return(infos);
        }
        public static DownloadInfoExpandPacket[] DecodeArray(MemoryStream ms)
        {
            int length = PacketBase.ReadInt(ms);

            DownloadInfoExpandPacket[] packets = new DownloadInfoExpandPacket[length];
            for (int i = 0; i < packets.Length; i++)
            {
                packets[i] = DownloadInfoExpandPacket.Decode(ms);
            }
            return(packets);
        }
示例#8
0
        public static TimePeriodPacket[] DecodeArray(Stream ms)
        {
            int tiLen = PacketBase.ReadInt(ms);

            TimePeriodPacket[] tis = new TimePeriodPacket[tiLen];
            for (int i = 0; i < tiLen; i++)
            {
                tis[i] = TimePeriodPacket.Decode(ms);
            }
            return(tis);
        }
示例#9
0
        public static VideoInfo[] DecodeArray(Stream stream)
        {
            int len = PacketBase.ReadInt(stream);

            VideoInfo[] vInfos = new VideoInfo[len];
            for (int i = 0; i < len; i++)
            {
                vInfos[i] = VideoInfo.Decode(stream);
            }
            return(vInfos);
        }
示例#10
0
        public static VideoStreamsPacket Decode(MemoryStream ms)
        {
            TimePeriodPacket ti = TimePeriodPacket.Decode(ms);
            int length          = PacketBase.ReadInt(ms);

            StreamPacket[] spList = new StreamPacket[length];
            for (int i = 0; i < length; i++)
            {
                spList[i] = StreamPacket.Decode(ms);
            }
            return(new VideoStreamsPacket(ti, spList));
        }
示例#11
0
        public static LocalVideosInfoPacket Decode(Stream ms)
        {
            ITimePeriod tp     = TimePeriodPacket.Decode(ms);
            int         length = PacketBase.ReadInt(ms);

            VideoTimePeriodsPacket[] vis = new VideoTimePeriodsPacket[length];
            for (int i = 0; i < length; i++)
            {
                vis[i] = VideoTimePeriodsPacket.Decode(ms);
            }
            return(new LocalVideosInfoPacket(tp, vis));
        }
示例#12
0
        public static FfmpegHeaderPacket Decode(MemoryStream ms)
        {
            int videoType = PacketBase.ReadInt(ms);

            if (videoType != (int)VideoType.Ffmpeg)
            {
                return(null);
            }
            int    streamId   = PacketBase.ReadInt(ms);
            string streamName = PacketBase.ReadString(ms);
            string streamUrl  = PacketBase.ReadString(ms);
            int    codecId    = PacketBase.ReadInt(ms);
            int    width      = PacketBase.ReadInt(ms);
            int    height     = PacketBase.ReadInt(ms);

            return(new FfmpegHeaderPacket(streamId, streamName, streamUrl, codecId, width, height));
        }
示例#13
0
        public static DownloadExpandPart Decode(MemoryStream ms)
        {
            Guid         guid = PacketBase.ReadGuid(ms);
            DownloadCode code = (DownloadCode)PacketBase.ReadInt(ms);
            Object       obj  = null;

            switch (code)
            {
            case DownloadCode.DownloadInfo:
                obj = DownloadInfoParam.Decode(ms);
                break;

            case DownloadCode.Name:
            case DownloadCode.Quality:
            case DownloadCode.ErrorInfo:
                obj = PacketBase.ReadString(ms);
                break;

            case DownloadCode.Size:
            case DownloadCode.Speed:
                obj = PacketBase.ReadLong(ms);
                break;

            case DownloadCode.IsLocalDownload:
                obj = PacketBase.ReadBool(ms);
                break;

            case DownloadCode.TimePeriodsAll:
            case DownloadCode.TimePeriodsCompleted:
                obj = TimePeriodPacket.DecodeArray(ms);
                break;

            case DownloadCode.Status:
                obj = (DownloadStatus)PacketBase.ReadInt(ms);
                break;

            case DownloadCode.UpdatedLastestTime:
                obj = PacketBase.ReadTime(ms);
                break;

            case DownloadCode.GoTop:
                obj = null;
                break;
            }
            return(new DownloadExpandPart(guid, code, obj));
        }
示例#14
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));
        }
        public static DownloadInfoExpandPacket Decode(MemoryStream ms)
        {
            Guid          guid            = PacketBase.ReadGuid(ms);
            IDownloadInfo di              = DownloadInfoParam.Decode(ms);
            string        name            = PacketBase.ReadString(ms);
            string        quality         = PacketBase.ReadString(ms);
            long          size            = PacketBase.ReadLong(ms);
            bool          isLocalDownload = PacketBase.ReadBool(ms);

            TimePeriodPacket[] tps       = TimePeriodPacket.DecodeArray(ms);
            TimePeriodPacket[] tpsc      = TimePeriodPacket.DecodeArray(ms);
            DownloadStatus     status    = (DownloadStatus)PacketBase.ReadInt(ms);
            string             errorInfo = PacketBase.ReadString(ms);
            DateTime           time      = PacketBase.ReadTime(ms);
            long speed = PacketBase.ReadLong(ms);

            return(new DownloadInfoExpandPacket(guid, di, name, quality, size, isLocalDownload, tps, tpsc, status, errorInfo, time, speed));
        }
示例#16
0
        public static VideoDataInfoParam Decode(MemoryStream ms)
        {
            string sourceIp   = PacketBase.ReadString(ms);
            int    sourcePort = PacketBase.ReadInt(ms);

            int count = PacketBase.ReadInt(ms);

            VideoInfo[] vis = new VideoInfo[count];
            for (int i = 0; i < count; i++)
            {
                string videoId  = PacketBase.ReadString(ms);
                int    streamId = PacketBase.ReadInt(ms);
                vis[i] = new VideoInfo(videoId, streamId);
            }
            DateTime beginTime = PacketBase.ReadTime(ms);
            DateTime endTime   = PacketBase.ReadTime(ms);

            return(new VideoDataInfoParam(sourceIp, sourcePort, vis, beginTime, endTime));
        }
        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;
            }
        }