Esempio n. 1
0
        //int videostreamid = -1;

        public uint ReadSynchroChunk(byte[] packet, ref uint pos, uint psize)
        {
            //long curpos = packet.Position;
            //packet.Position += pos;
            uint type;
            uint size;
            if (!MoLive.ReadVariableByte(packet, out type, ref pos, psize)
                || !MoLive.ReadVariableByte(packet, out size, ref pos, psize))
                goto LABEL_119;
            MoLiveChunk chunk = null;
            switch (type)
            {
                case 0:
                    pos += size;
                    //packet.Position = curpos;
                    return 0x100;
                case 1://MoLiveStreamVideo 
                    chunk = new MoLiveStreamVideo() { Id = 1, Size = 12, StreamIndex = -1 };
                    break;
                case 2://MoLiveStreamAudio
                    chunk = new MoLiveStreamAudio() { Id = 2, Size = 6, StreamIndex = -1 };
                    break;
                case 3://MoLiveStreamVideoWithLayout
                    chunk = new MoLiveStreamVideoWithLayout() { Id = 3, Size = 13, StreamIndex = -1, ImageRotation = 0 };
                    break;
                case 4://MoLiveStreamTimeline
                    chunk = new MoLiveStreamTimeline() { Id = 4, Size = 2, StreamIndex = -1 };
                    break;
                case 0x100000://MoLiveChunkFoo
                    chunk = new MoLiveChunkFoo() { Id = 0x100000, Size = 20 };
                    break;
            }
            if (chunk == null) return 0x44;
            if (chunk.Size != size || chunk.Read(packet, (int)pos) == 0)
            {
                //error
                return 0x45;
            }
            //if (chunk is MoLiveStreamVideo || chunk is MoLiveStreamVideoWithLayout)
            //    videostreamid = ((MoLiveStream)chunk).StreamIndex;
            Streams.Add(((MoLiveStream)chunk).StreamIndex, new Endpoint(chunk));
            pos += size;
            if (pos <= psize) return 0;
        LABEL_119:
            Desynchronize();
            //packet.Position = curpos;
            return 0x43u;
        }
Esempio n. 2
0
        //int videostreamid = -1;

        public uint ReadSynchroChunk(byte[] packet, ref uint pos, uint psize)
        {
            //long curpos = packet.Position;
            //packet.Position += pos;
            uint type;
            uint size;

            if (!MoLive.ReadVariableByte(packet, out type, ref pos, psize) ||
                !MoLive.ReadVariableByte(packet, out size, ref pos, psize))
            {
                goto LABEL_119;
            }
            MoLiveChunk chunk = null;

            switch (type)
            {
            case 0:
                pos += size;
                //packet.Position = curpos;
                return(0x100);

            case 1:    //MoLiveStreamVideo
                chunk = new MoLiveStreamVideo()
                {
                    Id = 1, Size = 12, StreamIndex = -1
                };
                break;

            case 2:    //MoLiveStreamAudio
                chunk = new MoLiveStreamAudio()
                {
                    Id = 2, Size = 6, StreamIndex = -1
                };
                break;

            case 3:    //MoLiveStreamVideoWithLayout
                chunk = new MoLiveStreamVideoWithLayout()
                {
                    Id = 3, Size = 13, StreamIndex = -1, ImageRotation = 0
                };
                break;

            case 4:    //MoLiveStreamTimeline
                chunk = new MoLiveStreamTimeline()
                {
                    Id = 4, Size = 2, StreamIndex = -1
                };
                break;

            case 0x100000:    //MoLiveChunkFoo
                chunk = new MoLiveChunkFoo()
                {
                    Id = 0x100000, Size = 20
                };
                break;
            }
            if (chunk == null)
            {
                return(0x44);
            }
            if (chunk.Size != size || chunk.Read(packet, (int)pos) == 0)
            {
                //error
                return(0x45);
            }
            //if (chunk is MoLiveStreamVideo || chunk is MoLiveStreamVideoWithLayout)
            //    videostreamid = ((MoLiveStream)chunk).StreamIndex;
            Streams.Add(((MoLiveStream)chunk).StreamIndex, new Endpoint(chunk));
            pos += size;
            if (pos <= psize)
            {
                return(0);
            }
LABEL_119:
            Desynchronize();
            //packet.Position = curpos;
            return(0x43u);
        }