Esempio n. 1
0
        public static MetadataBlock New(FlacStream stream)
        {
            MetadataBlockHeader header = new MetadataBlockHeader();
            header.Read(stream);

            MetadataBlock block = GetBlock(header);
            block.Read(stream);
            return block;
        }
Esempio n. 2
0
 private static MetadataBlock GetBlock(MetadataBlockHeader header)
 {
     MetadataBlock block;
     switch (header.BlockType)
     {
         case 0:
         {
             block = new MetadataBlockStreamInfo(header);
             break;
         }
         case 1:
         {
             block = new MetadataBlockPadding(header);
             break;
         }
         case 2:
         case 3:
         case 4:
         case 5:
         case 6:
         {
             // we won't read any block except streaminfo
             // skip over them all.
             // think of them as padding.
             block = new MetadataBlockPadding(header);
             break;
         }
         case 127:
         {
             throw new FlacFormatInvalidException();
         }
         default:
         {
             throw new FlacFormatReservedException();
         }
     }
     return block;
 }
Esempio n. 3
0
 protected MetadataBlock(MetadataBlockHeader header)
 {
     header_ = header;
 }
 public MetadataBlockPadding(MetadataBlockHeader header)
     : base(header)
 {
 }
 public MetadataBlockStreamInfo(MetadataBlockHeader header)
     : base(header)
 {
 }
 public MetadataBlockVorbisComment(MetadataBlockHeader header, byte [] blockData)
     : base(header)
 {
     blockData_ = blockData;
 }
Esempio n. 7
0
        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();
        }