 |
AJA NTV2 SDK
18.0.0.2717
NTV2 SDK 18.0.0.2717
|
Go to the documentation of this file.
18 #if !defined(NTV2_PREVENT_PLUGIN_LOAD)
22 #include "mbedtls/x509.h"
23 #include "mbedtls/error.h"
24 #include "mbedtls/md.h"
25 #include "mbedtls/ssl.h"
26 #endif // defined(NTV2_PREVENT_PLUGIN_LOAD)
28 #include <CoreFoundation/CoreFoundation.h>
30 #define DLL_EXTENSION ".dylib"
31 #define PATH_DELIMITER "/"
32 #define FIRMWARE_FOLDER "Firmware"
33 #elif defined(AJALinux)
35 #define DLL_EXTENSION ".so"
36 #define PATH_DELIMITER "/"
37 #define FIRMWARE_FOLDER "firmware"
38 #elif defined(MSWindows)
39 #define DLL_EXTENSION ".dll"
40 #define PATH_DELIMITER "\\"
41 #define FIRMWARE_FOLDER "Firmware"
42 #elif defined(AJABareMetal)
43 #define DLL_EXTENSION ".so"
44 #define PATH_DELIMITER "/"
45 #define FIRMWARE_FOLDER "firmware"
47 #define SIG_EXTENSION ".sig"
51 #define INSTP(_p_) xHEX0N(uint64_t(_p_),16)
52 #define NBFAIL(__x__) AJA_sERROR (AJA_DebugUnit_RPCClient, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
53 #define NBWARN(__x__) AJA_sWARNING(AJA_DebugUnit_RPCClient, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
54 #define NBNOTE(__x__) AJA_sNOTICE (AJA_DebugUnit_RPCClient, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
55 #define NBINFO(__x__) AJA_sINFO (AJA_DebugUnit_RPCClient, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
56 #define NBDBG(__x__) AJA_sDEBUG (AJA_DebugUnit_RPCClient, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
57 #define NBCFAIL(__x__) AJA_sERROR (AJA_DebugUnit_RPCClient, AJAFUNC << ": " << __x__)
58 #define NBCWARN(__x__) AJA_sWARNING(AJA_DebugUnit_RPCClient, AJAFUNC << ": " << __x__)
59 #define NBCNOTE(__x__) AJA_sNOTICE (AJA_DebugUnit_RPCClient, AJAFUNC << ": " << __x__)
60 #define NBCINFO(__x__) AJA_sINFO (AJA_DebugUnit_RPCClient, AJAFUNC << ": " << __x__)
61 #define NBCDBG(__x__) AJA_sDEBUG (AJA_DebugUnit_RPCClient, AJAFUNC << ": " << __x__)
62 #define NBSFAIL(__x__) AJA_sERROR (AJA_DebugUnit_RPCServer, AJAFUNC << ": " << __x__)
63 #define NBSWARN(__x__) AJA_sWARNING(AJA_DebugUnit_RPCServer, AJAFUNC << ": " << __x__)
64 #define NBSNOTE(__x__) AJA_sNOTICE (AJA_DebugUnit_RPCServer, AJAFUNC << ": " << __x__)
65 #define NBSINFO(__x__) AJA_sINFO (AJA_DebugUnit_RPCServer, AJAFUNC << ": " << __x__)
66 #define NBSDBG(__x__) AJA_sDEBUG (AJA_DebugUnit_RPCServer, AJAFUNC << ": " << __x__)
68 #define PLGFAIL(__x__) AJA_sERROR (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
69 #define PLGWARN(__x__) AJA_sWARNING(AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
70 #define PLGNOTE(__x__) AJA_sNOTICE (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
71 #define PLGINFO(__x__) AJA_sINFO (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
72 #define PLGDBG(__x__) AJA_sDEBUG (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
74 #define P_FAIL(__x__) do \
77 _os_ << AJAFUNC << ": " << __x__; \
79 cout << "## ERROR: " << _os_.str() << endl; \
80 AJA_sERROR (AJA_DebugUnit_Plugins, _os_.str()); \
81 errMsg = _os_.str(); \
83 #define P_WARN(__x__) if (useStdout()) cout << "## WARNING: " << AJAFUNC << ": " << __x__ << endl; \
84 AJA_sWARNING(AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
85 #define P_NOTE(__x__) if (useStdout()) cout << "## NOTE: " << AJAFUNC << ": " << __x__ << endl; \
86 AJA_sNOTICE (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
87 #define P_INFO(__x__) if (useStdout()) cout << "## INFO: " << AJAFUNC << ": " << __x__ << endl; \
88 AJA_sINFO (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
89 #define P_DBG(__x__) if (useStdout()) cout << "## DEBUG: " << AJAFUNC << ": " << __x__ << endl; \
90 AJA_sDEBUG (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
92 #if defined(_DEBUGSTATS_)
93 #define PDBGX(__x__) AJA_sDEBUG (AJA_DebugUnit_Plugins, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
115 if (it == mDict.end())
122 string str(valueForKey(inKey));
125 if (str.find(
"0x") == 0 || str.find(
"0X") == 0)
132 if (str.find(
"x") == 0 || str.find(
"X") == 0)
139 if (str.find(
"o") == 0 || str.find(
"O") == 0)
146 if (str.find(
"b") == 0 || str.find(
"B") == 0)
161 const string & key(it->first), val(it->second), quote(val.find(
' ') != string::npos ?
"'" :
"");
162 oss << key <<
"=" << quote << val << quote;
163 if (++it != mDict.end())
170 const int kyWdth(
int(largestKeySize()+0)), valWdth(
int(largestValueSize()+0));
171 oss << string(
size_t(kyWdth),
'-') <<
" " << string(
size_t(valWdth),
'-') << endl;
174 const string & key(it->first), val(it->second);
175 oss << std::setw(kyWdth) << key <<
" : " << val;
176 if (++it != mDict.end())
185 size_t badKVPairs(0), insertFailures(0);
191 if (keyValPair.size() != 2)
192 {badKVPairs++;
continue;}
193 const string k(keyValPair.at(0)), v(keyValPair.at(1));
197 return !empty() && !badKVPairs && !insertFailures;
206 oss << it->first <<
"\t" << it->second;
207 if (++it != mDict.end())
211 return !outStr.empty();
217 for (
DictConstIter it(mDict.begin()); it != mDict.end(); ++it)
218 result.insert(it->first);
225 for (
DictConstIter it(mDict.begin()); it != mDict.end(); ++it)
226 if (it->first.length() > result)
227 result = it->first.length();
234 for (
DictConstIter it(mDict.begin()); it != mDict.end(); ++it)
235 if (it->second.length() > result)
236 result = it->second.length();
244 if (inKey.find(
"\t") != string::npos)
246 if (inKey.find(
"\n") != string::npos)
248 if (inValue.find(
"\t") != string::npos)
250 if (inValue.find(
"\n") != string::npos)
252 mDict[inKey] = inValue;
258 size_t numUpdated(0);
259 for (
DictConstIter it(inDict.mDict.begin()); it != inDict.mDict.end(); ++it)
260 if (hasKey(it->first))
261 {mDict[it->first] = it->second; numUpdated++;}
268 for (
DictConstIter it(inDict.mDict.begin()); it != inDict.mDict.end(); ++it)
269 if (!hasKey(it->first))
270 {mDict[it->first] = it->second; numAdded++;}
284 mQueryParams.clear();
296 if (!inStripLeadSlash)
298 if (rsrc.at(0) ==
'/')
303 void NTV2DeviceSpecParser::Parse (
void)
312 string tokDevID, tokIndexNum, tokScheme, tokSerial, tokModelName, tokIPV4, tokPortNum;
313 size_t posDevID(0), posIndexNum(0), posScheme(0), posSerial(0), posModelName(0), posNetAddr(0);
314 bool isSerial(ParseSerialNum(posSerial, tokSerial)), isScheme(ParseScheme(posScheme, tokScheme));
315 bool isIndexNum(ParseDecNumber(posIndexNum, tokIndexNum)), isDeviceID(ParseDeviceID(posDevID, tokDevID));
316 bool isModelName(ParseModelName(posModelName, tokModelName));
317 bool isIPV4Port(ParseHostAddressAndPortNumber(posNetAddr, tokIPV4, tokPortNum));
320 posDevID = posIndexNum = posSerial = posModelName = posScheme;
321 isSerial = ParseSerialNum(posSerial, tokSerial);
322 isIndexNum = ParseDecNumber(posIndexNum, tokIndexNum);
323 isDeviceID = ParseDeviceID(posDevID, tokDevID);
324 isModelName = ParseModelName(posModelName, tokModelName);
337 bool converted(
false);
339 if (tokSerial.length() == 18)
342 const bool hasLeading0X (tokSerial.find(
"0X") == 0 || tokSerial.find(
"0x") == 0);
343 const string hex64(tokSerial.substr(hasLeading0X ? 2 : 0, 16));
346 for (
size_t ndx(0); ndx < 8; ndx++)
347 serTxt +=
char(serNum64 >> ((7-ndx)*8));
353 for (
size_t ndx(0); ndx < tokSerial.length(); ndx++)
354 {
char ch(tokSerial.at(ndx));
355 if ( ! ( ( (ch >=
'0') && (ch <=
'9') ) ||
356 ( (ch >=
'A') && (ch <=
'Z') ) ||
357 ( (ch >=
'a') && (ch <=
'z') ) ||
358 (ch ==
' ') || (ch ==
'-') ) )
360 err <<
"Illegal serial number character '" << (ch ? ch :
'?') <<
"' (" <<
xHEX0N(
UWord(ch),2) <<
")";
362 mPos -= converted ? 16 : 8; mPos += ndx * (converted ? 2 : 1) + (converted ? 1 : 0);
379 if (posIndexNum < SpecLength())
381 if (isIPV4Port && !tokIPV4.empty())
386 if (!tokPortNum.empty())
390 err <<
"Extra characters past index number";
401 err <<
"Invalid local device specification";
403 mPos += isScheme ? 12 : 0;
414 size_t posURL(posScheme), posRsrc(0);
415 string host, port, rsrcPath;
416 if (!ParseHostAddressAndPortNumber(posURL, host, port))
417 {mPos = posURL; AddError(
"Bad host address or port number");
break;}
426 if (ParseResourcePath(posRsrc, rsrcPath))
429 size_t posQuery(mPos);
431 if (ParseQuery(posQuery, params))
434 mQueryParams = params;
439 if (mPos < SpecLength())
440 {err <<
"Parser failed at character position " <<
DEC(mPos); AddError(err.str());}
444 { oss <<
"NTV2DeviceSpecParser::Parse success: '" << DeviceSpec() <<
"' -- ";
449 { oss <<
"NTV2DeviceSpecParser::Parse failed: ";
453 #endif // defined(_DEBUG)
459 oss <<
"local device";
460 else if (HasScheme())
461 oss <<
"device '" << Scheme() <<
"'";
465 oss <<
" serial '" << DeviceSerial() <<
"'";
467 oss <<
" model '" << DeviceModel() <<
"'";
469 oss <<
" ID '" << DeviceID() <<
"'";
471 oss <<
" " << DeviceIndex();
481 {oss << endl; Results().Print(oss,
false);}
489 ostringstream result;
492 result <<
"ntv2local://";
494 result << DeviceSerial();
496 result << DeviceModel();
498 result << DeviceID();
500 result << DeviceIndex();
505 result << Scheme() <<
"://";
511 if (HasQueryParams())
513 string q (MakeQueryString(urlEncodeQuery));
524 if (!HasQueryParams())
531 string k(*it), v(mQueryParams.valueForKey(k));
535 oss << k <<
"=" << v;
536 parms.push_back(oss.str());
551 if (devIDStr.find(
"0X") != string::npos)
566 oss <<
DEC(ErrorCount()) << (ErrorCount() == 1 ?
" error" :
" errors") << (HasErrors() ?
":" :
"");
570 << DeviceSpec() << endl
571 << string(mPos ? mPos : 0,
' ') <<
"^" << endl;
572 for (
size_t num(0); num < ErrorCount(); )
575 if (++num < ErrorCount())
582 bool NTV2DeviceSpecParser::ParseHexNumber (
size_t & pos,
string & outToken)
586 while (pos < SpecLength())
588 const char ch(CharAt(pos));
589 if (tokHexNum.length() == 0)
593 ++pos; tokHexNum = ch;
595 else if (tokHexNum.length() == 1)
597 if (ch !=
'x' && ch !=
'X')
599 ++pos; tokHexNum += ch;
605 ++pos; tokHexNum += ch;
608 if (tokHexNum.length() > 2)
609 {
aja::upper(tokHexNum); outToken = tokHexNum;}
610 return !outToken.empty();
613 bool NTV2DeviceSpecParser::ParseDecNumber (
size_t & pos,
string & outToken)
617 while (pos < SpecLength())
619 const char ch(CharAt(pos));
620 if (!IsDecimalDigit(ch))
623 if (ch !=
'0' || tokDecNum !=
"0")
626 if (tokDecNum.length() > 0)
627 outToken = tokDecNum;
628 return !outToken.empty();
631 bool NTV2DeviceSpecParser::ParseAlphaNum (
size_t & pos,
string & outToken,
const std::string & inOtherChars)
635 while (pos < SpecLength())
637 const char ch(CharAt(pos));
638 if (!IsLetter(ch) && !IsDecimalDigit(ch) && inOtherChars.find(ch) == string::npos)
640 if (tokAlphaNum.empty() && !IsLetter(ch))
642 ++pos; tokAlphaNum += ch;
644 if (tokAlphaNum.length() > 0)
645 outToken = tokAlphaNum;
646 return !outToken.empty();
649 bool NTV2DeviceSpecParser::ParseAlphaNumeric (
size_t & pos,
string & outToken,
const std::string & inOtherChars)
653 while (pos < SpecLength())
655 const char ch(CharAt(pos));
656 if (!IsLetter(ch) && !IsDecimalDigit(ch) && inOtherChars.find(ch) == string::npos)
658 ++pos; tokAlphaNum += ch;
660 if (tokAlphaNum.length() > 0)
661 outToken = tokAlphaNum;
662 return !outToken.empty();
665 bool NTV2DeviceSpecParser::ParseScheme (
size_t & pos,
string & outToken)
668 string rawScheme, tokScheme;
669 while (ParseAlphaNum(pos, rawScheme))
671 tokScheme = rawScheme;
672 char ch(CharAt(pos));
675 ++pos; tokScheme += ch;
680 ++pos; tokScheme += ch;
685 ++pos; tokScheme += ch;
688 if (tokScheme.find(
"://") != string::npos)
689 {
aja::lower(rawScheme); outToken = rawScheme;}
690 return !outToken.empty();
693 bool NTV2DeviceSpecParser::ParseSerialNum (
size_t & pos,
string & outToken)
696 string tokAlphaNum, tokHexNum;
697 size_t origPos(pos), posAlphaNum(pos), posHexNum(pos);
700 while (posAlphaNum < SpecLength())
702 const char ch(CharAt(posAlphaNum));
703 if (!IsUpperLetter(ch) && !IsLowerLetter(ch) && !IsDecimalDigit(ch) && ch !=
'-' && ch !=
' ')
705 ++posAlphaNum; tokAlphaNum += ch;
707 if (tokAlphaNum.length() < 2)
709 else if (tokAlphaNum.length() == 8 || tokAlphaNum.length() == 9)
710 {pos = posAlphaNum; outToken = tokAlphaNum;
break;}
712 if (ParseHexNumber(posHexNum, tokHexNum))
713 if (tokHexNum.length() == 18)
714 {pos = posHexNum; outToken = tokHexNum;}
716 if (tokAlphaNum ==
"ntv2kona1")
717 {outToken.clear(); pos = origPos;
return false;}
718 return !outToken.empty();
721 bool NTV2DeviceSpecParser::ParseDeviceID (
size_t & pos,
string & outToken)
725 if (!ParseHexNumber(pos, tokHexNum))
727 if (tokHexNum.length() != 10)
736 ostringstream devID; devID <<
xHEX0N(*it,8);
737 string devIDStr(devID.str());
739 devIDStrs.insert(devIDStr);
741 if (devIDStrs.find(tokHexNum) != devIDStrs.end())
742 outToken = tokHexNum;
743 return !outToken.empty();
746 bool NTV2DeviceSpecParser::ParseModelName (
size_t & pos,
string & outToken)
750 if (!ParseAlphaNum(pos, tokName,
" "))
761 modelNames.insert(modelName);
763 if (modelNames.find(tokName) != modelNames.end())
765 return !outToken.empty();
768 bool NTV2DeviceSpecParser::ParseDNSName (
size_t & pos,
string & outDNSName)
771 string dnsName, name;
774 while (ParseAlphaNum(dnsPos, name,
"_-"))
776 if (!dnsName.empty())
784 if (!dnsName.empty())
786 outDNSName = dnsName;
787 return !outDNSName.empty();
790 bool NTV2DeviceSpecParser::ParseIPv4Address (
size_t & pos,
string & outIPv4)
797 while (ParseDecNumber(ipv4Pos, num))
799 ipv4Name.push_back(num);
800 ch = CharAt(ipv4Pos);
805 if (ipv4Name.size() == 4)
808 return ipv4Name.size() == 4;
811 bool NTV2DeviceSpecParser::ParseHostAddressAndPortNumber (
size_t & pos,
string & outAddr,
string & outPort)
813 outAddr.clear(); outPort.clear();
815 string dnsName, ipv4, port;
816 size_t dnsPos(pos), ipv4Pos(pos), portPos(0);
817 bool isDNS(ParseDNSName(dnsPos, dnsName)), isIPv4(ParseIPv4Address(ipv4Pos, ipv4));
818 if (!isDNS && !isIPv4)
819 {pos = dnsPos < ipv4Pos ? ipv4Pos : dnsPos;
return false;}
822 {outAddr = ipv4; pos = portPos = ipv4Pos;}
824 {outAddr = dnsName; pos = portPos = dnsPos;}
827 char ch (CharAt(portPos));
831 if (!ParseDecNumber(portPos, port))
832 {pos = portPos;
return false;}
838 bool NTV2DeviceSpecParser::ParseResourcePath (
size_t & pos,
string & outRsrc)
843 char ch(CharAt(rsrcPos));
848 if (!ParseAlphaNumeric(rsrcPos, name,
" "))
851 ch = CharAt(rsrcPos);
856 return !outRsrc.empty();
859 bool NTV2DeviceSpecParser::ParseParamAssignment (
size_t & pos,
string & outKey,
string & outValue)
861 outKey.clear(); outValue.clear();
863 size_t paramPos(pos);
864 char ch(CharAt(paramPos));
866 ch = CharAt(++paramPos);
869 if (!ParseAlphaNumeric(paramPos, key))
871 ch = CharAt(paramPos);
874 ch = CharAt(++paramPos);
875 while (ch != 0 && ch !=
'&')
878 ch = CharAt(++paramPos);
882 {pos = paramPos; outKey =
key; outValue =
value;}
886 bool NTV2DeviceSpecParser::ParseQuery (
size_t & pos,
NTV2Dictionary & outParams)
890 size_t queryPos(pos);
891 char ch(CharAt(queryPos));
896 while (ParseParamAssignment(queryPos, key, value))
898 outParams.
insert(key, value);
899 ch = CharAt(queryPos);
903 if (!outParams.empty())
905 return !outParams.empty();
908 bool NTV2DeviceSpecParser::IsUpperLetter (
const char inChar)
909 {
static const string sHexDigits(
"_ABCDEFGHIJKLMNOPQRSTUVWXYZ");
910 return sHexDigits.find(inChar) != string::npos;
913 bool NTV2DeviceSpecParser::IsLowerLetter (
const char inChar)
914 {
static const string sHexDigits(
"abcdefghijklmnopqrstuvwxyz");
915 return sHexDigits.find(inChar) != string::npos;
918 bool NTV2DeviceSpecParser::IsLetter (
const char inChar,
const bool inIncludeUnderscore)
919 {
return (inIncludeUnderscore && inChar ==
'_') || IsUpperLetter(inChar) || IsLowerLetter(inChar);
922 bool NTV2DeviceSpecParser::IsDecimalDigit (
const char inChar)
923 {
static const string sDecDigits(
"0123456789");
924 return sDecDigits.find(inChar) != string::npos;
927 bool NTV2DeviceSpecParser::IsHexDigit (
const char inChar)
928 {
static const string sHexDigits(
"0123456789ABCDEFabcdef");
929 return sHexDigits.find(inChar) != string::npos;
932 bool NTV2DeviceSpecParser::IsLegalSerialNumChar (
const char inChar)
933 {
return IsLetter(inChar) || IsDecimalDigit(inChar);
937 void NTV2DeviceSpecParser::test (
void)
940 specParser.
Reset(
"1");
941 specParser.
Reset(
"00000000000000000000000000000000000000000000000000000000000000000000000000000000000001");
942 specParser.
Reset(
"corvid24");
943 specParser.
Reset(
"corvid88");
944 specParser.
Reset(
"konalhi");
945 specParser.
Reset(
"alpha");
946 specParser.
Reset(
"00T64450");
947 specParser.
Reset(
"00t6-450");
948 specParser.
Reset(
"BLATZBE0");
949 specParser.
Reset(
"0x424C41545A424530");
950 specParser.
Reset(
"0x424C415425424530");
952 specParser.
Reset(
"badscheme://1");
954 specParser.
Reset(
"ntv2local://1");
955 specParser.
Reset(
"NtV2lOcAl://00000000000000000000000000000000000000000000000000000000000000000000000000000000000001");
956 specParser.
Reset(
"NTV2Local://corvid24");
957 specParser.
Reset(
"ntv2local://corvid88");
958 specParser.
Reset(
"ntv2local://konalhi");
959 specParser.
Reset(
"ntv2local://alpha");
960 specParser.
Reset(
"ntv2local://00T64450");
961 specParser.
Reset(
"ntv2local://00t6-450");
962 specParser.
Reset(
"ntv2local://BLATZBE0");
964 specParser.
Reset(
"ntv2nub://1.2.3.4");
965 specParser.
Reset(
"ntv2nub://1.2.3.4/doc");
966 specParser.
Reset(
"ntv2nub://1.2.3.4/doc/");
967 specParser.
Reset(
"ntv2nub://1.2.3.4/doc/alpha?one&two=2&three=&four=4");
968 specParser.
Reset(
"ntv2nub://1.2.3.4/doc/?one&two=2&three=&four=4");
969 specParser.
Reset(
"ntv2nub://1.2.3.4:badport/doc?one&two=2&three=&four=4");
970 specParser.
Reset(
"ntv2nub://1.2.3.4:200/doc?one&two=2&three=&four=4");
971 specParser.
Reset(
"ntv2nub://1.2.3.4:200/doc/?one&two=2&three=&four=4");
972 specParser.
Reset(
"ntv2nub://1.2.3.4:12345");
973 specParser.
Reset(
"ntv2nub://1.2.3.4:65000/doc");
974 specParser.
Reset(
"ntv2nub://1.2.3.4:32767/doc/");
975 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc/");
976 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc/?");
977 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc?");
978 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc/?one");
979 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc?one");
980 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc/?one=");
981 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc?one=");
982 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc/?one=1");
983 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc?one=1");
984 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc/?one=1&two");
985 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc?one=1&two");
986 specParser.
Reset(
"ntv2nub://50.200.250.300");
987 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.com/path/to/doc/?one=1&two");
988 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.edu:badport/path/to/doc/?one=1&two");
989 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.info:5544/path/to/doc/?one=1&two");
990 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.org/path/to/doc/?one=1&two");
991 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.nz:badport/path/to/doc/?one=1&two");
992 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.au:000004/path/to/doc/?one=1&two");
993 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.ch:4/corvid88");
994 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.cn:4/00T64450");
995 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.ru:4/2");
996 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.co.uk:4/00000000000000000000000000000001");
997 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.com:4/0000000000000000000000000000000001");
998 specParser.
Reset(
"ntv2://swdevice/?"
1000 "&supportlog=file%3A%2F%2F%2FUsers%2Fdemo%2FDesktop%2FAJAWatcherSupport.log"
1001 "&sdram=file%3A%2F%2F%2FUsers%2Fdemo%2FDesktop%2FSDRAMsnapshot.dat");
1003 #endif // defined(_DEBUG)
1005 #if defined(MSWindows)
1006 static string WinErrStr (
const DWORD inErr)
1008 string result(
"foo");
1010 const DWORD res(FormatMessage ( FORMAT_MESSAGE_ALLOCATE_BUFFER
1011 | FORMAT_MESSAGE_FROM_SYSTEM
1012 | FORMAT_MESSAGE_IGNORE_INSERTS,
1015 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
1021 result =
reinterpret_cast<const char *
>(lpMsgBuf);
1022 LocalFree(lpMsgBuf);
1029 #if !defined(NTV2_PREVENT_PLUGIN_LOAD)
1042 static bool LoadPlugin (
const string & path,
const string & folderPath,
NTV2PluginPtr & outPtr,
string & outErrMsg,
const bool inUseStdout);
1045 #if defined(MSWindows)
1046 NTV2Plugin (HMODULE handle,
const string & path,
const bool useStdout);
1047 inline operator HMODULE()
const {
return mHandle;}
1049 NTV2Plugin (
void * handle,
const string & path,
const bool useStdout);
1050 inline operator void*()
const {
return mHandle;}
1053 inline bool isLoaded (
void)
const {
return mHandle && !mPath.empty() ?
true :
false;}
1054 void * addressForSymbol (
const string & inSymbol,
string & outErrorMsg);
1060 inline bool useStdout(
void) {
return mUseStdout;}
1062 #if defined(MSWindows)
1074 ostringstream loadErr;
1075 #if defined(AJABareMetal)
1077 #elif defined(MSWindows)
1079 std::wstring dllsFolderW;
1081 if (!AddDllDirectory(dllsFolderW.c_str()))
1083 loadErr <<
"AddDllDirectory '" << path <<
"' failed: " << WinErrStr(::GetLastError());
1086 HMODULE h = ::LoadLibraryExA(LPCSTR(path.c_str()),
AJA_NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
1088 loadErr <<
"Unable to open '" << path <<
"': " << WinErrStr(::GetLastError());
1089 #else // MacOS or Linux
1091 void * h = ::dlopen(path.c_str(), RTLD_LAZY);
1094 const char * pErrorStr(::dlerror());
1095 const string errStr (pErrorStr ? pErrorStr :
"");
1096 loadErr <<
"Unable to open '" << path <<
"': " << errStr;
1098 #endif // MacOS or Linux
1099 if (!loadErr.str().empty())
1100 outErrMsg = loadErr.str();
1103 outPtr =
new NTV2Plugin(h, path, inUseStdout);
1107 NTV2Plugin::NTV2Plugin()
1125 #if defined(MSWindows)
1136 P_NOTE(
"Dynamic/shared library '" << mPath <<
"' (" <<
INSTP(mHandle) <<
") loaded, "
1143 #if defined(AJABareMetal)
1145 #elif !defined(MSWindows)
1147 #else // macOS or Linux
1148 ::FreeLibrary(mHandle);
1151 P_NOTE(
"Dynamic/shared library '" << mPath <<
"' (" <<
INSTP(mHandle) <<
") unloaded, "
1159 outErrorMsg.clear();
1162 if (inSymbolName.empty())
1166 #if defined(AJABareMetal)
1168 #elif defined(MSWindows)
1169 result =
reinterpret_cast<void*
>(::GetProcAddress(
reinterpret_cast<HMODULE
>(mHandle), inSymbolName.c_str()));
1171 err <<
"'GetProcAddress' failed for '" << inSymbolName <<
"': " << WinErrStr(::GetLastError());
1172 #else // MacOS or Linux
1173 result = ::dlsym(mHandle, inSymbolName.c_str());
1175 {
const char * pErrorStr(::dlerror());
1176 const string errStr (pErrorStr ? pErrorStr :
"");
1177 err <<
"'dlsym' failed for '" << inSymbolName <<
"': " << errStr;
1179 #endif // MacOS or Linux
1180 outErrorMsg = err.str();
1199 static void Terminate (
void);
1200 static inline void EnableDebugging (
const bool inEnable =
true) {sDebugRegistry = inEnable;}
1206 bool loadPlugin (
const string & path,
const string & folderPath,
NTV2PluginPtr & outPtr,
string & errMsg,
const bool useStdout);
1207 bool unloadPlugin (
const string & path,
string & errMsg);
1208 bool pluginIsLoaded (
const string & path);
1209 bool pluginForPath (
const string & path,
NTV2PluginPtr & outHandle);
1212 bool hasPath (
const string & path);
1213 bool indexForPath (
const string & path,
size_t & outIndex);
1214 ULWord countForPath (
const string & path);
1215 uint32_t * refConForPath (
const string & path);
1216 inline bool useStdout (
void)
const {
return DebuggingEnabled();}
1219 typedef map<string, NTV2PluginPtr> NTV2PluginMap;
1223 NTV2PluginMap mPluginMap;
1228 static void Monitor (
AJAThread * pThread,
void * pContext);
1229 void monitor (
void);
1232 static bool sDebugRegistry;
1236 AJALock PluginRegistry::sMutex;
1237 bool PluginRegistry::sDebugRegistry(
false);
1254 void PluginRegistry::Monitor (
AJAThread * pThread,
void * pContext)
1262 : mQuitMonitor(
false)
1264 P_NOTE (
"PluginRegistry " <<
INSTP(
this) <<
" constructed");
1265 mPluginCounts.reserve(256);
1266 for (
size_t num(0); num < 256; num++)
1267 mPluginCounts.push_back(0);
1268 mCompareCounts = mPluginCounts;
1269 mMonitor.
Attach(Monitor,
this);
1276 mQuitMonitor =
true;
1277 while (mMonitor.
Active())
1287 {
P_FAIL(
"empty path");
return false;}
1294 {
P_WARN(
INSTP(
this) <<
": '" << path <<
"': 'pluginForPath' returned false, but 'hasPath' returned true, count=" <<
countForPath(path));}
1297 {
P_FAIL(msg);
return false;}
1298 P_NOTE(
INSTP(
this) <<
": Dynamic/shared library '" << path <<
"' loaded");
1299 mPluginMap[path] = outPtr;
1300 mPluginPaths.push_back(path);
1301 mPluginCounts.at(mPluginPaths.size()-1) = 0;
1312 {
P_FAIL(
INSTP(
this) <<
": '" << path <<
"' requested to unload, but not loaded");
return false;}
1313 mPluginMap.erase(path);
1314 P_NOTE(
INSTP(
this) <<
": '" << path <<
"' unloaded");
1321 return mPluginMap.find(path) != mPluginMap.end();
1327 NTV2PluginMap::const_iterator it(mPluginMap.find(path));
1328 if (it == mPluginMap.end())
1331 outHandle = it->second;
1339 for (NTV2PluginMap::const_iterator it(mPluginMap.begin()); it != mPluginMap.end(); ++it)
1340 result.push_back(it->first);
1348 for (
size_t ndx(0); ndx < mPluginPaths.size(); ndx++)
1350 const string path (mPluginPaths.at(ndx));
1354 oss <<
"\t" << (p->
isLoaded() ?
"loaded" :
"unloaded");
1356 oss <<
"\t" <<
"---";
1357 result.push_back(oss.str());
1371 for (outIndex = 0; outIndex < mPluginPaths.size(); outIndex++)
1372 if (path == mPluginPaths.at(outIndex))
1382 return &mPluginCounts[ndx];
1390 return mPluginCounts.at(ndx);
1394 void PluginRegistry::monitor (
void)
1396 P_NOTE(
"PluginRegistry " <<
INSTP(
this) <<
" monitor started");
1397 ostringstream oss; oss <<
"PluginReg" <<
HEX0N(uint32_t(uint64_t(
this)),8);
1399 while (!mQuitMonitor)
1403 for (
size_t ndx(0); ndx < mPluginPaths.size(); ndx++)
1405 const uint32_t oldCount(mCompareCounts.at(ndx)), newCount(mPluginCounts.at(ndx));
1406 if (newCount != oldCount)
1408 string errMsg, path(mPluginPaths.at(ndx));
1409 if (newCount > oldCount)
1410 {
P_NOTE(
"PluginRegistry " <<
INSTP(
this) <<
": Plugin '" << path <<
"' utilization "
1411 <<
"increased from " <<
DEC(oldCount) <<
" to " <<
DEC(newCount));}
1414 P_NOTE(
"PluginRegistry " <<
INSTP(
this) <<
": Plugin '" << path <<
"' utilization "
1415 <<
"decreased from " <<
DEC(oldCount) <<
" to " <<
DEC(newCount));
1419 mCompareCounts.at(ndx) = newCount;
1425 P_NOTE(
"PluginRegistry " <<
INSTP(
this) <<
" monitor stopped");
1443 void *
refCon (
void)
const;
1447 void *
getSymbolAddress (
const string & inSymbolName,
string & outErrorMsg);
1450 inline bool isOpen (
void) {
return mpPlugin ? mpPlugin->
isLoaded() :
false;}
1461 mutable string errMsg;
1466 static string mbedErrStr (
const int mbedtlsReturnCode);
1494 { cout <<
"## NOTE: Original params for '" <<
pluginPath() <<
"':" << endl;
1495 originalParams.
Print(cout,
false) << endl;
1500 { cout <<
"## NOTE: Final params for '" <<
pluginPath() <<
"':" << endl;
1501 mDict.
Print(cout,
false) << endl;
1517 mbedtls_strerror (mbedtlsReturnCode, errBuff, errBuff);
1529 for (
size_t lineNdx(0); lineNdx < lines.size(); lineNdx++)
1531 string line (lines.at(lineNdx));
1532 const bool indented (line.empty() ?
false : line.at(0) ==
' ');
1537 if (keyValPair.size() != 2)
1539 if (keyValPair.size() == 1)
1541 keyPrefix = keyValPair.at(0);
1546 PLGFAIL(
"cert info line " <<
DEC(lineNdx+1) <<
" '" << line <<
"' has "
1547 <<
DEC(keyValPair.size()) <<
" column(s) -- expected 2");
1550 string key(keyValPair.at(0)), val(keyValPair.at(1));
1552 {
PLGFAIL(
"cert info line " <<
DEC(lineNdx+1) <<
" '" << line <<
"' empty key for value '" << val <<
"'");
continue;}
1553 if (indented && !keyPrefix.empty())
1554 {
aja::strip(key); key = keyPrefix +
": " + key;}
1557 if (outInfo.hasKey(key))
1572 for (
size_t ndx(0); ndx < pairs.size(); ndx++)
1574 string assignment (pairs.at(ndx));
1575 if (assignment.find(
'=') == string::npos)
1577 if (!lastKey.empty())
1583 if (pieces.size() != 2)
1584 {
PLGFAIL(
"'" << inParentKey <<
"' assignment '" << assignment <<
"' has " << pieces.size() <<
" component(s) -- expected 2");
continue;}
1585 lastKey = pieces.at(0);
1586 string val(pieces.at(1));
1598 if (!queryStr.empty())
1599 if (queryStr[0] ==
'?')
1600 queryStr.erase(0,1);
1601 PLGDBG(
"Query: '" << queryStr <<
"'");
1605 string str(*it), key, value;
1606 if (str.find(
"=") == string::npos)
1609 outQueryParams.
insert(key, value);
1610 PLGDBG(
"'" << key <<
"' = ''");
1617 if (pieces.size() > 1)
1618 value = pieces.at(1);
1620 {
PLGWARN(
"Empty key '" << key <<
"'");
continue;}
1621 if (outQueryParams.hasKey(key))
1622 PLGDBG(
"Param '" << key <<
"' value '" << outQueryParams.
valueForKey(key) <<
"' to be replaced with '" << value <<
"'");
1631 outErrorMsg.clear();
1649 if (outPath.empty())
1651 PLGDBG(
"AJA plugin path is '" << outPath <<
"'");
1653 return !outPath.empty();
1663 {
P_FAIL(
"Missing scheme -- params: " << mDict);
return false;}
1667 return !outName.empty();
1688 const size_t maxBufSize = 512*1024*1024;
1691 dllF.open(
pluginPath(), std::ios::in | std::ios::binary);
1696 ifstream::pos_type curOffset(dllF.tellg());
1697 if (
int(curOffset) == -1)
1699 size_t size = size_t(curOffset);
1702 if (size > maxBufSize)
1703 {
P_FAIL(
"EOF not reached in plugin file '" <<
pluginPath() <<
"' -- over 500MB in size?");
return fail();}
1707 if (!dllF.seekg(0, ios_base::beg))
1708 {
P_FAIL(
"Could not seek back to start of plugin file '" <<
pluginPath() <<
"'");
return fail();}
1710 {
P_FAIL(
"EOF not reached in plugin file '" <<
pluginPath() <<
"' -- over 500MB in size?");
return fail();}
1711 tmp.
Truncate(
size_t(dllF.gcount()));
1715 ifstream sigF(
pluginSigPath().c_str(), std::ios::in | std::ios::binary);
1719 {
P_FAIL(
"EOF not reached in signature file '" <<
pluginSigPath() <<
"' -- over 500MB in size?");
return fail();}
1720 tmp.
Truncate(
size_t(sigF.gcount()));
1731 NTV2Buffer checksumFromSigFile, x509CertFromSigFile, signature;
1742 mbedtls_x509_crt crt;
1743 mbedtls_x509_crt_init(&crt);
1744 int ret = mbedtls_x509_crt_parse(&crt, x509CertFromSigFile, x509CertFromSigFile);
1747 mbedtls_x509_crt_free(&crt);
1755 int msgLength (mbedtls_x509_crt_info (msgBuff, msgBuff,
"", &crt));
1756 string msg (msgBuff,
size_t(msgLength));
1758 {
P_FAIL(
"'mbedtls_x509_crt_info' returned no info for X509 cert found in '" <<
pluginSigPath() <<
"'");
1762 cout <<
"## DEBUG: Raw X509 certificate info extracted from signature file '" <<
pluginSigPath() <<
"':" << endl
1763 <<
" " << msg << endl;
1767 { cout <<
"## NOTE: X509 certificate info extracted from signature file '" <<
pluginSigPath() <<
"':" << endl;
1768 certInfo.
Print(cout,
false) << endl;
1770 if (certInfo.hasKey(
"issuer name"))
1773 if (certInfo.hasKey(
"subject name"))
1781 { cout <<
"## NOTE: 'issuer name' info:" << endl;
1782 issuerInfo.
Print(cout,
false) << endl;
1784 if (
isVerbose() && !subjectInfo.empty())
1785 { cout <<
"## NOTE: 'subject name' info:" << endl;
1786 subjectInfo.
Print(cout,
false) << endl;
1805 ret = mbedtls_md_file (mbedtls_md_info_from_type(MBEDTLS_MD_SHA256),
pluginPath().c_str(), checksumFromDLL);
1810 if (
isVerbose()) {
string str;
if (checksumFromDLL.
toHexString(str)) cout <<
"## DEBUG: Digest: " << str << endl;}
1813 ret = mbedtls_pk_verify (&crt.pk, MBEDTLS_MD_SHA256,
1815 signature, signature);
1820 mbedtls_x509_crt_free(&crt);
1821 P_DBG(
"'mbedtls_pk_verify' succeeded for '" <<
pluginPath() <<
"' -- signature valid");
1841 if (regInfo.empty())
1850 for (
size_t ndx(0); ndx < reqKeys.size(); ndx++)
1851 if (!regInfo.hasKey(reqKeys.at(ndx)))
1852 missingRegInfoKeys.push_back(reqKeys.at(ndx));
1853 if (!missingRegInfoKeys.empty())
1854 {
P_FAIL(
"'" <<
pluginPath() <<
"': missing key(s) in registration info: '"
1855 <<
aja::join(missingRegInfoKeys,
"','") <<
"'");
1872 if (onReg != onCert)
1875 <<
"') \"" << onCert <<
"\" from X509 certificate 'Issuer' in '" <<
pluginSigPath() <<
"'");
1878 if (cnReg != cnCert)
1881 <<
"') \"" << cnCert <<
"\" from X509 certificate 'Issuer' in '" <<
pluginSigPath() <<
"'");
1884 if (ouReg != ouCert)
1887 <<
"') \"" << ouCert <<
"\" from X509 certificate 'Subject' in '" <<
pluginSigPath() <<
"'");
1890 if (myVers != plVers)
1892 <<
"\" doesn't match client SDK version '" << myVers <<
"'");
1895 if (fingerprint != ajaFingerprint)
1897 <<
"Issuer serial: " << fingerprint <<
"|AJA serial: " << ajaFingerprint);
1926 return mpPlugin && mValidated;
1933 cout <<
"0 plugins" << endl;
1934 else if (paths.size() == 1)
1935 cout <<
"1 plugin: " << paths.at(0) << endl;
1936 else cout <<
DEC(paths.size()) <<
" plugins:" << endl <<
aja::join(paths,
"\n") << endl;
1938 #endif // !defined(NTV2_PREVENT_PLUGIN_LOAD)
1956 {cout << __FILE__ <<
"(" << __LINE__ <<
"):" <<
AJAFUNC <<
":" << endl;
mParams.
Print(cout,
false) << endl;}
1971 size_t oldCount(
mParams.size()), updated(0), added(0);
1981 NBSDBG(
DEC(oldCount) <<
" param(s) removed, replaced with " << inNewParams);
1995 while (nums.size() > 3)
2003 static const string sAJAFingerprint (
"70:1A:37:93:FA:4F:34:30:58:55:51:0C:01:4E:45:7C:BE:5B:41:65");
2004 string result(sAJAFingerprint);
2042 return mParams.hasKey(inParam);
2058 oss << (IsConnected() ?
"Connected" :
"Disconnected");
2059 if (IsConnected() && !Name().empty())
2060 oss <<
" to '" << Name() <<
"'";
2069 strs.push_back(
string(
"from '") + fName +
"'");
2072 if (!hostName.empty())
2073 {strs.push_back(
"on"); strs.push_back(
string(
"'") + hostName +
"'");}
2100 { (
void) autoCircData;
2105 { (
void) eInterrupt; (
void) timeOutMs;
2109 #if !defined(NTV2_DEPRECATE_16_3)
2111 { (
void) bitFileType;
2112 ::memset(&bitFileInfo, 0,
sizeof(bitFileInfo));
2118 ::memset(&buildInfo, 0,
sizeof(buildInfo));
2123 const UWord signalMask,
const bool testPatDMAEnb,
const ULWord testPatNum)
2124 { (
void) channel; (
void) testPatternFBF; (
void) signalMask; (
void) testPatDMAEnb; (
void) testPatNum;
2129 { (
void) numRegs; (
void) outFailedRegNum; (
void) outRegs;
2135 outDriverVersion = 0xFFFFFFFF;
2138 #endif // !defined(NTV2_DEPRECATE_16_3)
2142 const ULWord inNumSegments,
const ULWord inSegmentHostPitch,
2143 const ULWord inSegmentCardPitch,
const bool inSynchronous)
2144 { (
void) inDMAEngine; (
void) inIsRead; (
void) inFrameNumber; (
void) inOutFrameBuffer;
2145 (
void) inCardOffsetBytes; (
void) inNumSegments; (
void) inSegmentHostPitch;
2146 (
void) inSegmentCardPitch; (
void) inSynchronous;
2151 { (
void) pInMessage;
2169 outSupported.clear();
2187 #if defined(NTV2_PREVENT_PLUGIN_LOAD)
2215 #if defined(NTV2_PREVENT_PLUGIN_LOAD)
2239 if (parser.HasErrors())
2241 NBSFAIL(parser.Error() <<
" in URL:\n" << inURL);
2242 parser.PrintErrors(cerr);
2291 return mParams.hasKey(inParam);
virtual bool NTV2WriteRegisterRemote(const ULWord regNum, const ULWord regValue, const ULWord regMask, const ULWord regShift)
virtual bool NTV2GetNumericParamRemote(const ULWord inParamID, ULWord &outValue)
#define kNTV2PluginRegInfoKey_ShortName
Plugin short name.
unsigned long stoul(const std::string &str, std::size_t *idx, int base)
@ value
the parser finished reading a JSON value
static void Terminate(void)
static NTV2RPCServerAPI * CreateServer(NTV2ConfigParams &inParams)
Factory method that instantiates a new NTV2RPCServerAPI instance using a plugin based on the specifie...
virtual std::string ConfigParam(const std::string &inParam) const
static bool DebuggingEnabled(void)
#define kLegalSchemeNTV2Local
void Reset(const std::string inSpec="")
Resets me, then parses the given device specification.
uint32_t gBaseDestructCount(0)
Declares the AJASystemInfo class.
static string mbedErrStr(const int mbedtlsReturnCode)
virtual bool NTV2OpenRemote(void)
enum _INTERRUPT_ENUMS_ INTERRUPT_ENUMS
#define kNTV2PluginRegInfoKey_Vendor
Plugin vendor (manufacturer) name.
@ AJA_SystemInfoMemoryUnit_Megabytes
bool unloadPlugin(const string &path, string &errMsg)
#define kQParamShowX509Cert
Query parameter option that dumps X509 certificate info into message log.
size_t addFrom(const NTV2Dictionary &inDict)
Adds all values from inDict with non-matching keys, ignoring all matching keys.
#define kNTV2PluginRegInfoKey_Copyright
Plugin copyright notice.
virtual bool NTV2Disconnect(void)
Disconnects me from the remote/fake host, closing the connection.
static std::string AJAFingerprint(const bool inLowerCase=false, const bool inStripColons=false)
std::set< std::string > NTV2StringSet
virtual bool NTV2DriverGetBitFileInformationRemote(BITFILE_INFO_STRUCT &bitFileInfo, const NTV2BitFileType bitFileType)
std::string & strip(std::string &str, const std::string &ws)
ULWord countForPath(const string &path)
uint32_t gPluginConstructCount(0)
#define kQParamDebugRegistry
Query parameter option that enables debugging of PluginRegistry.
NTV2DeviceIDSet NTV2GetSupportedDevices(const NTV2DeviceKinds inKinds=NTV2_DEVICEKIND_ALL)
Returns an NTV2DeviceIDSet of devices supported by the SDK.
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They're also commonly use...
Describes a user-space buffer on the host computer. I have an address and a length,...
NTV2Plugin(void *handle, const string &path, const bool useStdout)
std::string join(const std::vector< std::string > &parts, const std::string &delim)
void split(const std::string &str, const char delim, std::vector< std::string > &elems)
ULWord GetByteCount(void) const
#define NTV2_ASSERT(_expr_)
NTV2RPCClientAPI *(* fpCreateClient)(void *, const NTV2ConnectParams &, const uint32_t)
Instantiates a new client instance to talk to a remote server.
virtual AJAStatus Attach(AJAThreadFunction *pThreadFunction, void *pUserContext)
static bool ExtractIssuerInfo(NTV2Dictionary &outInfo, const string &inStr, const string &inParentKey)
NTV2RPCServerAPI *(* fpCreateServer)(void *, const NTV2ConfigParams &, const uint32_t)
Instantiates a new server instance for talking to clients.
#define kConnectParamDevID
First device having this ID (e.g. '0x10518400')
#define kNTV2PluginInfoKey_PluginSigPath
Local host full path to plugin signature file.
Declares the AJATime class.
Base class of objects that can serve device operation RPCs with NTV2RPCClientAPI instances.
Common base class for NTV2RPCClientAPI and NTV2RPCServerAPI.
#define kNTV2PluginX500AttrKey_OrganizationName
virtual ~NTV2RPCClientAPI()
My destructor, automatically calls NTV2Disconnect.
virtual bool NTV2DMATransferRemote(const NTV2DMAEngine inDMAEngine, const bool inIsRead, const ULWord inFrameNumber, NTV2Buffer &inOutBuffer, const ULWord inCardOffsetBytes, const ULWord inNumSegments, const ULWord inSegmentHostPitch, const ULWord inSegmentCardPitch, const bool inSynchronous)
bool SetParams(const NTV2ConfigParams &inNewParams, const bool inAugment=false)
bool showParams(void) const
NTV2DeviceID
Identifies a specific AJA NTV2 device model number. The NTV2DeviceID is actually the PROM part number...
NTV2DeviceID DeviceID(void) const
NTV2FrameBufferFormat
Identifies a particular video frame buffer format. See Device Frame Buffer Formats for details.
std::ostream & Print(std::ostream &oss, const bool inCompact=true) const
Prints human-readable representation to ostream.
std::string MakeQueryString(const bool urlEncode) const
bool Allocate(const size_t inByteCount, const bool inPageAligned=false)
Allocates (or re-allocates) my user-space storage using the given byte count. I assume full responsib...
#define kNTV2PluginInfoKey_Errors
Plugin load or validation error(s), if any.
virtual bool ConnectHasScheme(void) const
NTV2DeviceIDSet::const_iterator NTV2DeviceIDSetConstIter
A convenient const iterator for NTV2DeviceIDSet.
bool insert(const std::string &inKey, const std::string &inValue)
Stores the given value using the given key; overwrites existing value if already present.
bool toHexString(std::string &outStr, const size_t inLineBreakInterval=0) const
Converts my contents into a hex-encoded string.
#define kConnectParamPort
Port number (optional)
NTV2RPCServerAPI(NTV2ConnectParams inParams, void *pRefCon)
My constructor.
virtual bool HasConnectParam(const std::string &inParam) const
NTV2StringSet::const_iterator NTV2StringSetConstIter
std::string PercentEncode(const std::string &inStr)
virtual bool NTV2GetDriverVersionRemote(ULWord &outDriverVersion)
AJARefPtr< NTV2Plugin > NTV2PluginPtr
uint32_t gServerConstructCount(0)
void * addressForSymbol(const string &inSymbol, string &outErrorMsg)
#define kFuncNameCreateServer
Create an NTV2RPCServerAPI instance.
Declares the most fundamental data types used by NTV2. Since Windows NT was the first principal devel...
std::ostream & Print(std::ostream &oss, const bool inDumpResults=false) const
virtual bool NTV2CloseRemote(void)
std::string Resource(const bool inStripLeadSlash=true) const
@ key
the parser read a key of a value in an object
static bool ParseQueryParams(const NTV2Dictionary &inParams, NTV2Dictionary &outQueryParams)
#define kConnectParamDevModel
First device of this model (e.g. 'kona4')
size_t updateFrom(const NTV2Dictionary &inDict)
Updates all values from inDict with matching keys, ignoring all non-matching keys.
uint32_t mSpare[1024]
Reserved.
NTV2Dictionary mParams
Copy of config params passed to my constructor.
#define kNTV2PluginSigFileKey_X509Certificate
X509 certificate (encoded as hex string)
string pluginPath(void) const
virtual NTV2ConnectParams ConnectParams(void) const
std::string & lower(std::string &str)
#define kNTV2PluginX500AttrKey_OrganizationalUnitName
#define kQParamLogToStdout
Query parameter option that logs messages to standard output.
static void Sleep(const int32_t inMilliseconds)
Suspends execution of the current thread for a given number of milliseconds.
#define kNTV2PluginRegInfoKey_CommonName
Plugin vendor domain name.
std::set< ULWord > ULWordSet
A collection of unique ULWord (uint32_t) values.
std::string & replace(std::string &str, const std::string &from, const std::string &to)
virtual AJAStatus GetValue(const AJASystemInfoTag inTag, std::string &outValue) const
Answers with the host system info value string for the given AJASystemInfoTag.
virtual bool NTV2GetBoolParamRemote(const ULWord inParamID, ULWord &outValue)
virtual std::string ConnectParam(const std::string &inParam) const
@ AJA_SystemInfoTag_System_Name
#define kNTV2PluginInfoKey_Fingerprint
Issuer cert fingerprint.
NTV2PluginLoader(NTV2Dictionary ¶ms)
#define kConnectParamHost
DNS name, IPv4 or sw device DLL name.
virtual NTV2ConfigParams ConfigParams(void) const
virtual std::ostream & Print(std::ostream &oss) const
virtual bool HasConfigParam(const std::string &inParam) const
std::string MakeDeviceSpec(const bool urlEncodeQuery) const
static PluginRegistry & Get(void)
static std::string ShortSDKVersion(void)
uint32_t gBaseConstructCount(0)
std::string NTV2DeviceIDToString(const NTV2DeviceID inValue, const bool inForRetailDisplay=false)
virtual bool NTV2DriverGetBuildInformationRemote(BUILD_INFO_STRUCT &buildInfo)
bool mTerminate
Set true to stop server.
NTV2StringList loadedPlugins(void)
#define kNTV2PluginInfoKey_PluginPath
Local host full path to plugin file.
static bool ExtractCertInfo(NTV2Dictionary &outInfo, const string &inStr)
bool deserialize(const std::string &inStr)
Resets me from the given string.
virtual std::string Description(void) const
bool showCertificate(void) const
#define kNTV2PluginRegInfoKey_OrgUnit
Plugin organization unit (to match certificate subject OU)
void DumpLoadedPlugins(void)
All new NTV2 structs start with this common header.
std::string & upper(std::string &str)
virtual ~NTV2RPCServerAPI()
My destructor, automatically calls NTV2Disconnect.
NTV2DeviceSpecParser(const std::string inSpec="")
My constructor. If given device specification is non-empty, proceeds to Parse it.
bool string_to_wstring(const std::string &str, std::wstring &wstr)
#define kNTV2PluginInfoKey_PluginBaseName
Plugin base name (i.e. without extension)
Declares numerous NTV2 utility functions.
string pluginsPath(void) const
std::string NTV2Version(const bool inDetailed=false)
NTV2StringList pluginStats(void)
bool getBaseNameFromScheme(string &outName) const
virtual bool NTV2DownloadTestPatternRemote(const NTV2Channel channel, const NTV2PixelFormat testPatternFBF, const UWord signalMask, const bool testPatDMAEnb, const ULWord testPatNum)
UWord DeviceIndex(void) const
#define AJA_NTV2_SDK_VERSION
#define kQParamVDevFileName
.vdev file name (with extension)
bool useStdout(void) const
std::string NTV2GetPluginsFolderPath(const bool inAddTrailingPathDelim=false)
NTV2RPCBase(NTV2Dictionary params, uint32_t *pRefCon)
bool GetString(std::string &outString, const size_t inU8Offset=0, const size_t inMaxSize=128) const
Answers with my contents as a character string.
AJALock mParamLock
Mutex to protect mParams.
unsigned long long stoull(const std::string &str, std::size_t *idx, int base)
static bool LoadPlugin(const string &path, const string &folderPath, NTV2PluginPtr &outPtr, string &outErrMsg, const bool inUseStdout)
Defines for the NTV2 SDK version number, used by ajantv2/includes/ntv2enums.h. See the ajantv2/includ...
Dict::const_iterator DictConstIter
#define kNTV2PluginX500AttrKey_CommonName
std::string PercentDecode(const std::string &inStr)
uint16_t u16ValueForKey(const std::string &inKey, const uint16_t inDefault=0) const
bool loadPlugin(const string &path, const string &folderPath, NTV2PluginPtr &outPtr, string &errMsg, const bool useStdout)
std::vector< std::string > NTV2StringList
#define kConnectParamScheme
URL scheme.
static AJAStatus Open(bool incrementRefCount=false)
#define kNTV2PluginRegInfoKey_Description
Brief plugin description.
bool pluginIsLoaded(const string &path)
virtual bool NTV2AutoCirculateRemote(AUTOCIRCULATE_DATA &autoCircData)
bool isLoaded(void) const
virtual bool NTV2WaitForInterruptRemote(const INTERRUPT_ENUMS eInterrupt, const ULWord timeOutMs)
One-stop shop for parsing device specifications. (New in SDK 16.3) I do very little in the way of val...
virtual void RunServer(void)
Principal server thread function, subclsses should override.
void * GetHostPointer(void) const
#define kNTV2PluginRegInfoKey_NTV2SDKVersion
NTV2 SDK version that plugin was compiled with.
uint32_t gLoaderDestructCount(0)
static int32_t Increment(int32_t volatile *pTarget)
#define kConnectParamDevIndex
Device having this index number.
string pluginBaseName(void) const
#define kFuncNameCreateClient
Create an NTV2RPCClientAPI instance.
bool serialize(std::string &outStr) const
Serializes my contents into the given string.
bool pluginForPath(const string &path, NTV2PluginPtr &outHandle)
#define kQParamShowParams
Query parameter option that dumps parameters into message log.
Everything needed to call CNTV2Card::ReadRegister or CNTV2Card::WriteRegister functions.
Private include file for all ajabase sources.
std::ostream & PrintErrors(std::ostream &oss) const
#define HEX0N(__x__, __n__)
bool SetFromHexString(const std::string &inStr)
Replaces my contents from the given hex-encoded string, resizing me if necessary.
bool hasPath(const string &path)
static NTV2RPCClientAPI * CreateClient(NTV2ConnectParams &inParams)
Instantiates a new NTV2RPCClientAPI instance using the given NTV2ConnectParams.
AJARefPtr< PluginRegistry > PluginRegistryPtr
virtual AJAStatus SetThreadName(const char *name)
virtual bool NTV2Connect(void)
#define kFuncNameGetRegInfo
Answers with plugin registration info.
std::vector< uint32_t > ULWordSequence
An ordered sequence of ULWord (uint32_t) values.
#define kNTV2PluginSigFileKey_Signature
X509 digital signature (encoded as hex string)
#define AJA_sERROR(_index_, _expr_)
@ AJA_DebugUnit_Application
Declares the AJAAtomic class.
uint32_t gServerDestructCount(0)
uint32_t gClientDestructCount(0)
#define kNTV2PluginInfoKey_PluginsPath
Local host full path to folder containing plugins.
virtual bool NTV2GetSupportedRemote(const ULWord inEnumsID, ULWordSet &outSupported)
#define kConnectParamResource
Resource path – everything past URL [scheme://host[:port]/], excluding [?query].
std::set< NTV2DeviceID > NTV2DeviceIDSet
A set of NTV2DeviceIDs.
uint32_t gLoaderConstructCount(0)
static void EnableDebugging(const bool inEnable=true)
NTV2StringList::const_iterator NTV2StringListConstIter
bool Truncate(const size_t inByteCount)
Truncates me to the given length. No reallocation takes place.
void * refCon(void) const
virtual bool NTV2MessageRemote(NTV2_HEADER *pInMessage)
bool Fill(const T &inValue)
Fills me with the given scalar value.
virtual AJAStatus SetPriority(AJAThreadPriority priority)
virtual bool NTV2ReadRegisterMultiRemote(const ULWord numRegs, ULWord &outFailedRegNum, NTV2RegInfo outRegs[])
Declares enums and structs used by all platform drivers and the SDK.
bool indexForPath(const string &path, size_t &outIndex)
#define kConnectParamQuery
Query – everything past '?' in URL.
size_t largestKeySize(void) const
virtual AJAStatus Start()
uint32_t gClientConstructCount(0)
virtual std::ostream & Print(std::ostream &oss) const
#define kNTV2PluginRegInfoKey_Version
Plugin version (string)
#define xHEX0N(__x__, __n__)
bool isValidated(void) const
uint32_t gPluginDestructCount(0)
#define kConnectParamDevSerial
Device with this serial number.
bool(* fpGetRegistrationInfo)(const uint32_t, NTV2Dictionary &)
Obtains a plugin's registration information. Starting in SDK 17.1, all plugins must implement this fu...
bool getPluginsFolder(string &outPath) const
string pluginSigPath(void) const
An object that can connect to, and operate remote or fake devices. I have three general API groups:
bool isVerbose(void) const
std::string valueForKey(const std::string &inKey) const
Declares the AJAThread class.
uint32_t * mpRefCon
Reserved for internal use.
size_t largestValueSize(void) const
NTV2StringSet keys(void) const
A simple (not thread-safe) set of key/value pairs. (New in SDK 16.3)
Defines the AJARefPtr template class.
void * getFunctionAddress(const string &inFuncName)
std::string InfoString(void) const
@ AJA_SystemInfoSection_System
#define AJA_sDEBUG(_index_, _expr_)
virtual bool NTV2ReadRegisterRemote(const ULWord regNum, ULWord &outRegValue, const ULWord regMask, const ULWord regShift)
Declares NTV2 "nub" client functions.
bool useStdout(void) const
uint32_t * refConForPath(const string &path)
Declares the AJADebug class.
static int32_t Decrement(int32_t volatile *pTarget)
NTV2RPCClientAPI(NTV2ConnectParams inParams, void *pRefCon)
My constructor.
void * getSymbolAddress(const string &inSymbolName, string &outErrorMsg)
#define kQParamVerboseLogging
Query parameter option that enables verbose message logging.
#define kNTV2PluginRegInfoKey_LongName
Plugin long name.