Пример #1
0
        public static VideoDataParam Decode(MemoryStream ms)
        {
            VideoInfo videoInfo = VideoInfo.Decode(ms);
            DateTime  time      = PacketBase.ReadTime(ms);

            return(new VideoDataParam(videoInfo, time));
        }
Пример #2
0
        public static TimePeriodPacket Decode(Stream ms)
        {
            DateTime beginTime = PacketBase.ReadTime(ms);
            DateTime endTime   = PacketBase.ReadTime(ms);

            return(new TimePeriodPacket(beginTime, endTime));
        }
Пример #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 IndexesPacket Decode(byte[] buffer)
 {
     using (MemoryStream ms = new MemoryStream(buffer))
     {
         DateTime beginTime  = PacketBase.ReadTime(ms);
         DateTime endTime    = PacketBase.ReadTime(ms);
         long     startIndex = PacketBase.ReadLong(ms);
         return(new IndexesPacket(beginTime, endTime, startIndex));
     }
 }
Пример #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 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));
        }
        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));
        }
Пример #8
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));
        }