public class FLVReader extends Object implements IoConstants, ITagReader, IKeyFrameDataAnalyzer
IKeyFrameDataAnalyzer.KeyFrameMetaAVC_PACKET_TYPE_END_OF_SEQUENCE, AVC_PACKET_TYPE_NALU, AVC_PACKET_TYPE_SEQUENCE_HEADER, FLAG_CODEC_H263, FLAG_CODEC_SCREEN, FLAG_CODEC_VP6, FLAG_FORMAT_ADPCM, FLAG_FORMAT_MP3, FLAG_FORMAT_NELLYMOSER, FLAG_FORMAT_NELLYMOSER_8_KHZ, FLAG_FORMAT_RAW, FLAG_FRAMETYPE_DISPOSABLE, FLAG_FRAMETYPE_GENERATED_KEYFRAME, FLAG_FRAMETYPE_INFO, FLAG_FRAMETYPE_INTERFRAME, FLAG_FRAMETYPE_KEYFRAME, FLAG_RATE_11_KHZ, FLAG_RATE_22_KHZ, FLAG_RATE_44_KHZ, FLAG_RATE_48_KHZ, FLAG_RATE_5_5_KHZ, FLAG_SIZE_16_BIT, FLAG_SIZE_8_BIT, FLAG_TYPE_MONO, FLAG_TYPE_STEREO, INFO_PACKET_SEEK_END, INFO_PACKET_SEEK_START, MASK_SOUND_FORMAT, MASK_SOUND_RATE, MASK_SOUND_SIZE, MASK_SOUND_TYPE, MASK_VIDEO_CODEC, MASK_VIDEO_FRAMETYPE, TYPE_AUDIO, TYPE_ENCRYPTED, TYPE_ENCRYPTED_AUDIO, TYPE_ENCRYPTED_METADATA, TYPE_ENCRYPTED_VIDEO, TYPE_METADATA, TYPE_VIDEO| Constructor and Description |
|---|
FLVReader(File f)
Creates FLV reader from file input stream.
|
FLVReader(File f,
boolean generateMetadata)
Creates FLV reader from file input stream, sets up metadata generation flag.
|
FLVReader(FileChannel channel)
Creates FLV reader from file channel.
|
FLVReader(org.apache.mina.core.buffer.IoBuffer buffer,
boolean generateMetadata)
Accepts mapped file bytes to construct internal members.
|
| Modifier and Type | Method and Description |
|---|---|
IKeyFrameDataAnalyzer.KeyFrameMeta |
analyzeKeyFrames()
Key frames analysis may be used as a utility method so synchronize it.
|
void |
close()
Closes the reader and free any allocated memory.
|
void |
decodeHeader()
Decode the header of the stream;
|
int |
getAudioCodecId() |
static int |
getBufferSize()
Getter for buffer size.
|
static String |
getBufferType()
Getter for buffer type (auto, direct or heap).
|
long |
getBytesRead()
Returns the amount of bytes read
|
long |
getDuration()
Return length in seconds
|
static int |
getDuration(File flvFile)
Returns the last tag's timestamp as the files duration.
|
IStreamableFile |
getFile()
Return the file that is loaded.
|
org.apache.mina.core.buffer.IoBuffer |
getFileData()
Returns the file buffer.
|
int |
getOffset()
Returns the offet length
|
long |
getTotalBytes()
Get the total readable bytes in a file or ByteBuffer.
|
int |
getVideoCodecId() |
boolean |
hasMoreTags()
Returns a boolean stating whether the FLV has more tags
|
boolean |
hasVideo()
Check if the reader also has video tags.
|
void |
position(long pos)
Put the current position to pos.
|
ITag |
readTag()
Returns a Tag object
|
static void |
setBufferSize(int bufferSize)
Setter for property 'bufferSize'.
|
static void |
setBufferType(String bufferType)
Setter for buffer type.
|
void |
setKeyFrameCache(IKeyFrameMetaCache keyframeCache) |
public FLVReader(File f) throws IOException
f - FileIOException - on errorpublic FLVReader(File f, boolean generateMetadata) throws IOException
f - File input streamgenerateMetadata - true if metadata generation required, false otherwiseIOException - on errorpublic FLVReader(FileChannel channel) throws IOException
channel - file channelIOException - on errorpublic FLVReader(org.apache.mina.core.buffer.IoBuffer buffer,
boolean generateMetadata)
generateMetadata - true if metadata generation required, false otherwisebuffer - IoBufferpublic void setKeyFrameCache(IKeyFrameMetaCache keyframeCache)
public long getTotalBytes()
getTotalBytes in interface ITagReaderpublic boolean hasVideo()
hasVideo in interface ITagReaderpublic static String getBufferType()
public static void setBufferType(String bufferType)
bufferType - Value to set for property 'bufferType'public static int getBufferSize()
public static void setBufferSize(int bufferSize)
bufferSize - Value to set for property 'bufferSize'public org.apache.mina.core.buffer.IoBuffer getFileData()
public void decodeHeader()
decodeHeader in interface ITagReaderpublic IStreamableFile getFile()
getFile in interface ITagReaderpublic int getOffset()
getOffset in interface ITagReaderpublic long getBytesRead()
getBytesRead in interface ITagReaderpublic long getDuration()
getDuration in interface ITagReaderpublic int getVideoCodecId()
public int getAudioCodecId()
public boolean hasMoreTags()
hasMoreTags in interface ITagReaderpublic ITag readTag()
readTag in interface ITagReaderpublic void close()
close in interface ITagReaderpublic IKeyFrameDataAnalyzer.KeyFrameMeta analyzeKeyFrames()
analyzeKeyFrames in interface IKeyFrameDataAnalyzerpublic void position(long pos)
position in interface ITagReaderpos - New position in file. Pass Long.MAX_VALUE to seek to end of file.public static int getDuration(File flvFile)
flvFile - FLV fileCopyright © 2005–2017 Red5. All rights reserved.