Exemplo n.º 1
0
        public List <MUX> ParseEntireMUX(Stream currentStream)
        {
            List <MUX>           muxs             = new List <MUX>();
            MultiplexFrameHeader _mf1ConfigHeader = ParseMultiplexFrameHeader(0, currentStream);

            // 解析 控制帧
            int offset = SearchServiceMultiplexConfigTable(currentStream, _mf1ConfigHeader);

            if (offset != -1)
            {
                ParseServiceMultiplexConfigTable(offset, currentStream);
            }

            // fill the MF length
            foreach (var v in _msConfigTable.mfConfigTables)
            {
                uint len = MFLengthLookupTable(v);
                v.Length = len;
            }

            // 初始化结束,开始解视频帧
            uint offset2 = _msConfigTable.mfConfigTables[0].Length + _msConfigTable.mfConfigTables[1].Length;

            for (int i = 2; i < _msConfigTable.mpFameNum; i++)
            {
                uint offset3 = offset2;
                MUX  mux     = new MUX();
                mux.stream = currentStream;
                // 从第二个复用帧开始
                mux.muxHeader = ParseMultiplexFrameHeader((int)offset3, currentStream);
                offset3      += mux.muxHeader.headerLength + CRC_Size;

                mux.msf           = new MSF();
                mux.msf.msfHeader = ParseMSFHeader((int)offset3, currentStream);

                // 解析视频段’
                offset3           += mux.msf.msfHeader.Length + CRC_Size;
                mux.msf.videoBlock = ParseVideoBlock((int)offset3, currentStream);
                //TODO 解析 音频段
                offset3           += mux.msf.msfHeader.VideoBlockLenth;
                mux.msf.audioBlock = ParseAudioBlock((int)offset3, currentStream);

                // the next
                muxs.Add(mux);
                offset2 += _msConfigTable.mfConfigTables[i].Length;
            }
            return(muxs);
        }
Exemplo n.º 2
0
        public List<MUX> ParseEntireMUX(Stream currentStream)
        {
            List<MUX> muxs = new List<MUX>();
            MultiplexFrameHeader _mf1ConfigHeader = ParseMultiplexFrameHeader(0, currentStream);

            // 解析 控制帧
            int offset = SearchServiceMultiplexConfigTable(currentStream, _mf1ConfigHeader);
            if (offset != -1)
                ParseServiceMultiplexConfigTable(offset, currentStream);

            // fill the MF length
            foreach (var v in _msConfigTable.mfConfigTables)
            {
                uint len = MFLengthLookupTable(v);
                v.Length = len;
            }

            // 初始化结束,开始解视频帧
            uint offset2 = _msConfigTable.mfConfigTables[0].Length + _msConfigTable.mfConfigTables[1].Length;
            for (int i = 2; i < _msConfigTable.mpFameNum; i++)
            {
                uint offset3 = offset2;
                MUX mux = new MUX();
                mux.stream = currentStream;
                // 从第二个复用帧开始
                mux.muxHeader = ParseMultiplexFrameHeader((int)offset3, currentStream);
                offset3 += mux.muxHeader.headerLength + CRC_Size;

                mux.msf = new MSF();
                mux.msf.msfHeader = ParseMSFHeader((int)offset3, currentStream);

                // 解析视频段’
                offset3 += mux.msf.msfHeader.Length + CRC_Size;
                mux.msf.videoBlock = ParseVideoBlock((int)offset3, currentStream);
                //TODO 解析 音频段
                offset3 += mux.msf.msfHeader.VideoBlockLenth;
                mux.msf.audioBlock = ParseAudioBlock((int)offset3, currentStream);

                // the next
                muxs.Add(mux);
                offset2 += _msConfigTable.mfConfigTables[i].Length;
            }
            return muxs;
        }