Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.red5.io.mp4.impl
Class MP4Reader

    java.lang.Object
      org.red5.io.mp4.impl.MP4Reader

All Implemented Interfaces:
  IoConstants, ITagReader

    public class MP4Reader

extends Object
implements IoConstants, ITagReader

This reader is used to read the contents of an MP4 file. NOTE: This class is not implemented as thread-safe, the caller should ensure the thread-safety.

New NetStream notifications
Two new notifications facilitate the implementation of the playback components:

- NetStream.Play.FileStructureInvalid: This event is sent if the player detects an MP4 with an invalid file structure. Flash Player cannot play files that have invalid file structures.
- NetStream.Play.NoSupportedTrackFound: This event is sent if the player does not detect any supported tracks. If there aren't any supported video, audio or data tracks found, Flash Player does not play the file.

Author:
  The Red5 Project (red5@osflash.org), Paul Gregoire (mondain@gmail.com)

Field Summary
`static byte[]` | `AUDIO_CONFIG_FRAME_AAC_LC` Audio config aac lc
`static byte[]` | `AUDIO_CONFIG_FRAME_AAC_MAIN` Audio config aac main
`static byte[]` | `AUDIO_CONFIG_FRAME_SBR` Audio config sbr
`static byte[]` | `PREFIX_AUDIO_FRAME` Audio packet prefix
`static byte[]` | `PREFIX_VIDEO_CONFIG_FRAME` Video packet prefix for the decoder frame
`static byte[]` | `PREFIX_VIDEO_FRAME` Video packet prefix for standard frames (interframe)
`static byte[]` | `PREFIX_VIDEO_KEYFRAME` Video packet prefix for key frames

Fields inherited from interface org.red5.io.IoConstants
`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_INTERFRAME, FLAG_FRAMETYPE_KEYFRAME, FLAG_RATE_11_KHZ, FLAG_RATE_22_KHZ, FLAG_RATE_44_KHZ, FLAG_RATE_5_5_KHZ, FLAG_SIZE_16_BIT, FLAG_SIZE_8_BIT, FLAG_TYPE_MONO, FLAG_TYPE_STEREO, MASK_SOUND_FORMAT, MASK_SOUND_RATE, MASK_SOUND_SIZE, MASK_SOUND_TYPE, MASK_VIDEO_CODEC, MASK_VIDEO_FRAMETYPE, TYPE_AUDIO, TYPE_METADATA, TYPE_VIDEO`

Constructor Summary
`MP4Reader(File f)` Creates MP4 reader from file input stream, sets up metadata generation flag.

Method Summary
`void` | `analyzeFrames()` Performs frame analysis and generates metadata for use in seeking.
`void` | `close()` Closes the reader and free any allocated memory.
`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.
`String` | `getAudioCodecId()`
`long` | `getBytesRead()` Returns the amount of bytes read
`long` | `getDuration()` Return length in seconds
`IStreamableFile` | `getFile()` Return the file that is loaded.
`IoBuffer` | `getFileData()` Returns the file buffer.
`long` | `getFramePosition(int timestamp)` Returns the position of a frame given the timestamp.
`int` | `getOffset()` Returns the offet length
`long` | `getTotalBytes()` Get the total readable bytes in a file or IoBuffer.
`String` | `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()` Packages media data for return to providers.
`ITag` | `readTagHeader()`
`void` | `setAudioCodecId(String audioCodecId)`
`void` | `setVideoCodecId(String videoCodecId)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### PREFIX_AUDIO_FRAME

    public static final byte[] PREFIX_AUDIO_FRAME

  Audio packet prefix

### AUDIO_CONFIG_FRAME_AAC_MAIN

    public static final byte[] AUDIO_CONFIG_FRAME_AAC_MAIN

  Audio config aac main

### AUDIO_CONFIG_FRAME_AAC_LC

    public static final byte[] AUDIO_CONFIG_FRAME_AAC_LC

  Audio config aac lc

### AUDIO_CONFIG_FRAME_SBR

    public static final byte[] AUDIO_CONFIG_FRAME_SBR

  Audio config sbr

### PREFIX_VIDEO_CONFIG_FRAME

    public static final byte[] PREFIX_VIDEO_CONFIG_FRAME

  Video packet prefix for the decoder frame

### PREFIX_VIDEO_KEYFRAME

    public static final byte[] PREFIX_VIDEO_KEYFRAME

  Video packet prefix for key frames

### PREFIX_VIDEO_FRAME

    public static final byte[] PREFIX_VIDEO_FRAME

  Video packet prefix for standard frames (interframe)

Constructor Detail

### MP4Reader

    public MP4Reader(File f)
              throws IOException

  Creates MP4 reader from file input stream, sets up metadata generation flag.

  Parameters:
    `f` - File input stream
  Throws:
    `IOException`

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:
    `decodeHeader` in interface `ITagReader`

### getTotalBytes

    public long getTotalBytes()

  Get the total readable bytes in a file or IoBuffer.

  Specified by:
    `getTotalBytes` in interface `ITagReader`
  Returns:
    Total readable bytes

### hasVideo

    public boolean hasVideo()

  Check if the reader also has video tags.

  Specified by:
    `hasVideo` in interface `ITagReader`
  Returns:
    has video

### getFileData

    public IoBuffer getFileData()

  Returns the file buffer.

  Returns:
    File contents as byte buffer

### getFile

    public IStreamableFile getFile()

  Return the file that is loaded.

  Specified by:
    `getFile` in interface `ITagReader`
  Returns:
    the file to be loaded

### getOffset

    public int getOffset()

  Returns the offet length

  Specified by:
    `getOffset` in interface `ITagReader`
  Returns:
    int

### getBytesRead

    public long getBytesRead()

  Returns the amount of bytes read

  Specified by:
    `getBytesRead` in interface `ITagReader`
  Returns:
    long

### getDuration

    public long getDuration()

  Return length in seconds

  Specified by:
    `getDuration` in interface `ITagReader`
  Returns:
    length in seconds

### getVideoCodecId

    public String getVideoCodecId()

### getAudioCodecId

    public String getAudioCodecId()

### hasMoreTags

    public boolean hasMoreTags()

  Returns a boolean stating whether the FLV has more tags

  Specified by:
    `hasMoreTags` in interface `ITagReader`
  Returns:
    boolean

### readTag

    public ITag readTag()

  Packages media data for return to providers.

  Specified by:
    `readTag` in interface `ITagReader`
  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.

### getFramePosition

    public long getFramePosition(int timestamp)

  Returns the position of a frame given the timestamp.

  Parameters:
    `timestamp` -
  Returns:
    the position

### position

    public void position(long pos)

  Put the current position to pos. The caller must ensure the pos is a valid one.

  Specified by:
    `position` in interface `ITagReader`
  Parameters:
    `pos` - position to move to in file / channel

### close

    public void close()

  Closes the reader and free any allocated memory.

  Specified by:
    `close` in interface `ITagReader`

### setVideoCodecId

    public void setVideoCodecId(String videoCodecId)

### setAudioCodecId

    public void setAudioCodecId(String audioCodecId)

### readTagHeader

    public ITag readTagHeader()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2006-2010 The Red5 Project