AJA NTV2 SDK  18.1.0.2439
NTV2 SDK 18.1.0.2439
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:
48  NTV2Line21Mode fCaptionMode;
49  NTV2Line21Channel fCaptionChannel;
51  double fCharsPerMinute;
52  NTV2Line21Attrs fAttributes;
53 
57  inline explicit CCGenConfig ()
60  fCaptionMode (NTV2_CC608_CapModeRollUp4),
61  fCaptionChannel (NTV2_CC608_CC1),
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  NTV2TaskMode mSavedTaskMode;
231  NTV2Standard mVideoStandard;
232  bool mPlayerQuit;
233  bool mCaptionGeneratorQuit;
234  CNTV2CaptionEncoder608Ptr m608Encoder;
235  CNTV2CaptionEncoder708Ptr m708Encoder;
236  NTV2Buffer mVideoBuffer;
237  NTV2ChannelSet mActiveFrameStores;
238  NTV2XptConnections mConnections;
239 
240 }; // NTV2CCPlayer
241 
242 #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
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: NTV2 Device Sharing.
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:416
#define true
NTV2Standard
Identifies a particular video standard.
Definition: ntv2enums.h:169
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
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.
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.).
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
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.
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.
std::vector< std::string > NTV2StringList
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
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
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