use of org.red5.io.flv.FLVHeader in project red5-io by Red5.
the class FLVReader method decodeHeader.
/**
* {@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());
}
}
use of org.red5.io.flv.FLVHeader in project red5-io by Red5.
the class FLVWriter method writeHeader.
/**
* Writes the header bytes
*
* @throws IOException
* Any I/O exception
*/
@Override
public void writeHeader() throws IOException {
// create a buffer
// FLVHeader (9 bytes) + PreviousTagSize0 (4 bytes)
ByteBuffer buf = ByteBuffer.allocate(HEADER_LENGTH + 4);
// 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;
}
Aggregations