Constructors Summary |
---|
public IsoFile()
super("");
|
public IsoFile(String filename)Shortcut constructor that creates a FileChannel from the
given filename and pass it to the {@link IsoFile#IsoFile(java.nio.channels.FileChannel)}
constructor.
this(new FileInputStream(filename).getChannel());
|
public IsoFile(FileChannel fileChannel)Creates a new IsoFile from a FileChannel . Uses memory-mapping
to save heap memory.
this((ReadableByteChannel) fileChannel);
|
public IsoFile(ReadableByteChannel byteChannel)Creates a new IsoFile from a ReadableByteChannel .
Try to use {@link IsoFile#IsoFile(FileChannel)} so you can benefit from
{@link FileChannel#map(java.nio.channels.FileChannel.MapMode, long, long)}. It will
reduce your heap requirements drastically!
super("");
this.byteChannel = byteChannel;
boxParser = createBoxParser();
parse();
|
public IsoFile(ReadableByteChannel byteChannel, BoxParser boxParser)
super("");
this.byteChannel = byteChannel;
this.boxParser = boxParser;
parse();
|
Methods Summary |
---|
public void | _parseDetails(java.nio.ByteBuffer content)
// there are no details to parse we should be just file
|
public static java.lang.String | bytesToFourCC(byte[] type)
byte[] result = new byte[]{0, 0, 0, 0};
if (type != null) {
System.arraycopy(type, 0, result, 0, Math.min(type.length, 4));
}
try {
return new String(result, "ISO-8859-1");
} catch (UnsupportedEncodingException e) {
throw new Error("Required character encoding is missing", e);
}
|
public void | close()
this.byteChannel.close();
|
protected BoxParser | createBoxParser()
return new PropertyBoxParserImpl();
|
public static byte[] | fourCCtoBytes(java.lang.String fourCC)
byte[] result = new byte[4];
if (fourCC != null) {
for (int i = 0; i < Math.min(4, fourCC.length()); i++) {
result[i] = (byte) fourCC.charAt(i);
}
}
return result;
|
public void | getBox(java.nio.channels.WritableByteChannel os)
for (Box box : boxes) {
if (os instanceof FileChannel) {
long startPos = ((FileChannel) os).position();
box.getBox(os);
long size = ((FileChannel) os).position() - startPos;
assert size == box.getSize() : box.getType() + " Size: " + size + " box.getSize(): " + box.getSize();
} else {
box.getBox(os);
}
}
|
public com.coremedia.iso.IsoFile | getIsoFile()
return this;
|
public com.coremedia.iso.boxes.MovieBox | getMovieBox()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 ).
for (Box box : boxes) {
if (box instanceof MovieBox) {
return (MovieBox) box;
}
}
return null;
|
public long | getNumOfBytesToFirstChild()
return 0;
|
public long | getSize()
long size = 0;
for (Box box : boxes) {
size += box.getSize();
}
return size;
|
public void | parse(java.nio.channels.ReadableByteChannel inFC, java.nio.ByteBuffer header, long contentSize, AbstractBoxParser abstractBoxParser)
throw new IOException("This method is not meant to be called. Use #parse() directly.");
|
private void | parse()
boolean done = false;
while (!done) {
try {
Box box = boxParser.parseBox(byteChannel, this);
if (box != null) {
// System.err.println(box.getType());
boxes.add(box);
} else {
done = true;
}
} catch (EOFException e) {
done = true;
}
}
|
public java.lang.String | toString()
StringBuilder buffer = new StringBuilder();
buffer.append("IsoFile[");
if (boxes == null) {
buffer.append("unparsed");
} else {
for (int i = 0; i < boxes.size(); i++) {
if (i > 0) {
buffer.append(";");
}
buffer.append(boxes.get(i).toString());
}
}
buffer.append("]");
return buffer.toString();
|