All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jcodec.containers.mp4.boxes.ChunkOffsetsBox Maven / Gradle / Ivy

There is a newer version: 0.2.5
Show newest version
package org.jcodec.containers.mp4.boxes;

import java.io.DataOutput;
import java.io.IOException;

import org.jcodec.containers.mp4.io.Input;
import org.jcodec.containers.mp4.io.Parser;

/**
 * This class is part of JCodec ( www.jcodec.org )
 * This software is distributed under FreeBSD License
 * 
 * A box to hold chunk offsets
 * 
 * @author Stanislav Vitvitskiy
 * 
 */

public class ChunkOffsetsBox extends FullBox {
    private long[] chunkOffsets;
    
    public static String fourcc() {
        return "stco";
    }

    public ChunkOffsetsBox(long[] chunkOffsets) {
        super(new Header(fourcc()));
        this.chunkOffsets = chunkOffsets;
    }

    public ChunkOffsetsBox() {
        super(new Header(fourcc()));
    }

    public void parse(Input input) throws IOException {
        super.parse(input);
        int length = (int) Parser.readInt32(input);
        chunkOffsets = new long[length];
        for (int i = 0; i < length; i++) {
            chunkOffsets[i] = Parser.readInt32(input);
        }
    }

    @Override
    public void doWrite(DataOutput out) throws IOException {
        super.doWrite(out);
        out.writeInt(chunkOffsets.length);
        for (long offset : chunkOffsets) {
            out.writeInt((int) offset);
        }
    }

    public long[] getChunkOffsets() {
        return chunkOffsets;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy