AJA NTV2 SDK  17.1.1.1245
NTV2 SDK 17.1.1.1245
AJACircularBuffer< FrameDataPtr > Class Template Reference

I am a circular frame buffer that simplifies implementing a type-safe producer/consumer model for processing frame-based streaming media. I can be used with any client-defined "frame", be it a struct or class. To use me: More...

#include <circularbuffer.h>

Public Member Functions

 AJACircularBuffer ()
 My default constructor. More...
 
virtual ~AJACircularBuffer ()
 My destructor. More...
 
void SetAbortFlag (const bool *pAbortFlag)
 Tells me the boolean variable I should monitor such that when it gets set to "true" will cause any threads waiting on my events/locks to gracefully exit. More...
 
unsigned int GetCircBufferCount (void) const
 Retrieves the size count of the circular buffer, i.e. how far the tail pointer is behind the head pointer. More...
 
bool IsEmpty (void) const
 Returns "true" if I'm empty – i.e., if my tail and head are in the same place. More...
 
unsigned int GetNumFrames (void) const
 Returns my frame storage capacity, which reflects how many times my Add method has been called. More...
 
AJAStatus Add (FrameDataPtr pInFrameData)
 Appends a new frame buffer to me, increasing my frame storage capacity by one frame. More...
 
FrameDataPtr StartProduceNextBuffer (void)
 The thread that's responsible for providing frames – the producer – calls this function to populate the the returned FrameDataPtr. More...
 
void EndProduceNextBuffer (void)
 The producer thread calls this function to signal that it has finished populating the frame it obtained from a prior call to StartProduceNextBuffer. This releases the frame, making it available for processing by the consumer thread. More...
 
FrameDataPtr StartConsumeNextBuffer (void)
 The thread that's responsible for processing incoming frames – the consumer – calls this function to obtain the next available frame. More...
 
void EndConsumeNextBuffer (void)
 The consumer thread calls this function to signal that it has finished processing the frame it obtained from a prior call to StartConsumeNextBuffer. This releases the frame, making it available for filling by the producer thread. More...
 
void Clear (void)
 Clears my frame collection, their locks, everything. More...
 

Detailed Description

template<typename FrameDataPtr>
class AJACircularBuffer< FrameDataPtr >

I am a circular frame buffer that simplifies implementing a type-safe producer/consumer model for processing frame-based streaming media. I can be used with any client-defined "frame", be it a struct or class. To use me:

  1. Instantiate me.
    1. Initialize me by calling my Add method, adding client-defined frames for me to manage.
    2. Spawn a producer thread and a consumer thread.
    3. The producer thread repeatedly calls my StartProduceNextBuffer, puts data in the frame, then calls EndProduceNextBuffer when finished.
    4. The consumer thread repeatedly calls my StartConsumeNextBuffer, processes data in the frame, then calls EndConsumeNextBuffer when finished.

Definition at line 30 of file circularbuffer.h.

Constructor & Destructor Documentation

◆ AJACircularBuffer()

template<typename FrameDataPtr >
AJACircularBuffer< FrameDataPtr >::AJACircularBuffer

My default constructor.

Definition at line 239 of file circularbuffer.h.

◆ ~AJACircularBuffer()

template<typename FrameDataPtr >
AJACircularBuffer< FrameDataPtr >::~AJACircularBuffer
virtual

My destructor.

Definition at line 250 of file circularbuffer.h.

Member Function Documentation

◆ Add()

template<typename FrameDataPtr >
AJAStatus AJACircularBuffer< FrameDataPtr >::Add ( FrameDataPtr  pInFrameData)
inline

Appends a new frame buffer to me, increasing my frame storage capacity by one frame.

Parameters
[in]pInFrameDataSpecifies the FrameDataPtr to be added to me.
Returns
AJA_STATUS_SUCCESS Frame successfully added. AJA_STATUS_FAIL Frame failed to add.

Definition at line 92 of file circularbuffer.h.

◆ Clear()

template<typename FrameDataPtr >
void AJACircularBuffer< FrameDataPtr >::Clear ( void  )

Clears my frame collection, their locks, everything.

Note
This is not thread-safe. Thus, before calling this method, be sure all locks have been released and producer/consumer threads using me have terminated.

Definition at line 314 of file circularbuffer.h.

◆ EndConsumeNextBuffer()

template<typename FrameDataPtr >
void AJACircularBuffer< FrameDataPtr >::EndConsumeNextBuffer ( void  )

The consumer thread calls this function to signal that it has finished processing the frame it obtained from a prior call to StartConsumeNextBuffer. This releases the frame, making it available for filling by the producer thread.

Definition at line 266 of file circularbuffer.h.

◆ EndProduceNextBuffer()

template<typename FrameDataPtr >
void AJACircularBuffer< FrameDataPtr >::EndProduceNextBuffer ( void  )

The producer thread calls this function to signal that it has finished populating the frame it obtained from a prior call to StartProduceNextBuffer. This releases the frame, making it available for processing by the consumer thread.

Definition at line 259 of file circularbuffer.h.

◆ GetCircBufferCount()

template<typename FrameDataPtr >
unsigned int AJACircularBuffer< FrameDataPtr >::GetCircBufferCount ( void  ) const
inline

Retrieves the size count of the circular buffer, i.e. how far the tail pointer is behind the head pointer.

Returns
The number of frames that I contain.

Definition at line 61 of file circularbuffer.h.

◆ GetNumFrames()

template<typename FrameDataPtr >
unsigned int AJACircularBuffer< FrameDataPtr >::GetNumFrames ( void  ) const
inline

Returns my frame storage capacity, which reflects how many times my Add method has been called.

Returns
My frame capacity.

Definition at line 80 of file circularbuffer.h.

◆ IsEmpty()

template<typename FrameDataPtr >
bool AJACircularBuffer< FrameDataPtr >::IsEmpty ( void  ) const
inline

Returns "true" if I'm empty – i.e., if my tail and head are in the same place.

Returns
True if I contain no frames.

Definition at line 71 of file circularbuffer.h.

◆ SetAbortFlag()

template<typename FrameDataPtr >
void AJACircularBuffer< FrameDataPtr >::SetAbortFlag ( const bool *  pAbortFlag)
inline

Tells me the boolean variable I should monitor such that when it gets set to "true" will cause any threads waiting on my events/locks to gracefully exit.

Parameters
[in]pAbortFlagSpecifies the valid, non-NULL address of a boolean variable that, when it becomes "true", will cause threads waiting on me to exit gracefully.

Definition at line 51 of file circularbuffer.h.

◆ StartConsumeNextBuffer()

template<typename FrameDataPtr >
FrameDataPtr AJACircularBuffer< FrameDataPtr >::StartConsumeNextBuffer ( void  )
inline

The thread that's responsible for processing incoming frames – the consumer – calls this function to obtain the next available frame.

Returns
A pointer (of the type in the template argument) to the next frame to be processed by the consumer thread.

Definition at line 153 of file circularbuffer.h.

◆ StartProduceNextBuffer()

template<typename FrameDataPtr >
FrameDataPtr AJACircularBuffer< FrameDataPtr >::StartProduceNextBuffer ( void  )
inline

The thread that's responsible for providing frames – the producer – calls this function to populate the the returned FrameDataPtr.

Returns
A pointer (of the type in the template argument) to the next frame to be filled by the producer thread.

Definition at line 109 of file circularbuffer.h.


The documentation for this class was generated from the following file: