BodyWriter Class Reference

Body writer class - manages multiplexing of essence. More...

#include <essence.h>

Inheritance diagram for BodyWriter:

RefCount IRefCount List of all members.

Public Member Functions

 BodyWriter (MXFFilePtr &DestFile)
 Construct a body writer for a specified file.
void ClearStreams (void)
 Clear any stream details ready to call AddStream().
bool AddStream (BodyStreamPtr &Stream, Length StopAfter=0)
 Add a stream to the list of those to write.
void SetKAG (UInt32 NewKAG)
 Set the KLV Alignment Grid.
UInt32 GetKAG (void)
 Get the KLV Alignment Grid.
void SetForceBER4 (bool Force)
 Set flag if BER lengths should be forced to 4-byte (where possible).
bool GetForceBER4 (void)
 Get flag stating whether BER lengths should be forced to 4-byte (where possible).
void SetMetadataSharing (bool IndexMayShare=true, bool EssenceMayShare=false)
 Set what sort of data may share with header metadata.
void SetPartition (PartitionPtr &ThePartition)
 Set the template partition pack to use when partition packs are required.
PartitionPtr GetPartition (void)
 Get a pointer to the current template partition pack.
void WriteHeader (bool IsClosed, bool IsComplete)
 Write the file header.
void EndPartition (void)
 End the current partition.
void WriteBody (Length Duration=0, Length MaxPartitionSize=0)
 Write stream data.
Length WritePartition (Length Duration=0, Length MaxPartitionSize=0)
 Write the next partition or continue the current one (if not complete).
bool BodyDone (void)
 Determine if all body partitions have been written.
void WriteFooter (bool WriteMetadata=false, bool IsComplete=true)
 Write the file footer.
void SetPartitionHandler (BodyWriterHandlerPtr &NewBodyHandler)
 Set a handler to be called before writing a partition pack within the body.
void SetPartitionSize (UInt32 PartitionSize)
 Set the minumum size of the non-essence part of the next partition.
void SetPartitionFiller (UInt32 PartitionFiller)
 Set the minumum size of filler between the non-essence part of the next partition and any following essence.
void InitIndexManagers (void)
 Initialize all required index managers.

Protected Types

enum  BodyState {
  BodyStateStart = 0, BodyStateHeader, BodyStateBody, BodyStateFooter,
  BodyStateDone
}
typedef SmartPtr< StreamInfoStreamInfoPtr
 Smart pointer to a StreamInfo.
typedef std::list< StreamInfoPtrStreamInfoList
 Type for list of streams to write.

Protected Member Functions

 BodyWriter ()
 Prevent NULL construction.
 BodyWriter (BodyWriter &)
 Prevent copy construction.
void SetNextStream (void)
 Move to the next active stream (will also advance State as required).
Length WriteEssence (StreamInfoPtr &Info, Length Duration=0, Length MaxPartitionSize=0)
 Write a complete partition's worth of essence.

Protected Attributes

BodyState State
 The state for this writer.
MXFFilePtr File
 Destination file.
StreamInfoList StreamList
 List of streams to write.
UInt32 KAG
 KLV Alignment Grid to use.
bool ForceBER4
 Flag set if BER lengths should be forced to 4-byte (where possible).
PartitionPtr BasePartition
 Partition pack to use when one is required.
BodyWriterHandlerPtr PartitionHandler
 The body partition handler.
UInt32 MinPartitionSize
 The minimum size of the non-essence part of the next partition.
UInt32 MinPartitionFiller
 The minimum size of filler before the essence part of the next partition.
bool IndexSharesWithMetadata
 If true index tables may exist in the same partition as metadata.
bool EssenceSharesWithMetadata
 If true essence may exist in the same partition as metadata.
UInt32 CurrentBodySID
 The current BodySID, or 0 if not known (will move back to the start of the list).
bool PartitionDone
 The current partition is done and must not be continued - any new data must start a new partition.
StreamInfoList::iterator CurrentStream
 Iterator for the current (or previous) stream data. Only valid if CurrentBodySID != 0.
bool PartitionWritePending
 Flag set when a partition pack is ready to be written.
bool PendingHeader
 Is the pending metadata a header?
bool PendingFooter
 Is the pending metadata a footer?
