AJA NTV2 SDK  18.0.0.2122
NTV2 SDK 18.0.0.2122
ntv2config2110.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
8 #ifndef NTV2_2110CONFIG_H
9 #define NTV2_2110CONFIG_H
10 
11 #include "ntv2card.h"
12 #include "ntv2enums.h"
13 #include "ntv2registers2110.h"
14 #include "ntv2mbcontroller.h"
15 #include <string>
16 #include <iostream>
17 #include <fstream>
18 #include <sstream>
19 
24 #define RX_USE_SFP_IP BIT(31)
25 #define IP_STRSIZE 32
26 
27 
28 typedef enum
29 {
30  kNetworkData2110 = NTV2_FOURCC('n','t','1','3'), // 4CC of network config data
31  kTransmitVideoData2110 = NTV2_FOURCC('t','v','1','3'), // 4CC of video transmit config data
32  kTransmitAudioData2110 = NTV2_FOURCC('t','a','1','3'), // 4CC of audio transmit config data
33  kTransmitAncData2110 = NTV2_FOURCC('t','n','1','3'), // 4CC of anc transmit config data
34  kReceiveVideoData2110 = NTV2_FOURCC('r','v','1','3'), // 4CC of video receive config data
35  kReceiveAudioData2110 = NTV2_FOURCC('r','a','1','3'), // 4CC of audio receive config data
36  kReceiveAncData2110 = NTV2_FOURCC('r','n','1','3'), // 4CC of anc receive config data
37  kChStatusData2110 = NTV2_FOURCC('s','t','1','3') // 4CC of channel status config data
39 
40 typedef enum
41 {
46 
47 // force 1 byte alignment so can work across 32/64 bit apps
48 #pragma pack(push,1)
49 
50 typedef struct
51 {
53  char remoteIP[2][IP_STRSIZE];
54  uint32_t remotePort[2];
55  uint32_t localPort[2];
56  uint32_t sfpEnable[2];
57  uint32_t ttl;
58  uint32_t ssrc;
59  uint32_t payloadType;
62  uint32_t enable;
63  uint8_t unused[12];
65 
66 typedef struct
67 {
70  char remoteIP[2][IP_STRSIZE];
71  uint32_t localPort[2];
72  uint32_t remotePort[2];
73  uint32_t sfpEnable[2];
74  uint32_t ttl;
75  uint32_t ssrc;
76  uint32_t payloadType;
77  uint32_t numAudioChannels;
80  uint32_t enable;
81  uint8_t unused[16];
83 
84 typedef struct
85 {
87  char remoteIP[2][IP_STRSIZE];
88  uint32_t localPort[2];
89  uint32_t remotePort[2];
90  uint32_t sfpEnable[2];
91  uint32_t ttl;
92  uint32_t ssrc;
93  uint32_t payloadType;
94  uint32_t enable;
95  uint8_t unused[16];
97 
98 typedef struct
99 {
101  char sourceIP[2][IP_STRSIZE];
102  char destIP[2][IP_STRSIZE];
103  uint32_t sourcePort[2];
104  uint32_t destPort[2];
105  uint32_t sfpEnable[2];
106  uint32_t vlan;
107  uint32_t ssrc;
108  uint32_t payloadType;
110  uint32_t enable;
111  uint8_t unused[16];
113 
114 typedef struct
115 {
118  char sourceIP[2][IP_STRSIZE];
119  char destIP[2][IP_STRSIZE];
120  uint32_t sourcePort[2];
121  uint32_t destPort[2];
122  uint32_t sfpEnable[2];
123  uint32_t vlan;
124  uint32_t ssrc;
125  uint32_t payloadType;
128  uint32_t enable;
129  uint8_t unused[16];
131 
132 typedef struct
133 {
135  char sourceIP[2][IP_STRSIZE];
136  char destIP[2][IP_STRSIZE];
137  uint32_t sourcePort[2];
138  uint32_t destPort[2];
139  uint32_t sfpEnable[2];
140  uint32_t vlan;
141  uint32_t ssrc;
142  uint32_t payloadType;
143  uint32_t enable;
144  uint8_t unused[16];
146 
147 typedef struct
148 {
150  char ipAddress[IP_STRSIZE];
151  char subnetMask[IP_STRSIZE];
152  char gateWay[IP_STRSIZE];
153  uint32_t enable;
154  uint8_t unused[16];
155 } SFPData2110;
156 
157 typedef struct
158 {
159  uint32_t txChStatus[4];
160  uint32_t rxChStatus[4];
161  uint8_t unused[16];
162 } IpStatus2110;
163 
164 typedef struct
165 {
166  bool setup4k;
167  uint32_t ptpDomain;
168  uint8_t ptpPreferredGMID[8];
169  uint32_t numSFPs;
170  SFPData2110 sfp[2];
171  bool multiSDP;
173  uint32_t rxMatchOverride;
174  uint8_t unused[10];
176 
177 typedef struct
178 {
180  TxVideoChData2110 txVideoCh[4];
182 
183 typedef struct
184 {
186  TxAudioChData2110 txAudioCh[4];
188 
189 typedef struct
190 {
192  TxAncChData2110 txAncCh[4];
194 
195 typedef struct
196 {
198  RxVideoChData2110 rxVideoCh[4];
200 
201 typedef struct
202 {
204  RxAudioChData2110 rxAudioCh[4];
206 
207 typedef struct
208 {
210  RxAncChData2110 rxAncCh[4];
212 
213 #pragma pack(pop)
214 
216  { return (NTV2Stream)(NTV2_VIDEO1_STREAM+ch); }
218  { return (int)(s); }
219 
221  { return (NTV2Stream)(NTV2_AUDIO1_STREAM+ch); }
223  { return (int)(s >= NTV2_AUDIO1_STREAM ? s-NTV2_AUDIO1_STREAM : 0); }
224 
225 inline NTV2Stream ChToAncStream(int ch)
226  { return (NTV2Stream)(NTV2_ANC1_STREAM+ch); }
228  { return (int)(s >= NTV2_ANC1_STREAM ? s-NTV2_ANC1_STREAM : 0); }
229 
235 {
236  public:
237  tx_2110Config() { init(); }
238 
239  void init();
240 
241  bool operator != ( const tx_2110Config &other );
242  bool operator == ( const tx_2110Config &other );
243 
244  public:
245  std::string remoteIP[2];
246  uint32_t localPort[2];
247  uint32_t remotePort[2];
248  uint16_t payloadType;
249  uint8_t tos; // type of service
250  uint8_t ttl; // time to live
251  uint32_t ssrc;
258 };
259 
265 {
266  public:
267  rx_2110Config() { init(); }
268 
269  void init();
270 
271  bool operator != ( const rx_2110Config &other );
272  bool operator == ( const rx_2110Config &other );
273 
274  public:
275  uint32_t rxMatch;
276  std::string sourceIP;
277  std::string destIP;
279  uint32_t sourcePort;
280  uint32_t destPort;
281  uint32_t ssrc;
282  uint16_t vlan;
283  uint16_t payloadType;
288 };
289 
290 typedef struct
291 {
292  rx_2110Config rx2110Config[4];
294 
295 
301 {
302  friend class CKonaIpJsonSetup;
303 public:
304  CNTV2Config2110 (CNTV2Card & device);
305  ~CNTV2Config2110();
306 
307  bool SetNetworkConfiguration (const eSFP sfp, const IPVNetConfig & netConfig);
308  bool GetNetworkConfiguration (const eSFP sfp, IPVNetConfig & netConfig);
309  bool SetNetworkConfiguration (const eSFP sfp, const std::string localIPAddress, const std::string subnetMask, const std::string gateway);
310  bool GetNetworkConfiguration (const eSFP sfp, std::string & localIPAddress, std::string & subnetMask, std::string & gateway);
311  bool DisableNetworkInterface (const eSFP sfp);
312  bool SetRxStreamConfiguration (const eSFP sfp, const NTV2Stream stream, const rx_2110Config & rxConfig);
313  bool GetRxStreamConfiguration (const eSFP sfp, const NTV2Stream stream, rx_2110Config & rxConfig);
314  bool SetRxStreamEnable (const eSFP sfp, const NTV2Stream stream, bool enable);
315  bool GetRxStreamEnable (const eSFP sfp, const NTV2Stream stream, bool & enabled);
316  bool GetRxPacketCount (const NTV2Stream stream, uint32_t &packets);
317  bool GetRxByteCount (const NTV2Stream stream, uint32_t &bytes);
318  bool GetRxByteCount (const eSFP sfp, uint64_t &bytes);
319 
320  bool SetTxStreamConfiguration (const NTV2Stream stream, const tx_2110Config & txConfig);
321  bool GetTxStreamConfiguration (const NTV2Stream stream, tx_2110Config & txConfig);
322  bool SetTxStreamEnable (const NTV2Stream stream, bool enableSfp1, bool enableSfp2 = false);
323  bool GetTxStreamEnable (const NTV2Stream stream, bool & sfp1Enabled, bool & sfp2Enabled);
324  bool GetTxPacketCount (NTV2Stream stream, uint32_t &packets);
325  bool GetTxByteCount (const eSFP sfp, uint64_t &bytes);
326 
327  bool SetPTPDomain (const uint8_t domain);
328  bool GetPTPDomain (uint8_t &domain);
329  bool SetPTPPreferredGrandMasterId (const uint8_t id[8]);
330  bool GetPTPPreferredGrandMasterId (uint8_t (&id)[8]);
331  bool GetPTPStatus (PTPStatus & ptpStatus);
332 
333  bool Set4KModeEnable (const bool enable);
334  bool Get4KModeEnable (bool & enable);
335 
347  bool SetAudioCombineEnable (const bool enable);
348 
359  bool GetAudioCombineEnable (bool & outEnabled);
360 
361  bool SetIPServicesControl (const bool enable, const bool forceReconfig);
362  bool GetIPServicesControl (bool & enable, bool & forceReconfig);
363 
364  std::string GetSDPUrl (const eSFP sfp, const NTV2Stream stream);
365  std::string GetGeneratedSDP (bool enabledSfp1, bool enabledSfp2, const NTV2Stream stream);
366  bool GetActualSDP (std::string url, std::string & sdp);
367  bool ExtractRxVideoConfigFromSDP (std::string sdp, rx_2110Config & rxConfig);
368  bool ExtractRxVideoConfigFromSDP (std::string sdp, multiRx_2110Config & rxConfig);
369  bool ExtractRxAudioConfigFromSDP (std::string sdp, rx_2110Config & rxConfig);
370  bool ExtractRxAncConfigFromSDP (std::string sdp, rx_2110Config & rxConfig);
371 
380  bool SetIGMPDisable (const eSFP sfp, const bool disable);
381  bool GetIGMPDisable (const eSFP sfp, bool & disabled);
382 
383  bool SetIGMPVersion (const eIGMPVersion_t version);
384  bool GetIGMPVersion (eIGMPVersion_t & version);
385 
386  void SetBiDirectionalChannels (const bool bidirectional) { _biDirectionalChannels = bidirectional;}
387  bool GetBiDirectionalChannels (void) {return _biDirectionalChannels;}
388 
389  bool GetMACAddress (const eSFP port, const NTV2Stream stream, std::string remoteIP, uint32_t & hi, uint32_t & lo);
390 
391  bool GetSFPMSAData (eSFP port, SFPMSAData & data);
392  bool GetLinkStatus (eSFP port, SFPStatus & sfpStatus);
393 
394  bool GenSDP (bool enableSfp1, bool enableSfp2, const NTV2Stream stream, bool pushit=true);
395 
396  static uint32_t Get2110TxStreamIndex (NTV2Stream stream );
397  static uint32_t GetDecapsulatorAddress (eSFP sfp, NTV2Stream stream);
398 
399  bool SetLLDPInfo (std::string sysname);
400  bool GetLLDPInfo (std::string &chassisId0, std::string &portId0,
401  std::string &chassisId1, std::string &portId1);
402  uint64_t GetNTPTimestamp (void);
403 
404  // If method returns false call this to get details
405  std::string getLastError (void);
406  NTV2IpError getLastErrorCode (void);
407 
408  static uint32_t videoPacketizers[4];
409  static uint32_t videoRGB12Packetizers[4];
410  static uint32_t audioPacketizers[4];
411 
412  static uint32_t videoDepacketizers[4];
413  static uint32_t audioDepacketizers[4];
414 
415 protected:
416  uint32_t GetDepacketizerAddress (const NTV2Stream stream);
417  uint32_t GetPacketizerAddress (const NTV2Stream stream, const VPIDSampling sampling);
418  uint32_t GetFramerAddress (const eSFP sfp, const NTV2Stream stream);
419  void SelectTxFramerChannel (const NTV2Stream stream, const uint32_t baseAddr);
420  void AcquireFramerControlAccess (const uint32_t baseAddr);
421  void ReleaseFramerControlAccess (const uint32_t baseAddr);
422 
423  void EnableFramerStream (const eSFP sfp, const NTV2Stream stream, bool enable);
424  bool SetFramerStream (const eSFP sfp, const NTV2Stream stream, const tx_2110Config & txConfig);
425  void GetFramerStream (const eSFP sfp, const NTV2Stream stream, tx_2110Config & txConfig);
426  void SetArbiter (const eSFP sfp, const NTV2Stream stream, bool enable);
427  void GetArbiter (const eSFP sfp, const NTV2Stream stream, bool & enable);
428 
429  void SetSampling(const eSFP sfp, const NTV2Stream stream, const VPIDSampling sampling);
430  VPIDSampling GetSampling(const eSFP sfp, const NTV2Stream stream);
431 
432  void DisableDepacketizerStream (const NTV2Stream stream);
433  void EnableDepacketizerStream (const NTV2Stream stream);
434  void DisableDecapsulatorStream (const eSFP sfp, const NTV2Stream stream);
435  void EnableDecapsulatorStream (const eSFP sfp, const NTV2Stream stream);
436 
437  void SetupDecapsulatorStream (const eSFP sfp, const NTV2Stream stream, const rx_2110Config &rxConfig);
438 
439  void ResetPacketizerStream (const NTV2Stream stream);
440 
441  void SetupDepacketizerStream (const NTV2Stream stream, const rx_2110Config & rxConfig);
442  void ResetDepacketizerStream (const NTV2Stream stream);
443 
444  void SetVideoFormatForRxTx (const NTV2Stream stream, const NTV2VideoFormat format, const bool rx);
445  void GetVideoFormatForRxTx (const NTV2Stream stream, NTV2VideoFormat & format, uint32_t & hwFormat, const bool rx);
446 
447  bool ConfigurePTP (const eSFP sfp, const std::string localIPAddress);
448 
449  bool GenVideoStreamSDP (std::stringstream &sdp, const bool enableSfp1,
450  const bool enableSfp2, const NTV2Stream stream, char *gmInfo);
451  bool GenVideoStreamSDPInfo (std::stringstream & sdp, const eSFP sfp, const NTV2Stream stream, char* gmInfo);
452  bool GenVideoStreamMultiSDPInfo (std::stringstream & sdp, char* gmInfo);
453  bool GenAudioStreamSDP (std::stringstream &sdp, const bool enableSfp1,
454  const bool enableSfp2, const NTV2Stream stream, char *gmInfo);
455  bool GenAudioStreamSDPInfo (std::stringstream & sdp, const eSFP sfp, const NTV2Stream stream, char* gmInfo);
456  bool GenAncStreamSDP (std::stringstream &sdp, const bool enableSfp1,
457  const bool enableSfp2, const NTV2Stream stream, char *gmInfo);
458  bool GenAncStreamSDPInfo (std::stringstream & sdp, const eSFP sfp, const NTV2Stream stream, char* gmInfo);
459 
460  NTV2StreamType StreamType (const NTV2Stream stream);
461  NTV2Channel VideoStreamToChannel (const NTV2Stream stream);
462 
463 private:
464  std::string To_String (int val);
465 
466  std::vector<std::string> split (const char *str, char delim);
467 
468  std::string rateToString (NTV2FrameRate rate);
469  NTV2FrameRate stringToRate (std::string str);
470 
471  int LeastCommonMultiple (int a,int b);
472  int getDescriptionValue (int startLine, std::string type, std::string & value);
473  std::string getVideoDescriptionValue (std::string type);
474 
475  std::stringstream txsdp;
476 
477  uint32_t _numRx0Chans;
478  uint32_t _numRx1Chans;
479  uint32_t _numTx0Chans;
480  uint32_t _numTx1Chans;
481  uint32_t _numRxChans;
482  uint32_t _numTxChans;
483  bool _biDirectionalChannels; // logically bi-directional channels
484 
485  std::vector<std::string> sdpLines;
486  std::vector<std::string> tokens;
487 
488 }; // CNTV2Config2110
489 
490 #endif // NTV2_2110CONFIG_H
NTV2Channel channel
NTV2VideoFormat videoFormat
#define IP_STRSIZE
eNTV2PacketInterval audioPktInterval
VPIDSampling videoSamples
uint32_t numAudioChannels
I interrogate and control an AJA video/audio capture/playout device.
Definition: ntv2card.h:28
uint8_t firstAudioChannel
uint32_t numAudioChannels
uint32_t firstAudioChannel
enum _NTV2VideoFormat NTV2VideoFormat
Identifies a particular video format.
#define NTV2_FOURCC(_a_, _b_, _c_, _d_)
VirtualDataTag2110
bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition: json.hpp:14762
uint32_t payloadType
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They&#39;re also commonly use...
Definition: ntv2enums.h:1357
uint32_t sourcePort
Specifies the source (sender) port number (if RX_MATCH_2110_SOURCE_PORT set)
bool GetBiDirectionalChannels(void)
uint16_t vlan
Specifies the VLAN TCI (if RX_MATCH_2110_VLAN set)
Defines the KonaIP/IoIP S2110 registers.
uint32_t rxMatchOverride
uint32_t rxMatch
Bitmap of rxMatch criteria used.
uint32_t payloadType
NTV2Stream ChToVideoStream(int ch)
uint16_t payloadType
eNTV2PacketInterval
NTV2Channel channel
NTV2FrameRate
Identifies a particular video frame rate.
Definition: ntv2enums.h:412
Enumerations for controlling NTV2 devices.
uint32_t numAudioChannels
eNTV2PacketInterval audioPktInterval
int VideoStreamToCh(NTV2Stream s)
eIGMPVersion_t
NTV2VideoFormat videoFormat
void split(const std::string &str, const char delim, std::vector< std::string > &elems)
Definition: common.cpp:350
NTV2Stream stream
Configures a SMPTE 2110 Receive Channel.
Configures a SMPTE 2110 Transmit Channel.
VPIDSampling
Definition: ntv2enums.h:4088
bool SetIGMPVersion(uint32_t version)
void SetBiDirectionalChannels(const bool bidirectional)
uint8_t numAudioChannels
NTV2Channel channel
bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition: json.hpp:14737
#define AJAExport
Definition: export.h:33
int AncStreamToCh(NTV2Stream s)
bool GetLLDPInfo(std::string &chassisId0, std::string &portId0, std::string &chassisId1, std::string &portId1)
NTV2Stream stream
The CNTV2Config2110 class inquires and configures SMPTE 2110 network I/O for KONA IP and Io IP...
NTV2Stream
Identifies a specific IP-based data stream.
Definition: ntv2enums.h:1407
Declares the CNTV2Card class.
NTV2VideoFormat videoFormat
std::string sourceIP
Specifies the source (sender) IP address (if RX_MATCH_2110_SOURCE_IP set). If it&#39;s in the multiclass ...
NTV2StreamType
Identifies the kind of data that can be carried by an IP-based data stream.
Definition: ntv2enums.h:1433
uint32_t enable
NTV2VideoFormat videoFormat
uint32_t destPort
Specifies the destination (target) port number (if RX_MATCH_2110_DEST_PORT set)
eNTV2PacketInterval audioPktInterval
eNTV2PacketInterval audioPktInterval
bool DisableNetworkInterface(eSFP port)
VPIDSampling sampling
NTV2Stream ChToAudioStream(int ch)
NTV2IpError
Definition: ntv2enums.h:4313
uint16_t payloadType
IpChStatusState
VPIDSampling videoSamples
uint32_t ssrc
Specifies the SSRC identifier (if RX_MATCH_2110_SSRC set)
int AudioStreamToCh(NTV2Stream s)
Declares the CNTV2MBController class.
bool SetLLDPInfo(std::string sysname)
NTV2Stream ChToAncStream(int ch)