当前位置: 首页>>代码示例>>C#>>正文


C# DataPacket.ReadBytes方法代码示例

本文整理汇总了C#中NVorbis.DataPacket.ReadBytes方法的典型用法代码示例。如果您正苦于以下问题:C# DataPacket.ReadBytes方法的具体用法?C# DataPacket.ReadBytes怎么用?C# DataPacket.ReadBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NVorbis.DataPacket的用法示例。


在下文中一共展示了DataPacket.ReadBytes方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadBooks

 private void LoadBooks(DataPacket packet)
 {
   packet.SkipBits(8);
   if (!Enumerable.SequenceEqual<byte>((IEnumerable<byte>) packet.ReadBytes(6), (IEnumerable<byte>) new byte[6]
   {
     (byte) 118,
     (byte) 111,
     (byte) 114,
     (byte) 98,
     (byte) 105,
     (byte) 115
   }))
     throw new InvalidDataException("Corrupted book header!");
   long bitsRead1 = packet.BitsRead;
   this._glueBits += packet.BitsRead;
   this.Books = new VorbisCodebook[(int) packet.ReadByte() + 1];
   for (int number = 0; number < this.Books.Length; ++number)
     this.Books[number] = VorbisCodebook.Init(this, packet, number);
   this._bookBits += packet.BitsRead - bitsRead1;
   long bitsRead2 = packet.BitsRead;
   this.Times = new VorbisTime[(int) packet.ReadBits(6) + 1];
   for (int index = 0; index < this.Times.Length; ++index)
     this.Times[index] = VorbisTime.Init(this, packet);
   this._timeHdrBits += packet.BitsRead - bitsRead2;
   long bitsRead3 = packet.BitsRead;
   this.Floors = new VorbisFloor[(int) packet.ReadBits(6) + 1];
   for (int index = 0; index < this.Floors.Length; ++index)
     this.Floors[index] = VorbisFloor.Init(this, packet);
   this._floorHdrBits += packet.BitsRead - bitsRead3;
   long bitsRead4 = packet.BitsRead;
   this.Residues = new VorbisResidue[(int) packet.ReadBits(6) + 1];
   for (int index = 0; index < this.Residues.Length; ++index)
     this.Residues[index] = VorbisResidue.Init(this, packet);
   this._resHdrBits += packet.BitsRead - bitsRead4;
   long bitsRead5 = packet.BitsRead;
   this.Maps = new VorbisMapping[(int) packet.ReadBits(6) + 1];
   for (int index = 0; index < this.Maps.Length; ++index)
     this.Maps[index] = VorbisMapping.Init(this, packet);
   this._mapHdrBits += packet.BitsRead - bitsRead5;
   long bitsRead6 = packet.BitsRead;
   this.Modes = new VorbisMode[(int) packet.ReadBits(6) + 1];
   for (int index = 0; index < this.Modes.Length; ++index)
     this.Modes[index] = VorbisMode.Init(this, packet);
   this._modeHdrBits += packet.BitsRead - bitsRead6;
   if (!packet.ReadBit())
     throw new InvalidDataException();
   ++this._glueBits;
   this._wasteHdrBits += (long) (8 * packet.Length) - packet.BitsRead;
   this._modeFieldBits = Utils.ilog(this.Modes.Length - 1);
 }
开发者ID:tanis2000,项目名称:FEZ,代码行数:50,代码来源:VorbisStreamDecoder.cs

示例2: TryInit

 internal bool TryInit(DataPacket initialPacket)
 {
   if (!Enumerable.SequenceEqual<byte>((IEnumerable<byte>) initialPacket.ReadBytes(7), (IEnumerable<byte>) new byte[7]
   {
     (byte) 1,
     (byte) 118,
     (byte) 111,
     (byte) 114,
     (byte) 98,
     (byte) 105,
     (byte) 115
   }))
   {
     this._glueBits += (long) (initialPacket.Length * 8);
     return false;
   }
   else
   {
     this._glueBits += 56L;
     this.ProcessStreamHeader(initialPacket);
     bool flag1 = false;
     bool flag2 = false;
     while (!(flag1 & flag2))
     {
       DataPacket packet = this._getNextPacket();
       if (packet.IsResync)
         throw new InvalidDataException("Missing header packets!");
       if (!this._pagesSeen.Contains(packet.PageSequenceNumber))
         this._pagesSeen.Add(packet.PageSequenceNumber);
       switch (packet.PeekByte())
       {
         case (byte) 1:
           throw new InvalidDataException("Found second init header!");
         case (byte) 3:
           this.LoadComments(packet);
           flag1 = true;
           continue;
         case (byte) 5:
           this.LoadBooks(packet);
           flag2 = true;
           continue;
         default:
           continue;
       }
     }
     this.InitDecoder();
     return true;
   }
 }
