@Override public Collection<Collection<Writable>> sequenceRecord() { File next = iter.next(); try{ return loadData(NIOUtils.readableFileChannel(next)); }catch(IOException e){ throw new RuntimeException(e); } }
public static ByteBuffer fetchFrom(File file, int length) throws IOException { FileChannel is = null; try { is = new FileInputStream(file).getChannel(); return fetchFrom(is, length); } finally { closeQuietly(is); } }
public static ByteBuffer combine(ByteBuffer... buffer) { return combine(buffer); }
if ((flags & 0x1) != 0) // self ref return; type = NIOUtils.readString(is, 4); recordSize = is.getShort(); version = is.getShort(); kind = is.getShort(); volumeName = NIOUtils.readPascalString(is, 27); volumeCreateDate = is.getInt(); volumeSignature = is.getShort(); volumeType = is.getShort(); parentDirId = is.getInt(); fileName = NIOUtils.readPascalString(is, 63); fileNumber = is.getInt(); createdLocalDate = is.getInt(); fileTypeName = NIOUtils.readString(is, 4); creatorName = NIOUtils.readString(is, 4); nlvlFrom = is.getShort(); nlvlTo = is.getShort(); volumeAttributes = is.getInt(); fsId = is.getShort(); NIOUtils.skip(is, 10); break; int len = is.getShort(); byte[] bs = NIOUtils.toArray(NIOUtils.read(is, (len + 1) & 0xfffffffe)); if (bs == null) break;
public void readFile(File source, int bufferSize, FileReaderListener listener) throws IOException { ByteBuffer buf = ByteBuffer.allocate(bufferSize); SeekableByteChannel ch = null; try { ch = NIOUtils.readableFileChannel(source); long size = ch.size(); for (long pos = ch.position(); ch.read(buf) != -1; pos = ch.position()) { buf.flip(); data(buf, pos); buf.flip(); if (listener != null) { int newPd = (int) (100 * pos / size); if (newPd != oldPd) listener.progress(newPd); oldPd = newPd; } } } finally { NIOUtils.closeQuietly(ch); } } }
public static ByteBuffer fetchFrom(File file) throws IOException { return NIOUtils.fetchFrom(file, (int) file.length()); }
/** * NALProcessor to mux a raw h264 stream into a mp4 file * * @param file File to save to * @param fps frame rate of the video * @param width Width of the video * @param height Height of the video * @throws IOException */ public MP4H264Muxer(File file, int fps, int width, int height) throws IOException { this.width = width; this.height = height; channel = NIOUtils.writableFileChannel(file); muxer = new MP4Muxer(channel); timescale = fps; track = muxer.addTrack(TrackType.VIDEO, timescale); }
public static ByteBuffer fetchFrom(ReadableByteChannel ch, int size) throws IOException { ByteBuffer buf = ByteBuffer.allocate(size); NIOUtils.read(ch, buf); buf.flip(); return buf; }
@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 void writeTo(ByteBuffer buffer, File file) throws IOException { FileChannel out = null; try { out = new FileOutputStream(file).getChannel(); out.write(buffer); } finally { closeQuietly(out); } }
public void parse(ByteBuffer input) { name = NIOUtils.readNullTermString(input); }
public void copy(SeekableByteChannel input, WritableByteChannel out) throws IOException { input.position(offset); NIOUtils.copy(input, out, header.getSize()); } }
public static final MappedByteBuffer map(String fileName) throws IOException { return map(new File(fileName)); }
if ((flags & 0x1) != 0) // self ref return; type = NIOUtils.readString(is, 4); recordSize = is.getShort(); version = is.getShort(); kind = is.getShort(); volumeName = NIOUtils.readPascalString(is, 27); volumeCreateDate = is.getInt(); volumeSignature = is.getShort(); volumeType = is.getShort(); parentDirId = is.getInt(); fileName = NIOUtils.readPascalString(is, 63); fileNumber = is.getInt(); createdLocalDate = is.getInt(); fileTypeName = NIOUtils.readString(is, 4); creatorName = NIOUtils.readString(is, 4); nlvlFrom = is.getShort(); nlvlTo = is.getShort(); volumeAttributes = is.getInt(); fsId = is.getShort(); NIOUtils.skip(is, 10); break; int len = is.getShort(); byte[] bs = NIOUtils.toArray(NIOUtils.read(is, (len + 1) & 0xfffffffe)); if (bs == null) break;
public void readFile(File source, int bufferSize, FileReaderListener listener) throws IOException { ByteBuffer buf = ByteBuffer.allocate(bufferSize); SeekableByteChannel ch = null; try { ch = NIOUtils.readableFileChannel(source); long size = ch.size(); for (long pos = ch.position(); ch.read(buf) != -1; pos = ch.position()) { buf.flip(); data(buf, pos); buf.flip(); if (listener != null) { int newPd = (int) (100 * pos / size); if (newPd != oldPd) listener.progress(newPd); oldPd = newPd; } } } finally { NIOUtils.closeQuietly(ch); } } }
public static ByteBuffer fetchFrom(File file) throws IOException { return NIOUtils.fetchFrom(file, (int) file.length()); }
/** * NALProcessor to mux a raw h264 stream into a mp4 file * * @param file File to save to * @param fps frame rate of the video * @param width Width of the video * @param height Height of the video * @throws IOException */ public MP4H264Muxer(File file, int fps, int width, int height) throws IOException { this.width = width; this.height = height; channel = NIOUtils.writableFileChannel(file); muxer = new MP4Muxer(channel); timescale = fps; track = muxer.addTrack(TrackType.VIDEO, timescale); }
public static ByteBuffer fetchFrom(ReadableByteChannel ch, int size) throws IOException { ByteBuffer buf = ByteBuffer.allocate(size); NIOUtils.read(ch, buf); buf.flip(); return buf; }