本文整理汇总了Java中org.red5.io.flv.FLVHeader类的典型用法代码示例。如果您正苦于以下问题:Java FLVHeader类的具体用法?Java FLVHeader怎么用?Java FLVHeader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FLVHeader类属于org.red5.io.flv包,在下文中一共展示了FLVHeader类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeHeader
import org.red5.io.flv.FLVHeader; //导入依赖的package包/类
/**
* Writes the header bytes
*
* @throws IOException
* Any I/O exception
*/
@Override
public void writeHeader() throws IOException {
// create a buffer
ByteBuffer buf = ByteBuffer.allocate(HEADER_LENGTH + 4); // FLVHeader (9 bytes) + PreviousTagSize0 (4 bytes)
// instance an flv header
FLVHeader flvHeader = new FLVHeader();
flvHeader.setFlagAudio(audioCodecId != -1 ? true : false);
flvHeader.setFlagVideo(videoCodecId != -1 ? true : false);
// write the flv header in the buffer
flvHeader.write(buf);
// the final version of the file will go here
createOutputFile();
// write header to output channel
bytesWritten = fileChannel.write(buf);
assert ((HEADER_LENGTH + 4) - bytesWritten == 0);
log.debug("Header size: {} bytes written: {}", (HEADER_LENGTH + 4), bytesWritten);
buf.clear();
buf = null;
}
示例2: writeHeader
import org.red5.io.flv.FLVHeader; //导入依赖的package包/类
/**
* Writes the header bytes
*
* @throws IOException Any I/O exception
*/
public void writeHeader() throws IOException {
FLVHeader flvHeader = new FLVHeader();
flvHeader.setFlagAudio(audioCodecId != -1 ? true : false);
flvHeader.setFlagVideo(videoCodecId != -1 ? true : false);
// create a buffer
ByteBuffer header = ByteBuffer.allocate(HEADER_LENGTH + 4); // FLVHeader (9 bytes) + PreviousTagSize0 (4 bytes)
flvHeader.write(header);
// the final version of the file will go here
this.file = new RandomAccessFile(filePath, "rw");
// write header to output channel
file.setLength(HEADER_LENGTH + 4);
if (header.hasArray()) {
log.debug("Header bytebuffer has a backing array");
file.write(header.array());
} else {
log.debug("Header bytebuffer does not have a backing array");
byte[] tmp = new byte[HEADER_LENGTH + 4];
header.get(tmp);
file.write(tmp);
}
bytesWritten = file.length();
assert ((HEADER_LENGTH + 4) - bytesWritten == 0);
log.debug("Header size: {} bytes written: {}", (HEADER_LENGTH + 4), bytesWritten);
header.clear();
header = null;
}
示例3: decodeHeader
import org.red5.io.flv.FLVHeader; //导入依赖的package包/类
/** {@inheritDoc} */
public void decodeHeader() {
// flv header is 9 bytes
fillBuffer(9);
header = new FLVHeader();
// skip signature
in.skip(4);
header.setTypeFlags(in.get());
header.setDataOffset(in.getInt());
if (log.isDebugEnabled()) {
log.debug("Header: {}", header.toString());
}
}
示例4: decodeHeader
import org.red5.io.flv.FLVHeader; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void decodeHeader() {
// flv header is 9 bytes
fillBuffer(9);
header = new FLVHeader();
// skip signature
in.skip(4);
header.setTypeFlags(in.get());
header.setDataOffset(in.getInt());
if (log.isDebugEnabled()) {
log.debug("Header: {}", header.toString());
}
}