bool PendingMetadata
 Is the next partition write going to have metadata?
DataChunkPtr PendingIndexData
 Pointer to a chunk of index table data for the pendinf partition or NULL if none is required.
UInt32 PartitionBodySID
 BodySID of the essence or index data already written or pending for this partition.

Classes

class  StreamInfo
 Class for holding info relating to a stream. More...

Detailed Description

Body writer class - manages multiplexing of essence.


Member Typedef Documentation

typedef SmartPtr<StreamInfo> StreamInfoPtr [protected]

Smart pointer to a StreamInfo.

typedef std::list<StreamInfoPtr> StreamInfoList [protected]

Type for list of streams to write.

The list is kept in the order that the BodySIDs are added


Member Enumeration Documentation

enum BodyState [protected]

Enumerator:
BodyStateStart  The BodyWriter has not yet started writing.
BodyStateHeader  Writing the header (and/or post header indexes).
BodyStateBody  Writing the body essence and indexes.
BodyStateFooter  Writing the footer (and/or pre-footer indexes or RIP).
BodyStateDone  All done.


Constructor & Destructor Documentation

BodyWriter (  )  [protected]

Prevent NULL construction.

BodyWriter ( BodyWriter  )  [protected]

Prevent copy construction.

BodyWriter ( MXFFilePtr DestFile  )  [inline]

Construct a body writer for a specified file.


Member Function Documentation

void ClearStreams ( void   )  [inline]

Clear any stream details ready to call AddStream().

This allows previously used streams to be removed before a call to WriteBody() or WriteNext()

bool AddStream ( BodyStreamPtr Stream,
Length  StopAfter = 0 
)

Add a stream to the list of those to write.

Parameters:
Stream - The stream to write
StopAfter - If > 0 the writer will stop writing this stream at the earliest opportunity after (at least) this number of edit units have been written Streams will be written in the order that they were offered and the list is kept in this order.
Returns:
false if unable to add this stream (for example this BodySID already in use)

void SetKAG ( UInt32  NewKAG  )  [inline]

Set the KLV Alignment Grid.

UInt32 GetKAG ( void   )  [inline]

Get the KLV Alignment Grid.

void SetForceBER4 ( bool  Force  )  [inline]

Set flag if BER lengths should be forced to 4-byte (where possible).

bool GetForceBER4 ( void   )  [inline]

Get flag stating whether BER lengths should be forced to 4-byte (where possible).

void SetMetadataSharing ( bool  IndexMayShare = true,
bool  EssenceMayShare = false 
) [inline]

Set what sort of data may share with header metadata.

void SetPartition ( PartitionPtr ThePartition  )  [inline]

Set the template partition pack to use when partition packs are required.

The byte counts and SIDs will be updated are required before writing. FooterPosition will not be updated so it must either be 0 or the correct value. Any associated metadata will be written for the header and if the handler (called just before the write) requests it.

Note:
The original object given will be modified - not a copy of it

PartitionPtr GetPartition ( void   )  [inline]

Get a pointer to the current template partition pack.

void WriteHeader ( bool  IsClosed,
bool  IsComplete 
)

Write the file header.

No essence will be written, but CBR index tables will be written if required. The partition will not be "ended" if only the header partition is written meaning that essence will be added by the next call to WritePartition()

void EndPartition ( void   ) 

End the current partition.

Once "ended" no more essence will be added, even if otherwise valid. A new partition will be started by the next call to WritePartition()

Note:
This function will also flush any pending partition writes

void WriteBody ( Length  Duration = 0,
Length  MaxPartitionSize = 0 
)

Write stream data.

Parameters:
Duration If > 0 the stop writing at the earliest opportunity after (at least) this number of edit units have been written for each stream
MaxPartitionSize If > 0 the writer will attempt to keep the partition no larger than this size in bytes. There is no guarantee that it will succeed
Note:
Streams that have finished or hit thier own StopAfter value will be regarded as having written enough when judging whether to stop

Length WritePartition ( Length  Duration = 0,
Length  MaxPartitionSize = 0 
)

Write the next partition or continue the current one (if not complete).

Will stop at the point where the next partition will start, or (if Duration > 0) at the earliest opportunity after (at least) Duration edit units have been written

bool BodyDone ( void   )  [inline]

Determine if all body partitions have been written.

