AJA NTV2 SDK  17.5.0.1242
NTV2 SDK 17.5.0.1242
ntv2mbcontroller.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
8 #ifndef NTV2MBCONTROLLER_H
9 #define NTV2MBCONTROLLER_H
10 
11 #include "ntv2card.h"
12 #include "ntv2mailbox.h"
13 #include <iostream>
14 #include <vector>
15 
16 enum eMBCmd
17 {
30 };
31 
33 {
36 };
37 
38 enum eSFP
39 {
44 };
45 
46 #define NTV2_IS_VALID_SFP(__sfp__) (((__sfp__) >= SFP_1) && ((__sfp__) < SFP_INVALID))
47 
49 {
54 };
55 
56 typedef enum
57 {
62 
63 typedef struct
64 {
65  uint8_t mac[6];
66 } MACAddr;
67 
68 typedef struct
69 {
70  uint8_t data[64];
71 } SFPMSAData;
72 
73 struct SFPStatus
74 {
75  bool SFP_present; // true indicates SFP plugged in
76  bool SFP_rxLoss; // true indicates loss of signal
77  bool SFP_txFault; // true indicates tx fault
78  bool SFP_linkUp; // true indicates link is up
79 };
80 
81 typedef enum
82 {
89 
90 struct PTPStatus
91 {
92  uint8_t PTP_gmId[8]; // GrandMasterID
93  uint8_t PTP_masterId[8]; // MasterID
94  uint8_t PTP_domain; // domain
95  PTPLockStatus PTP_LockedState; // locked state
96 };
97 
98 
99 // IGMP Control Block
100 #define IGMPCB_REG_STATE 0
101 #define IGMPCB_REG_MCAST_ADDR 1
102 #define IGMPCB_REG_SRC_ADDR 2
103 #define IGMPCB_SIZE 3
104 
105 #define IGMPCB_STATE_USED BIT(0)
106 #define IGMPCB_STATE_ENABLED BIT(1)
107 #define IGMPCB_STATE_BUSY BIT(31) // ignore when busy
108 
109 #define S2022_LINK_A_ACTIVE BIT(31)
110 #define S2022_LINK_B_ACTIVE BIT(30)
111 #define S2022_DUAL_LINK BIT(29)
112 
114 {
115 public:
117 
118  void init();
119 
120  bool operator == ( const IPVNetConfig &other );
121  bool operator != ( const IPVNetConfig &other );
122 
123  uint32_t ipc_ip;
124  uint32_t ipc_subnet;
125  uint32_t ipc_gateway;
126 };
127 
129 {
130 public:
131  CNTV2MBController(CNTV2Card & device);
132 
133 protected:
134  // all these methods block until response received or timeout
135  bool SetMBNetworkConfiguration(eSFP port, std::string ipaddr, std::string netmask,std::string gateway);
136  bool DisableNetworkInterface(eSFP port);
137  bool GetRemoteMAC(std::string remote_IPAddress, eSFP port, NTV2Stream stream, std::string & MACaddress);
138  bool SetIGMPVersion(uint32_t version);
139 
140  void SetIGMPGroup(eSFP port, NTV2Stream stream, uint32_t mcast_addr, uint32_t src_addr, bool enable);
141  void UnsetIGMPGroup(eSFP port, NTV2Stream stream);
142  void EnableIGMPGroup(eSFP port, NTV2Stream stream, bool enable);
143 
144  bool SetTxLinkState(NTV2Channel channel, bool sfp1Enable, bool sfp2Enable);
145  bool GetTxLinkState(NTV2Channel channel, bool & sfp1Enable, bool & sfp2Enable);
146  bool SetRxLinkState(NTV2Channel channel, bool sfp1Enable, bool sfp2Enable);
147  bool GetRxLinkState(NTV2Channel channel, bool & sfp1Enable, bool & sfp2Enable);
148 
149  bool SetDualLinkMode(bool enable);
150  bool GetDualLinkMode(bool & enable);
151 
152  bool SetRxMatch(NTV2Channel channel, eSFP link, uint8_t match);
153  bool GetRxMatch(NTV2Channel channel, eSFP link, uint8_t & match);
154 
155  bool SetSFPActive(eSFP sfp);
156  bool SetSFPInactive(eSFP sfp);
157  bool GetSFPActive(eSFP sfp);
158 
159  bool SetTxFormat(NTV2Channel chan, NTV2VideoFormat fmt);
160  bool GetTxFormat(NTV2Channel chan, NTV2VideoFormat & fmt);
161 
162  uint64_t GetNTPTimestamp();
163  bool PushSDP(std::string filename, std::stringstream & sdpstream);
164  bool GetSDP(std::string url, std::string & sdp);
165 
166  bool GetSFPInfo(eSFP port, SFPMSAData & sfpdata);
167 
168  bool SetLLDPInfo(std::string sysname);
169  bool GetLLDPInfo(std::string &chassisId0, std::string &portId0,
170  std::string &chassisId1, std::string &portId1);
171 
172 
173 private:
174  eArpState GetRemoteMACFromArpTable(std::string remote_IPAddress, eSFP port, NTV2Stream stream, std::string & MACaddress);
175  bool SendArpRequest(std::string remote_IPAddress, eSFP port);
176 
177  void splitResponse(const std::string response, std::vector<std::string> & results);
178  bool getDecimal(const std::string & resp, const std::string & parm, uint32_t & result);
179  bool getHex(const std::string & resp, const std::string & parm, uint32_t &result);
180  bool getString(const std::string & resp, const std::string & parm, std::string & result);
181  uint32_t getIGMPCBOffset(eSFP port, NTV2Stream stream);
182 
183 private:
184 };
185 
186 #endif // NTV2MBCONTROLLER_H
SFPStatus::SFP_rxLoss
bool SFP_rxLoss
Definition: ntv2mbcontroller.h:76
eIGMPVersion_Default
@ eIGMPVersion_Default
Definition: ntv2mbcontroller.h:60
eSFP
eSFP
Definition: ntv2mbcontroller.h:38
IPVNetConfig::ipc_ip
uint32_t ipc_ip
Definition: ntv2mbcontroller.h:123
IPVNetConfig::IPVNetConfig
IPVNetConfig()
Definition: ntv2mbcontroller.h:116
eIGMPVersion_t
eIGMPVersion_t
Definition: ntv2mbcontroller.h:56
PTP_NO_PTP
@ PTP_NO_PTP
Definition: ntv2mbcontroller.h:83
MB_CMD_FETCH_GM_INFO
@ MB_CMD_FETCH_GM_INFO
Definition: ntv2mbcontroller.h:23
NTV2Channel
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They're also commonly use...
Definition: ntv2enums.h:1334
MB_CMD_GET_MAC_FROM_ARP_TABLE
@ MB_CMD_GET_MAC_FROM_ARP_TABLE
Definition: ntv2mbcontroller.h:19
PTPStatus::PTP_domain
uint8_t PTP_domain
Definition: ntv2mbcontroller.h:94
ARP_INCOMPLETE
@ ARP_INCOMPLETE
Definition: ntv2mbcontroller.h:52
MB_CMD_SEND_ARP_REQ
@ MB_CMD_SEND_ARP_REQ
Definition: ntv2mbcontroller.h:20
IPVNetConfig::operator!=
bool operator!=(const IPVNetConfig &other)
Definition: ntv2mbcontroller.cpp:26
MB_CMD_FETCH_SFP_INFO
@ MB_CMD_FETCH_SFP_INFO
Definition: ntv2mbcontroller.h:27
PTPLockStatus
PTPLockStatus
Definition: ntv2mbcontroller.h:81
IPVNetConfig::operator==
bool operator==(const IPVNetConfig &other)
Definition: ntv2mbcontroller.cpp:31
eNTV2PacketInterval
eNTV2PacketInterval
Definition: ntv2mbcontroller.h:32
MB_CMD_SET_IGMP_VERSION
@ MB_CMD_SET_IGMP_VERSION
Definition: ntv2mbcontroller.h:22
MB_CMD_SET_NET
@ MB_CMD_SET_NET
Definition: ntv2mbcontroller.h:18
PTP_NOT_LOCKED
@ PTP_NOT_LOCKED
Definition: ntv2mbcontroller.h:85
eIGMPVersion_3
@ eIGMPVersion_3
Definition: ntv2mbcontroller.h:59
PACKET_INTERVAL_1mS
@ PACKET_INTERVAL_1mS
Definition: ntv2mbcontroller.h:35
SFPStatus::SFP_present
bool SFP_present
Definition: ntv2mbcontroller.h:75
SFP_1
@ SFP_1
Definition: ntv2mbcontroller.h:40
SFPStatus
Definition: ntv2mbcontroller.h:73
PTPStatus::PTP_LockedState
PTPLockStatus PTP_LockedState
Definition: ntv2mbcontroller.h:95
MB_CMD_DISABLE_NET_IF
@ MB_CMD_DISABLE_NET_IF
Definition: ntv2mbcontroller.h:26
ntv2card.h
Declares the CNTV2Card class.
ARP_NOT_FOUND
@ ARP_NOT_FOUND
Definition: ntv2mbcontroller.h:53
ARP_VALID
@ ARP_VALID
Definition: ntv2mbcontroller.h:51
SFPMSAData
Definition: ntv2mbcontroller.h:68
MB_CMD_UNKNOWN
@ MB_CMD_UNKNOWN
Definition: ntv2mbcontroller.h:21
CNTV2Card
I interrogate and control an AJA video/audio capture/playout device.
Definition: ntv2card.h:28
PTP_LOCKED
@ PTP_LOCKED
Definition: ntv2mbcontroller.h:87
ARP_ERROR
@ ARP_ERROR
Definition: ntv2mbcontroller.h:50
ntv2mailbox.h
Declares the CNTV2MailBox class.
NTV2Stream
NTV2Stream
Identifies a specific IP-based data stream.
Definition: ntv2enums.h:1382
PACKET_INTERVAL_125uS
@ PACKET_INTERVAL_125uS
Definition: ntv2mbcontroller.h:34
SFPStatus::SFP_txFault
bool SFP_txFault
Definition: ntv2mbcontroller.h:77
PTPStatus
Definition: ntv2mbcontroller.h:90
SFP_2
@ SFP_2
Definition: ntv2mbcontroller.h:41
CNTV2MBController
Definition: ntv2mbcontroller.h:128
MB_CMD_GET_LLDP_INFO
@ MB_CMD_GET_LLDP_INFO
Definition: ntv2mbcontroller.h:29
IPVNetConfig::ipc_subnet
uint32_t ipc_subnet
Definition: ntv2mbcontroller.h:124
eMBCmd
eMBCmd
Definition: ntv2mbcontroller.h:16
SFPStatus::SFP_linkUp
bool SFP_linkUp
Definition: ntv2mbcontroller.h:78
MACAddr
Definition: ntv2mbcontroller.h:63
IPVNetConfig
Definition: ntv2mbcontroller.h:113
AJAExport
#define AJAExport
Definition: export.h:33
NTV2VideoFormat
enum _NTV2VideoFormat NTV2VideoFormat
Identifies a particular video format.
PTP_ERROR
@ PTP_ERROR
Definition: ntv2mbcontroller.h:84
eArpState
eArpState
Definition: ntv2mbcontroller.h:48
PTP_LOCKING
@ PTP_LOCKING
Definition: ntv2mbcontroller.h:86
IPVNetConfig::init
void init()
Definition: ntv2mbcontroller.cpp:19
SFP_MAX_NUM_SFPS
@ SFP_MAX_NUM_SFPS
Definition: ntv2mbcontroller.h:42
MB_CMD_SET_LLDP_INFO
@ MB_CMD_SET_LLDP_INFO
Definition: ntv2mbcontroller.h:28
SFP_INVALID
@ SFP_INVALID
Definition: ntv2mbcontroller.h:43
PTPStatus::PTP_masterId
uint8_t PTP_masterId[8]
Definition: ntv2mbcontroller.h:93
CNTV2MailBox
Definition: ntv2mailbox.h:42
MB_CMD_TAKE_SDP
@ MB_CMD_TAKE_SDP
Definition: ntv2mbcontroller.h:24
MB_CMD_FETCH_SDP
@ MB_CMD_FETCH_SDP
Definition: ntv2mbcontroller.h:25
IPVNetConfig::ipc_gateway
uint32_t ipc_gateway
Definition: ntv2mbcontroller.h:125
eIGMPVersion_2
@ eIGMPVersion_2
Definition: ntv2mbcontroller.h:58
PTPStatus::PTP_gmId
uint8_t PTP_gmId[8]
Definition: ntv2mbcontroller.h:92