public static <T extends Box> T findFirstPath(NodeBox box, Class<T> clazz, String[] path) { T[] result = (T[]) findAllPath(box, clazz, path); return result.length > 0 ? result[0] : null; }
public SampleEntry[] getSampleEntries() { return NodeBox.findAllPath(this, SampleEntry.class, new String[]{"mdia", "minf", "stbl", "stsd", null}); }
public static <T extends Box> T[] findAll(Box box, Class<T> class1, String path) { return findAllPath(box, class1, new String[] { path }); }
public Map<String, MetaValue> getKeyedMeta() { Map<String, MetaValue> result = new LinkedHashMap<String, MetaValue>(); IListBox ilst = NodeBox.findFirst(this, IListBox.class, IListBox.fourcc()); MdtaBox[] keys = NodeBox.findAllPath(this, MdtaBox.class, new String[] { KeysBox.fourcc(), MdtaBox.fourcc() }); if (ilst == null || keys.length == 0) return result; for (Entry<Integer, List<Box>> entry : ilst.getValues().entrySet()) { Integer index = entry.getKey(); if (index == null) continue; DataBox db = getDataBox(entry.getValue()); if (db == null) continue; MetaValue value = MetaValue.createOtherWithLocale(db.getType(), db.getLocale(), db.getData()); if (index > 0 && index <= keys.length) { result.put(keys[index - 1].getKey(), value); } } return result; }
public AbstractMP4DemuxerTrack(TrakBox trak) { no = trak.getTrackHeader().getNo(); type = TrakBox.getTrackType(trak); sampleEntries = NodeBox.findAllPath(trak, SampleEntry.class, new String[]{"mdia", "minf", "stbl", "stsd", null}); NodeBox stbl = trak.getMdia().getMinf().getStbl(); TimeToSampleBox stts = NodeBox.findFirst(stbl, TimeToSampleBox.class, "stts"); SampleToChunkBox stsc = NodeBox.findFirst(stbl, SampleToChunkBox.class, "stsc"); ChunkOffsetsBox stco = NodeBox.findFirst(stbl, ChunkOffsetsBox.class, "stco"); ChunkOffsets64Box co64 = NodeBox.findFirst(stbl, ChunkOffsets64Box.class, "co64"); timeToSamples = stts.getEntries(); sampleToChunks = stsc.getSampleToChunk(); chunkOffsets = stco != null ? stco.getChunkOffsets() : co64.getChunkOffsets(); for (int i = 0; i < timeToSamples.length; i++) { TimeToSampleEntry ttse = timeToSamples[i]; duration += ttse.getSampleCount() * ttse.getSampleDuration(); } box = trak; timescale = trak.getTimescale(); }