AJA NTV2 SDK  18.0.0.2122
NTV2 SDK 18.0.0.2122
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
virtual AJAStatus Init(void)
Initializes me and prepares me to Run.
bool fSuppress608
If true, don&#39;t transmit CEA608 packets; otherwise include 608 packets.
Definition: ntv2ccplayer.h:85
static void PlayThreadStatic(AJAThread *pThread, void *pContext)
This is the playout thread&#39;s static callback function that gets called when the playout thread runs...
I am an object that can inject text captions into an SDI output of an AJA device in real time...
Definition: ntv2ccplayer.h:125
Declares the CNTV2CaptionEncoder708 class.
CaptionChanGenMap::const_iterator CaptionChanGenMapCIter
Definition: ntv2ccplayer.h:73
I interrogate and control an AJA video/audio capture/playout device.
Definition: ntv2card.h:28
_AtEndAction_
These are the actions that can be taken after the last file is "played".
Definition: ntv2ccplayer.h:27
NTV2TaskMode
Describes the task mode state. See also: Sharing AJA Devices With Other Applications.
enum _AtEndAction_ AtEndAction
These are the actions that can be taken after the last file is "played".
AJAStatus
Definition: types.h:380
virtual void Quit(const bool inQuitImmediately=(0))
Stops me.
NTV2Line21Channel fCaptionChannel
The caption channel to use.
Definition: ntv2ccplayer.h:49
CCPlayerConfig CCPlayerConfig
Configures an NTV2CCPlayer instance.
std::vector< AJALabelValuePair > AJALabelValuePairs
An ordered sequence of label/value pairs.
Definition: info.h:71
Configures an NTV2CCPlayer instance.
Definition: ntv2ccplayer.h:80
bool fNewLinesAreNewRows
If true, newlines break caption rows; otherwise are treated as whitespace.
Definition: ntv2ccplayer.h:50
virtual void StartCaptionGeneratorThreads(void)
Starts my caption generator threads.
bool fSuppress708
If true, don&#39;t transmit CEA708 packets; otherwise include 708 packets.
Definition: ntv2ccplayer.h:86
virtual AJAStatus RouteOutputSignal(void)
Sets up signal routing for playout.
#define false
virtual AJAStatus SetUpOutputVideo(void)
Sets up everything I need to play video.
bool fSuppressLine21
SD output only: if true, do not encode Line 21 waveform; otherwise encode Line 21 waveform...
Definition: ntv2ccplayer.h:84
NTV2Line21Mode fCaptionMode
The CEA-608 caption mode to use.
Definition: ntv2ccplayer.h:48
std::ostream & operator<<(std::ostream &ioStrm, const CCPlayerConfig &inObj)
Repeat the file list (must Ctrl-C to terminate)
Definition: ntv2ccplayer.h:31
NTV2FrameRate
Identifies a particular video frame rate.
Definition: ntv2enums.h:412
#define true
NTV2Standard
Identifies a particular video standard.
Definition: ntv2enums.h:165
NTV2DeviceID
Identifies a specific AJA NTV2 device model number. The NTV2DeviceID is actually the PROM part number...
Definition: ntv2enums.h:20
Declares the AJAThread class.
NTV2StringList fFilesToPlay
A list of zero or more strings containing paths to text files to be "played".
Definition: ntv2ccplayer.h:46
CEA-608 Character Attributes.
virtual AJAStatus Run(void)
Runs me.
TimecodeFormat NTV2FrameRate2TimecodeFormat(NTV2FrameRate inFrameRate)
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.
std::vector< std::string > NTV2StringList
Definition: ntv2utils.h:1155
Caption channel 1, the primary caption channel.
CaptionChanGenMap fCapChanGenConfigs
Caption channel generator configs.
Definition: ntv2ccplayer.h:90
CaptionChanGenMap::iterator CaptionChanGenMapIter
Definition: ntv2ccplayer.h:74
virtual void StartPlayoutThread(void)
Starts my playout thread.
struct CCGenConfig CCGenConfig
This class is used to configure a caption generator for a single caption channel. ...
This class is used to configure a caption generator for a single caption channel. ...
Definition: ntv2ccplayer.h:43
NTV2Line21Attrs fAttributes
The character attributes to use.
Definition: ntv2ccplayer.h:52
Describes a user-space buffer on the host computer. I have an address and a length, plus some optional attributes (allocated by SDK?, page-aligned? etc.).
Declares the CNTV2CaptionEncoder608 class.
bool fEmitStats
If true, show stats while playing; otherwise echo caption text being played.
Definition: ntv2ccplayer.h:83
std::set< NTV2Channel > NTV2ChannelSet
A set of distinct NTV2Channel values.
static void CaptionGeneratorThreadStatic(AJAThread *pThread, void *pContext)
This is the caption generator thread&#39;s static callback function that gets called when the caption gen...
virtual bool DeviceAncExtractorIsAvailable(void)
Declares the AJASystemInfo class.
CCPlayerConfig(const std::string &inDeviceSpecifier="0")
Constructs a default CCPlayer configuration.
Definition: ntv2ccplayer.h:95
This is returned from the CNTV2Card::AutoCirculateGetStatus function.
double fCharsPerMinute
The rate at which caption characters get enqueued, in characters per minute.
Definition: ntv2ccplayer.h:51
4-row roll-up from bottom
TimecodeFormat
Definition: ntv2rp188.h:22
AJAThreadList::const_iterator AJAThreadListConstIter
Definition: ntv2ccplayer.h:220
virtual void PlayoutFrames(void)
Repeatedly plays frames (until time to quit).
std::vector< AJAThread > AJAThreadList
Definition: ntv2ccplayer.h:219
virtual ~NTV2CCPlayer(void)
bool fSuppressTimecode
If true, suppress timecode; otherwise embed VITC/LTC.
Definition: ntv2ccplayer.h:87
std::string fTestPatternName
The test pattern to use.
Definition: ntv2ccplayer.h:89
This file contains some structures, constants, classes and functions that are used in some of the dem...
Configures an NTV2Player instance.
NTV2Line21Mode
The CEA-608 modes: pop-on, roll-up (2, 3 and 4-line), and paint-on.
AtEndAction fEndAction
The action to take after the file list has finished playing.
Definition: ntv2ccplayer.h:47
Continue to emit gray field on the device (must Ctrl-C to terminate)
Definition: ntv2ccplayer.h:32
std::map< NTV2InputXptID, NTV2OutputXptID > NTV2XptConnections
AJALabelValuePairs Get(void) const
virtual AJAStatus SetUpBackgroundPatternBuffer(void)
Sets up my gray background field.
virtual void GenerateCaptions(const NTV2Line21Channel inCCChannel)
This is the thread function that produces caption messages for a given caption channel.
std::map< NTV2Line21Channel, CCGenConfig > CaptionChanGenMap
Definition: ntv2ccplayer.h:72
NTV2Line21Channel
The CEA-608 caption channels: CC1 thru CC4, TX1 thru TX4, plus XDS.
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
Declares several data types used with 608/SD captioning.
NTV2CCPlayer(const CCPlayerConfig &inConfigData)
Constructs me using the given configuration settings.
CCGenConfig()
Constructs a default generator configuration.
Definition: ntv2ccplayer.h:57
void SignalHandler(int inSignal)
Definition: main.cpp:26
AJALabelValuePairs Get(const bool inCompact=(0)) const