AJA NTV2 SDK  17.0.1.1246
NTV2 SDK 17.0.1.1246
NTV2DolbyPlayer Class Reference

I am an object that can play out a test pattern (with timecode) to an output of an AJA device with or without audio tone in real time. I make use of the AJACircularBuffer, which simplifies implementing a producer/consumer model, in which a "producer" thread generates the test pattern frames, and a "consumer" thread (i.e., the "play" thread) sends those frames to the AJA device. I demonstrate how to embed timecode into an SDI output signal using AutoCirculate during playout. More...

#include <ntv2dolbyplayer.h>

Classes

struct  NTV2DolbyBSI
 

Public Member Functions

 NTV2DolbyPlayer (const std::string &inDeviceSpecifier="0", const bool inWithAudio=true, const NTV2Channel inChannel=NTV2_CHANNEL1, const NTV2FrameBufferFormat inPixelFormat=NTV2_FBF_8BIT_YCBCR, const NTV2VideoFormat inVideoFormat=NTV2_FORMAT_1080i_5994, const bool inDoMultiFormat=false, const bool inDoRamp=false, AJAFileIO *inDolbyFile=NULL)
 Constructs me using the given configuration settings. More...
 
virtual ~NTV2DolbyPlayer (void)
 
virtual AJAStatus Init (void)
 Initializes me and prepares me to Run. More...
 
virtual AJAStatus Run (void)
 Runs me. More...
 
virtual void Quit (void)
 Gracefully stops me from running. More...
 
virtual bool IsRunning (void) const
 
virtual void GetACStatus (ULWord &outGoodFrames, ULWord &outDroppedFrames, ULWord &outBufferLevel)
 Provides status information about my output (playout) process. More...
 

Protected Member Functions

virtual AJAStatus SetUpVideo (void)
 Sets up everything I need to play video. More...
 
virtual AJAStatus SetUpAudio (void)
 Sets up everything I need to play audio. More...
 
virtual void RouteOutputSignal (void)
 Sets up device routing for playout. More...
 
virtual void SetUpHostBuffers (void)
 Sets up my circular buffers. More...
 
virtual AJAStatus SetUpTestPatternVideoBuffers (void)
 Creates my test pattern buffers. More...
 
virtual void StartConsumerThread (void)
 Starts my playout thread. More...
 
virtual void PlayFrames (void)
 Repeatedly plays out frames using AutoCirculate (until quit). More...
 
virtual void StartProducerThread (void)
 Starts my test pattern producer thread. More...
 
virtual void ProduceFrames (void)
 Repeatedly produces test pattern frames (until global quit flag set). More...
 
virtual uint32_t AddTone (ULWord *audioBuffer)
 Inserts audio tone (based on my current tone frequency) into the given audio buffer. More...
 
virtual uint32_t AddRamp (ULWord *audioBuffer)
 Inserts audio test ramp into the given audio buffer. More...
 
virtual uint32_t AddDolby (ULWord *audioBuffer)
 Inserts dolby audio into the given audio buffer. More...
 
virtual bool GetDolbyFrame (uint16_t *pInDolbyBuffer, uint32_t &numSamples)
 Get a dolby audio audio frame from the input file. More...
 
virtual bool ParseBSI (uint16_t *pInDolbyBuffer, uint32_t numSamples, NTV2DolbyBSI *pBsi)
 Parse the dolby audio bit stream information block. More...
 
virtual void SetBitBuffer (uint8_t *pBuffer, uint32_t size)
 Set the bitstream buffer for bit retrieval. More...
 
virtual bool GetBits (uint32_t &data, uint32_t inBitCount)
 Retreive the specified number of bits from the bitstream buffer. More...
 

Static Protected Member Functions

static void ConsumerThreadStatic (AJAThread *pThread, void *pContext)
 This is the consumer thread's static callback function that gets called when the consumer thread starts. This function gets "Attached" to the consumer thread's AJAThread instance. More...
 
static void ProducerThreadStatic (AJAThread *pThread, void *pContext)
 This is the producer thread's static callback function that gets called when the producer thread starts. This function gets "Attached" to the producer thread's AJAThread instance. More...
 
static ULWord GetRP188RegisterForOutput (const NTV2OutputDestination inOutputSource)
 Returns the RP188 DBB register number to use for the given NTV2OutputDestination. More...
 

Detailed Description

I am an object that can play out a test pattern (with timecode) to an output of an AJA device with or without audio tone in real time. I make use of the AJACircularBuffer, which simplifies implementing a producer/consumer model, in which a "producer" thread generates the test pattern frames, and a "consumer" thread (i.e., the "play" thread) sends those frames to the AJA device. I demonstrate how to embed timecode into an SDI output signal using AutoCirculate during playout.

Definition at line 30 of file ntv2dolbyplayer.h.

Constructor & Destructor Documentation

◆ NTV2DolbyPlayer()

