public static MetadataBlock New(FlacStream stream) { MetadataBlockHeader header = new MetadataBlockHeader(); header.Read(stream); MetadataBlock block = GetBlock(header); block.Read(stream); return block; }
private void ReadHeader() { outStream_.Encode(); inStream_.Reader.Seek(4); MetadataBlockHeader h = new MetadataBlockHeader(); h.Read(inStream_); MetadataBlockStreamInfo si = new MetadataBlockStreamInfo(h); si.Read(inStream_); h.IsLastMetadataBlock = false; si.MinBlockSize = track_.MinBlockSize; si.MaxBlockSize = track_.MaxBlockSize; si.MinFrameSize = track_.MinFrameSize; si.MaxFrameSize = track_.MaxFrameSize; si.TotalSamples = track_.TotalSamples; si.Checksum[0] = 0; si.Checksum[1] = 0; si.Checksum[2] = 0; si.Checksum[3] = 0; si.Write(outStream_); long pos = outStream_.FileStream.Position; h = new MetadataBlockHeader(); h.IsLastMetadataBlock = true; h.BlockLengthInBytes = track_.Metadata.block.Length; h.BlockType = MetadataBlockHeader.METADATA_BLOCK_VORBIS_COMMENT; MetadataBlockVorbisComment vc = new MetadataBlockVorbisComment(h, track_.Metadata.block); vc.Write(outStream_); Debug.Assert(outStream_.FileStream.Position == pos + h.BlockLengthInBytes + 4); outStream_.FileStream.Flush(); header_ = ReadAllBytes(); }