#include <mxffile.h>
Inheritance diagram for MXFFile:
Public Member Functions | |
MXFFile () | |
~MXFFile () | |
virtual bool | Open (std::string FileName, bool ReadOnly=false) |
Open the named MXF file. | |
virtual bool | OpenNew (std::string FileName) |
Create and open the named MXF file. | |
virtual bool | OpenMemory (DataChunkPtr Buff=NULL, Position Offset=0) |
virtual bool | Close (void) |
Close the file. | |
bool | ReadRunIn (void) |
Read the files run-in (if it exists). | |
bool | ReadRIP (void) |
Read the RIP from the end of the open MXF file. | |
bool | ScanRIP (Length MaxScan=1024 *1024) |
Build a RIP for the open MXF file by scanning partitions following links back from the footer. | |
bool | BuildRIP (void) |
Build a RIP for the open MXF file by scanning the entire file for partitions. | |
bool | GetRIP (Length MaxScan=1024 *1024) |
Get a RIP for the open MXF. | |
PartitionPtr | ReadMasterPartition (Length MaxScan=1024 *1024) |
Locate and read a partition containing closed header metadata. | |
PartitionPtr | ReadFooterPartition (Length MaxScan=1024 *1024) |
Locate and read the footer partition. | |
Position | Tell (void) |
Report the position of the file pointer. | |
int | Seek (Position Pos) |
Move the file pointer. | |
int | SeekEnd (void) |
bool | Eof (void) |
Determine if the file pointer is at the end of the file. | |
DataChunkPtr | Read (size_t Size) |
Read data from the file into a DataChunk. | |
size_t | Read (UInt8 *Buffer, size_t Size) |
Read data from the file into a supplied buffer. | |
MDObjectPtr | ReadObject (PrimerPtr UsePrimer=NULL) |
PartitionPtr | ReadPartition (void) |
KLVObjectPtr | ReadKLV (void) |
Read a KLVObject from the file. | |
void | WritePartitionPack (PartitionPtr ThisPartition, PrimerPtr UsePrimer=NULL) |
Write a partition pack to the file. | |
void | WritePartition (PartitionPtr ThisPartition, UInt32 Padding=0, UInt32 MinPartitionSize=0) |
Write a partition pack and associated metadata (no index table segments). | |
void | WritePartitionWithIndex (PartitionPtr ThisPartition, DataChunkPtr IndexData, UInt32 Padding=0, UInt32 MinPartitionSize=0) |
Write a partition pack and associated metadata and preformatted index table segments. | |
void | WritePartition (PartitionPtr ThisPartition, PrimerPtr UsePrimer, UInt32 Padding=0, UInt32 MinPartitionSize=0) |
Write a partition pack and associated metadata (no index table segments). | |
void | WritePartitionWithIndex (PartitionPtr ThisPartition, DataChunkPtr IndexData, PrimerPtr UsePrimer, UInt32 Padding=0, UInt32 MinPartitionSize=0) |
Write a partition pack and associated metadata and preformatted index table segments. | |
void | WritePartition (PartitionPtr ThisPartition, bool IncludeMetadata, PrimerPtr UsePrimer=NULL, UInt32 Padding=0, UInt32 MinPartitionSize=0) |
Write a partition pack and (optionally) associated metadata (no index table segments). | |
void | WritePartitionWithIndex (PartitionPtr ThisPartition, DataChunkPtr IndexData, bool IncludeMetadata, PrimerPtr UsePrimer=NULL, UInt32 Padding=0, UInt32 MinPartitionSize=0) |
Write a partition pack and (optionally) associated metadata and preformatted index table segments. | |
bool | ReWritePartition (PartitionPtr ThisPartition, PrimerPtr UsePrimer=NULL) |
Re-write a partition pack and associated metadata (no index table segments). | |
bool | ReWritePartitionWithIndex (PartitionPtr ThisPartition, DataChunkPtr IndexData, PrimerPtr UsePrimer=NULL) |
Re-write a partition pack and associated metadata and preformatted index table segments. | |
void | WriteRIP (void) |
Write the RIP. | |
UInt32 | FillerSize (UInt64 FillPos, UInt32 KAGSize, UInt32 MinSize=0) |
Calculate the size of a filler to align to a specified KAG. | |
UInt32 | FillerSize (bool ForceBER4, UInt64 FillPos, UInt32 KAGSize, UInt32 MinSize=0) |
Calculate the size of a filler to align to a specified KAG. | |
UInt64 | Align (UInt32 KAGSize, UInt32 MinSize=0) |
Write a filler to align to a specified KAG. | |
UInt64 | Align (bool ForceBER4, UInt32 KAGSize, UInt32 MinSize=0) |
Write a filler to align to a specified KAG. | |
ULPtr | ReadKey (void) |
Read a Key length from the open file. | |
Length | ReadBER (void) |
Read a BER length from the open file. | |
UInt32 | WriteBER (UInt64 Length, UInt32 Size=0) |
Write a BER length. | |
size_t | Write (const UInt8 *Buffer, size_t Size) |
Write raw data. | |
size_t | Write (const DataChunk &Data) |
Write the contents of a DataChunk by reference. | |
size_t | Write (DataChunkPtr Data) |
Write the contents of a DataChunk by SmartPtr. | |
void | WriteU8 (UInt8 Val) |
Write 8-bit unsigned integer. | |
void | WriteU16 (UInt16 Val) |
Write 16-bit unsigned integer. | |
void | WriteU32 (UInt32 Val) |
Write 32-bit unsigned integer. | |
void | WriteU64 (UInt64 Val) |
Write 64-bit unsigned integer. | |
void | WriteI8 (Int8 Val) |
Write 8-bit signed integer. | |
void | WriteI16 (Int16 Val) |
Write 16-bit signed integer. | |
void | WriteI32 (Int32 Val) |
Write 32-bit signed integer. | |
void | WriteI64 (Int64 Val) |
Write 64-bit signed integer. | |
UInt8 | ReadU8 (void) |
Read 8-bit unsigned integer. | |
UInt16 | ReadU16 (void) |
Read 16-bit unsigned integer. | |
UInt32 | ReadU32 (void) |
Read 32-bit unsigned integer. | |
UInt64 | ReadU64 (void) |
Read 64-bit unsigned integer. | |
Int8 | ReadI8 (void) |
Read 8-bit signed integer (casts from unsigned version). | |
Int16 | ReadI16 (void) |
Read 16-bit signed integer (casts from unsigned version). | |
Int32 | ReadI32 (void) |
Read 32-bit signed integer (casts from unsigned version). | |
Int64 | ReadI64 (void) |
Read 64-bit signed integer (casts from unsigned version). | |
void | SetMemoryBuffer (DataChunkPtr Buff, UInt32 Offset) |
void | SetBlockAlign (UInt32 Size, Int32 EssenceOffset=0, Int32 IndexOffset=0) |
Set the block alignment block size. | |
bool | IsBlockAligned (void) |
Determine if this file used block alignment. | |
Public Attributes | |
RIP | FileRIP |
DataChunk | RunIn |
std::string | Name |
Protected Member Functions | |
bool | WritePartitionInternal (bool ReWrite, PartitionPtr ThisPartition, bool IncludeMetadata, DataChunkPtr IndexData, PrimerPtr UsePrimer, UInt32 Padding, UInt32 MinPartitionSize) |
Write or re-write a partition pack and associated metadata (and index table segments?). | |
Position | ScanRIP_FindFooter (Length MaxScan) |
Scan for the footer. | |
virtual size_t | MemoryWrite (UInt8 const *Data, size_t Size) |
Write to memory file buffer. | |
virtual size_t | MemoryRead (UInt8 *Data, size_t Size) |
Read from a memory file buffer. | |
Protected Attributes | |
bool | isOpen |
True when the file is open. | |
bool | isMemoryFile |
True is the file is a "memory file". | |
FileHandle | Handle |
File hanlde. | |
UInt32 | RunInSize |
Size of run-in in physical file. | |
DataChunkPtr | Buffer |
Memory file buffer pointer. | |
UInt64 | BufferOffset |
Offset of the start of the buffer from the start of the memory file. | |
UInt64 | BufferCurrentPos |
Offset of the current position from the start of the memory file. | |
UInt32 | BlockAlign |
Some systems can run more efficiently if the essence and index data start on a block boundary - if used this is the block size. | |
Int32 | BlockAlignEssenceOffset |
Fixed distance from the block grid at which to align essence (+ve is after the grid, -ve before). | |
Int32 | BlockAlignIndexOffset |
Fixed distance from the block grid at which to align index (+ve is after the grid, -ve before). |
MXFFile | ( | ) | [inline] |
~MXFFile | ( | ) | [inline] |
bool Open | ( | std::string | FileName, | |
bool | ReadOnly = false | |||
) | [virtual] |
Open the named MXF file.
bool OpenNew | ( | std::string | FileName | ) | [virtual] |
Create and open the named MXF file.
bool OpenMemory | ( | DataChunkPtr | Buff = NULL , |
|
Position | Offset = 0 | |||
) | [virtual] |
bool Close | ( | void | ) | [virtual] |
Close the file.
bool ReadRunIn | ( | void | ) |
Read the files run-in (if it exists).
The run-in is placed in property run-in After this function the file pointer is at the start of the non-run in data
bool ReadRIP | ( | void | ) |
bool ScanRIP | ( | Length | MaxScan = 1024*1024 |
) |
Build a RIP for the open MXF file by scanning partitions following links back from the footer.
The new RIP is placed in property FileRIP
This new RIP will represent what is in the physical file so any data in memory will not be considered
The current contents of FileRIP will be destroyed
An ideal file will not need scanning because it will contain a RIP (handled by ReadRIP).
The next best situation is for the header to hold the location of the footer in the FooterPartition property. If this is the case the scan will happen as follows:
If the last partition processed was not the header then goto step 3
If the header doesn't hold the location of the footer then a search is performed to find the footer. This is somewhat optimised and is performed as follows:
Each 4Kb block is scanned forwards (CPU optimisations work better scanning forwards) looking for bytes with the value 0x06
If the lookup shows this as a footer then the search is over and steps 2-5 of the above method are used
TODO: There should be some way to scan without loading every partition into memory (it could be millions!) TODO: We could read the IndexSID as we go and build an enhanced RIP or Greater-RIP
bool BuildRIP | ( | void | ) |
bool GetRIP | ( | Length | MaxScan = 1024*1024 |
) |
Get a RIP for the open MXF.
The RIP is read using ReadRIP() if possible. Otherwise it is Scanned using ScanRIP(). If that fails it is built the hard way using BuildRIP().
PartitionPtr ReadMasterPartition | ( | Length | MaxScan = 1024 *1024 |
) |
Locate and read a partition containing closed header metadata.
NULL if none found
PartitionPtr ReadFooterPartition | ( | Length | MaxScan = 1024 *1024 |
) |
Locate and read the footer partition.
NULL if not found
Position Tell | ( | void | ) | [inline] |
Report the position of the file pointer.
int Seek | ( | Position | Pos | ) | [inline] |
Move the file pointer.
int SeekEnd | ( | void | ) | [inline] |
bool Eof | ( | void | ) | [inline] |
Determine if the file pointer is at the end of the file.
DataChunkPtr Read | ( | size_t | Size | ) |
Read data from the file into a DataChunk.
size_t Read | ( | UInt8 * | Buffer, | |
size_t | Size | |||
) |
Read data from the file into a supplied buffer.
MDObjectPtr ReadObject | ( | PrimerPtr | UsePrimer = NULL |
) | [inline] |
PartitionPtr ReadPartition | ( | void | ) | [inline] |
KLVObjectPtr ReadKLV | ( | void | ) |
Read a KLVObject from the file.
void WritePartitionPack | ( | PartitionPtr | ThisPartition, | |
PrimerPtr | UsePrimer = NULL | |||
) |
Write a partition pack to the file.
The property "ThisPartition" is updated to reflect the correct location in the file
void WritePartition | ( | PartitionPtr | ThisPartition, | |
UInt32 | Padding = 0 , |
|||
UInt32 | MinPartitionSize = 0 | |||
) | [inline] |
Write a partition pack and associated metadata (no index table segments).
void WritePartitionWithIndex | ( | PartitionPtr | ThisPartition, | |
DataChunkPtr | IndexData, | |||
UInt32 | Padding = 0 , |
|||
UInt32 | MinPartitionSize = 0 | |||
) | [inline] |
Write a partition pack and associated metadata and preformatted index table segments.
void WritePartition | ( | PartitionPtr | ThisPartition, | |
PrimerPtr | UsePrimer, | |||
UInt32 | Padding = 0 , |
|||
UInt32 | MinPartitionSize = 0 | |||
) | [inline] |
Write a partition pack and associated metadata (no index table segments).
void WritePartitionWithIndex | ( | PartitionPtr | ThisPartition, | |
DataChunkPtr | IndexData, | |||
PrimerPtr | UsePrimer, | |||
UInt32 | Padding = 0 , |
|||
UInt32 | MinPartitionSize = 0 | |||
) | [inline] |
Write a partition pack and associated metadata and preformatted index table segments.
void WritePartition | ( | PartitionPtr | ThisPartition, | |
bool | IncludeMetadata, | |||
PrimerPtr | UsePrimer = NULL , |
|||
UInt32 | Padding = 0 , |
|||
UInt32 | MinPartitionSize = 0 | |||
) | [inline] |
Write a partition pack and (optionally) associated metadata (no index table segments).
void WritePartitionWithIndex | ( | PartitionPtr | ThisPartition, | |
DataChunkPtr | IndexData, | |||
bool | IncludeMetadata, | |||
PrimerPtr | UsePrimer = NULL , |
|||
UInt32 | Padding = 0 , |
|||
UInt32 | MinPartitionSize = 0 | |||
) | [inline] |
Write a partition pack and (optionally) associated metadata and preformatted index table segments.
bool ReWritePartition | ( | PartitionPtr | ThisPartition, | |
PrimerPtr | UsePrimer = NULL | |||
) | [inline] |
Re-write a partition pack and associated metadata (no index table segments).
bool ReWritePartitionWithIndex | ( | PartitionPtr | ThisPartition, | |
DataChunkPtr | IndexData, | |||
PrimerPtr | UsePrimer = NULL | |||
) | [inline] |
Re-write a partition pack and associated metadata and preformatted index table segments.
bool WritePartitionInternal | ( | bool | ReWrite, | |
PartitionPtr | ThisPartition, | |||
bool | IncludeMetadata, | |||
DataChunkPtr | IndexData, | |||
PrimerPtr | UsePrimer, | |||
UInt32 | Padding, | |||
UInt32 | MinPartitionSize | |||
) | [protected] |
Write or re-write a partition pack and associated metadata (and index table segments?).
Length of the partition pack for calculating block alignment
Essence BodySID for calculating block alignment
Length of block alignment padding after the header metadata (if required)
Length of block alignment padding after the index table (if required)
Previous partition if re-writing
void WriteRIP | ( | void | ) | [inline] |
Write the RIP.
Calculate the size of a filler to align to a specified KAG.
Calculate the size of a filler to align to a specified KAG.
Note: Maximum supported filler size is 0x00ffffff bytes
Write a filler to align to a specified KAG.
Write a filler to align to a specified KAG.
ULPtr ReadKey | ( | void | ) |
Read a Key length from the open file.
Length ReadBER | ( | void | ) |
Read a BER length from the open file.
Write a BER length.
Length | The length to be written | |
Size | The total number of bytes to use for BER length (or 0 for auto) |
size_t Write | ( | const UInt8 * | Buffer, | |
size_t | Size | |||
) | [inline] |
Write raw data.
size_t Write | ( | DataChunkPtr | Data | ) | [inline] |
void WriteU8 | ( | UInt8 | Val | ) | [inline] |
Write 8-bit unsigned integer.
void WriteU16 | ( | UInt16 | Val | ) | [inline] |
Write 16-bit unsigned integer.
void WriteU32 | ( | UInt32 | Val | ) | [inline] |
Write 32-bit unsigned integer.
void WriteU64 | ( | UInt64 | Val | ) | [inline] |
Write 64-bit unsigned integer.
void WriteI8 | ( | Int8 | Val | ) | [inline] |
Write 8-bit signed integer.
void WriteI16 | ( | Int16 | Val | ) | [inline] |
Write 16-bit signed integer.
void WriteI32 | ( | Int32 | Val | ) | [inline] |
Write 32-bit signed integer.
void WriteI64 | ( | Int64 | Val | ) | [inline] |
Write 64-bit signed integer.
UInt8 ReadU8 | ( | void | ) | [inline] |
Read 8-bit unsigned integer.
UInt16 ReadU16 | ( | void | ) | [inline] |
Read 16-bit unsigned integer.
UInt32 ReadU32 | ( | void | ) | [inline] |
Read 32-bit unsigned integer.
UInt64 ReadU64 | ( | void | ) | [inline] |
Read 64-bit unsigned integer.
Int8 ReadI8 | ( | void | ) | [inline] |
Read 8-bit signed integer (casts from unsigned version).
Int16 ReadI16 | ( | void | ) | [inline] |
Read 16-bit signed integer (casts from unsigned version).
Int32 ReadI32 | ( | void | ) | [inline] |
Read 32-bit signed integer (casts from unsigned version).
Int64 ReadI64 | ( | void | ) | [inline] |
Read 64-bit signed integer (casts from unsigned version).
void SetMemoryBuffer | ( | DataChunkPtr | Buff, | |
UInt32 | Offset | |||
) | [inline] |
Set the block alignment block size.
bool IsBlockAligned | ( | void | ) | [inline] |
Determine if this file used block alignment.
Scan for the footer.
size_t MemoryWrite | ( | UInt8 const * | Data, | |
size_t | Size | |||
) | [protected, virtual] |
Write to memory file buffer.
size_t MemoryRead | ( | UInt8 * | Data, | |
size_t | Size | |||
) | [protected, virtual] |
Read from a memory file buffer.
bool isOpen [protected] |
True when the file is open.
bool isMemoryFile [protected] |
True is the file is a "memory file".
FileHandle Handle [protected] |
File hanlde.
DataChunkPtr Buffer [protected] |
Memory file buffer pointer.
UInt64 BufferOffset [protected] |
Offset of the start of the buffer from the start of the memory file.
UInt64 BufferCurrentPos [protected] |
Offset of the current position from the start of the memory file.
UInt32 BlockAlign [protected] |
Some systems can run more efficiently if the essence and index data start on a block boundary - if used this is the block size.
Int32 BlockAlignEssenceOffset [protected] |
Fixed distance from the block grid at which to align essence (+ve is after the grid, -ve before).
Int32 BlockAlignIndexOffset [protected] |
Fixed distance from the block grid at which to align index (+ve is after the grid, -ve before).
std::string Name |