public static ByteBuffer fetchFrom(ReadableByteChannel ch, int size) throws IOException { ByteBuffer buf = ByteBuffer.allocate(size); NIOUtils.read(ch, buf); buf.flip(); return buf; }
break; int len = is.getShort(); byte[] bs = NIOUtils.toArray(NIOUtils.read(is, (len + 1) & 0xfffffffe)); if (bs == null) break;
break; int len = is.getShort(); byte[] bs = NIOUtils.toArray(NIOUtils.read(is, (len + 1) & 0xfffffffe)); if (bs == null) break;
public static ByteBuffer fetchFrom(ReadableByteChannel ch, int size) throws IOException { ByteBuffer buf = ByteBuffer.allocate(size); NIOUtils.read(ch, buf); buf.flip(); return buf; }
/** * Reads size amount of bytes from ch into a new ByteBuffer allocated from a * buffer buf * * @param buf * @param ch * @param size * @return * @throws IOException */ public static ByteBuffer fetchFrom(ByteBuffer buf, ReadableByteChannel ch, int size) throws IOException { ByteBuffer result = buf.duplicate(); result.limit(size); NIOUtils.read(ch, result); result.flip(); return result; }
/** * Reads size amount of bytes from ch into a new ByteBuffer allocated from a * buffer buf * * @param buf * @param ch * @param size * @return * @throws IOException */ public static ByteBuffer fetchFrom(ByteBuffer buf, ReadableByteChannel ch, int size) throws IOException { ByteBuffer result = buf.duplicate(); result.limit(size); NIOUtils.read(ch, result); result.flip(); return result; }
protected ByteBuffer readPacketData(SeekableByteChannel input, ByteBuffer buffer, long offset, int size) throws IOException { ByteBuffer result = buffer.duplicate(); synchronized (input) { input.position(offset); NIOUtils.read(input, result, size); } result.flip(); return result; }
protected ByteBuffer readPacketData(SeekableByteChannel input, ByteBuffer buffer, long offset, int size) throws IOException { ByteBuffer result = buffer.duplicate(); synchronized (input) { input.position(offset); NIOUtils.read(input, result, size); } result.flip(); return result; }
public void parse(ByteBuffer input) { data = NIOUtils.read(input, (int) header.getBodySize()); }
public static String readString(ByteBuffer buffer, int len) { return new String(toArray(read(buffer, len))); }
public static String readString(ByteBuffer buffer, int len) { return new String(toArray(read(buffer, len))); }
public void parse(ByteBuffer input) { data = NIOUtils.read(input, (int) header.getBodySize()); }
public static Box parseChildBox(ByteBuffer input, BoxFactory factory) { ByteBuffer fork = input.duplicate(); while (input.remaining() >= 4 && fork.getInt() == 0) input.getInt(); if (input.remaining() < 4) return null; Header childAtom = Header.read(input); if (childAtom != null && input.remaining() >= childAtom.getBodySize()) return parseBox(NIOUtils.read(input, (int) childAtom.getBodySize()), childAtom, factory); else return null; }
@Override public void parse(ByteBuffer input) { NIOUtils.skip(input, 1); profile = input.get() & 0xff; profileCompat = input.get() & 0xff; level = input.get() & 0xff; int flags = input.get() & 0xff; nalLengthSize = (flags & 0x03) + 1; int nSPS = input.get() & 0x1f; // 3 bits reserved + 5 bits number of // sps for (int i = 0; i < nSPS; i++) { int spsSize = input.getShort(); Assert.assertEquals(0x27, input.get() & 0x3f); spsList.add(NIOUtils.read(input, spsSize - 1)); } int nPPS = input.get() & 0xff; for (int i = 0; i < nPPS; i++) { int ppsSize = input.getShort(); Assert.assertEquals(0x28, input.get() & 0x3f); ppsList.add(NIOUtils.read(input, ppsSize - 1)); } }
@Override public void parse(ByteBuffer input) { NIOUtils.skip(input, 1); profile = input.get() & 0xff; profileCompat = input.get() & 0xff; level = input.get() & 0xff; int flags = input.get() & 0xff; nalLengthSize = (flags & 0x03) + 1; int nSPS = input.get() & 0x1f; // 3 bits reserved + 5 bits number of // sps for (int i = 0; i < nSPS; i++) { int spsSize = input.getShort(); Assert.assertEquals(0x27, input.get() & 0x3f); spsList.add(NIOUtils.read(input, spsSize - 1)); } int nPPS = input.get() & 0xff; for (int i = 0; i < nPPS; i++) { int ppsSize = input.getShort(); Assert.assertEquals(0x28, input.get() & 0x3f); ppsList.add(NIOUtils.read(input, ppsSize - 1)); } }
public static Box parseChildBox(ByteBuffer input, BoxFactory factory) { ByteBuffer fork = input.duplicate(); while (input.remaining() >= 4 && fork.getInt() == 0) input.getInt(); if (input.remaining() < 4) return null; Header childAtom = Header.read(input); if (childAtom != null && input.remaining() >= childAtom.getBodySize()) return parseBox(NIOUtils.read(input, (int) childAtom.getBodySize()), childAtom, factory); else return null; }