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

org.mp4parser.boxes.apple.Utf8AppleDataBox Maven / Gradle / Ivy

Go to download

A generic parser and writer for all ISO 14496 based files (MP4, Quicktime, DCF, PDCF, ...)

There is a newer version: 1.9.56
Show newest version
package org.mp4parser.boxes.apple;

import org.mp4parser.support.DoNotParseDetail;
import org.mp4parser.tools.IsoTypeReader;
import org.mp4parser.tools.Utf8;

import java.nio.ByteBuffer;
import java.nio.charset.Charset;

/**
 *
 */
public abstract class Utf8AppleDataBox extends AppleDataBox {
    String value;

    protected Utf8AppleDataBox(String type) {
        super(type, 1);
    }

    public String getValue() {
        //patched by Toias Bley / UltraMixer
        if (!isParsed()) {
            parseDetails();
        }
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    @DoNotParseDetail
    public byte[] writeData() {
        return Utf8.convert(value);
    }

    @Override
    protected int getDataLength() {
        return value.getBytes(Charset.forName("UTF-8")).length;
    }

    @Override
    protected void parseData(ByteBuffer data) {
        value = IsoTypeReader.readString(data, data.remaining());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy