org.jcodec.containers.mp4.boxes.EndianBox Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jcodec Show documentation
Show all versions of jcodec Show documentation
Pure Java implementation of video/audio codecs and formats
package org.jcodec.containers.mp4.boxes;
import java.nio.ByteBuffer;
/**
* This class is part of JCodec ( www.jcodec.org ) This software is distributed
* under FreeBSD License
*
* @author The JCodec project
*
*/
public class EndianBox extends Box {
public static enum Endian {
LITTLE_ENDIAN, BIG_ENDIAN
};
private Endian endian;
public EndianBox(Box other) {
super(other);
}
public static String fourcc() {
return "enda";
}
public EndianBox(Header header) {
super(header);
}
public EndianBox(Endian endian) {
super(new Header(fourcc()));
this.endian = endian;
}
public void parse(ByteBuffer input) {
long end = input.getShort();
if (end == 1) {
this.endian = Endian.LITTLE_ENDIAN;
} else {
this.endian = Endian.BIG_ENDIAN;
}
}
protected void doWrite(ByteBuffer out) {
out.putShort((short)(endian == Endian.LITTLE_ENDIAN ? 1 : 0));
}
public Endian getEndian() {
return endian;
}
protected int calcSize() {
return 2;
}
}