public void position(long nuPos) throws IOException { data.position(l2i(nuPos)); }
public void parse(ReadableByteChannel dataSource, ByteBuffer header, long contentSize, BoxParser boxParser) throws IOException { data = ByteBuffer.allocate(CastUtils.l2i(contentSize)); int bytesRead = 0; int b; while (((((b = dataSource.read(data))) + bytesRead) < contentSize)) { bytesRead += b; } }
public byte[] get(long start, int count) { byte[] result = new byte[count]; try { System.arraycopy(buf, l2i(start - startOffset), result, 0, count); } catch (ArrayIndexOutOfBoundsException e) { System.out.println("start: " + start + " count: " + count + " startOffset:" + startOffset + " count:" + count + " len(buf):" + buf.length + " (start - startOffset):" + (start - startOffset)); throw e; } return result; }
public ByteBuffer get(long offset, long size) throws IOException { byte[] b = new byte[l2i(size)]; raf.seek(offset); raf.read(b); return ByteBuffer.wrap(b); }
public synchronized ByteBuffer map(long startPosition, long size) throws IOException { ByteBuffer bb = ByteBuffer.allocate(l2i(size)); fc.read(bb, startPosition); return (ByteBuffer) bb.rewind(); }
/** * Gets all samples starting with <code>startSample</code> (one based -> one is the first) and * ending with <code>endSample</code> (exclusive). * * @param startSample low endpoint (inclusive) of the sample sequence * @param endSample high endpoint (exclusive) of the sample sequence * @param track source of the samples * @return a <code>List<Sample></code> of raw samples */ protected List<Sample> getSamples(long startSample, long endSample, Track track) { // since startSample and endSample are one-based substract 1 before addressing list elements return track.getSamples().subList(l2i(startSample) - 1, l2i(endSample) - 1); }
public ByteBuffer asByteBuffer() { byte[] bCopy = new byte[l2i(size)]; ByteBuffer copy = ByteBuffer.wrap(bCopy); for (ByteBuffer b : data) { copy.put(b.duplicate()); } copy.rewind(); return copy; }
public ByteBuffer asByteBuffer() { return (ByteBuffer) ((ByteBuffer) finalTrunData.position(finalOffset)).slice().limit(l2i(sampleSize)); }
public ByteBuffer map(long startPosition, long size) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(l2i(size)); transferTo(startPosition, size, Channels.newChannel(baos)); return ByteBuffer.wrap(baos.toByteArray()); }
@Override public SampleEntry getSampleEntry() { return sampleEntries.size() == 1 ? sampleEntries.get(0) : sampleEntries.get(l2i(Math.max(0, tfhd.getSampleDescriptionIndex()-1))); } };
@Override public void parse(ReadableByteChannel dataSource, ByteBuffer header, long contentSize, BoxParser boxParser) throws IOException { ByteBuffer byteBuffer = ByteBuffer.allocate(CastUtils.l2i(contentSize)); dataSource.read(byteBuffer); byteBuffer.position(6); dataReferenceIndex = IsoTypeReader.readUInt16(byteBuffer); vc1Content = new byte[byteBuffer.remaining()]; byteBuffer.get(vc1Content); }
@Override public void parse(ReadableByteChannel dataSource, ByteBuffer header, long contentSize, BoxParser boxParser) throws IOException { ByteBuffer b1 = ByteBuffer.allocate(8); dataSource.read(b1); b1.position(6); dataReferenceIndex = IsoTypeReader.readUInt16(b1); data = new byte[CastUtils.l2i(contentSize - 8)]; dataSource.read(ByteBuffer.wrap(data)); }
public void addAndReplace(ParsableBox parsableBox) { data.position(CastUtils.l2i(parsableBox.getSize())); data = data.slice(); replacers.add(parsableBox); }
/** * {@inheritDoc} */ @DoNotParseDetail public void parse(ReadableByteChannel dataSource, ByteBuffer header, long contentSize, BoxParser boxParser) throws IOException { content = ByteBuffer.allocate(l2i(contentSize)); while ((content.position() < contentSize)) { if (dataSource.read(content) == -1) { LOG.error("{} might have been truncated by file end. bytesRead={} contentSize={}", this, content.position(), contentSize); break; } } content.position(0); isParsed = false; }
@Override public void _parseDetails(ByteBuffer content) { parseVersionAndFlags(content); int numberOfEntries = CastUtils.l2i(IsoTypeReader.readUInt32(content)); entries = new ArrayList<Entry>(numberOfEntries); for (int i = 0; i < numberOfEntries; i++) { Entry e = new Entry(CastUtils.l2i(IsoTypeReader.readUInt32(content)), content.getInt()); entries.add(e); } }
@Override public void parse(ByteBuffer byteBuffer) { operationPointCut = byteBuffer.getShort(); if (operationPointCut == 1) { targetRateShare = byteBuffer.getShort(); } else { int entriesLeft = operationPointCut; while (entriesLeft-- > 0) { entries.add(new Entry(CastUtils.l2i(IsoTypeReader.readUInt32(byteBuffer)), byteBuffer.getShort())); } } maximumBitrate = CastUtils.l2i(IsoTypeReader.readUInt32(byteBuffer)); minimumBitrate = CastUtils.l2i(IsoTypeReader.readUInt32(byteBuffer)); discardPriority = (short) IsoTypeReader.readUInt8(byteBuffer); }