MP3:XingFrame VBR

小站开通了:http://noteba.com/ 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.IO;

namespace WindowsFormsApplication1
{
    public class XingFrame
    {
        private MP3Stream mp3Stream;
       


        private bool _framesFlag;
        public bool FramesFlag
        {
            get { return _framesFlag; }
        }

        private bool _bytesFlag;
        public bool BytesFlag
        {
            get { return _bytesFlag; }
        }

        private bool _TOCFlag;
        public bool TOCFlag
        {
            get { return _TOCFlag; }
        }

        private bool _VBRScaleFlag;
        public bool VBRScaleFlag
        {
            get { return _VBRScaleFlag; }
        }


        private int _framesCount;
        //帧数量
        public int FramesCount
        {
            get { return _framesCount; }
        }

        private int _fileLength;
        ///


        /// 文件长度
        ///

        public int FileLength
        {
            get { return _fileLength; }
        }


        private byte[] tocTable;

        private byte[] vbrScale;


        private int _frameTime = 26;
        ///


        /// 毫秒(MS)
        ///

        public int FrameTime
        {
            get { return _frameTime; }
        }

     

        public XingFrame(MP3Stream stream)
        {
            mp3Stream = stream;

            mp3Stream.Seek(3, SeekOrigin.Current);
            byte flag = mp3Stream.ReadByte();

            _framesFlag = (flag & 0x01) == 0x01;
            _bytesFlag = (flag & 0x02) == 0x02;
            _TOCFlag = (flag & 0x04) == 0x04;
            _VBRScaleFlag = (flag & 0x08) == 0x08;

            _framesCount = (int)mp3Stream.ReadUInt(4);
            _fileLength = (int)mp3Stream.ReadUInt(4);

          
            tocTable = new byte[100];
            mp3Stream.Read(tocTable, 0, 100);


            vbrScale = new byte[4];
            mp3Stream.Read(vbrScale, 0, 4);

        }
    }

}

你可能感兴趣的:(MP3:XingFrame VBR)