AJA NTV2 SDK  17.5.0.1242
NTV2 SDK 17.5.0.1242
ntv2ccplayer.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
9 #ifndef _NTV2CCPLAYER_H
10 #define _NTV2CCPLAYER_H
11 
12 #include "ntv2democommon.h"
13 #include "ajabase/system/thread.h"
14 #include "ajabase/system/info.h"
15 #include "ntv2captionencoder608.h"
16 #include "ntv2captionencoder708.h"
17 #include "ntv2caption608types.h"
18 #include <vector>
19 #include <map>
20 
21 #define SIG_AJA_STOP 31 // Our own user-defined "stop" signal
22 
23 
27 typedef enum _AtEndAction_
28 {
33 } AtEndAction;
34 
35 
36 // Declaration for function that sets the master "quit" flag (see main.cpp).
37 void SignalHandler (int inSignal);
38 
39 
43 typedef struct CCGenConfig
44 {
45  public:
51  double fCharsPerMinute;
53 
57  inline explicit CCGenConfig ()
63  fCharsPerMinute (500),
64  fAttributes ()
65  {
66  }
67 
68  AJALabelValuePairs Get (void) const;
69 } CCGenConfig;
70 
71 
72 typedef std::map <NTV2Line21Channel, CCGenConfig> CaptionChanGenMap;
73 typedef CaptionChanGenMap::const_iterator CaptionChanGenMapCIter;
74 typedef CaptionChanGenMap::iterator CaptionChanGenMapIter;
75 
76 
80 typedef struct CCPlayerConfig : public PlayerConfig
81 {
82  public:
83  bool fEmitStats;
85  bool fSuppress608;
86  bool fSuppress708;
88  uint16_t fForceRTP;
89  std::string fTestPatternName;
91 
95  inline explicit CCPlayerConfig (const std::string & inDeviceSpecifier = "0")
96  : PlayerConfig (inDeviceSpecifier),
97  fEmitStats (true),
102  fForceRTP (0),
103  fTestPatternName ("Flat Field"),
105  {
106  }
107 
108  AJALabelValuePairs Get (const bool inCompact = false) const;
109 
111 
112 std::ostream & operator << (std::ostream & ioStrm, const CCPlayerConfig & inObj);
113 
114 
115 
126 {
127  // Public Instance Methods
128  public:
134  NTV2CCPlayer (const CCPlayerConfig & inConfigData);
135 
136  virtual ~NTV2CCPlayer (void);
137 
141  virtual AJAStatus Init (void);
142 
147  virtual AJAStatus Run (void);
148 
156  virtual void Quit (const bool inQuitImmediately = false);
157 
158 
170  virtual void GetStatus (size_t & outMessagesQueued, size_t & outBytesQueued,
171  size_t & outTotMsgsEnq, size_t & outTotBytesEnq,
172  size_t & outTotMsgsDeq, size_t & outTotBytesDeq,
173  size_t & outMaxQueDepth, size_t & outDroppedFrames) const;
174 
175 
176  // Protected Instance Methods
177  protected:
178  virtual AJAStatus SetUpBackgroundPatternBuffer (void);
179  virtual AJAStatus SetUpOutputVideo (void);
180  virtual AJAStatus RouteOutputSignal (void);
181  virtual void StartPlayoutThread (void);
182  virtual void PlayoutFrames (void);
183  virtual void StartCaptionGeneratorThreads (void);
184 
189  virtual void GenerateCaptions (const NTV2Line21Channel inCCChannel);
190 
194  virtual bool DeviceAncExtractorIsAvailable (void);
195 
196 
197  // Protected Class Methods
198  protected:
206  static void PlayThreadStatic (AJAThread * pThread, void * pContext);
207 
215  static void CaptionGeneratorThreadStatic (AJAThread * pThread, void * pContext);
216 
218 
219  typedef std::vector<AJAThread> AJAThreadList;
220  typedef AJAThreadList::const_iterator AJAThreadListConstIter;
221 
222 
223  // Private Member Data
224  private:
225  CCPlayerConfig mConfig;
226  AJAThread mPlayThread;
227  AJAThreadList mGeneratorThreads;
228  AUTOCIRCULATE_STATUS mACStatus;
229  mutable CNTV2Card mDevice;
230  NTV2DeviceID mDeviceID;
231  NTV2TaskMode mSavedTaskMode;
232  NTV2Standard mVideoStandard;
233  bool mPlayerQuit;
234  bool mCaptionGeneratorQuit;
235  CNTV2CaptionEncoder608Ptr m608Encoder;
236  CNTV2CaptionEncoder708Ptr m708Encoder;
237  NTV2Buffer mVideoBuffer;
238  NTV2ChannelSet mActiveFrameStores;
239  NTV2XptConnections mConnections;
240 
241 }; // NTV2CCPlayer
242 
243 #endif // _NTV2CCPLAYER_H
NTV2CCPlayer
I am an object that can inject text captions into an SDI output of an AJA device in real time....
Definition: ntv2ccplayer.h:125
NTV2TaskMode
enum NTV2EveryFrameTaskMode NTV2TaskMode
info.h
Declares the AJASystemInfo class.
ntv2caption608types.h
Declares several data types used with 608/SD captioning.
NTV2CCPlayer::DeviceAncExtractorIsAvailable
virtual bool DeviceAncExtractorIsAvailable(void)
Definition: ntv2ccplayer.cpp:930
CCGenConfig
struct CCGenConfig CCGenConfig
This class is used to configure a caption generator for a single caption channel.
NTV2CCPlayer::SetUpOutputVideo
virtual AJAStatus SetUpOutputVideo(void)
Sets up everything I need to play video.
Definition: ntv2ccplayer.cpp:1050
NTV2CCPlayer::PlayoutFrames
virtual void PlayoutFrames(void)
Repeatedly plays frames (until time to quit).
Definition: ntv2ccplayer.cpp:1571
CaptionChanGenMapCIter
CaptionChanGenMap::const_iterator CaptionChanGenMapCIter
Definition: ntv2ccplayer.h:73
NTV2Buffer
A generic user-space buffer object that has an address and a length. Used most often to share an arbi...
Definition: ntv2publicinterface.h:6022
CCGenConfig::fNewLinesAreNewRows
bool fNewLinesAreNewRows
If true, newlines break caption rows; otherwise are treated as whitespace.
Definition: ntv2ccplayer.h:50
NTV2CCPlayer::StartCaptionGeneratorThreads
virtual void StartCaptionGeneratorThreads(void)
Starts my caption generator threads.
Definition: ntv2ccplayer.cpp:1375
AJARefPtr< CNTV2CaptionEncoder608 >
CCPlayerConfig::fForceRTP
uint16_t fForceRTP
BIT(0):0=normal,1=forceRTP BIT(1):0=uniPkt,1=multiPkt BIT(2):0=normal,1=patchDeviceID.
Definition: ntv2ccplayer.h:88
AtEndAction_Idle
@ AtEndAction_Idle
Repeat the file list (must Ctrl-C to terminate)
Definition: ntv2ccplayer.h:31
AtEndAction
enum _AtEndAction_ AtEndAction
These are the actions that can be taken after the last file is "played".
CCPlayerConfig
Configures an NTV2CCPlayer instance.
Definition: ntv2ccplayer.h:80
CCGenConfig::fCaptionMode
NTV2Line21Mode fCaptionMode
The CEA-608 caption mode to use.
Definition: ntv2ccplayer.h:48
CCPlayerConfig::fSuppressTimecode
bool fSuppressTimecode
If true, suppress timecode; otherwise embed VITC/LTC.
Definition: ntv2ccplayer.h:87
CCGenConfig::CCGenConfig
CCGenConfig()
Constructs a default generator configuration.
Definition: ntv2ccplayer.h:57
CCGenConfig::fFilesToPlay
NTV2StringList fFilesToPlay
A list of zero or more strings containing paths to text files to be "played".
Definition: ntv2ccplayer.h:46
CaptionChanGenMapIter
CaptionChanGenMap::iterator CaptionChanGenMapIter
Definition: ntv2ccplayer.h:74
NTV2DeviceID
NTV2DeviceID
Identifies a specific AJA NTV2 device model number. The NTV2DeviceID is actually the PROM part number...
Definition: ntv2enums.h:20
NTV2CCPlayer::AJAThreadList
std::vector< AJAThread > AJAThreadList
Definition: ntv2ccplayer.h:219
CCPlayerConfig::fCapChanGenConfigs
CaptionChanGenMap fCapChanGenConfigs
Caption channel generator configs.
Definition: ntv2ccplayer.h:90
CCGenConfig::fCaptionChannel
NTV2Line21Channel fCaptionChannel
The caption channel to use.
Definition: ntv2ccplayer.h:49
ntv2captionencoder608.h
Declares the CNTV2CaptionEncoder608 class.
TimecodeFormat
TimecodeFormat
Definition: ntv2rp188.h:27
NTV2CCPlayer::SetUpBackgroundPatternBuffer
virtual AJAStatus SetUpBackgroundPatternBuffer(void)
Sets up my gray background field.
Definition: ntv2ccplayer.cpp:1018
CCGenConfig::Get
AJALabelValuePairs Get(void) const
Definition: ntv2ccplayer.cpp:211
NTV2FrameRate
NTV2FrameRate
Identifies a particular video frame rate.
Definition: ntv2enums.h:399
NTV2CCPlayer::PlayThreadStatic
static void PlayThreadStatic(AJAThread *pThread, void *pContext)
This is the playout thread's static callback function that gets called when the playout thread runs....
Definition: ntv2ccplayer.cpp:1562
NTV2CCPlayer::StartPlayoutThread
virtual void StartPlayoutThread(void)
Starts my playout thread.
Definition: ntv2ccplayer.cpp:1552
operator<<
std::ostream & operator<<(std::ostream &ioStrm, const CCPlayerConfig &inObj)
Definition: ntv2ccplayer.cpp:248
AJAThread
Definition: thread.h:69
NTV2CCPlayer::Init
virtual AJAStatus Init(void)
Initializes me and prepares me to Run.
Definition: ntv2ccplayer.cpp:944
AJAStatus
AJAStatus
Definition: types.h:378
CCGenConfig::fEndAction
AtEndAction fEndAction
The action to take after the file list has finished playing.
Definition: ntv2ccplayer.h:47
CCPlayerConfig::fEmitStats
bool fEmitStats
If true, show stats while playing; otherwise echo caption text being played.
Definition: ntv2ccplayer.h:83
NTV2Standard
NTV2Standard
Identifies a particular video standard.
Definition: ntv2enums.h:156
AUTOCIRCULATE_STATUS
This is returned from the CNTV2Card::AutoCirculateGetStatus function.
Definition: ntv2publicinterface.h:7193
CaptionChanGenMap
std::map< NTV2Line21Channel, CCGenConfig > CaptionChanGenMap
Definition: ntv2ccplayer.h:72
CCPlayerConfig::fSuppress608
bool fSuppress608
If true, don't transmit CEA608 packets; otherwise include 608 packets.
Definition: ntv2ccplayer.h:85
_AtEndAction_
_AtEndAction_
These are the actions that can be taken after the last file is "played".
Definition: ntv2ccplayer.h:27
CCGenConfig
This class is used to configure a caption generator for a single caption channel.
Definition: ntv2ccplayer.h:43
CCPlayerConfig::CCPlayerConfig
CCPlayerConfig(const std::string &inDeviceSpecifier="0")
Constructs a default CCPlayer configuration.
Definition: ntv2ccplayer.h:95
AtEndAction_Repeat
@ AtEndAction_Repeat
Terminate.
Definition: ntv2ccplayer.h:30
NTV2CCPlayer::RouteOutputSignal
virtual AJAStatus RouteOutputSignal(void)
Sets up signal routing for playout.
Definition: ntv2ccplayer.cpp:1189
CCPlayerConfig::fSuppressLine21
bool fSuppressLine21
SD output only: if true, do not encode Line 21 waveform; otherwise encode Line 21 waveform.
Definition: ntv2ccplayer.h:84
CNTV2Card
I interrogate and control an AJA video/audio capture/playout device.
Definition: ntv2card.h:28
NTV2CCPlayer::NTV2FrameRate2TimecodeFormat
TimecodeFormat NTV2FrameRate2TimecodeFormat(NTV2FrameRate inFrameRate)
NTV2_CC608_CapModeRollUp4
@ NTV2_CC608_CapModeRollUp4
4-row roll-up from bottom
Definition: ntv2caption608types.h:130
NTV2ChannelSet
std::set< NTV2Channel > NTV2ChannelSet
A set of distinct NTV2Channel values.
Definition: ntv2publicinterface.h:3854
NTV2StringList
std::vector< std::string > NTV2StringList
Definition: ntv2utils.h:1143
NTV2CCPlayer::~NTV2CCPlayer
virtual ~NTV2CCPlayer(void)
Definition: ntv2ccplayer.cpp:878
NTV2Line21Mode
NTV2Line21Mode
The CEA-608 modes: pop-on, roll-up (2, 3 and 4-line), and paint-on.
Definition: ntv2caption608types.h:123
false
#define false
Definition: ntv2devicefeatures.h:25
ntv2democommon.h
This file contains some structures, constants, classes and functions that are used in some of the dem...
NTV2CCPlayer::CaptionGeneratorThreadStatic
static void CaptionGeneratorThreadStatic(AJAThread *pThread, void *pContext)
This is the caption generator thread's static callback function that gets called when the caption gen...
Definition: ntv2ccplayer.cpp:1390
NTV2_CC608_CC1
@ NTV2_CC608_CC1
Caption channel 1, the primary caption channel.
Definition: ntv2caption608types.h:84
ntv2captionencoder708.h
Declares the CNTV2CaptionEncoder708 class.
NTV2XptConnections
std::map< NTV2InputXptID, NTV2OutputXptID > NTV2XptConnections
Definition: ntv2signalrouter.h:39
NTV2Line21Channel
NTV2Line21Channel
The CEA-608 caption channels: CC1 thru CC4, TX1 thru TX4, plus XDS.
Definition: ntv2caption608types.h:82
NTV2CCPlayer::AJAThreadListConstIter
AJAThreadList::const_iterator AJAThreadListConstIter
Definition: ntv2ccplayer.h:220
CCPlayerConfig::fTestPatternName
std::string fTestPatternName
The test pattern to use.
Definition: ntv2ccplayer.h:89
NTV2CCPlayer::Quit
virtual void Quit(const bool inQuitImmediately=(0))
Stops me.
Definition: ntv2ccplayer.cpp:893
NTV2CCPlayer::GenerateCaptions
virtual void GenerateCaptions(const NTV2Line21Channel inCCChannel)
This is the thread function that produces caption messages for a given caption channel.
Definition: ntv2ccplayer.cpp:1407
true
#define true
Definition: ntv2devicefeatures.h:26
NTV2CCPlayer::Run
virtual AJAStatus Run(void)
Runs me.
Definition: ntv2ccplayer.cpp:1350
CCPlayerConfig::fSuppress708
bool fSuppress708
If true, don't transmit CEA708 packets; otherwise include 708 packets.
Definition: ntv2ccplayer.h:86
AtEndAction_Max
@ AtEndAction_Max
Continue to emit gray field on the device (must Ctrl-C to terminate)
Definition: ntv2ccplayer.h:32
PlayerConfig
Configures an NTV2Player instance.
Definition: ntv2democommon.h:319
CCGenConfig::fAttributes
NTV2Line21Attrs fAttributes
The character attributes to use.
Definition: ntv2ccplayer.h:52
NTV2Line21Attributes
CEA-608 Character Attributes.
Definition: ntv2caption608types.h:357
CCGenConfig::fCharsPerMinute
double fCharsPerMinute
The rate at which caption characters get enqueued, in characters per minute.
Definition: ntv2ccplayer.h:51
NTV2CCPlayer::GetStatus
virtual void GetStatus(size_t &outMessagesQueued, size_t &outBytesQueued, size_t &outTotMsgsEnq, size_t &outTotBytesEnq, size_t &outTotMsgsDeq, size_t &outTotBytesDeq, size_t &outMaxQueDepth, size_t &outDroppedFrames) const
Returns status information from my caption encoder.
Definition: ntv2ccplayer.cpp:1825
AJALabelValuePairs
std::vector< AJALabelValuePair > AJALabelValuePairs
An ordered sequence of label/value pairs.
Definition: info.h:69
thread.h
Declares the AJAThread class.
SignalHandler
void SignalHandler(int inSignal)
Definition: main.cpp:26
CCPlayerConfig::Get
AJALabelValuePairs Get(const bool inCompact=(0)) const
Definition: ntv2ccplayer.cpp:227
AtEndAction_Quit
@ AtEndAction_Quit
Definition: ntv2ccplayer.h:29
CCPlayerConfig
CCPlayerConfig CCPlayerConfig
Configures an NTV2CCPlayer instance.
NTV2CCPlayer::NTV2CCPlayer
NTV2CCPlayer(const CCPlayerConfig &inConfigData)
Constructs me using the given configuration settings.
Definition: ntv2ccplayer.cpp:859