Package org.red5.io.m4a.impl
Class M4AReader
- java.lang.Object
-
- org.red5.io.m4a.impl.M4AReader
-
- All Implemented Interfaces:
IoConstants,ITagReader
public class M4AReader extends Object implements IoConstants, ITagReader
A Reader is used to read the contents of a M4A file. NOTE: This class is not implemented as threading-safe. The caller should make sure the threading-safety.- Author:
- The Red5 Project, Paul Gregoire, (mondain@gmail.com)
-
-
Field Summary
-
Fields inherited from interface org.red5.io.IoConstants
AVC_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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidanalyzeFrames()Performs frame analysis and generates metadata for use in seeking.voidclose()Closes the reader and free any allocated memory.voiddecodeHeader()This handles the moov atom being at the beginning or end of the file, so the mdat may also be before or after the moov atom.StringgetAudioCodecId()longgetBytesRead()Returns the amount of bytes readlonggetDuration()Return length in secondsIStreamableFilegetFile()Return the file that is loaded.org.apache.mina.core.buffer.IoBuffergetFileData()Returns the file buffer.intgetOffset()Returns the offet lengthlonggetTotalBytes()Get the total readable bytes in a file or ByteBufferbooleanhasMoreTags()Returns a boolean stating whether the FLV has more tagsbooleanhasVideo()Check if the reader also has video tags.voidposition(long pos)Put the current position to pos.ITagreadTag()Packages media data for return to providers.ITagreadTagHeader()voidsetAudioCodecId(String audioCodecId)
-
-
-
Constructor Detail
-
M4AReader
public M4AReader(File f) throws IOException
Creates M4A reader from file input stream, sets up metadata generation flag.- Parameters:
f- File input stream- Throws:
IOException- on IO error
-
-
Method Detail
-
decodeHeader
public void decodeHeader()
This handles the moov atom being at the beginning or end of the file, so the mdat may also be before or after the moov atom.- Specified by:
decodeHeaderin interfaceITagReader
-
getTotalBytes
public long getTotalBytes()
Description copied from interface:ITagReaderGet the total readable bytes in a file or ByteBuffer- Specified by:
getTotalBytesin interfaceITagReader- Returns:
- Total readable bytes
-
hasVideo
public boolean hasVideo()
Check if the reader also has video tags.- Specified by:
hasVideoin interfaceITagReader- Returns:
- has video
-
getFileData
public org.apache.mina.core.buffer.IoBuffer getFileData()
Returns the file buffer.- Returns:
- File contents as byte buffer
-
getFile
public IStreamableFile getFile()
Return the file that is loaded.- Specified by:
getFilein interfaceITagReader- Returns:
- the file to be loaded
-
getOffset
public int getOffset()
Returns the offet length- Specified by:
getOffsetin interfaceITagReader- Returns:
- int
-
getBytesRead
public long getBytesRead()
Returns the amount of bytes read- Specified by:
getBytesReadin interfaceITagReader- Returns:
- long
-
getDuration
public long getDuration()
Return length in seconds- Specified by:
getDurationin interfaceITagReader- Returns:
- length in seconds
-
getAudioCodecId
public String getAudioCodecId()
-
hasMoreTags
public boolean hasMoreTags()
Returns a boolean stating whether the FLV has more tags- Specified by:
hasMoreTagsin interfaceITagReader- Returns:
- boolean
-
readTag
public ITag readTag()
Packages media data for return to providers.- Specified by:
readTagin interfaceITagReader- Returns:
- Tag
-
analyzeFrames
public void analyzeFrames()
Performs frame analysis and generates metadata for use in seeking. All the frames are analyzed and sorted together based on time and offset.
-
position
public void position(long pos)
Put the current position to pos. The caller must ensure the pos is a valid one.- Specified by:
positionin interfaceITagReader- Parameters:
pos- position to move to in file / channel
-
close
public void close()
Closes the reader and free any allocated memory.- Specified by:
closein interfaceITagReader
-
setAudioCodecId
public void setAudioCodecId(String audioCodecId)
-
readTagHeader
public ITag readTagHeader()
-
-