开发者ID:tanis2000,项目名称:FEZ,代码行数:49,代码来源:VorbisStreamDecoder.cs

示例3: LoadComments

 private void LoadComments(DataPacket packet)
 {
   packet.SkipBits(8);
   if (!Enumerable.SequenceEqual<byte>((IEnumerable<byte>) packet.ReadBytes(6), (IEnumerable<byte>) new byte[6]
   {
     (byte) 118,
     (byte) 111,
     (byte) 114,
     (byte) 98,
     (byte) 105,
     (byte) 115
   }))
     throw new InvalidDataException("Corrupted comment header!");
   this._glueBits += 56L;
   this._vendor = Encoding.UTF8.GetString(packet.ReadBytes(packet.ReadInt32()));
   this._comments = new string[packet.ReadInt32()];
   for (int index = 0; index < this._comments.Length; ++index)
     this._comments[index] = Encoding.UTF8.GetString(packet.ReadBytes(packet.ReadInt32()));
   this._metaBits += packet.BitsRead - 56L;
   this._wasteHdrBits += (long) (8 * packet.Length) - packet.BitsRead;
 }
开发者ID:tanis2000,项目名称:FEZ,代码行数:21,代码来源:VorbisStreamDecoder.cs

示例4: LoadBooks

        void LoadBooks(DataPacket packet)
        {
            packet.SkipBits(8);
            if ( !packet.ReadBytes ( 6 ).SequenceEqual ( new byte [] { 0x76, 0x6f, 0x72, 0x62, 0x69, 0x73 } ) ) throw new ArgumentException ( "Corrupted book header!" );

            var bits = packet.BitsRead;

            _glueBits += packet.BitsRead;

            // get books
            Books = new VorbisCodebook[packet.ReadByte() + 1];
            for (int i = 0; i < Books.Length; i++)
            {
                Books[i] = VorbisCodebook.Init(this, packet, i);
            }

            _bookBits += packet.BitsRead - bits;
            bits = packet.BitsRead;

            // get times
            Times = new VorbisTime[(int)packet.ReadBits(6) + 1];
            for (int i = 0; i < Times.Length; i++)
            {
                Times[i] = VorbisTime.Init(this, packet);
            }

            _timeHdrBits += packet.BitsRead - bits;
            bits = packet.BitsRead;

            // get floor
            Floors = new VorbisFloor[(int)packet.ReadBits(6) + 1];
            for (int i = 0; i < Floors.Length; i++)
            {
                Floors[i] = VorbisFloor.Init(this, packet);
            }

            _floorHdrBits += packet.BitsRead - bits;
            bits = packet.BitsRead;

            // get residue
            Residues = new VorbisResidue[(int)packet.ReadBits(6) + 1];
            for (int i = 0; i < Residues.Length; i++)
            {
                Residues[i] = VorbisResidue.Init(this, packet);
            }

            _resHdrBits += packet.BitsRead - bits;
            bits = packet.BitsRead;

            // get map
            Maps = new VorbisMapping[(int)packet.ReadBits(6) + 1];
            for (int i = 0; i < Maps.Length; i++)
            {
                Maps[i] = VorbisMapping.Init(this, packet);
            }

            _mapHdrBits += packet.BitsRead - bits;
            bits = packet.BitsRead;

            // get mode settings
            Modes = new VorbisMode[(int)packet.ReadBits(6) + 1];
            for (int i = 0; i < Modes.Length; i++)
            {
                Modes[i] = VorbisMode.Init(this, packet);
            }

            _modeHdrBits += packet.BitsRead - bits;

            // check the framing bit
            if ( !packet.ReadBit () ) throw new ArgumentException ();

            ++_glueBits;

            _wasteHdrBits += 8 * packet.Length - packet.BitsRead;

            _modeFieldBits = Utils.ilog(Modes.Length - 1);
        }
开发者ID:Daramkun,项目名称:Misty,代码行数:77,代码来源:VorbisStreamDecoder.cs

示例5: LoadComments

        void LoadComments(DataPacket packet)
        {
            byte [] temp;

            packet.SkipBits(8);
            if (!packet.ReadBytes(6).SequenceEqual(new byte[] { 0x76, 0x6f, 0x72, 0x62, 0x69, 0x73 })) throw new ArgumentException("Corrupted comment header!");

            _glueBits += 56;

            temp = packet.ReadBytes ( packet.ReadInt32 () );
            _vendor = Encoding.UTF8.GetString ( temp, 0, temp.Length );

            _comments = new string[packet.ReadInt32()];
            for (int i = 0; i < _comments.Length; i++)
            {
                temp = packet.ReadBytes ( packet.ReadInt32 () );
                _comments[i] = Encoding.UTF8.GetString( temp, 0, temp.Length );
            }

            _metaBits += packet.BitsRead - 56;
            _wasteHdrBits += 8 * packet.Length - packet.BitsRead;
        }
开发者ID:Daramkun,项目名称:Misty,代码行数:22,代码来源:VorbisStreamDecoder.cs

示例6: ProcessStreamHeader

        bool ProcessStreamHeader(DataPacket packet)
        {
            bool equal = true;
            byte[] sequence = new byte[] { 0x01, 0x76, 0x6f, 0x72, 0x62, 0x69, 0x73 };
            byte[] packets  = packet.ReadBytes(7);

            for (int i = 0; i < 7; i++)
            {
                if (packets[i] != sequence[i])
                {
                    equal = false;
                    break;
                }
            }

            if (!equal)
            {
                // don't mark the packet as done... it might be used elsewhere
                _glueBits += packet.Length * 8;
                return false;
            }

            if (!_pagesSeen.Contains((_lastPageSeen = packet.PageSequenceNumber))) _pagesSeen.Add(_lastPageSeen);

            _glueBits += 56;

            var startPos = packet.BitsRead;

            if (packet.ReadInt32() != 0) throw new InvalidDataException("Only Vorbis stream version 0 is supported.");

            _channels = packet.ReadByte();
            _sampleRate = packet.ReadInt32();
            _upperBitrate = packet.ReadInt32();
            _nominalBitrate = packet.ReadInt32();
            _lowerBitrate = packet.ReadInt32();

            Block0Size = 1 << (int)packet.ReadBits(4);
            Block1Size = 1 << (int)packet.ReadBits(4);

            if (_nominalBitrate == 0)
            {
                if (_upperBitrate > 0 && _lowerBitrate > 0)
                {
                    _nominalBitrate = (_upperBitrate + _lowerBitrate) / 2;
                }
            }

            _metaBits += packet.BitsRead - startPos + 8;

            _wasteHdrBits += 8 * packet.Length - packet.BitsRead;

            return true;
        }
开发者ID:SirusDoma,项目名称:nvorbis,代码行数:53,代码来源:VorbisStreamDecoder.cs

示例7: LoadComments

        bool LoadComments(DataPacket packet)
        {
            bool equal = true;
            byte[] sequence = new byte[] { 0x03, 0x76, 0x6f, 0x72, 0x62, 0x69, 0x73 };
            byte[] packets  = packet.ReadBytes(7);

            for (int i = 0; i < 7; i++)
            {
                if (packets[i] != sequence[i])
                {
                    equal = false;
                    break;
                }
            }

            if (!equal)
            {
                return false;
            }

            if (!_pagesSeen.Contains((_lastPageSeen = packet.PageSequenceNumber))) _pagesSeen.Add(_lastPageSeen);

            _glueBits += 56;

            _vendor = Encoding.UTF8.GetString(packet.ReadBytes(packet.ReadInt32()));

            _comments = new string[packet.ReadInt32()];
            for (int i = 0; i < _comments.Length; i++)
            {
                _comments[i] = Encoding.UTF8.GetString(packet.ReadBytes(packet.ReadInt32()));
            }

            _metaBits += packet.BitsRead - 56;
            _wasteHdrBits += 8 * packet.Length - packet.BitsRead;

            return true;
        }
开发者ID:SirusDoma,项目名称:nvorbis,代码行数:37,代码来源:VorbisStreamDecoder.cs