NTV2DolbyPlayer::NTV2DolbyPlayer ( const std::string &  inDeviceSpecifier = "0",
const bool  inWithAudio = true,
const NTV2Channel  inChannel = NTV2_CHANNEL1,
const NTV2FrameBufferFormat  inPixelFormat = NTV2_FBF_8BIT_YCBCR,
const NTV2VideoFormat  inVideoFormat = NTV2_FORMAT_1080i_5994,
const bool  inDoMultiFormat = false,
const bool  inDoRamp = false,
AJAFileIO inDolbyFile = NULL 
)

Constructs me using the given configuration settings.

Note
I'm not completely initialized and ready for use until after my Init method has been called.
Parameters
[in]inDeviceSpecifierSpecifies the AJA device to use. Defaults to "0", the first device found.
[in]inWithAudioIf true, include audio tone in the output signal; otherwise, omit it. Defaults to "true".
[in]inChannelSpecifies the channel to use. Defaults to NTV2_CHANNEL1.
[in]inPixelFormatSpecifies the pixel format to use for the device's frame buffers. Defaults to 8-bit YUV.
[in]inVideoFormatSpecifies the video format to use. Defaults to 1080i5994.
[in]inDoMultiFormatIf true, use multi-format mode; otherwise use uniformat mode. Defaults to false (uniformat mode).

Definition at line 53 of file ntv2dolbyplayer.cpp.

◆ ~NTV2DolbyPlayer()

NTV2DolbyPlayer::~NTV2DolbyPlayer ( void  )
virtual

Definition at line 99 of file ntv2dolbyplayer.cpp.

Member Function Documentation

◆ AddDolby()

uint32_t NTV2DolbyPlayer::AddDolby ( ULWord audioBuffer)
protectedvirtual

Inserts dolby audio into the given audio buffer.

Parameters
[out]audioBufferSpecifies a valid, non-NULL pointer to the buffer that is to receive the audio tone data.
Returns
Total number of bytes written into the buffer.

Definition at line 676 of file ntv2dolbyplayer.cpp.

◆ AddRamp()

uint32_t NTV2DolbyPlayer::AddRamp ( ULWord audioBuffer)
protectedvirtual

Inserts audio test ramp into the given audio buffer.

Parameters
[out]audioBufferSpecifies a valid, non-NULL pointer to the buffer that is to receive the audio ramp data.
Returns
Total number of bytes written into the buffer.

Definition at line 645 of file ntv2dolbyplayer.cpp.

◆ AddTone()

uint32_t NTV2DolbyPlayer::AddTone ( ULWord audioBuffer)
protectedvirtual

Inserts audio tone (based on my current tone frequency) into the given audio buffer.

Parameters
[out]audioBufferSpecifies a valid, non-NULL pointer to the buffer that is to receive the audio tone data.
Returns
Total number of bytes written into the buffer.

Definition at line 610 of file ntv2dolbyplayer.cpp.

◆ ConsumerThreadStatic()

void NTV2DolbyPlayer::ConsumerThreadStatic ( AJAThread pThread,
void *  pContext 
)
staticprotected

This is the consumer thread's static callback function that gets called when the consumer thread starts. This function gets "Attached" to the consumer thread's AJAThread instance.

Parameters
[in]pThreadA valid pointer to the consumer thread's AJAThread instance.
[in]pContextContext information to pass to the thread. (For this application, this will be set to point to the NTV2DolbyPlayer instance.)

Definition at line 390 of file ntv2dolbyplayer.cpp.

◆ GetACStatus()

void NTV2DolbyPlayer::GetACStatus ( ULWord outGoodFrames,
ULWord outDroppedFrames,
ULWord outBufferLevel 
)
virtual

Provides status information about my output (playout) process.

Parameters
[out]outGoodFramesReceives the number of successfully played frames.
[out]outDroppedFramesReceives the number of dropped frames.
[out]outBufferLevelReceives the driver's current buffer level.

Definition at line 600 of file ntv2dolbyplayer.cpp.

◆ GetBits()

bool NTV2DolbyPlayer::GetBits ( uint32_t &  data,
uint32_t  inBitCount 
)
protectedvirtual

Retreive the specified number of bits from the bitstream buffer.

Parameters
dataBitstream data
[in]inBitCountNumber of bits to retrieve from the buffer
Returns
True if suceeded.

Definition at line 1239 of file ntv2dolbyplayer.cpp.

◆ GetDolbyFrame()

bool NTV2DolbyPlayer::GetDolbyFrame ( uint16_t *  pInDolbyBuffer,
uint32_t &  numSamples 
)
protectedvirtual

Get a dolby audio audio frame from the input file.

Parameters
[out]pInDolbyBufferSpecifies a valid, non-NULL pointer to the buffer that is to receive the dolby frame data.
[out]numSamplesNumber of samples in the buffer.
Returns
True if valid sync frame in buffer.

Definition at line 879 of file ntv2dolbyplayer.cpp.

◆ GetRP188RegisterForOutput()

