|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.InputStream javax.sound.sampled.AudioInputStream org.xiph.speex.spi.FilteredAudioInputStream org.xiph.speex.spi.Pcm2SpeexAudioInputStream
Converts a PCM 16bits/sample mono audio stream to Ogg Speex
Nested Class Summary |
Nested classes inherited from class javax.sound.sampled.AudioInputStream |
|
Field Summary | |
private int |
channels
The number of audio channels (1=mono, 2=stereo). |
private java.lang.String |
comment
The comment String that will appear in the Ogg comment packet. |
static int |
DEFAULT_BUFFER_SIZE
The default size of the buffer (UWB stereo requires at least 2560b). |
static int |
DEFAULT_CHANNELS
The default number of channels if none is given in the constructor. |
static int |
DEFAULT_FRAMES_PER_PACKET
The default number of Speex frames that will be put in each Ogg packet. |
static int |
DEFAULT_PACKETS_PER_OGG_PAGE
The default number of Ogg packets that will be put in each Ogg page. |
static int |
DEFAULT_QUALITY
The default quality setting for the Speex encoder. |
static int |
DEFAULT_SAMPLERATE
The default sample rate if none is given in the constructor. |
private SpeexEncoder |
encoder
The Speex Encoder class. |
private boolean |
first
Flag to indicate if this is the first time a encode method is called. |
private int |
frameSize
The size in bytes of PCM data that will be encoded into 1 Speex frame. |
private int |
framesPerPacket
The number of Speex frames that will be put in each Ogg packet. |
private int |
granulpos
A counter for the number of PCM samples that have been encoded. |
private int |
mode
The encoder mode (0=NB, 1=WB, 2=UWB). |
private int |
oggCount
Pointer in the buffer to the point where Ogg data is added. |
private int |
packetCount
The number of Ogg packets that have been encoded in the current page. |
private int |
packetsPerOggPage
The number of Ogg packets that will be put in each Ogg page. |
private int |
pageCount
The number of Ogg pages that have been written to the stream. |
private int |
streamSerialNumber
A unique serial number that identifies the Ogg stream. |
static int |
UNKNOWN
Indicates the value is unknown or undetermined. |
Fields inherited from class org.xiph.speex.spi.FilteredAudioInputStream |
buf, count, in, marklimit, markpos, pos, prebuf, precount, prepos |
Fields inherited from class javax.sound.sampled.AudioInputStream |
format, frameLength, framePos |
Fields inherited from class java.io.InputStream |
|
Constructor Summary | |
Pcm2SpeexAudioInputStream(java.io.InputStream in,
javax.sound.sampled.AudioFormat format,
long length)
Constructor |
|
Pcm2SpeexAudioInputStream(java.io.InputStream in,
javax.sound.sampled.AudioFormat format,
long length,
int size)
Constructor |
|
Pcm2SpeexAudioInputStream(int mode,
int quality,
java.io.InputStream in,
javax.sound.sampled.AudioFormat format,
long length)
Constructor |
|
Pcm2SpeexAudioInputStream(int mode,
int quality,
java.io.InputStream in,
javax.sound.sampled.AudioFormat format,
long length,
int size)
Constructor |
Method Summary | |
int |
available()
Returns the number of bytes that can be read from this inputstream without blocking. |
protected void |
fill()
Fills the buffer with more data, taking into account shuffling and other tricks for dealing with marks. |
Encoder |
getEncoder()
Returns the Encoder. |
void |
setComment(java.lang.String comment,
boolean appendVersion)
Sets the comment for the Ogg Comment Header. |
void |
setFramesPerPacket(int framesPerPacket)
Sets the number of Audio Frames that are to be put in every Speex Packet. |
void |
setPacketsPerOggPage(int packetsPerOggPage)
Sets the number of Speex Packets that are to be put in every Ogg Page. |
void |
setQuality(int quality)
Sets the Speex encoder Quality. |
void |
setSerialNumber(int serialNumber)
Sets the Stream Serial Number. |
void |
setVbr(boolean vbr)
Sets whether of not the encoder is to use VBR. |
private void |
writeCommentFrame()
Write the OGG Speex Comment header. |
private void |
writeHeaderFrame()
Write the OGG Speex header. |
private static void |
writeInt(byte[] data,
int offset,
int v)
Writes a Little-endian int. |
private static void |
writeLong(byte[] data,
int offset,
long v)
Writes a Little-endian long. |
private void |
writeOggPageChecksum()
Calculate and write the OGG page checksum. |
private void |
writeOggPageHeader(int packets,
int headertype)
Write an OGG page header. |
private static void |
writeString(byte[] data,
int offset,
java.lang.String v)
Writes a String. |
Methods inherited from class org.xiph.speex.spi.FilteredAudioInputStream |
close, makeSpace, mark, markSupported, read, read, reset, skip |
Methods inherited from class javax.sound.sampled.AudioInputStream |
getFormat, getFrameLength, read |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DEFAULT_BUFFER_SIZE
public static final int DEFAULT_SAMPLERATE
public static final int DEFAULT_CHANNELS
public static final int DEFAULT_QUALITY
public static final int DEFAULT_FRAMES_PER_PACKET
public static final int DEFAULT_PACKETS_PER_OGG_PAGE
public static final int UNKNOWN
private SpeexEncoder encoder
private int mode
private int frameSize
private int framesPerPacket
private int channels
private java.lang.String comment
private int granulpos
private int streamSerialNumber
private int packetsPerOggPage
private int packetCount
private int pageCount
private int oggCount
private boolean first
Constructor Detail |
public Pcm2SpeexAudioInputStream(java.io.InputStream in, javax.sound.sampled.AudioFormat format, long length)
in
- the underlying input stream.format
- the target format of this stream's audio data.length
- the length in sample frames of the data in this stream.public Pcm2SpeexAudioInputStream(int mode, int quality, java.io.InputStream in, javax.sound.sampled.AudioFormat format, long length)
mode
- the mode of the encoder (0=NB, 1=WB, 2=UWB).quality
- the quality setting of the encoder (between 0 and 10).in
- the underlying input stream.format
- the target format of this stream's audio data.length
- the length in sample frames of the data in this stream.public Pcm2SpeexAudioInputStream(java.io.InputStream in, javax.sound.sampled.AudioFormat format, long length, int size)
in
- the underlying input stream.format
- the target format of this stream's audio data.length
- the length in sample frames of the data in this stream.size
- the buffer size.
java.lang.IllegalArgumentException
- if size <= 0.public Pcm2SpeexAudioInputStream(int mode, int quality, java.io.InputStream in, javax.sound.sampled.AudioFormat format, long length, int size)
mode
- the mode of the encoder (0=NB, 1=WB, 2=UWB).quality
- the quality setting of the encoder (between 0 and 10).in
- the underlying input stream.format
- the target format of this stream's audio data.length
- the length in sample frames of the data in this stream.size
- the buffer size.
java.lang.IllegalArgumentException
- if size <= 0.Method Detail |
public void setSerialNumber(int serialNumber)
serialNumber
- public void setFramesPerPacket(int framesPerPacket)
framesPerPacket
- DEFAULT_FRAMES_PER_PACKET
public void setPacketsPerOggPage(int packetsPerOggPage)
packetsPerOggPage
- DEFAULT_PACKETS_PER_OGG_PAGE
public void setComment(java.lang.String comment, boolean appendVersion)
comment
- appendVersion
- public void setQuality(int quality)
quality
- public void setVbr(boolean vbr)
vbr
- public Encoder getEncoder()
protected void fill() throws java.io.IOException
fill
in class FilteredAudioInputStream
java.io.IOException
public int available() throws java.io.IOException
The available
method of FilteredAudioInputStream
returns the sum of the the number of bytes remaining to be read in the
buffer (count - pos
) and the result of calling the
available
method of the underlying inputstream.
available
in class FilteredAudioInputStream
java.io.IOException
- if an I/O error occurs.FilteredAudioInputStream.in
private void writeOggPageHeader(int packets, int headertype)
packets
- - the number of packets in the Ogg Page (must be between 1 and 255)headertype
- - 2=bos: beginning of sream, 4=eos: end of sreamprivate void writeOggPageChecksum()
private void writeHeaderFrame()
private void writeCommentFrame()
private static void writeInt(byte[] data, int offset, int v)
data
- the array into which the data should be written.offset
- the offset from which to start writing in the array.v
- the value to write.private static void writeLong(byte[] data, int offset, long v)
data
- the array into which the data should be written.offset
- the offset from which to start writing in the array.v
- the value to write.private static void writeString(byte[] data, int offset, java.lang.String v)
data
- the array into which the data should be written.offset
- the offset from which to start writing in the array.v
- the value to write.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |