Class DataAtomOutputStream

java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.monte.media.quicktime.DataAtomOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class DataAtomOutputStream extends FilterOutputStream
This output stream filter supports common data types used inside of a QuickTime Data Atom.
Author:
Werner Randelshofer
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final long
     
    protected long
    The number of bytes written to the data output stream so far.

    Fields inherited from class java.io.FilterOutputStream

    out
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    incCount(int value)
    Increases the written counter by the specified value until it reaches Long.MAX_VALUE.
    final long
    Returns the current value of the counter written, the number of bytes written to this data output stream so far.
    void
    write(byte[] b, int off, int len)
    Writes len bytes from the specified byte array starting at offset off to the underlying output stream.
    void
    write(int b)
    Writes the specified byte (the low eight bits of the argument b) to the underlying output stream.
    void
    writeBCD2(int v)
    Writes a BCD2 to the underlying output stream.
    void
    writeBCD4(int v)
    Writes a BCD4 to the underlying output stream.
    final void
    writeByte(int v)
    Writes out a byte to the underlying output stream as a 1-byte value.
    void
    writeFixed16D16(double f)
    Writes 32-bit fixed-point number divided as 16.16.
    void
    writeFixed2D30(double f)
    Writes 32-bit fixed-point number divided as 2.30.
    void
    writeFixed8D8(double f)
    Writes 32-bit fixed-point number divided as 8.8.
    void
    writeInt(int v)
    Writes an int to the underlying output stream as four bytes, high byte first.
    void
    writeInt24(int v)
     
    void
    writeInts(int[] i, int off, int len)
     
    void
    writeInts24(int[] i, int off, int len)
     
    void
    writeLong(long v)
     
    void
    Writes a 32-bit Mac timestamp (seconds since 1902).
    void
    Writes a Pascal String.
    void
    writePString(String s, int length)
    Writes a Pascal String padded to the specified fixed size in bytes
    void
    writeShort(int v)
    Writes a signed 16 bit integer value.
    void
    writeShorts(short[] s, int off, int len)
     
    void
    Writes an Atom Type identifier (4 bytes).
    void
    writeUInt(long v)
    Writes an unsigned 32 bit integer value.
    void
    writeUShort(int v)
     

    Methods inherited from class java.io.FilterOutputStream

    close, flush, write

    Methods inherited from class java.io.OutputStream

    nullOutputStream

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAC_TIMESTAMP_EPOCH

      protected static final long MAC_TIMESTAMP_EPOCH
    • written

      protected long written
      The 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

      public DataAtomOutputStream(OutputStream out)
  • Method Details

    • writeType

      public void writeType(String s) throws IOException
      Writes an Atom Type identifier (4 bytes).
      Parameters:
      s - A string with a length of 4 characters.
      Throws:
      IOException
    • writeByte

      public final void writeByte(int v) throws IOException
      Writes out a byte to the underlying output stream as a 1-byte value. If no exception is thrown, the counter written is incremented by 1.
      Parameters:
      v - a byte value to be written.
      Throws:
      IOException - if an I/O error occurs.
      See Also:
    • write

      public void write(byte[] b, int off, int len) throws IOException
      Writes len bytes from the specified byte array starting at offset off to the underlying output stream. If no exception is thrown, the counter written is incremented by len.
      Overrides:
      write in class FilterOutputStream
      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

      public void write(int b) throws IOException
      Writes the specified byte (the low eight bits of the argument b) to the underlying output stream. If no exception is thrown, the counter written is incremented by 1.

      Implements the write method of OutputStream.

      Overrides:
      write in class FilterOutputStream
      Parameters:
      b - the byte to be written.
      Throws:
      IOException - if an I/O error occurs.
      See Also:
    • writeInt

      public void writeInt(int v) throws IOException
      Writes an int to the underlying output stream as four bytes, high byte first. If no exception is thrown, the counter written is incremented by 4.
      Parameters:
      v - an int to be written.
      Throws:
      IOException - if an I/O error occurs.
      See Also:
    • writeUInt

      public void writeUInt(long v) throws IOException
      Writes an unsigned 32 bit integer value.
      Parameters:
      v - The value
      Throws:
      IOException
    • writeShort

      public void writeShort(int v) throws IOException
      Writes a signed 16 bit integer value.
      Parameters:
      v - The value
      Throws:
      IOException
    • writeBCD2

      public void writeBCD2(int v) throws IOException
      Writes a BCD2 to the underlying output stream.
      Parameters:
      v - an int to be written.
      Throws:
      IOException - if an I/O error occurs.
      See Also:
    • writeBCD4

      public void writeBCD4(int v) throws IOException
      Writes a BCD4 to the underlying output stream.
      Parameters:
      v - an int to be written.
      Throws:
      IOException - if an I/O error occurs.
      See Also:
    • writeMacTimestamp

      public void writeMacTimestamp(Date date) throws IOException
      Writes a 32-bit Mac timestamp (seconds since 1902).
      Parameters:
      date -
      Throws:
      IOException
    • writeFixed16D16

      public void writeFixed16D16(double f) throws IOException
      Writes 32-bit fixed-point number divided as 16.16.
      Parameters:
      f - an int to be written.
      Throws:
      IOException - if an I/O error occurs.
      See Also:
    • writeFixed2D30

      public void writeFixed2D30(double f) throws IOException
      Writes 32-bit fixed-point number divided as 2.30.
      Parameters:
      f - an int to be written.
      Throws:
      IOException - if an I/O error occurs.
      See Also:
    • writeFixed8D8

      public void writeFixed8D8(double f) throws IOException
      Writes 32-bit fixed-point number divided as 8.8.
      Parameters:
      f - an int to be written.
      Throws:
      IOException - if an I/O error occurs.
      See Also:
    • writePString

      public void writePString(String s) throws IOException
      Writes a Pascal String.
      Parameters:
      s -
      Throws:
      IOException
    • writePString

      public void writePString(String s, int length) throws IOException
      Writes a Pascal String padded to the specified fixed size in bytes
      Parameters:
      s -
      length - the fixed size in bytes
      Throws:
      IOException
    • writeLong

      public void writeLong(long v) throws IOException
      Throws:
      IOException
    • writeUShort

      public void writeUShort(int v) throws IOException
      Throws:
      IOException
    • incCount

      protected void incCount(int value)
      Increases the written counter by the specified value until it reaches Long.MAX_VALUE.
    • writeShorts

      public void writeShorts(short[] s, int off, int len) throws IOException
      Throws:
      IOException
    • writeInts

      public void writeInts(int[] i, int off, int len) throws IOException
      Throws:
      IOException
    • writeInt24

      public void writeInt24(int v) throws IOException
      Throws:
      IOException
    • writeInts24

      public void writeInts24(int[] i, int off, int len) throws IOException
      Throws:
      IOException
    • size

      public final long size()
      Returns the current value of the counter written, 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 written field.
      See Also: