org.mp4parser.boxes.apple.AppleGPSCoordinatesBox Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of isoparser Show documentation
Show all versions of isoparser Show documentation
A generic parser and writer for all ISO 14496 based files (MP4, Quicktime, DCF, PDCF, ...)
The newest version!
package org.mp4parser.boxes.apple;
import org.mp4parser.support.AbstractBox;
import org.mp4parser.tools.Utf8;
import java.nio.ByteBuffer;
/**
* Created by marwatk on 02/27/15
*/
public class AppleGPSCoordinatesBox extends AbstractBox {
public static final String TYPE = "©xyz";
private static final int DEFAULT_LANG = 5575; //Empirical
String coords;
int lang = DEFAULT_LANG; //? Docs says lang, but it doesn't match anything in the traditional language map
public AppleGPSCoordinatesBox() {
super(TYPE);
}
public String getValue() {
return coords;
}
public void setValue(String iso6709String) {
lang = DEFAULT_LANG;
coords = iso6709String;
}
@Override
protected long getContentSize() {
return 4 + Utf8.utf8StringLengthInBytes(coords);
}
@Override
protected void getContent(ByteBuffer byteBuffer) {
byteBuffer.putShort((short) coords.length());
byteBuffer.putShort((short) lang);
byteBuffer.put(Utf8.convert(coords));
}
@Override
protected void _parseDetails(ByteBuffer content) {
int length = content.getShort();
lang = content.getShort(); //Not sure if this is accurate. It always seems to be 15 c7
byte bytes[] = new byte[length];
content.get(bytes);
coords = Utf8.convert(bytes);
}
public String toString() {
return "AppleGPSCoordinatesBox[" + coords + "]";
}
}