org.xiph.speex
Class OggSpeexWriter

java.lang.Object
  extended byorg.xiph.speex.AudioFileWriter
      extended byorg.xiph.speex.OggSpeexWriter

public class OggSpeexWriter
extends AudioFileWriter

Ogg Speex Writer

Version:
$Revision: 1.7 $
Author:
Marc Gimpel, Wimba S.A. (marc@wimba.com)

Field Summary
private  int channels
           
private  byte[] dataBuffer
           
private  int dataBufferPtr
           
private  long granulepos
           
private  byte[] headerBuffer
           
private  int headerBufferPtr
           
private  int mode
           
private  int nframes
           
private  java.io.OutputStream out
           
private  int packetCount
           
private  int pageCount
           
private  int sampleRate
           
private  int size
           
private  int streamSerialNumber
           
private  boolean vbr
           
 
Constructor Summary
OggSpeexWriter()
          Builds an Ogg Speex Writer.
OggSpeexWriter(int mode, int sampleRate, int channels, int nframes, boolean vbr)
          Builds an Ogg Speex Writer.
 
Method Summary
 void close()
          Closes the output file.
private  void flush(boolean eos)
          Flush the Ogg page out of the buffers into the file.
 void open(java.lang.String filename)
          Open the output file.
private  void setFormat(int mode, int sampleRate, int channels, int nframes, boolean vbr)
          Sets the output format.
 void setSerialNumber(int serialNumber)
          Sets the Stream Serial Number.
 void writeHeader(java.lang.String comment)
          Writes the header pages that start the Ogg Speex file.
 void writePacket(byte[] data, int offset, int len)
          Writes a packet of audio.
 
Methods inherited from class org.xiph.speex.AudioFileWriter
writeInt, writeInt, writeLong, writeShort, writeShort
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

out

private java.io.OutputStream out

mode

private int mode

sampleRate

private int sampleRate

channels

private int channels

nframes

private int nframes

vbr

private boolean vbr

size

private int size

streamSerialNumber

private int streamSerialNumber

dataBuffer

private byte[] dataBuffer

dataBufferPtr

private int dataBufferPtr

headerBuffer

private byte[] headerBuffer

headerBufferPtr

private int headerBufferPtr

pageCount

private int pageCount

packetCount

private int packetCount

granulepos

private long granulepos
Constructor Detail

OggSpeexWriter

public OggSpeexWriter()
Builds an Ogg Speex Writer.


OggSpeexWriter

public OggSpeexWriter(int mode,
                      int sampleRate,
                      int channels,
                      int nframes,
                      boolean vbr)
Builds an Ogg Speex Writer.

Parameters:
mode -
sampleRate -
channels -
nframes -
vbr -
Method Detail

setFormat

private void setFormat(int mode,
                       int sampleRate,
                       int channels,
                       int nframes,
                       boolean vbr)
Sets the output format. Must be called before WriteHeader().

Parameters:
mode -
sampleRate -
channels -
nframes -
vbr -

setSerialNumber

public void setSerialNumber(int serialNumber)
Sets the Stream Serial Number. Must not be changed mid stream.

Parameters:
serialNumber -

close

public void close()
           throws java.io.IOException
Closes the output file.

Specified by:
close in class AudioFileWriter
Throws:
java.io.IOException

open

public void open(java.lang.String filename)
          throws java.io.IOException
Open the output file.

Specified by:
open in class AudioFileWriter
Parameters:
filename - - file to open.
Throws:
java.io.IOException

writeHeader

public void writeHeader(java.lang.String comment)
                 throws java.io.IOException
Writes the header pages that start the Ogg Speex file. Prepares file for data to be written.

Specified by:
writeHeader in class AudioFileWriter
Parameters:
comment - description to be included in the header.
Throws:
java.io.IOException

writePacket

public void writePacket(byte[] data,
                        int offset,
                        int len)
                 throws java.io.IOException
Writes a packet of audio.

Specified by:
writePacket in class AudioFileWriter
Parameters:
data - - audio data.
offset - - the offset from which to start reading the data.
len - - the length of data to read.
Throws:
java.io.IOException

flush

private void flush(boolean eos)
            throws java.io.IOException
Flush the Ogg page out of the buffers into the file.

Parameters:
eos - - end of stream
Throws:
java.io.IOException


Copyright © 1999-2004 Wimba S.A. All Rights Reserved.