Ejemplo n.º 1
0
        public override void WriteHeader(string comment)
        {
            OggCrc oggCrc = new OggCrc();

            byte[] array = OggSpeexWriter.BuildOggPageHeader(2, 0L, this.streamSerialNumber, this.pageCount++, 1, new byte[]
            {
                80
            });
            byte[] array2 = AudioFileWriter.BuildSpeexHeader(this.sampleRate, this.mode, this.channels, this.vbr, this.nframes);
            oggCrc.Initialize();
            oggCrc.TransformBlock(array, 0, array.Length, array, 0);
            oggCrc.TransformFinalBlock(array2, 0, array2.Length);
            this.xout.Write(array, 0, 22);
            this.xout.Write(oggCrc.Hash, 0, oggCrc.HashSize / 8);
            this.xout.Write(array, 26, array.Length - 26);
            this.xout.Write(array2, 0, array2.Length);
            array = OggSpeexWriter.BuildOggPageHeader(0, 0L, this.streamSerialNumber, this.pageCount++, 1, new byte[]
            {
                (byte)(comment.Length + 8)
            });
            array2 = AudioFileWriter.BuildSpeexComment(comment);
            oggCrc.Initialize();
            oggCrc.TransformBlock(array, 0, array.Length, array, 0);
            oggCrc.TransformFinalBlock(array2, 0, array2.Length);
            this.xout.Write(array, 0, 22);
            this.xout.Write(oggCrc.Hash, 0, oggCrc.HashSize / 8);
            this.xout.Write(array, 26, array.Length - 26);
            this.xout.Write(array2, 0, array2.Length);
        }
Ejemplo n.º 2
0
        private void Flush(bool eos)
        {
            OggCrc oggCrc = new OggCrc();

            byte[] array = OggSpeexWriter.BuildOggPageHeader(eos ? 4 : 0, this.granulepos, this.streamSerialNumber, this.pageCount++, this.packetCount, this.headerBuffer);
            oggCrc.Initialize();
            oggCrc.TransformBlock(array, 0, array.Length, array, 0);
            oggCrc.TransformFinalBlock(this.dataBuffer, 0, this.dataBufferPtr);
            this.xout.Write(array, 0, 22);
            this.xout.Write(oggCrc.Hash, 0, oggCrc.HashSize / 8);
            this.xout.Write(array, 26, array.Length - 26);
            this.xout.Write(this.dataBuffer, 0, this.dataBufferPtr);
            this.dataBufferPtr   = 0;
            this.headerBufferPtr = 0;
            this.packetCount     = 0;
        }