GCReader Class Reference

Class that reads data from an MXF file. More...

#include <essence.h>

Inheritance diagram for GCReader:

RefCount IRefCount List of all members.

Public Member Functions

 GCReader (MXFFilePtr File, GCReadHandlerPtr DefaultHandler=NULL, GCReadHandlerPtr FillerHandler=NULL)
 Create a new GCReader, optionally with a given default item handler and filler handler.
void SetDefaultHandler (GCReadHandlerPtr DefaultHandler=NULL)
 Set the default read handler.
void SetFillerHandler (GCReadHandlerPtr FillerHandler=NULL)
 Set the filler handler.
void SetEncryptionHandler (GCReadHandlerPtr EncryptionHandler=NULL)
 Set encryption handler.
void SetDataHandler (UInt32 TrackNumber, GCReadHandlerPtr DataHandler=NULL)
 Set data handler for a given track number.
bool ReadFromFile (Position FilePos, Position StreamPos, bool SingleKLV=false)
 Read from file - and specify a start location.
bool ReadFromFile (bool SingleKLV=false)
 Read from file - continuing from a previous read.
void SetStreamOffset (Position NewOffset)
 Set the offset of the start of the next KLV within this GC stream.
Position GetFileOffset (void)
 Get the file offset of the next read (or the current KLV if inside ReadFromFile).
bool HandleData (KLVObjectPtr Object)
 Force a KLVObject to be handled.
void StopReading (bool PushBackKLV=false)
 Stop reading even though there appears to be valid data remaining.
Position GetStreamOffset (void)
 Get the offset of the start of the current KLV within this GC stream.

Protected Attributes

MXFFilePtr File
 File from which to read.
Position FileOffset
 The offset of the start of the current (or next) KLV within the file. Current KLV during HandleData() and next at other times.
Position StreamOffset
 The offset of the start of the current KLV within the data stream.
bool StopNow
 True if no more KLVs should be read - set by StopReading() and ReadFromFile() with SingleKLV=true.
bool StopCalled
 True if StopReading() called while processing the current KLV.
bool PushBackRequested
 True if StopReading() called with PushBackKLV = true.
GCReadHandlerPtr DefaultHandler
 The default handler to receive all KLVs without a specific handler.
GCReadHandlerPtr FillerHandler
 The hanlder to receive all filler KLVs.
GCReadHandlerPtr EncryptionHandler
 The hanlder to receive all encrypted KLVs.
std::map< UInt32, GCReadHandlerPtrHandlers
 Map of read handlers indexed by track number.

Detailed Description

Class that reads data from an MXF file.


Constructor & Destructor Documentation

GCReader ( MXFFilePtr  File,
GCReadHandlerPtr  DefaultHandler = NULL,
GCReadHandlerPtr  FillerHandler = NULL 
)

Create a new GCReader, optionally with a given default item handler and filler handler.

Note:
The default handler receives all KLVs without a specific handler (except fillers) The filler handler receives all filler KLVs


Member Function Documentation

void SetDefaultHandler ( GCReadHandlerPtr  DefaultHandler = NULL  )  [inline]

Set the default read handler.

This handler receives all KLVs without a specific data handler assigned including KLVs that do not appear to be standard GC KLVs. If not default handler is set KLVs with no specific handler will be discarded.

void SetFillerHandler ( GCReadHandlerPtr  FillerHandler = NULL  )  [inline]

Set the filler handler.

If no filler handler is set all filler KLVs are discarded

Note:
Filler KLVs are never sent to the default handler unless it is also set as the filler handler

void SetEncryptionHandler ( GCReadHandlerPtr  EncryptionHandler = NULL  )  [inline]

Set encryption handler.

This handler will receive all encrypted KLVs and after decrypting them will resubmit the decrypted version for handling using function HandleData()

void SetDataHandler ( UInt32  TrackNumber,
GCReadHandlerPtr  DataHandler = NULL 
) [inline]

Set data handler for a given track number.

bool ReadFromFile ( Position  FilePos,
Position  StreamPos,
bool  SingleKLV = false 
) [inline]

Read from file - and specify a start location.

All KLVs are dispatched to handlers Stops reading at the next partition pack unless SingleKLV is true when only one KLV is dispatched

Parameters:
FilePos Location within the file to start this read
StreamPos Stream offset of the first KLV to be read
SingleKLV True if only a single KLV is to be read
Returns:
true if all went well, false end-of-file, an error occured or StopReading() was called

bool ReadFromFile ( bool  SingleKLV = false  ) 

Read from file - continuing from a previous read.

All KLVs are dispatched to handlers Stops reading at the next partition pack unless SingleKLV is true when only one KLV is dispatched

Returns:
true if all went well, false end-of-file, an error occured or StopReading() was called

void SetStreamOffset ( Position  NewOffset  )  [inline]

Set the offset of the start of the next KLV within this GC stream.

Generally this will only be called as a result of parsing a partition pack

Note:
The offset will start at zero and increment automatically as data is read. If a seek is performed the offset will need to be adjusted.

Position GetFileOffset ( void   )  [inline]

Get the file offset of the next read (or the current KLV if inside ReadFromFile).

Note:
This is not the correct way to access the raw KLV in the file - that should be done via the KLVObject. This function allows the caller to determine where the file pointer ended up after a read.

bool HandleData ( KLVObjectPtr  Object  ) 

Force a KLVObject to be handled.

Note:
This is not the normal way that the GCReader is used, but allows the encryption handler to push the decrypted data back to the GCReader to pass to the appropriate handler
Returns:
true if all OK, false on error

void StopReading ( bool  PushBackKLV = false  ) 

Stop reading even though there appears to be valid data remaining.

This function can be called from a handler if it detects that the current KLV is either the last KLV in partition, or does not belong in this partition at all. If the KLV belongs to another partition, or handling should be deferred for some reason, PushBackKLV can be set to true

Position GetStreamOffset ( void   )  [inline]

Get the offset of the start of the current KLV within this GC stream.


Member Data Documentation

MXFFilePtr File [protected]

File from which to read.

Position FileOffset [protected]

The offset of the start of the current (or next) KLV within the file. Current KLV during HandleData() and next at other times.

Position StreamOffset [protected]

The offset of the start of the current KLV within the data stream.

bool StopNow [protected]

True if no more KLVs should be read - set by StopReading() and ReadFromFile() with SingleKLV=true.

bool StopCalled [protected]

True if StopReading() called while processing the current KLV.

bool PushBackRequested [protected]

True if StopReading() called with PushBackKLV = true.

GCReadHandlerPtr DefaultHandler [protected]

The default handler to receive all KLVs without a specific handler.

GCReadHandlerPtr FillerHandler [protected]

The hanlder to receive all filler KLVs.

GCReadHandlerPtr EncryptionHandler [protected]

The hanlder to receive all encrypted KLVs.

std::map<UInt32, GCReadHandlerPtr> Handlers [protected]

Map of read handlers indexed by track number.


The documentation for this class was generated from the following files:
Generated on Mon Apr 2 15:20:59 2007 for MXFLib by  doxygen 1.5.1-p1