// Path: src/main/java/com/github/xsavikx/androidscreencast/api/recording/atom/AtomType.java
// public enum AtomType {
//     MEDIA_DATA("mdat"),
//     MOVIE("moov"),
//     MOVIE_HEADER("mvhd"),
//     TRACK("trak"),
//     TRACK_HEADER("tkhd"),
//     MEDIA("mdia"),
//     MEDIA_HEADER("mdhd"),
//     HANDLER("hdlr"),
//     MEDIA_HANDLER("mhlr"),
//     VIDEO("vide"),
//     MEDIA_INFORMATION("minf"),
//     VIDEO_MEDIA_INFORMATION("vmhd"),
//     FILE_ALIAS("alis"),
//     DATA_INFORMATION("dinf"),
//     DATA_REFERENCE("dref"),
//     SAMPLE_TABLE("stbl"),
//     SAMPLE_DESCRIPTION("stsd"),
//     RAW("raw "),
//     JAVA("java"),
//     JPEG("jpeg"),
//     PNG("png "),
//     TIME_TO_SAMPLE_MAPPING("stts"),
//     SAMPLE_TO_CHUNK_MAPPING("stsc"),
//     SAMPLE_SIZE("stsz"),
//     STANDARD_CHUNK_OFFSET_TABLE("stco"),
//     WIDE_CHUNK_OFFSET_TABLE("co64"),
//     FILE_TYPE("ftyp"),
//     QUICK_TIME("qt  "),
//     WIDE("wide"),
//     DATA_HANDLER("dhlr");
//     /**
//      * String representation of AtomType that must have exactly 4 characters
//      */
//     private final String stringRepresentation;
// 
//     AtomType(String stringRepresentation) {
//         this.stringRepresentation = stringRepresentation;
//     }
// 
//     public String toStringRepresentation() {
//         return stringRepresentation;
//     }
// }
// 
// Path: src/main/java/com/github/xsavikx/androidscreencast/exception/IORuntimeException.java
// public final class IORuntimeException extends AndroidScreenCastRuntimeException {
// 
//     public IORuntimeException(String message, IOException cause) {
//         super(message, cause);
//     }
// 
//     public IORuntimeException(IOException cause) {
//         super(cause);
//     }
// 
//     public IORuntimeException(String message, IOException cause, boolean enableSuppression, boolean writableStackTrace) {
//         super(message, cause, enableSuppression, writableStackTrace);
//     }
// }


import static com.google.common.base.Preconditions.checkNotNull;
import com.github.xsavikx.androidscreencast.api.recording.atom.AtomType;
import com.github.xsavikx.androidscreencast.exception.IORuntimeException;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import static com.google.common.base.Preconditions.checkArgument;
    public void writeType(AtomType atomType) throws IOException {
        checkNotNull(atomType, "AtomType should not be null");
        writeType(atomType.toStringRepresentation());
    }

    /**
     * Writes an unsigned 32 bit integer value.
     *
     * @param v The value
     * @throws java.io.IOException
     */
    public void writeUInt(long v) throws IOException {
        out.write((int) ((v >>> 24) & 0xff));
        out.write((int) ((v >>> 16) & 0xff));
        out.write((int) ((v >>> 8) & 0xff));
        out.write((int) ((v >>> 0) & 0xff));
        incCount(4);
    }

    void writeUShort(int v) throws IOException {
        out.write((v >> 8) & 0xff);
        out.write((v >>> 0) & 0xff);
        incCount(2);
    }

    @Override
    public void close() {
        try {
            flush();
        } catch (IOException e) {
// Path: src/main/java/com/github/xsavikx/androidscreencast/api/recording/atom/AtomType.java
// public enum AtomType {
//     MEDIA_DATA("mdat"),
//     MOVIE("moov"),
//     MOVIE_HEADER("mvhd"),
//     TRACK("trak"),
//     TRACK_HEADER("tkhd"),
//     MEDIA("mdia"),
//     MEDIA_HEADER("mdhd"),
//     HANDLER("hdlr"),
//     MEDIA_HANDLER("mhlr"),
//     VIDEO("vide"),
//     MEDIA_INFORMATION("minf"),
//     VIDEO_MEDIA_INFORMATION("vmhd"),
//     FILE_ALIAS("alis"),
//     DATA_INFORMATION("dinf"),
//     DATA_REFERENCE("dref"),
//     SAMPLE_TABLE("stbl"),
//     SAMPLE_DESCRIPTION("stsd"),
//     RAW("raw "),
//     JAVA("java"),
//     JPEG("jpeg"),
//     PNG("png "),
//     TIME_TO_SAMPLE_MAPPING("stts"),
//     SAMPLE_TO_CHUNK_MAPPING("stsc"),
//     SAMPLE_SIZE("stsz"),
//     STANDARD_CHUNK_OFFSET_TABLE("stco"),
//     WIDE_CHUNK_OFFSET_TABLE("co64"),
//     FILE_TYPE("ftyp"),
//     QUICK_TIME("qt  "),
//     WIDE("wide"),
//     DATA_HANDLER("dhlr");
//     /**
//      * String representation of AtomType that must have exactly 4 characters
//      */
//     private final String stringRepresentation;
// 
//     AtomType(String stringRepresentation) {
//         this.stringRepresentation = stringRepresentation;
//     }
// 
//     public String toStringRepresentation() {
//         return stringRepresentation;
//     }
// }
// 
// Path: src/main/java/com/github/xsavikx/androidscreencast/exception/IORuntimeException.java
// public final class IORuntimeException extends AndroidScreenCastRuntimeException {
// 
//     public IORuntimeException(String message, IOException cause) {
//         super(message, cause);
//     }
// 
//     public IORuntimeException(IOException cause) {
//         super(cause);
//     }
// 
//     public IORuntimeException(String message, IOException cause, boolean enableSuppression, boolean writableStackTrace) {
//         super(message, cause, enableSuppression, writableStackTrace);
//     }
// }


// Path: src/main/java/com/github/xsavikx/androidscreencast/api/recording/DataAtomOutputStream.java
import static com.google.common.base.Preconditions.checkNotNull;
import com.github.xsavikx.androidscreencast.api.recording.atom.AtomType;
import com.github.xsavikx.androidscreencast.exception.IORuntimeException;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import static com.google.common.base.Preconditions.checkArgument;

    public void writeType(AtomType atomType) throws IOException {
        checkNotNull(atomType, "AtomType should not be null");
        writeType(atomType.toStringRepresentation());
    }

    /**
     * Writes an unsigned 32 bit integer value.
     *
     * @param v The value
     * @throws java.io.IOException
     */
    public void writeUInt(long v) throws IOException {
        out.write((int) ((v >>> 24) & 0xff));
        out.write((int) ((v >>> 16) & 0xff));
        out.write((int) ((v >>> 8) & 0xff));
        out.write((int) ((v >>> 0) & 0xff));
        incCount(4);
    }

    void writeUShort(int v) throws IOException {
        out.write((v >> 8) & 0xff);
        out.write((v >>> 0) & 0xff);
        incCount(2);
    }

    @Override
    public void close() {
        try {
            flush();
        } catch (IOException e) {
            throw new IORuntimeException(e);