本文整理汇总了Java中org.jcodec.common.SeekableByteChannel.position方法的典型用法代码示例。如果您正苦于以下问题:Java SeekableByteChannel.position方法的具体用法?Java SeekableByteChannel.position怎么用?Java SeekableByteChannel.position使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jcodec.common.SeekableByteChannel
的用法示例。
在下文中一共展示了SeekableByteChannel.position方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRootAtoms
import org.jcodec.common.SeekableByteChannel; //导入方法依赖的package包/类
public static List<Atom> getRootAtoms(SeekableByteChannel input) throws IOException {
input.position(0);
List<Atom> result = new ArrayList<Atom>();
long off = 0;
Header atom;
while (off < input.size()) {
input.position(off);
atom = Header.read(NIOUtils.fetchFrom(input, 16));
if (atom == null)
break;
result.add(new Atom(atom, off));
off += atom.getSize();
}
return result;
}
示例2: Y4MDecoder
import org.jcodec.common.SeekableByteChannel; //导入方法依赖的package包/类
public Y4MDecoder(SeekableByteChannel is) throws IOException {
ByteBuffer buf = NIOUtils.fetchFrom(is, 2048);
String[] header = split(readLine(buf), ' ');
if (!"YUV4MPEG2".equals(header[0])) {
invalidFormat = "Not yuv4mpeg stream";
return;
}
String chroma = find(header, 'C');
if (chroma != null && !chroma.startsWith("420")) {
invalidFormat = "Only yuv420p is supported";
return;
}
width = Integer.parseInt(find(header, 'W'));
height = Integer.parseInt(find(header, 'H'));
String fpsStr = find(header, 'F');
if (fpsStr != null) {
String[] numden = split(fpsStr, ':');
fps = new Rational(Integer.parseInt(numden[0]), Integer.parseInt(numden[1]));
}
is.position(buf.position());
bufSize = width * height * 2;
}
示例3: cacheAudioFrameSizes
import org.jcodec.common.SeekableByteChannel; //导入方法依赖的package包/类
private void cacheAudioFrameSizes(SeekableByteChannel ch) throws IOException {
for (MXFPartition mxfPartition : partitions) {
if (mxfPartition.getEssenceLength() > 0) {
ch.position(mxfPartition.getEssenceFilePos());
KLV kl;
do {
kl = KLV.readKL(ch);
if (kl == null)
break;
ch.position(ch.position() + kl.len);
} while (!essenceUL.equals(kl.key));
if (essenceUL.equals(kl.key)) {
dataLen = (int) kl.len;
break;
}
}
}
}
示例4: getData
import org.jcodec.common.SeekableByteChannel; //导入方法依赖的package包/类
@Override
public ByteBuffer getData() throws IOException {
ByteBuffer bb = ByteBuffer.allocate(packet.getSize());
SeekableByteChannel ch = null;
try {
ch = pool.getChannel();
if(packet.getFileOff() >= ch.size())
return null;
ch.position(packet.getFileOff());
ch.read(bb);
bb.flip();
return bb;
} finally {
if (ch != null)
ch.close();
}
}
示例5: getData
import org.jcodec.common.SeekableByteChannel; //导入方法依赖的package包/类
@Override
public ByteBuffer getData() throws IOException {
SeekableByteChannel ch = null;
try {
ch = fp.getChannel();
ch.position(pkt.getOffset());
KLV kl = KLV.readKL(ch);
while (kl != null && !essenceUL.equals(kl.key)) {
ch.position(ch.position() + kl.len);
kl = KLV.readKL(ch);
}
return kl != null && essenceUL.equals(kl.key) ? NIOUtils.fetchFrom(ch, (int) kl.len) : null;
} finally {
NIOUtils.closeQuietly(ch);
}
}
示例6: parseHeader
import org.jcodec.common.SeekableByteChannel; //导入方法依赖的package包/类
public void parseHeader(SeekableByteChannel ff) throws IOException {
KLV kl;
header = readHeaderPartition(ff);
metadata = new ArrayList<MXFMetadata>();
partitions = new ArrayList<MXFPartition>();
long nextPartition = ff.size();
ff.position(header.getPack().getFooterPartition());
do {
long thisPartition = ff.position();
kl = KLV.readKL(ff);
ByteBuffer fetchFrom = NIOUtils.fetchFrom(ff, (int) kl.len);
header = MXFPartition.read(kl.key, fetchFrom, ff.position() - kl.offset, nextPartition);
if (header.getPack().getNbEssenceContainers() > 0)
partitions.add(0, header);
metadata.addAll(0, readPartitionMeta(ff, header));
ff.position(header.getPack().getPrevPartition());
nextPartition = thisPartition;
} while (header.getPack().getThisPartition() != 0);
}
示例7: readPacketData
import org.jcodec.common.SeekableByteChannel; //导入方法依赖的package包/类
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;
}
示例8: write
import org.jcodec.common.SeekableByteChannel; //导入方法依赖的package包/类
public void write(Chunk chunk) throws IOException {
SeekableByteChannel input = getInput(chunk);
input.position(chunk.getOffset());
long pos = out.position();
out.write(NIOUtils.fetchFrom(input, (int) chunk.getSize()));
offsets[curChunk++] = pos;
}
示例9: WebOptimizedMP4Muxer
import org.jcodec.common.SeekableByteChannel; //导入方法依赖的package包/类
public WebOptimizedMP4Muxer(SeekableByteChannel output, Brand brand, int headerSize) throws IOException {
super(output, brand);
headerPos = output.position() - 24;
output.position(headerPos);
header = ByteBuffer.allocate(headerSize);
output.write(header);
header.clear();
new Header("wide", 8).write(output);
new Header("mdat", 1).write(output);
mdatOffset = output.position();
NIOUtils.writeLong(output, 0);
}
示例10: getData
import org.jcodec.common.SeekableByteChannel; //导入方法依赖的package包/类
@Override
public ByteBuffer getData() throws IOException {
SeekableByteChannel ch = null;
try {
ch = pool.getChannel();
ch.position(offset);
ByteBuffer buffer = ByteBuffer.allocate(dataLen);
NIOUtils.read(ch, buffer);
buffer.flip();
return buffer;
} finally {
ch.close();
}
}
示例11: readPes
import org.jcodec.common.SeekableByteChannel; //导入方法依赖的package包/类
protected ByteBuffer readPes(SeekableByteChannel ch, long pesPosition, int pesSize, int payloadSize, int pesIdx)
throws IOException {
ch.position(pesPosition);
ByteBuffer pes = NIOUtils.fetchFrom(ch, pesSize);
readPESHeader(pes, 0);
return pes;
}
示例12: readPes
import org.jcodec.common.SeekableByteChannel; //导入方法依赖的package包/类
@Override
protected ByteBuffer readPes(SeekableByteChannel ch, long pesPosition, int pesSize, int payloadSize,
int pesAbsIdx) throws IOException {
ch.position(pesPosition * 188);
ByteBuffer buf = NIOUtils.fetchFrom(ch, pesSize * 188);
// NOW REMOVE THE TS CRAP
ByteBuffer dst = buf.duplicate();
while (buf.hasRemaining()) {
ByteBuffer tsBuf = NIOUtils.read(buf, 188);
Assert.assertEquals(0x47, tsBuf.get() & 0xff);
int guidFlags = ((tsBuf.get() & 0xff) << 8) | (tsBuf.get() & 0xff);
int guid = (int) guidFlags & 0x1fff;
if (guid == targetGuid) {
int b0 = tsBuf.get() & 0xff;
int counter = b0 & 0xf;
if ((b0 & 0x20) != 0) {
NIOUtils.skip(tsBuf, tsBuf.get() & 0xff);
}
dst.put(tsBuf);
}
}
dst.flip();
readPESHeader(dst, 0);
dst.limit(dst.position() + payloadSize);
return dst;
}
示例13: readTsFile
import org.jcodec.common.SeekableByteChannel; //导入方法依赖的package包/类
public void readTsFile(SeekableByteChannel ch) throws IOException {
ch.position(0);
ByteBuffer buf = ByteBuffer.allocate(BUFFER_SIZE);
for (long pos = ch.position(); ch.read(buf) != -1; pos = ch.position()) {
buf.flip();
while (buf.hasRemaining()) {
ByteBuffer tsBuf = NIOUtils.read(buf, 188);
pos += 188;
Assert.assertEquals(0x47, tsBuf.get() & 0xff);
int guidFlags = ((tsBuf.get() & 0xff) << 8) | (tsBuf.get() & 0xff);
int guid = (int) guidFlags & 0x1fff;
int payloadStart = (guidFlags >> 14) & 0x1;
int b0 = tsBuf.get() & 0xff;
int counter = b0 & 0xf;
if ((b0 & 0x20) != 0) {
NIOUtils.skip(tsBuf, tsBuf.get() & 0xff);
}
boolean sectionSyntax = payloadStart == 1 && (getRel(tsBuf, getRel(tsBuf, 0) + 2) & 0x80) == 0x80;
if (sectionSyntax) {
NIOUtils.skip(tsBuf, tsBuf.get() & 0xff);
}
if (!onPkt(guid, payloadStart == 1, tsBuf, pos - tsBuf.remaining()))
return;
}
buf.flip();
}
}
示例14: MXFDemuxer
import org.jcodec.common.SeekableByteChannel; //导入方法依赖的package包/类
public MXFDemuxer(SeekableByteChannel ch) throws IOException {
this.ch = ch;
ch.position(0);
parseHeader(ch);
findIndex();
tracks = findTracks();
timecode = MXFUtil.findMeta(metadata, TimecodeComponent.class);
}
示例15: readPartitionMeta
import org.jcodec.common.SeekableByteChannel; //导入方法依赖的package包/类
public static List<MXFMetadata> readPartitionMeta(SeekableByteChannel ff, MXFPartition header) throws IOException {
KLV kl;
long basePos = ff.position();
List<MXFMetadata> local = new ArrayList<MXFMetadata>();
ByteBuffer metaBuffer = NIOUtils.fetchFrom(ff, (int) Math.max(0, header.getEssenceFilePos() - basePos));
while (metaBuffer.hasRemaining() && (kl = KLV.readKL(metaBuffer, basePos)) != null) {
MXFMetadata meta = parseMeta(kl.key, NIOUtils.read(metaBuffer, (int) kl.len));
if (meta != null)
local.add(meta);
}
return local;
}