public void setName(String string) { NodeBox udta = NodeBox.findFirst(this, NodeBox.class, "udta"); if (udta == null) { udta = new NodeBox(new Header("udta")); this.add(udta); } udta.removeChildren("name"); udta.add(NameBox.createNameBox(string)); }
protected void writeExtensions(ByteBuffer out) { super.doWrite(out); }
public ChunkWriter(TrakBox trak, SeekableByteChannel[] inputs, SeekableByteChannel out) { entries = NodeBox.findAll(trak, SampleEntry.class, "mdia", "minf", "stbl", "stsd", null); ChunkOffsetsBox stco = NodeBox.findFirst(trak, ChunkOffsetsBox.class, "mdia", "minf", "stbl", "stco"); ChunkOffsets64Box co64 = NodeBox.findFirst(trak, ChunkOffsets64Box.class, "mdia", "minf", "stbl", "co64"); int size; if (stco != null) size = stco.getChunkOffsets().length; else size = co64.getChunkOffsets().length; this.inputs = inputs; offsets = new long[size]; this.out = out; this.trak = trak; }
public void replace(String fourcc, Box box) { removeChildren(fourcc); add(box); }
public void apply() { NodeBox stbl = NodeBox.findFirst(trak, NodeBox.class, "mdia", "minf", "stbl"); stbl.removeChildren("stco", "co64"); stbl.add(new ChunkOffsets64Box(offsets)); cleanDrefs(trak); }
public void setName(String string) { NodeBox udta = findFirst(this, NodeBox.class, "udta"); if (udta == null) { udta = new NodeBox(new Header("udta")); this.add(udta); } udta.removeChildren("name"); udta.add(new NameBox(string)); }
public DataRefBox getDref() { return NodeBox.findFirst(this, DataRefBox.class, "dref"); } }
result.add(chunk); NodeBox stbl = NodeBox.findFirstPath(track, NodeBox.class, Box.path("mdia.minf.stbl")); stbl.replace("stts", getTimeToSamples(result)); stbl.replace("stsz", getSampleSizes(result)); stbl.replace("stsc", getSamplesToChunk(result)); stbl.removeChildren("stco", "co64"); stbl.add(getChunkOffsets(result)); NodeBox.findFirstPath(track, MediaHeaderBox.class, Box.path("mdia.mdhd")).setDuration(totalDuration(result));
public void apply() { NodeBox stbl = NodeBox.findFirstPath(trak, NodeBox.class, Box.path("mdia.minf.stbl")); stbl.removeChildren("stco", "co64"); stbl.add(ChunkOffsets64Box.createChunkOffsets64Box(offsets)); cleanDrefs(trak); }
protected void parseExtensions(ByteBuffer input) { super.parse(input); }
public void parse(ByteBuffer input) { while (input.remaining() >= 8) { Box child = parseChildBox(input, factory); if (child != null) boxes.add(child); } }
public TrakBox[] getTracks() { return NodeBox.findAll(this, TrakBox.class, "trak"); }
protected void dump(StringBuilder sb) { sb.append("{\"tag\":\"" + header.getFourcc() + "\","); List<String> fields = new ArrayList<String>(0); collectModel(this.getClass(), fields); ToJSON.fieldsToJSON(this, sb, fields.toArray(new String[0])); sb.append("\"boxes\": ["); dumpBoxes(sb); sb.append("]"); sb.append("}"); }
public static ByteBuffer getCodecPrivate(SampleEntry mp4a) { LeafBox b = NodeBox.findFirst(mp4a, LeafBox.class, "esds"); if (b == null) { b = NodeBox.findFirstPath(mp4a, LeafBox.class, new String[] { null, "esds" }); } if (b == null) return null; EsdsBox esds = EsdsBox.newEsdsBox(); esds.parse(b.getData()); return esds.getStreamInfo(); }
public static void findBox(Box root, List<String> path, Collection<Box> result) { if (path.size() > 0) { String head = path.remove(0); if (root instanceof NodeBox) { NodeBox nb = (NodeBox) root; for (Box candidate : nb.getBoxes()) { if (head == null || head.equals(candidate.header.getFourcc())) { findBox(candidate, path, result); } } } path.add(0, head); } else { result.add(root); } } }
public static <T extends Box> void findDeepInner(Box box, Class<T> class1, String name, List<T> storage) { if (box == null) return; if (name.equals(box.getHeader().getFourcc())) { storage.add((T) box); return; } if (box instanceof NodeBox) { NodeBox nb = (NodeBox) box; for (Box candidate : nb.getBoxes()) { findDeepInner(candidate, class1, name, storage); } } }
protected void addDref(NodeBox minf) { DataInfoBox dinf = DataInfoBox.createDataInfoBox(); minf.add(dinf); DataRefBox dref = DataRefBox.createDataRefBox(); dinf.add(dref); dref.add(LeafBox.createLeafBox(Header.createHeader("alis", 0), ByteBuffer.wrap(new byte[] { 0, 0, 0, 1 }))); }
private static void findSub(Box box, List<String> path, Collection<Box> result) { if (path.size() > 0) { String head = path.remove(0); if (box instanceof NodeBox) { NodeBox nb = (NodeBox) box; for (Box candidate : nb.getBoxes()) { if (head == null || head.equals(candidate.header.getFourcc())) { findSub(candidate, path, result); } } } path.add(0, head); } else { result.add(box); } }