public MSFHeader ParseMSFHeader(int offset, Stream _stream) { _stream.Seek(offset, SeekOrigin.Begin); byte[] tmp = new byte[4]; MSFHeader msfHeader = new MSFHeader(); _stream.Read(tmp, 0, 1); msfHeader.Length = tmp[0]; _stream.Read(tmp, 0, 1); msfHeader.VideoBlockIndicator = (uint)BitTools.MaskBits(tmp, 1, 1); msfHeader.AudioBlockIndicator = (uint)BitTools.MaskBits(tmp, 2, 1); msfHeader.DataBlockIndicator = (uint)BitTools.MaskBits(tmp, 3, 1); msfHeader.ExtBlockIndicator = (uint)BitTools.MaskBits(tmp, 4, 1); // 起始播放时间 if (BitTools.MaskBits(tmp, 0, 1) == 1) { _stream.Read(tmp, 0, 4); msfHeader.PlayStartTime = BitTools.MaskBits(tmp, 0, 32) * timeUint; } // 视频段信息 if (msfHeader.VideoBlockIndicator == 1) { _stream.Read(tmp, 0, 3); msfHeader.VideoBlockLenth = (uint)BitTools.MaskBits(tmp, 0, 21); msfHeader.VideoBlockNum = (uint)BitTools.MaskBits(tmp, 21, 3); } //音频段信息 if (msfHeader.AudioBlockIndicator == 1) { _stream.Read(tmp, 0, 3); msfHeader.AudioBlockLenth = (uint)BitTools.MaskBits(tmp, 0, 21); msfHeader.AudioBlockNum = (uint)BitTools.MaskBits(tmp, 21, 3); } if (msfHeader.DataBlockIndicator == 1) { _stream.Seek(3, SeekOrigin.Current); } if (msfHeader.ExtBlockIndicator == 1) { _stream.Seek(3, SeekOrigin.Current); } // 跳过视频和音频参数集 return(msfHeader); }
public MSFHeader ParseMSFHeader(int offset, Stream _stream) { _stream.Seek(offset, SeekOrigin.Begin); byte[] tmp = new byte[4]; MSFHeader msfHeader = new MSFHeader(); _stream.Read(tmp, 0, 1); msfHeader.Length = tmp[0]; _stream.Read(tmp, 0, 1); msfHeader.VideoBlockIndicator = (uint)BitTools.MaskBits(tmp, 1, 1); msfHeader.AudioBlockIndicator = (uint)BitTools.MaskBits(tmp, 2, 1); msfHeader.DataBlockIndicator = (uint)BitTools.MaskBits(tmp, 3, 1); msfHeader.ExtBlockIndicator = (uint)BitTools.MaskBits(tmp, 4, 1); // 起始播放时间 if (BitTools.MaskBits(tmp, 0, 1) == 1) { _stream.Read(tmp, 0, 4); msfHeader.PlayStartTime = BitTools.MaskBits(tmp, 0, 32) * timeUint ; } // 视频段信息 if (msfHeader.VideoBlockIndicator == 1) { _stream.Read(tmp, 0, 3); msfHeader.VideoBlockLenth = (uint)BitTools.MaskBits(tmp, 0, 21); msfHeader.VideoBlockNum = (uint)BitTools.MaskBits(tmp, 21, 3); } //音频段信息 if (msfHeader.AudioBlockIndicator == 1) { _stream.Read(tmp, 0, 3); msfHeader.AudioBlockLenth = (uint)BitTools.MaskBits(tmp, 0, 21); msfHeader.AudioBlockNum = (uint)BitTools.MaskBits(tmp, 21, 3); } if (msfHeader.DataBlockIndicator == 1) _stream.Seek(3, SeekOrigin.Current); if (msfHeader.ExtBlockIndicator == 1) _stream.Seek(3, SeekOrigin.Current); // 跳过视频和音频参数集 return msfHeader; }