static ULWord NTV2DolbyPlayer::GetRP188RegisterForOutput ( const NTV2OutputDestination  inOutputSource)
staticprotected

Returns the RP188 DBB register number to use for the given NTV2OutputDestination.

Parameters
[in]inOutputSourceSpecifies the NTV2OutputDestination of interest.
Returns
The number of the RP188 DBB register to use for the given output destination.

◆ Init()

AJAStatus NTV2DolbyPlayer::Init ( void  )
virtual

Initializes me and prepares me to Run.

Definition at line 174 of file ntv2dolbyplayer.cpp.

◆ IsRunning()

virtual bool NTV2DolbyPlayer::IsRunning ( void  ) const
inlinevirtual
Returns
True if I'm running; otherwise false.

Definition at line 76 of file ntv2dolbyplayer.h.

◆ ParseBSI()

bool NTV2DolbyPlayer::ParseBSI ( uint16_t *  pInDolbyBuffer,
uint32_t  numSamples,
NTV2DolbyBSI pBsi 
)
protectedvirtual

Parse the dolby audio bit stream information block.

Parameters
[out]pInDolbyBufferSpecifies a valid, non-NULL pointer to the buffer that is to receive the dolby frame data.
[out]numSamplesNumber of samples in the buffer.
[out]pBsiParsed Dolby header data.
Returns
True if parser suceeded.

Definition at line 922 of file ntv2dolbyplayer.cpp.

◆ PlayFrames()

void NTV2DolbyPlayer::PlayFrames ( void  )
protectedvirtual

Repeatedly plays out frames using AutoCirculate (until quit).

Definition at line 403 of file ntv2dolbyplayer.cpp.

◆ ProduceFrames()

void NTV2DolbyPlayer::ProduceFrames ( void  )
protectedvirtual

Repeatedly produces test pattern frames (until global quit flag set).

Definition at line 530 of file ntv2dolbyplayer.cpp.

◆ ProducerThreadStatic()

void NTV2DolbyPlayer::ProducerThreadStatic ( AJAThread pThread,
void *  pContext 
)
staticprotected

This is the producer thread's static callback function that gets called when the producer thread starts. This function gets "Attached" to the producer thread's AJAThread instance.

Parameters
[in]pThreadA valid pointer to the producer thread's AJAThread instance.
[in]pContextContext information to pass to the thread. (For this application, this will be set to point to the NTV2DolbyPlayer instance.)

Definition at line 474 of file ntv2dolbyplayer.cpp.

◆ Quit()

void NTV2DolbyPlayer::Quit ( void  )
virtual

Gracefully stops me from running.

Definition at line 155 of file ntv2dolbyplayer.cpp.

◆ RouteOutputSignal()

void NTV2DolbyPlayer::RouteOutputSignal ( void  )
protectedvirtual

Sets up device routing for playout.

Definition at line 349 of file ntv2dolbyplayer.cpp.

◆ Run()

AJAStatus NTV2DolbyPlayer::Run ( void  )
virtual

Runs me.

Note
Do not call this method without first calling my Init method.

Definition at line 363 of file ntv2dolbyplayer.cpp.

◆ SetBitBuffer()

void NTV2DolbyPlayer::SetBitBuffer ( uint8_t *  pBuffer,
uint32_t  size 
)
protectedvirtual

Set the bitstream buffer for bit retrieval.

Parameters
[in]pBufferSpecifies a valid, non-NULL pointer to the bitstream buffer
[in]sizeBitstream buffer size

Definition at line 1232 of file ntv2dolbyplayer.cpp.

◆ SetUpAudio()

AJAStatus NTV2DolbyPlayer::SetUpAudio ( void  )
protectedvirtual

Sets up everything I need to play audio.

Definition at line 280 of file ntv2dolbyplayer.cpp.

◆ SetUpHostBuffers()

void NTV2DolbyPlayer::SetUpHostBuffers ( void  )
protectedvirtual

Sets up my circular buffers.

Definition at line 312 of file ntv2dolbyplayer.cpp.

◆ SetUpTestPatternVideoBuffers()

AJAStatus NTV2DolbyPlayer::SetUpTestPatternVideoBuffers ( void  )
protectedvirtual

Creates my test pattern buffers.

Definition at line 485 of file ntv2dolbyplayer.cpp.

◆ SetUpVideo()

AJAStatus NTV2DolbyPlayer::SetUpVideo ( void  )
protectedvirtual

Sets up everything I need to play video.

Definition at line 239 of file ntv2dolbyplayer.cpp.

◆ StartConsumerThread()

void NTV2DolbyPlayer::StartConsumerThread ( void  )
protectedvirtual

Starts my playout thread.

Definition at line 378 of file ntv2dolbyplayer.cpp.

◆ StartProducerThread()

void NTV2DolbyPlayer::StartProducerThread ( void  )
protectedvirtual

Starts my test pattern producer thread.

Definition at line 463 of file ntv2dolbyplayer.cpp.


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