Will be false until after the last required WritePartition() call

void WriteFooter ( bool  WriteMetadata = false,
bool  IsComplete = true 
)

Write the file footer.

No essence will be written, but index tables will be written if required.

void SetPartitionHandler ( BodyWriterHandlerPtr NewBodyHandler  )  [inline]

Set a handler to be called before writing a partition pack within the body.

Will be called before a body partition is written

void SetPartitionSize ( UInt32  PartitionSize  )  [inline]

Set the minumum size of the non-essence part of the next partition.

This will cause a filler KLV to be added (if required) after the partition pack, any header metadata and index table segments in order to reach the specified size. This is useful for reserving space for future metadata updates. This value is read after calling the partition handlers so this function may safely be used in the handlers.

Note:
The size used will be the minimum size that satisfies the following:
  • All required items are included (partition pack, metadata if required, index if required)
  • The total size, excluding essence, is at least as big as the value specified by SetPartitionSize()
  • The filler following the last non-essence item is at least as big as the value specified by SetPartitionFiller()
  • The KAGSize value is obeyed

void SetPartitionFiller ( UInt32  PartitionFiller  )  [inline]

Set the minumum size of filler between the non-essence part of the next partition and any following essence.

If non-zero this will cause a filler KLV to be added after the partition pack, any header metadata and index table segments of at least the size specified. This is useful for reserving space for future metadata updates. This value is read after calling the partition handlers so this function may safely be used in the handlers.

Note:
The size used will be the minimum size that satisfies the following:
  • All required items are included (partition pack, metadata if required, index if required)
  • The total size, excluding essence, is at least as big as the value specified by SetPartitionSize()
  • The filler following the last non-essence item is at least as big as the value specified by SetPartitionFiller()
  • The KAGSize value is obeyed

void InitIndexManagers ( void   ) 

Initialize all required index managers.

void SetNextStream ( void   )  [protected]

Move to the next active stream (will also advance State as required).

Note:
Will set CurrentBodySID to 0 if no more active streams

Length WriteEssence ( StreamInfoPtr Info,
Length  Duration = 0,
Length  MaxPartitionSize = 0 
) [protected]

Write a complete partition's worth of essence.

Will stop if: Frame or "other" wrapping and the "StopAfter" reaches zero or "Duration" reaches zero Clip wrapping and the entire clip is wrapped

< Exit this iteration - no further checks required

< Exit at the earliest valid time (for example the next edit point)


Member Data Documentation

BodyState State [protected]

The state for this writer.

MXFFilePtr File [protected]

Destination file.

StreamInfoList StreamList [protected]

List of streams to write.

UInt32 KAG [protected]

KLV Alignment Grid to use.

bool ForceBER4 [protected]

Flag set if BER lengths should be forced to 4-byte (where possible).

PartitionPtr BasePartition [protected]

Partition pack to use when one is required.

BodyWriterHandlerPtr PartitionHandler [protected]

The body partition handler.

UInt32 MinPartitionSize [protected]

The minimum size of the non-essence part of the next partition.

UInt32 MinPartitionFiller [protected]

The minimum size of filler before the essence part of the next partition.

bool IndexSharesWithMetadata [protected]

If true index tables may exist in the same partition as metadata.

bool EssenceSharesWithMetadata [protected]

If true essence may exist in the same partition as metadata.

UInt32 CurrentBodySID [protected]

The current BodySID, or 0 if not known (will move back to the start of the list).

bool PartitionDone [protected]

The current partition is done and must not be continued - any new data must start a new partition.

StreamInfoList::iterator CurrentStream [protected]

Iterator for the current (or previous) stream data. Only valid if CurrentBodySID != 0.

bool PartitionWritePending [protected]

Flag set when a partition pack is ready to be written.

bool PendingHeader [protected]

Is the pending metadata a header?

bool PendingFooter [protected]

Is the pending metadata a footer?

bool PendingMetadata [protected]

Is the next partition write going to have metadata?

DataChunkPtr PendingIndexData [protected]

Pointer to a chunk of index table data for the pendinf partition or NULL if none is required.

UInt32 PartitionBodySID [protected]

BodySID of the essence or index data already written or pending for this partition.

This is used to determine if particular essence can be added to this partition. Set to zero if none yet written.


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