java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.monte.media.quicktime.DataAtomOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
This output stream filter supports common data types used inside
of a QuickTime Data Atom.
- Author:
- Werner Randelshofer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final longprotected longThe number of bytes written to the data output stream so far.Fields inherited from class java.io.FilterOutputStream
out -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidincCount(int value) Increases the written counter by the specified value until it reaches Long.MAX_VALUE.final longsize()Returns the current value of the counterwritten, the number of bytes written to this data output stream so far.voidwrite(byte[] b, int off, int len) Writeslenbytes from the specified byte array starting at offsetoffto the underlying output stream.voidwrite(int b) Writes the specified byte (the low eight bits of the argumentb) to the underlying output stream.voidwriteBCD2(int v) Writes aBCD2to the underlying output stream.voidwriteBCD4(int v) Writes aBCD4to the underlying output stream.final voidwriteByte(int v) Writes out abyteto the underlying output stream as a 1-byte value.voidwriteFixed16D16(double f) Writes 32-bit fixed-point number divided as 16.16.voidwriteFixed2D30(double f) Writes 32-bit fixed-point number divided as 2.30.voidwriteFixed8D8(double f) Writes 32-bit fixed-point number divided as 8.8.voidwriteInt(int v) Writes anintto the underlying output stream as four bytes, high byte first.voidwriteInt24(int v) voidwriteInts(int[] i, int off, int len) voidwriteInts24(int[] i, int off, int len) voidwriteLong(long v) voidwriteMacTimestamp(Date date) Writes a 32-bit Mac timestamp (seconds since 1902).voidWrites a Pascal String.voidwritePString(String s, int length) Writes a Pascal String padded to the specified fixed size in bytesvoidwriteShort(int v) Writes a signed 16 bit integer value.voidwriteShorts(short[] s, int off, int len) voidWrites an Atom Type identifier (4 bytes).voidwriteUInt(long v) Writes an unsigned 32 bit integer value.voidwriteUShort(int v) Methods inherited from class java.io.FilterOutputStream
close, flush, writeMethods inherited from class java.io.OutputStream
nullOutputStream
-
Field Details
-
MAC_TIMESTAMP_EPOCH
protected static final long MAC_TIMESTAMP_EPOCH -
written
protected long writtenThe number of bytes written to the data output stream so far. If this counter overflows, it will be wrapped to Integer.MAX_VALUE.
-
-
Constructor Details
-
DataAtomOutputStream
-
-
Method Details
-
writeType
Writes an Atom Type identifier (4 bytes).- Parameters:
s- A string with a length of 4 characters.- Throws:
IOException
-
writeByte
Writes out abyteto the underlying output stream as a 1-byte value. If no exception is thrown, the counterwrittenis incremented by1.- Parameters:
v- abytevalue to be written.- Throws:
IOException- if an I/O error occurs.- See Also:
-
write
Writeslenbytes from the specified byte array starting at offsetoffto the underlying output stream. If no exception is thrown, the counterwrittenis incremented bylen.- Overrides:
writein classFilterOutputStream- Parameters:
b- the data.off- the start offset in the data.len- the number of bytes to write.- Throws:
IOException- if an I/O error occurs.- See Also:
-
write
Writes the specified byte (the low eight bits of the argumentb) to the underlying output stream. If no exception is thrown, the counterwrittenis incremented by1.Implements the
writemethod ofOutputStream.- Overrides:
writein classFilterOutputStream- Parameters:
b- thebyteto be written.- Throws:
IOException- if an I/O error occurs.- See Also:
-
writeInt
Writes anintto the underlying output stream as four bytes, high byte first. If no exception is thrown, the counterwrittenis incremented by4.- Parameters:
v- anintto be written.- Throws:
IOException- if an I/O error occurs.- See Also:
-
writeUInt
Writes an unsigned 32 bit integer value.- Parameters:
v- The value- Throws:
IOException
-
writeShort
Writes a signed 16 bit integer value.- Parameters:
v- The value- Throws:
IOException
-
writeBCD2
Writes aBCD2to the underlying output stream.- Parameters:
v- anintto be written.- Throws:
IOException- if an I/O error occurs.- See Also:
-
writeBCD4
Writes aBCD4to the underlying output stream.- Parameters:
v- anintto be written.- Throws:
IOException- if an I/O error occurs.- See Also:
-
writeMacTimestamp
Writes a 32-bit Mac timestamp (seconds since 1902).- Parameters:
date-- Throws:
IOException
-
writeFixed16D16
Writes 32-bit fixed-point number divided as 16.16.- Parameters:
f- anintto be written.- Throws:
IOException- if an I/O error occurs.- See Also:
-
writeFixed2D30
Writes 32-bit fixed-point number divided as 2.30.- Parameters:
f- anintto be written.- Throws:
IOException- if an I/O error occurs.- See Also:
-
writeFixed8D8
Writes 32-bit fixed-point number divided as 8.8.- Parameters:
f- anintto be written.- Throws:
IOException- if an I/O error occurs.- See Also:
-
writePString
Writes a Pascal String.- Parameters:
s-- Throws:
IOException
-
writePString
Writes a Pascal String padded to the specified fixed size in bytes- Parameters:
s-length- the fixed size in bytes- Throws:
IOException
-
writeLong
- Throws:
IOException
-
writeUShort
- Throws:
IOException
-
incCount
protected void incCount(int value) Increases the written counter by the specified value until it reaches Long.MAX_VALUE. -
writeShorts
- Throws:
IOException
-
writeInts
- Throws:
IOException
-
writeInt24
- Throws:
IOException
-
writeInts24
- Throws:
IOException
-
size
public final long size()Returns the current value of the counterwritten, the number of bytes written to this data output stream so far. If the counter overflows, it will be wrapped to Integer.MAX_VALUE.- Returns:
- the value of the
writtenfield. - See Also:
-