C# Class MP4_Mangler.FileRoot

Utility object for building useful MP4f files and file parts. This is not thread-safe!
Datei anzeigen Open project: i-e-b/HLS---Smooth-Encoder Class Usage Examples

Public Methods

Method Description
EndFile ( ) : void

Close a started MP4f file, writing footer data. After calling this, WriteStream() will cache data.

FileRoot ( ) : System

Create a new file root with the given streams. Frame data will be cached until StartFile() is called.

Once a file is started, the tracks and streams can't be changed. If you know the tracks in advance, it uses less memory to start the file as early as possible. If you don't know the tracks in advance, don't StartFile() until all tracks are known. It is possible to Write all frames in all tracks then StartFile() and EndFile() in direct succession.

GenerateFileSpec ( ) : byte[]

Output a 'ftyp' atom and it's children as raw data for the current set of streams. Does not write to file.

GenerateFooters ( ) : byte[]

Output a 'mfra' atom and it's children as raw data.

GenerateFragment ( MediaStream Stream ) : MediaFragmentHandler

Generate a pair of 'moof' and 'mdat' atoms for the given stream. The stream should contains a populated list of frame data, otherwise output will be empty. Keeps track of fragment index. Does not write to file. Does not remove frames. Does not adjust offset time.

GenerateHeaders ( ) : byte[]

Output a 'moov' atom and it's children as raw data for the current set of streams. Does not write to file.

StartFile ( string FilePath ) : void

Start an MP4f file. After a sucessful call, all cached data will be sent to this file, and frame data will no longer be cached on subsequent WriteStream() calls.

WriteStream ( MediaStream SourceStream ) : void

Write the frames of a stream to a file if one is open or to memory if not.

Private Methods

Method Description
CacheStreamFrames ( MediaStream SourceStream ) : MediaStream

Store the frames of a stream in the KnownStreams cache, adding a new entry if needed. If there is a file open, then new streams will be refused with an argument exception

GenerateMoov ( ) : byte[]

Output a 'moov' atom and it's children as raw data.

Method Details

EndFile() public method

Close a started MP4f file, writing footer data. After calling this, WriteStream() will cache data.
public EndFile ( ) : void
return void

FileRoot() public method

Create a new file root with the given streams. Frame data will be cached until StartFile() is called.
Once a file is started, the tracks and streams can't be changed. If you know the tracks in advance, it uses less memory to start the file as early as possible. If you don't know the tracks in advance, don't StartFile() until all tracks are known. It is possible to Write all frames in all tracks then StartFile() and EndFile() in direct succession.
public FileRoot ( ) : System
return System

GenerateFileSpec() public method

Output a 'ftyp' atom and it's children as raw data for the current set of streams. Does not write to file.
public GenerateFileSpec ( ) : byte[]
return byte[]

GenerateFooters() public method

Output a 'mfra' atom and it's children as raw data.
public GenerateFooters ( ) : byte[]
return byte[]

GenerateFragment() public method

Generate a pair of 'moof' and 'mdat' atoms for the given stream. The stream should contains a populated list of frame data, otherwise output will be empty. Keeps track of fragment index. Does not write to file. Does not remove frames. Does not adjust offset time.
public GenerateFragment ( MediaStream Stream ) : MediaFragmentHandler
Stream MediaStream
return MP4_Mangler.FragmentBoxes.MediaFragmentHandler

GenerateHeaders() public method

Output a 'moov' atom and it's children as raw data for the current set of streams. Does not write to file.
public GenerateHeaders ( ) : byte[]
return byte[]

StartFile() public method

Start an MP4f file. After a sucessful call, all cached data will be sent to this file, and frame data will no longer be cached on subsequent WriteStream() calls.
public StartFile ( string FilePath ) : void
FilePath string
return void

WriteStream() public method

Write the frames of a stream to a file if one is open or to memory if not.
public WriteStream ( MediaStream SourceStream ) : void
SourceStream MediaStream
return void