Package org.red5.io.flv.impl
Class FLVWriter
- java.lang.Object
-
- org.red5.io.flv.impl.FLVWriter
-
- All Implemented Interfaces:
ITagWriter
public class FLVWriter extends Object implements ITagWriter
A Writer is used to write the contents of a FLV file- Author:
- The Red5 Project, Dominick Accattato (daccattato@gmail.com), Luke Hubbard, Codegent Ltd (luke@codegent.com), Tiago Jacobs (tiago@imdt.com.br), Paul Gregoire (mondain@gmail.com)
-
-
Constructor Summary
Constructors Constructor Description FLVWriter(boolean repair, String filePath)Creates writer implementation with for a given fileFLVWriter(File file, boolean append)Creates writer implementation with given file and flag indicating whether or not to append.FLVWriter(String filePath)Creates writer implementation with for a given fileFLVWriter(Path path, boolean append)Creates writer implementation with given file and flag indicating whether or not to append.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPostProcessor(IPostProcessor postProcessor)Adds a post-process for execution once the instance completes.voidclose()Ends the writing process, then merges the data file with the flv file header and metadata.longgetBytesWritten()Return the bytes writtenIStreamableFilegetFile()Return the file that is written.intgetOffset()Return the offsetstatic voidmain(String[] args)Exposed to allow repair of flv files if .info and .ser files still exist.static booleanrepair(String path, Integer audioId, Integer videoId)Allows repair of flv files if .info and .ser files still exist.voidsetAudioCodecId(int audioCodecId)voidsetAudioDataSize(int audioDataSize)voidsetDuration(int duration)static voidsetFLV(IFLV flv)Setter for FLV objectvoidsetOffset(int offset)Setter for offsetvoidsetSoundRate(int soundRate)voidsetSoundSize(int soundSize)voidsetSoundType(boolean soundType)voidsetVideoCodecId(int videoCodecId)voidsetVideoDataSize(int videoDataSize)voidwriteHeader()Writes the header bytesbooleanwriteStream(byte[] b)Write a Stream to disk using bytesbooleanwriteTag(byte dataType, org.apache.mina.core.buffer.IoBuffer data)Write a Tag using bytesbooleanwriteTag(ITag tag)Writes a Tag object
-
-
-
Constructor Detail
-
FLVWriter
public FLVWriter(String filePath)
Creates writer implementation with for a given file- Parameters:
filePath- path to existing file
-
FLVWriter
public FLVWriter(boolean repair, String filePath)Creates writer implementation with for a given file- Parameters:
repair- repair the .ser filefilePath- path to existing file
-
FLVWriter
public FLVWriter(File file, boolean append)
Creates writer implementation with given file and flag indicating whether or not to append. FLV.java uses this constructor so we have access to the file object- Parameters:
file- File output streamappend- true if append to existing file
-
FLVWriter
public FLVWriter(Path path, boolean append)
Creates writer implementation with given file and flag indicating whether or not to append. FLV.java uses this constructor so we have access to the file object- Parameters:
path- File output pathappend- true if append to existing file
-
-
Method Detail
-
writeHeader
public void writeHeader() throws IOExceptionWrites the header bytes- Specified by:
writeHeaderin interfaceITagWriter- Throws:
IOException- Any I/O exception
-
writeTag
public boolean writeTag(ITag tag) throws IOException
Writes a Tag object- Specified by:
writeTagin interfaceITagWriter- Parameters:
tag- Tag to write- Returns:
trueon success,falseotherwise- Throws:
IOException- I/O exception
-
writeTag
public boolean writeTag(byte dataType, org.apache.mina.core.buffer.IoBuffer data) throws IOExceptionWrite a Tag using bytes- Specified by:
writeTagin interfaceITagWriter- Parameters:
dataType- Tag typedata- Byte data- Returns:
trueon success,falseotherwise- Throws:
IOException- I/O exception
-
writeStream
public boolean writeStream(byte[] b)
Write a Stream to disk using bytes- Specified by:
writeStreamin interfaceITagWriter- Parameters:
b- Array of bytes to write- Returns:
trueon success,falseotherwise
-
close
public void close()
Ends the writing process, then merges the data file with the flv file header and metadata.- Specified by:
closein interfaceITagWriter
-
addPostProcessor
public void addPostProcessor(IPostProcessor postProcessor)
Adds a post-process for execution once the instance completes.- Specified by:
addPostProcessorin interfaceITagWriter- Parameters:
postProcessor- an implementation instance of IPostProcessor
-
getFile
public IStreamableFile getFile()
Return the file that is written.- Specified by:
getFilein interfaceITagWriter- Returns:
- the File to be written
-
setFLV
public static void setFLV(IFLV flv)
Setter for FLV object- Parameters:
flv- FLV source
-
getOffset
public int getOffset()
Return the offset- Specified by:
getOffsetin interfaceITagWriter- Returns:
- Offset value
-
setOffset
public void setOffset(int offset)
Setter for offset- Parameters:
offset- Value to set for offset
-
getBytesWritten
public long getBytesWritten()
Return the bytes written- Specified by:
getBytesWrittenin interfaceITagWriter- Returns:
- Number of bytes written
-
setVideoCodecId
public void setVideoCodecId(int videoCodecId)
-
setAudioCodecId
public void setAudioCodecId(int audioCodecId)
-
setSoundRate
public void setSoundRate(int soundRate)
-
setSoundSize
public void setSoundSize(int soundSize)
-
setSoundType
public void setSoundType(boolean soundType)
-
setDuration
public void setDuration(int duration)
-
setVideoDataSize
public void setVideoDataSize(int videoDataSize)
-
setAudioDataSize
public void setAudioDataSize(int audioDataSize)
-
repair
public static boolean repair(String path, Integer audioId, Integer videoId) throws InterruptedException
Allows repair of flv files if .info and .ser files still exist.- Parameters:
path- path to .ser fileaudioId- audio codec idvideoId- video codec id- Returns:
- true if conversion was successful
- Throws:
InterruptedException- Exception on interruption
-
main
public static void main(String[] args) throws InterruptedException
Exposed to allow repair of flv files if .info and .ser files still exist.- Parameters:
args- 0: path to .ser file 1: audio codec id 2: video codec id- Throws:
InterruptedException- Exception on interruption
-
-