|
Sharkysoft home | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--lava.riff.RiffStreamWriter
Generates RIFF stream.
Details: RiffStreamWriter generates RIFF streams (duh!). Data is stored in a tagged, nested chunk structure, as specified by the RIFF standard. Most of the details for creating and nesting chunks are handled automatically, and the programmer needs only to call beginChunk, endChunk, and the data writing methods in order to produce a beautifully structured RIFF stream.
| Constructor Summary | |
RiffStreamWriter(IRiffOutput raos,
long length)
Writes RIFF header. |
|
| Method Summary | |
void |
beginChunk(int tag,
long length)
Creates inner chunk. |
void |
close()
Closes RIFF stream. |
void |
endChunk()
Terminates current chunk. |
protected void |
finalize()
Finalizes RIFF stream. |
void |
writeByte(byte b)
Writes BYTE. |
void |
writeBytes(byte[] src,
int offset,
int amount)
Writes BYTEs. |
void |
writeDword(int dword)
Writes DWORD. |
void |
writeDwords(int[] src,
int offset,
int amount)
Writes DWORDs. |
void |
writeTag(int tag)
Writes tag. |
void |
writeWord(short word)
Writes WORD. |
void |
writeWords(short[] src,
int offset,
int amount)
Writes WORDs. |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public RiffStreamWriter(IRiffOutput raos,
long length)
throws java.io.IOException
Details: This constructor initializes a new RiffStreamWriter so that all subsequent RIFF data is written to the given IRiffOutput (raos).
The length parameter can be used to declare the intended data length of the RIFF file's outer chunk, if that value is known. In most cases, however, because RiffStreamWriter is meant to insulate the API user from RIFF details, the length of the RIFF stream will not be known until the entire stream has been generated. Setting this parameter to 0 indicates that the data length of the outer chunk is unknown.
Because the second DWORD in a RIFF file specifies the RIFF file's data length, not knowing the data length ahead of time prevents a RiffStreamWriter from committing any data to the output stream until the entire RIFF structure has been generated. This can require significant memory resources for large streams, such as Microsoft Wave or AVI files.
raos - the output streamlength - the data length| Method Detail |
public void beginChunk(int tag,
long length)
throws java.io.IOException
Details: beginChunk creates a new inner chunk that is nested within the currently open outer chunk. The new inner chunk is tagged with tag. length indicates the length of the inner chunk's data field. If the inner chunk's data field length is unknown at the time beginChunk is called, the client should set length to 0. Setting length to 0 causes this RiffStreamWriter to wait until after the inner chunk is closed before writing the inner chunk's header.
tag - the inner chunk's taglength - the predicted data length
public void endChunk()
throws java.io.IOException
Details: endChunk terminates the currently open chunk and prepares to continue writing data in the parent chunk immediately after the last byte of the closed inner chunk. If the current chunk is the RIFF file's outer chunk, then this method wraps things up and closes the RIFF output stream entirely. If the chunk being closed did not have a predeclared length, the length field in the inner chunk's header is updated before closing the chunk.
public void close()
throws java.io.IOException
Details: close closes all currently open, nested chunks and completes the RIFF stream, updating the headers to all chunks structures as needed. The underlying data sink is closed as well.
public void writeTag(int tag)
throws java.io.IOException
Details: writeTag outputs the 4 bytes of tag in big endian order. This method is typically used to output the four character tags which appear in the headers to each chunk, but it may be used for other purposes as well.
tag - the tag
public void writeByte(byte b)
throws java.io.IOException
Details: This method writes a single BYTE to the current chunk.
b - the BYTEjava.io.IOException - if an I/O error occurs
public void writeWord(short word)
throws java.io.IOException
Details: This method writes a single WORD to the current chunk.
word - the WORDjava.io.IOException - if an I/O error occurs
public void writeDword(int dword)
throws java.io.IOException
Details: This method writes a single DWORD to the current chunk.
dword - the DWORDjava.io.IOException - if an I/O error occurs
public void writeBytes(byte[] src,
int offset,
int amount)
throws java.io.IOException
Details: writeBytes writes a sequence of BYTEs to the current chunk, taking them from the given byte array (src), starting with src [offset]. amount BYTEs are written.
src - BYTEs to writeoffset - offset into arrayamount - number of BYTEs to writejava.io.IOException - if an I/O error occursEOFException - if reading the BYTEs extends the chunk reader beyond the chunk's end
public void writeWords(short[] src,
int offset,
int amount)
throws java.io.IOException
Details: writeWords writes a sequence of WORDs to the current chunk, taking them from the given short array (src), starting with src [offset]. amount WORDs are written.
src - WORDs to writeoffset - offset into arrayamount - number of WORDs to writejava.io.IOException - if an I/O error occursEOFException - if reading the WORDs extends the chunk reader beyond the chunk's end
public void writeDwords(int[] src,
int offset,
int amount)
throws java.io.IOException
Details: writeDwords writes a sequence of DWORDs to the current chunk, taking them from the given int array (src), starting with src [offset]. amount DWORDs are written.
src - DWORDs to writeoffset - offset into arrayamount - number of DWORDs to writejava.io.IOException - if an I/O error occursEOFException - if reading the DWORDs extends the chunk reader beyond the chunk's end
protected void finalize()
throws java.lang.Throwable
Details: finalize calls .close
finalize in class java.lang.Object
|
Sharkysoft home | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||