コード例 #1
0
ファイル: OggOpusHeaderWriter.cs プロジェクト: StefH/Matroska
 private void WriteOggPage(OggHeaderType oggHeaderType, byte[] data)
 {
     _oggPageWriter.WriteOggPage(oggHeaderType, 1, new List <SegmentEntry> {
         new SegmentEntry
         {
             Data         = data,
             SegmentBytes = new byte[] { (byte)data.Length }
         }
     });
 }
コード例 #2
0
 public void ReadFromStream(BinaryReader r)
 {
     ID              = Encoding.ASCII.GetString(r.ReadBytes(4));
     StreamVersion   = r.ReadByte();
     TypeFlag        = (OggHeaderType)r.ReadByte();
     GranulePosition = r.ReadUInt64();
     Serial          = r.ReadInt32();
     PageNumber      = r.ReadInt32();
     Checksum        = r.ReadUInt32();
     TotalSegments   = r.ReadByte();
     SegmentTable    = r.ReadBytes(TotalSegments);
 }
コード例 #3
0
        public void WriteOggPage(OggHeaderType oggHeaderType, byte numberOfSegments, List <SegmentEntry> oggPages)
        {
            var data = oggPages.SelectMany(o => o.Data).ToArray();

            _granulePosition += (ulong)oggPages.Sum(op => op.NumberOfSamples * op.NumberOfFrames);

            var oggHeader = new OggHeader
            {
                StreamVersion   = 0,
                TypeFlag        = oggHeaderType,
                GranulePosition = _granulePosition,
                Serial          = _serial,
                PageNumber      = _page,
                Checksum        = 0,
                TotalSegments   = numberOfSegments,
                SegmentTable    = oggPages.SelectMany(o => o.SegmentBytes).ToArray()
            };

            CalculateChecksumAndWriteOggHeaderToBinaryWriter(oggHeader, data);

            _writer.Flush();

            _page++;
        }