public void writeTo(WritableByteChannel channel) throws java.io.IOException { for (Box box : boxes) { box.getBox(channel); } }
public static long find(Container container, ParsableBox target, long offset) { long nuOffset = offset; for (Box lightBox : container.getBoxes()) { if (lightBox == target) { return nuOffset; } if (lightBox instanceof Container) { long r = find((Container) lightBox, target, 0); if (r > 0) { return r + nuOffset; } else { nuOffset += lightBox.getSize(); } } else { nuOffset += lightBox.getSize(); } } return -1; } }
FreeBox findFreeBox(Container c) { for (Box box : c.getBoxes()) { System.err.println(box.getType()); if (box instanceof FreeBox) { return (FreeBox) box; } if (box instanceof Container) { FreeBox freeBox = findFreeBox((Container) box); if (freeBox != null) { return freeBox; } } } return null; }
public long getSize() { long l = 0; for (Box box : boxes) { l += box.getSize(); } return l; }
/** * Shortcut to get the MovieBox since it is often needed and present in * nearly all ISO 14496 files (at least if they are derived from MP4 ). * * @return the MovieBox or <code>null</code> */ public MovieBox getMovieBox() { for (Box box : getBoxes()) { if (box instanceof MovieBox) { return (MovieBox) box; } } return null; }
public void initContainer(ReadableByteChannel readableByteChannel, long containerSize, BoxParser boxParser) throws IOException { long contentProcessed = 0; while (containerSize < 0 || contentProcessed < containerSize) { try { ParsableBox b = boxParser.parseBox(readableByteChannel, (this instanceof ParsableBox) ? ((ParsableBox) this).getType() : null); boxes.add(b); contentProcessed += b.getSize(); } catch (EOFException e) { if (containerSize < 0) { return; } else { throw e; } } } }
public void getBox(WritableByteChannel os) throws IOException { writeContainer(os); }
@Override protected void getContent(ByteBuffer byteBuffer) { byteBuffer.put(IsoFile.fourCCtoBytes(dataFormat)); }
/** * @param readableByteChannel the data source * @throws IOException in case I/O error */ public IsoFile(ReadableByteChannel readableByteChannel) throws IOException { this(readableByteChannel, new PropertyBoxParserImpl()); }
public long getSize() { long size = 8; for (ParsableBox replacer : replacers) { size += replacer.getSize(); } size += data.limit(); return size; }
public static void closeQuietly(IsoFile input) { try { if (input != null) { input.close(); } } catch (IOException ioe) { // ignore } }
public IsoFile(ReadableByteChannel readableByteChannel, BoxParser boxParser) throws IOException { this.readableByteChannel = readableByteChannel; initContainer(readableByteChannel, -1, boxParser); }
public long getSize() { return getContainerSize(); }
public IsoFile(String file) throws IOException { this(new FileInputStream(file).getChannel(), new PropertyBoxParserImpl()); }
public IsoFile(File file) throws IOException { this(new FileInputStream(file).getChannel(), new PropertyBoxParserImpl()); }