示例8: LoadBooks

        bool LoadBooks(DataPacket packet)
        {
            bool equal = true;
            byte[] sequence = new byte[] { 0x05, 0x76, 0x6f, 0x72, 0x62, 0x69, 0x73 };
            byte[] packets  = packet.ReadBytes(7);

            for (int i = 0; i < 7; i++)
            {
                if (packets[i] != sequence[i])
                {
                    equal = false;
                    break;
                }
            }

            if (!equal)
            {
                return false;
            }

            if (!_pagesSeen.Contains((_lastPageSeen = packet.PageSequenceNumber))) _pagesSeen.Add(_lastPageSeen);

            var bits = packet.BitsRead;

            _glueBits += packet.BitsRead;

            // get books
            Books = new VorbisCodebook[packet.ReadByte() + 1];
            for (int i = 0; i < Books.Length; i++)
            {
                Books[i] = VorbisCodebook.Init(this, packet, i);
            }

            _bookBits += packet.BitsRead - bits;
            bits = packet.BitsRead;

            // get times
            Times = new VorbisTime[(int)packet.ReadBits(6) + 1];
            for (int i = 0; i < Times.Length; i++)
            {
                Times[i] = VorbisTime.Init(this, packet);
            }

            _timeHdrBits += packet.BitsRead - bits;
            bits = packet.BitsRead;

            // get floor
            Floors = new VorbisFloor[(int)packet.ReadBits(6) + 1];
            for (int i = 0; i < Floors.Length; i++)
            {
                Floors[i] = VorbisFloor.Init(this, packet);
            }

            _floorHdrBits += packet.BitsRead - bits;
            bits = packet.BitsRead;

            // get residue
            Residues = new VorbisResidue[(int)packet.ReadBits(6) + 1];
            for (int i = 0; i < Residues.Length; i++)
            {
                Residues[i] = VorbisResidue.Init(this, packet);
            }

            _resHdrBits += packet.BitsRead - bits;
            bits = packet.BitsRead;

            // get map
            Maps = new VorbisMapping[(int)packet.ReadBits(6) + 1];
            for (int i = 0; i < Maps.Length; i++)
            {
                Maps[i] = VorbisMapping.Init(this, packet);
            }

            _mapHdrBits += packet.BitsRead - bits;
            bits = packet.BitsRead;

            // get mode settings
            Modes = new VorbisMode[(int)packet.ReadBits(6) + 1];
            for (int i = 0; i < Modes.Length; i++)
            {
                Modes[i] = VorbisMode.Init(this, packet);
            }

            _modeHdrBits += packet.BitsRead - bits;

            // check the framing bit
            if (!packet.ReadBit()) throw new InvalidDataException();

            ++_glueBits;

            _wasteHdrBits += 8 * packet.Length - packet.BitsRead;

            _modeFieldBits = Utils.ilog(Modes.Length - 1);

            return true;
        }
开发者ID:SirusDoma,项目名称:nvorbis,代码行数:96,代码来源:VorbisStreamDecoder.cs

示例9: TryInit

        internal bool TryInit(DataPacket initialPacket)
        {
            // make sure it's a vorbis stream...
            if (!initialPacket.ReadBytes(7).SequenceEqual(new byte[] { 0x01, 0x76, 0x6f, 0x72, 0x62, 0x69, 0x73 }))
            {
                _glueBits += initialPacket.Length * 8;
                return false;
            }

            _glueBits += 56;

            // now load the initial header
            ProcessStreamHeader(initialPacket);

            // finally, load the comment and book headers...
            bool comments = false, books = false;
            while (!(comments & books))
            {
                var packet = _getNextPacket();
                if (packet.IsResync) throw new InvalidDataException("Missing header packets!");

                if (!_pagesSeen.Contains(packet.PageSequenceNumber)) _pagesSeen.Add(packet.PageSequenceNumber);

                switch (packet.PeekByte())
                {
                    case 1: throw new InvalidDataException("Found second init header!");
                    case 3: LoadComments(packet); comments = true; break;
                    case 5: LoadBooks(packet); books = true; break;
                }
            }

            InitDecoder();

            return true;
        }
开发者ID:reidyd,项目名称:nvorbis,代码行数:35,代码来源:VorbisStreamDecoder.cs

示例10: LoadComments

        bool LoadComments(DataPacket packet)
        {
            if (!packet.ReadBytes(7).SequenceEqual(new byte[] { 0x03, 0x76, 0x6f, 0x72, 0x62, 0x69, 0x73 }))
            {
                return false;
            }

            if (!_pagesSeen.Contains((_lastPageSeen = packet.PageSequenceNumber))) _pagesSeen.Add(_lastPageSeen);

            _glueBits += 56;

            byte[] vs = packet.ReadBytes(packet.ReadInt32());
            _vendor = Encoding.UTF8.GetString(vs,0,vs.Length);

            _comments = new string[packet.ReadInt32()];
            for (int i = 0; i < _comments.Length; i++)
            {
                vs = packet.ReadBytes(packet.ReadInt32());
                _comments[i] = Encoding.UTF8.GetString(vs,0,vs.Length);
            }

            _metaBits += packet.BitsRead - 56;
            _wasteHdrBits += 8 * packet.Length - packet.BitsRead;

            return true;
        }
开发者ID:YJh2046,项目名称:BlockFun,代码行数:26,代码来源:VorbisStreamDecoder.cs


注:本文中的NVorbis.DataPacket.ReadBytes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。