Track(Box trak, MP4InputStream in) {
this.in = in;
tkhd = (TrackHeaderBox) trak.getChild(BoxTypes.TRACK_HEADER_BOX);
final Box mdia = trak.getChild(BoxTypes.MEDIA_BOX);
mdhd = (MediaHeaderBox) mdia.getChild(BoxTypes.MEDIA_HEADER_BOX);
final Box minf = mdia.getChild(BoxTypes.MEDIA_INFORMATION_BOX);
final Box dinf = minf.getChild(BoxTypes.DATA_INFORMATION_BOX);
final DataReferenceBox dref = (DataReferenceBox) dinf.getChild(BoxTypes.DATA_REFERENCE_BOX);
//TODO: support URNs
if(dref.hasChild(BoxTypes.DATA_ENTRY_URL_BOX)) {
DataEntryUrlBox url = (DataEntryUrlBox) dref.getChild(BoxTypes.DATA_ENTRY_URL_BOX);
inFile = url.isInFile();
if(!inFile) {
try {
location = new URL(url.getLocation());
}
catch(MalformedURLException e) {
Logger.getLogger("MP4 API").log(Level.WARNING, "Parsing URL-Box failed: {0}, url: {1}", new String[]{e.toString(), url.getLocation()});
location = null;
}
}
}
/*else if(dref.containsChild(BoxTypes.DATA_ENTRY_URN_BOX)) {
DataEntryUrnBox urn = (DataEntryUrnBox) dref.getChild(BoxTypes.DATA_ENTRY_URN_BOX);
inFile = urn.isInFile();
location = urn.getLocation();
}*/
else {
inFile = true;
location = null;
}
//sample table
final Box stbl = minf.getChild(BoxTypes.SAMPLE_TABLE_BOX);
if(stbl.hasChildren()) {
frames = new ArrayList<Frame>();
parseSampleTable(stbl);
}
else frames = Collections.emptyList();