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

org.jcodec.containers.mp4.boxes.DataRefBox 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 java.util.HashMap;
import java.util.Map;

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
 * 
 * @author stan
 *
 */
public class DataRefBox extends NodeBox {

    private static final MyFactory FACTORY = new MyFactory();

    public static String fourcc() {
        return "dref";
    }

    public DataRefBox() {
        this(new Header(fourcc()));
    }

    private DataRefBox(Header atom) {
        super(atom);
        factory = FACTORY;
    }

    @Override
    public void parse(Input input) throws IOException {
        Parser.readInt32(input);
        Parser.readInt32(input);
        super.parse(input);
    }

    @Override
    public void doWrite(DataOutput out) throws IOException {
        out.writeInt(0);
        out.writeInt(boxes.size());
        super.doWrite(out);
    }

    public static class MyFactory extends BoxFactory {
        private Map> mappings = new HashMap>();

        public MyFactory() {
            mappings.put(UrlBox.fourcc(), UrlBox.class);
            mappings.put(AliasBox.fourcc(), AliasBox.class);
        }

        public Class toClass(String fourcc) {
            return mappings.get(fourcc);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy