|
AJA NTV2 SDK
17.5.0.1242
NTV2 SDK 17.5.0.1242
|
Go to the documentation of this file.
17 #if !defined(NTV2_PREVENT_PLUGIN_LOAD)
19 #include "mbedtls/x509.h"
20 #include "mbedtls/error.h"
21 #include "mbedtls/md.h"
22 #include "mbedtls/ssl.h"
23 #endif // defined(NTV2_PREVENT_PLUGIN_LOAD)
25 #include <CoreFoundation/CoreFoundation.h>
27 #define DLL_EXTENSION ".dylib"
28 #define PATH_DELIMITER "/"
29 #define FIRMWARE_FOLDER "Firmware"
30 #elif defined(AJALinux)
32 #define DLL_EXTENSION ".so"
33 #define PATH_DELIMITER "/"
34 #define FIRMWARE_FOLDER "firmware"
35 #elif defined(MSWindows)
36 #define DLL_EXTENSION ".dll"
37 #define PATH_DELIMITER "\\"
38 #define FIRMWARE_FOLDER "Firmware"
39 #elif defined(AJABareMetal)
40 #define DLL_EXTENSION ".so"
41 #define PATH_DELIMITER "/"
42 #define FIRMWARE_FOLDER "firmware"
44 #define SIG_EXTENSION ".sig"
48 #define INSTP(_p_) xHEX0N(uint64_t(_p_),16)
49 #define NBFAIL(__x__) AJA_sERROR (AJA_DebugUnit_RPCClient, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
50 #define NBWARN(__x__) AJA_sWARNING(AJA_DebugUnit_RPCClient, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
51 #define NBNOTE(__x__) AJA_sNOTICE (AJA_DebugUnit_RPCClient, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
52 #define NBINFO(__x__) AJA_sINFO (AJA_DebugUnit_RPCClient, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
53 #define NBDBG(__x__) AJA_sDEBUG (AJA_DebugUnit_RPCClient, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
54 #define NBCFAIL(__x__) AJA_sERROR (AJA_DebugUnit_RPCClient, AJAFUNC << ": " << __x__)
55 #define NBCWARN(__x__) AJA_sWARNING(AJA_DebugUnit_RPCClient, AJAFUNC << ": " << __x__)
56 #define NBCNOTE(__x__) AJA_sNOTICE (AJA_DebugUnit_RPCClient, AJAFUNC << ": " << __x__)
57 #define NBCINFO(__x__) AJA_sINFO (AJA_DebugUnit_RPCClient, AJAFUNC << ": " << __x__)
58 #define NBCDBG(__x__) AJA_sDEBUG (AJA_DebugUnit_RPCClient, AJAFUNC << ": " << __x__)
59 #define NBSFAIL(__x__) AJA_sERROR (AJA_DebugUnit_RPCServer, AJAFUNC << ": " << __x__)
60 #define NBSWARN(__x__) AJA_sWARNING(AJA_DebugUnit_RPCServer, AJAFUNC << ": " << __x__)
61 #define NBSNOTE(__x__) AJA_sNOTICE (AJA_DebugUnit_RPCServer, AJAFUNC << ": " << __x__)
62 #define NBSINFO(__x__) AJA_sINFO (AJA_DebugUnit_RPCServer, AJAFUNC << ": " << __x__)
63 #define NBSDBG(__x__) AJA_sDEBUG (AJA_DebugUnit_RPCServer, AJAFUNC << ": " << __x__)
65 #define PLGFAIL(__x__) AJA_sERROR (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
66 #define PLGWARN(__x__) AJA_sWARNING(AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
67 #define PLGNOTE(__x__) AJA_sNOTICE (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
68 #define PLGINFO(__x__) AJA_sINFO (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
69 #define PLGDBG(__x__) AJA_sDEBUG (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
71 #define P_FAIL(__x__) do \
74 _os_ << AJAFUNC << ": " << __x__; \
76 cout << "## ERROR: " << _os_.str() << endl; \
77 AJA_sERROR (AJA_DebugUnit_Plugins, _os_.str()); \
78 errMsg = _os_.str(); \
80 #define P_WARN(__x__) if (useStdout()) cout << "## WARNING: " << AJAFUNC << ": " << __x__ << endl; \
81 AJA_sWARNING(AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
82 #define P_NOTE(__x__) if (useStdout()) cout << "## NOTE: " << AJAFUNC << ": " << __x__ << endl; \
83 AJA_sNOTICE (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
84 #define P_INFO(__x__) if (useStdout()) cout << "## INFO: " << AJAFUNC << ": " << __x__ << endl; \
85 AJA_sINFO (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
86 #define P_DBG(__x__) if (useStdout()) cout << "## DEBUG: " << AJAFUNC << ": " << __x__ << endl; \
87 AJA_sDEBUG (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
88 #define _DEBUGSTATS_ // Define this to log above construct/destruct & open/close tallies
89 #if defined(_DEBUGSTATS_)
90 #define PDBGX(__x__) AJA_sDEBUG (AJA_DebugUnit_Plugins, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
112 if (it == mDict.end())
119 string str(valueForKey(inKey));
122 if (str.find(
"0x") == 0 || str.find(
"0X") == 0)
129 if (str.find(
"x") == 0 || str.find(
"X") == 0)
136 if (str.find(
"o") == 0 || str.find(
"O") == 0)
143 if (str.find(
"b") == 0 || str.find(
"B") == 0)
158 const string & key(it->first), val(it->second), quote(val.find(
' ') != string::npos ?
"'" :
"");
159 oss << key <<
"=" << quote << val << quote;
160 if (++it != mDict.end())
167 const int kyWdth(
int(largestKeySize()+0)), valWdth(
int(largestValueSize()+0));
168 oss << string(
size_t(kyWdth),
'-') <<
" " << string(
size_t(valWdth),
'-') << endl;
171 const string & key(it->first), val(it->second);
172 oss << std::setw(kyWdth) << key <<
" : " << val;
173 if (++it != mDict.end())
182 size_t badKVPairs(0), insertFailures(0);
188 if (keyValPair.size() != 2)
189 {badKVPairs++;
continue;}
190 const string k(keyValPair.at(0)), v(keyValPair.at(1));
194 return !empty() && !badKVPairs && !insertFailures;
203 oss << it->first <<
"\t" << it->second;
204 if (++it != mDict.end())
208 return !outStr.empty();
214 for (
DictConstIter it(mDict.begin()); it != mDict.end(); ++it)
215 result.insert(it->first);
222 for (
DictConstIter it(mDict.begin()); it != mDict.end(); ++it)
223 if (it->first.length() > result)
224 result = it->first.length();
231 for (
DictConstIter it(mDict.begin()); it != mDict.end(); ++it)
232 if (it->second.length() > result)
233 result = it->second.length();
241 if (inKey.find(
"\t") != string::npos)
243 if (inKey.find(
"\n") != string::npos)
245 if (inValue.find(
"\t") != string::npos)
247 if (inValue.find(
"\n") != string::npos)
249 mDict[inKey] = inValue;
255 size_t numUpdated(0);
256 for (
DictConstIter it(inDict.mDict.begin()); it != inDict.mDict.end(); ++it)
257 if (hasKey(it->first))
258 {mDict[it->first] = it->second; numUpdated++;}
265 for (
DictConstIter it(inDict.mDict.begin()); it != inDict.mDict.end(); ++it)
266 if (!hasKey(it->first))
267 {mDict[it->first] = it->second; numAdded++;}
281 mQueryParams.clear();
293 if (!inStripLeadSlash)
295 if (rsrc.at(0) ==
'/')
300 void NTV2DeviceSpecParser::Parse (
void)
309 string tokDevID, tokIndexNum, tokScheme, tokSerial, tokModelName;
310 size_t posDevID(0), posIndexNum(0), posScheme(0), posSerial(0), posModelName(0);
311 bool isSerial(ParseSerialNum(posSerial, tokSerial)), isScheme(ParseScheme(posScheme, tokScheme));
312 bool isIndexNum(ParseDecNumber(posIndexNum, tokIndexNum)), isDeviceID(ParseDeviceID(posDevID, tokDevID));
313 bool isModelName(ParseModelName(posModelName, tokModelName));
316 posDevID = posIndexNum = posSerial = posModelName = posScheme;
317 isSerial = ParseSerialNum(posSerial, tokSerial);
318 isIndexNum = ParseDecNumber(posIndexNum, tokIndexNum);
319 isDeviceID = ParseDeviceID(posDevID, tokDevID);
320 isModelName = ParseModelName(posModelName, tokModelName);
333 bool converted(
false);
335 if (tokSerial.length() == 18)
338 const bool hasLeading0X (tokSerial.find(
"0X") == 0 || tokSerial.find(
"0x") == 0);
339 const string hex64(tokSerial.substr(hasLeading0X ? 2 : 0, 16));
342 for (
size_t ndx(0); ndx < 8; ndx++)
343 serTxt +=
char(serNum64 >> ((7-ndx)*8));
349 for (
size_t ndx(0); ndx < tokSerial.length(); ndx++)
350 {
char ch(tokSerial.at(ndx));
351 if ( ! ( ( (ch >=
'0') && (ch <=
'9') ) ||
352 ( (ch >=
'A') && (ch <=
'Z') ) ||
353 ( (ch >=
'a') && (ch <=
'z') ) ||
354 (ch ==
' ') || (ch ==
'-') ) )
356 err <<
"Illegal serial number character '" << (ch ? ch :
'?') <<
"' (" <<
xHEX0N(
UWord(ch),2) <<
")";
358 mPos -= converted ? 16 : 8; mPos += ndx * (converted ? 2 : 1) + (converted ? 1 : 0);
382 err <<
"Invalid local device specification";
384 mPos += isScheme ? 12 : 0;
390 if (!IsSupportedScheme(tokScheme))
391 {err <<
"Unsupported scheme '" << tokScheme <<
"'"; AddError(err.str()); mPos -= 3;
break;}
397 size_t posURL(posScheme), posRsrc(0);
398 string host, port, rsrcPath;
399 if (!ParseHostAddressAndPortNumber(posURL, host, port))
400 {mPos = posURL; AddError(
"Bad host address or port number");
break;}
409 if (ParseResourcePath(posRsrc, rsrcPath))
412 size_t posQuery(mPos);
414 if (ParseQuery(posQuery, params))
417 mQueryParams = params;
420 if (mPos < SpecLength())
421 {err <<
"Extra character(s) at " <<
DEC(mPos); AddError(err.str());
break;}
430 #endif // defined(_DEBUG)
436 oss <<
"local device";
437 else if (HasScheme())
438 oss <<
"device '" << Scheme() <<
"'";
442 oss <<
" serial '" << DeviceSerial() <<
"'";
444 oss <<
" model '" << DeviceModel() <<
"'";
446 oss <<
" ID '" << DeviceID() <<
"'";
448 oss <<
" " << DeviceIndex();
458 {oss << endl; Results().Print(oss,
false);}
472 if (devIDStr.find(
"0X") != string::npos)
487 oss <<
DEC(ErrorCount()) << (ErrorCount() == 1 ?
" error" :
" errors") << (HasErrors() ?
":" :
"");
491 << DeviceSpec() << endl
492 << string(mPos ? mPos : 0,
' ') <<
"^" << endl;
493 for (
size_t num(0); num < ErrorCount(); )
496 if (++num < ErrorCount())
503 bool NTV2DeviceSpecParser::ParseHexNumber (
size_t & pos,
string & outToken)
507 while (pos < SpecLength())
509 const char ch(CharAt(pos));
510 if (tokHexNum.length() == 0)
514 ++pos; tokHexNum = ch;
516 else if (tokHexNum.length() == 1)
518 if (ch !=
'x' && ch !=
'X')
520 ++pos; tokHexNum += ch;
526 ++pos; tokHexNum += ch;
529 if (tokHexNum.length() > 2)
530 {
aja::upper(tokHexNum); outToken = tokHexNum;}
531 return !outToken.empty();
534 bool NTV2DeviceSpecParser::ParseDecNumber (
size_t & pos,
string & outToken)
538 while (pos < SpecLength())
540 const char ch(CharAt(pos));
541 if (!IsDecimalDigit(ch))
544 if (ch !=
'0' || tokDecNum !=
"0")
547 if (tokDecNum.length() > 0)
548 outToken = tokDecNum;
549 return !outToken.empty();
552 bool NTV2DeviceSpecParser::ParseAlphaNumeric (
size_t & pos,
string & outToken,
const std::string & inOtherChars)
556 while (pos < SpecLength())
558 const char ch(CharAt(pos));
559 if (!IsLetter(ch) && !IsDecimalDigit(ch) && inOtherChars.find(ch) == string::npos)
561 ++pos; tokAlphaNum += ch;
563 if (tokAlphaNum.length() > 1)
564 outToken = tokAlphaNum;
565 return !outToken.empty();
568 bool NTV2DeviceSpecParser::ParseScheme (
size_t & pos,
string & outToken)
571 string rawScheme, tokScheme;
572 while (ParseAlphaNumeric(pos, rawScheme))
574 tokScheme = rawScheme;
575 char ch(CharAt(pos));
578 ++pos; tokScheme += ch;
583 ++pos; tokScheme += ch;
588 ++pos; tokScheme += ch;
591 if (tokScheme.find(
"://") != string::npos)
592 {
aja::lower(rawScheme); outToken = rawScheme;}
593 return !outToken.empty();
596 bool NTV2DeviceSpecParser::ParseSerialNum (
size_t & pos,
string & outToken)
599 string tokAlphaNum, tokHexNum;
600 size_t posAlphaNum(pos), posHexNum(pos);
603 while (posAlphaNum < SpecLength())
605 const char ch(CharAt(posAlphaNum));
606 if (!IsUpperLetter(ch) && !IsDecimalDigit(ch) && ch !=
'-' && ch !=
' ')
608 ++posAlphaNum; tokAlphaNum += ch;
610 if (tokAlphaNum.length() < 2)
612 else if (tokAlphaNum.length() == 8 || tokAlphaNum.length() == 9)
613 {pos = posAlphaNum; outToken = tokAlphaNum;
break;}
615 if (ParseHexNumber(posHexNum, tokHexNum))
616 if (tokHexNum.length() == 18)
617 {pos = posHexNum; outToken = tokHexNum;}
619 return !outToken.empty();
622 bool NTV2DeviceSpecParser::ParseDeviceID (
size_t & pos,
string & outToken)
626 if (!ParseHexNumber(pos, tokHexNum))
628 if (tokHexNum.length() != 10)
637 ostringstream devID; devID <<
xHEX0N(*it,8);
638 string devIDStr(devID.str());
640 devIDStrs.insert(devIDStr);
642 if (devIDStrs.find(tokHexNum) != devIDStrs.end())
643 outToken = tokHexNum;
644 return !outToken.empty();
647 bool NTV2DeviceSpecParser::ParseModelName (
size_t & pos,
string & outToken)
651 if (!ParseAlphaNumeric(pos, tokName))
662 modelNames.insert(modelName);
664 if (modelNames.find(tokName) != modelNames.end())
666 return !outToken.empty();
669 bool NTV2DeviceSpecParser::ParseDNSName (
size_t & pos,
string & outDNSName)
672 string dnsName, name;
675 while (ParseAlphaNumeric(dnsPos, name,
"_-"))
677 if (!dnsName.empty())
685 if (!dnsName.empty())
687 outDNSName = dnsName;
688 return !outDNSName.empty();
691 bool NTV2DeviceSpecParser::ParseIPv4Address (
size_t & pos,
string & outIPv4)
694 string ipv4Name, num;
697 while (ParseDecNumber(ipv4Pos, num))
699 if (!ipv4Name.empty())
702 ch = CharAt(ipv4Pos);
707 if (!ipv4Name.empty())
710 return !outIPv4.empty();
713 bool NTV2DeviceSpecParser::ParseHostAddressAndPortNumber (
size_t & pos,
string & outAddr,
string & outPort)
715 outAddr.clear(); outPort.clear();
717 string dnsName, ipv4, port;
718 size_t dnsPos(pos), ipv4Pos(pos), portPos(0);
719 bool isDNS(ParseDNSName(dnsPos, dnsName)), isIPv4(ParseIPv4Address(ipv4Pos, ipv4));
720 if (!isDNS && !isIPv4)
721 {pos = dnsPos < ipv4Pos ? ipv4Pos : dnsPos;
return false;}
724 {outAddr = ipv4; pos = portPos = ipv4Pos;}
726 {outAddr = dnsName; pos = portPos = dnsPos;}
729 char ch (CharAt(portPos));
733 if (!ParseDecNumber(portPos, port))
734 {pos = portPos;
return false;}
740 bool NTV2DeviceSpecParser::ParseResourcePath (
size_t & pos,
string & outRsrc)
745 char ch(CharAt(rsrcPos));
750 if (!ParseAlphaNumeric(rsrcPos, name))
753 ch = CharAt(rsrcPos);
758 return !outRsrc.empty();
761 bool NTV2DeviceSpecParser::ParseParamAssignment (
size_t & pos,
string & outKey,
string & outValue)
763 outKey.clear(); outValue.clear();
765 size_t paramPos(pos);
766 char ch(CharAt(paramPos));
768 ch = CharAt(++paramPos);
771 if (!ParseAlphaNumeric(paramPos, key))
773 ch = CharAt(paramPos);
776 ch = CharAt(++paramPos);
777 while (ch != 0 && ch !=
'&')
780 ch = CharAt(++paramPos);
784 {pos = paramPos; outKey =
key; outValue =
value;}
788 bool NTV2DeviceSpecParser::ParseQuery (
size_t & pos,
NTV2Dictionary & outParams)
792 size_t queryPos(pos);
793 char ch(CharAt(queryPos));
798 while (ParseParamAssignment(queryPos, key, value))
800 outParams.
insert(key, value);
801 ch = CharAt(queryPos);
805 if (!outParams.empty())
807 return !outParams.empty();
812 return inScheme.find(
"ntv2") == 0;
815 bool NTV2DeviceSpecParser::IsUpperLetter (
const char inChar)
816 {
static const string sHexDigits(
"_ABCDEFGHIJKLMNOPQRSTUVWXYZ");
817 return sHexDigits.find(inChar) != string::npos;
820 bool NTV2DeviceSpecParser::IsLowerLetter (
const char inChar)
821 {
static const string sHexDigits(
"abcdefghijklmnopqrstuvwxyz");
822 return sHexDigits.find(inChar) != string::npos;
825 bool NTV2DeviceSpecParser::IsLetter (
const char inChar,
const bool inIncludeUnderscore)
826 {
return (inIncludeUnderscore && inChar ==
'_') || IsUpperLetter(inChar) || IsLowerLetter(inChar);
829 bool NTV2DeviceSpecParser::IsDecimalDigit (
const char inChar)
830 {
static const string sDecDigits(
"0123456789");
831 return sDecDigits.find(inChar) != string::npos;
834 bool NTV2DeviceSpecParser::IsHexDigit (
const char inChar)
835 {
static const string sHexDigits(
"0123456789ABCDEFabcdef");
836 return sHexDigits.find(inChar) != string::npos;
839 bool NTV2DeviceSpecParser::IsLegalSerialNumChar (
const char inChar)
840 {
return IsLetter(inChar) || IsDecimalDigit(inChar);
844 void NTV2DeviceSpecParser::test (
void)
847 specParser.
Reset(
"1");
848 specParser.
Reset(
"00000000000000000000000000000000000000000000000000000000000000000000000000000000000001");
849 specParser.
Reset(
"corvid24");
850 specParser.
Reset(
"corvid88");
851 specParser.
Reset(
"konalhi");
852 specParser.
Reset(
"alpha");
853 specParser.
Reset(
"00T64450");
854 specParser.
Reset(
"00t6-450");
855 specParser.
Reset(
"BLATZBE0");
856 specParser.
Reset(
"0x424C41545A424530");
857 specParser.
Reset(
"0x424C415425424530");
859 specParser.
Reset(
"badscheme://1");
861 specParser.
Reset(
"ntv2local://1");
862 specParser.
Reset(
"NtV2lOcAl://00000000000000000000000000000000000000000000000000000000000000000000000000000000000001");
863 specParser.
Reset(
"NTV2Local://corvid24");
864 specParser.
Reset(
"ntv2local://corvid88");
865 specParser.
Reset(
"ntv2local://konalhi");
866 specParser.
Reset(
"ntv2local://alpha");
867 specParser.
Reset(
"ntv2local://00T64450");
868 specParser.
Reset(
"ntv2local://00t6-450");
869 specParser.
Reset(
"ntv2local://BLATZBE0");
871 specParser.
Reset(
"ntv2nub://1.2.3.4");
872 specParser.
Reset(
"ntv2nub://1.2.3.4/doc");
873 specParser.
Reset(
"ntv2nub://1.2.3.4/doc/");
874 specParser.
Reset(
"ntv2nub://1.2.3.4/doc/alpha?one&two=2&three=&four=4");
875 specParser.
Reset(
"ntv2nub://1.2.3.4/doc/?one&two=2&three=&four=4");
876 specParser.
Reset(
"ntv2nub://1.2.3.4:badport/doc?one&two=2&three=&four=4");
877 specParser.
Reset(
"ntv2nub://1.2.3.4:200/doc?one&two=2&three=&four=4");
878 specParser.
Reset(
"ntv2nub://1.2.3.4:200/doc/?one&two=2&three=&four=4");
879 specParser.
Reset(
"ntv2nub://1.2.3.4:12345");
880 specParser.
Reset(
"ntv2nub://1.2.3.4:65000/doc");
881 specParser.
Reset(
"ntv2nub://1.2.3.4:32767/doc/");
882 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc/");
883 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc/?");
884 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc?");
885 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc/?one");
886 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc?one");
887 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc/?one=");
888 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc?one=");
889 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc/?one=1");
890 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc?one=1");
891 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc/?one=1&two");
892 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc?one=1&two");
893 specParser.
Reset(
"ntv2nub://50.200.250.300");
894 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.com/path/to/doc/?one=1&two");
895 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.edu:badport/path/to/doc/?one=1&two");
896 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.info:5544/path/to/doc/?one=1&two");
897 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.org/path/to/doc/?one=1&two");
898 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.nz:badport/path/to/doc/?one=1&two");
899 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.au:000004/path/to/doc/?one=1&two");
900 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.ch:4/corvid88");
901 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.cn:4/00T64450");
902 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.ru:4/2");
903 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.co.uk:4/00000000000000000000000000000001");
904 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.com:4/0000000000000000000000000000000001");
905 specParser.
Reset(
"ntv2://swdevice/?"
907 "&supportlog=file%3A%2F%2F%2FUsers%2Fdemo%2FDesktop%2FAJAWatcherSupport.log"
908 "&sdram=file%3A%2F%2F%2FUsers%2Fdemo%2FDesktop%2FSDRAMsnapshot.dat");
910 #endif // defined(_DEBUG)
912 #if defined(MSWindows)
913 static string WinErrStr (
const DWORD inErr)
915 string result(
"foo");
917 const DWORD res(FormatMessage ( FORMAT_MESSAGE_ALLOCATE_BUFFER
918 | FORMAT_MESSAGE_FROM_SYSTEM
919 | FORMAT_MESSAGE_IGNORE_INSERTS,
922 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
928 result =
reinterpret_cast<const char *
>(lpMsgBuf);
936 #if !defined(NTV2_PREVENT_PLUGIN_LOAD)
949 static bool LoadPlugin (
const string & path,
const string & folderPath,
NTV2PluginPtr & outPtr,
string & outErrMsg,
const bool inUseStdout);
952 #if defined(MSWindows)
953 NTV2Plugin (HMODULE handle,
const string & path,
const bool useStdout);
954 inline operator HMODULE()
const {
return mHandle;}
956 NTV2Plugin (
void * handle,
const string & path,
const bool useStdout);
957 inline operator void*()
const {
return mHandle;}
960 inline bool isLoaded (
void)
const {
return mHandle && !mPath.empty() ?
true :
false;}
961 void * addressForSymbol (
const string & inSymbol,
string & outErrorMsg);
967 inline bool useStdout(
void) {
return mUseStdout;}
969 #if defined(MSWindows)
981 ostringstream loadErr;
982 #if defined(AJABareMetal)
984 #elif defined(MSWindows)
986 std::wstring dllsFolderW;
988 if (!AddDllDirectory(dllsFolderW.c_str()))
990 loadErr <<
"AddDllDirectory '" << path <<
"' failed: " << WinErrStr(::GetLastError());
993 HMODULE h = ::LoadLibraryExA(LPCSTR(path.c_str()),
AJA_NULL, LOAD_LIBRARY_SEARCH_USER_DIRS);
995 loadErr <<
"Unable to open '" << path <<
"': " << WinErrStr(::GetLastError());
996 #else // MacOS or Linux
998 void * h = ::dlopen(path.c_str(), RTLD_LAZY);
1001 const char * pErrorStr(::dlerror());
1002 const string errStr (pErrorStr ? pErrorStr :
"");
1003 loadErr <<
"Unable to open '" << path <<
"': " << errStr;
1005 #endif // MacOS or Linux
1006 if (!loadErr.str().empty())
1007 outErrMsg = loadErr.str();
1010 outPtr =
new NTV2Plugin(h, path, inUseStdout);
1014 NTV2Plugin::NTV2Plugin()
1032 #if defined(MSWindows)
1043 P_NOTE(
"Dynamic/shared library '" << mPath <<
"' (" <<
INSTP(mHandle) <<
") loaded, "
1050 #if defined(AJABareMetal)
1052 #elif !defined(MSWindows)
1054 #else // macOS or Linux
1055 ::FreeLibrary(mHandle);
1058 P_NOTE(
"Dynamic/shared library '" << mPath <<
"' (" <<
INSTP(mHandle) <<
") unloaded, "
1066 outErrorMsg.clear();
1069 if (inSymbolName.empty())
1073 #if defined(AJABareMetal)
1075 #elif defined(MSWindows)
1076 result =
reinterpret_cast<void*
>(::GetProcAddress(
reinterpret_cast<HMODULE
>(mHandle), inSymbolName.c_str()));
1078 err <<
"'GetProcAddress' failed for '" << inSymbolName <<
"': " << WinErrStr(::GetLastError());
1079 #else // MacOS or Linux
1080 result = ::dlsym(mHandle, inSymbolName.c_str());
1082 {
const char * pErrorStr(::dlerror());
1083 const string errStr (pErrorStr ? pErrorStr :
"");
1084 err <<
"'dlsym' failed for '" << inSymbolName <<
"': " << errStr;
1086 #endif // MacOS or Linux
1087 outErrorMsg = err.str();
1106 static void Terminate (
void);
1107 static inline void EnableDebugging (
const bool inEnable =
true) {sDebugRegistry = inEnable;}
1113 bool loadPlugin (
const string & path,
const string & folderPath,
NTV2PluginPtr & outPtr,
string & errMsg,
const bool useStdout);
1114 bool unloadPlugin (
const string & path,
string & errMsg);
1115 bool pluginIsLoaded (
const string & path);
1116 bool pluginForPath (
const string & path,
NTV2PluginPtr & outHandle);
1119 bool hasPath (
const string & path);
1120 bool indexForPath (
const string & path,
size_t & outIndex);
1121 ULWord countForPath (
const string & path);
1122 uint32_t * refConForPath (
const string & path);
1123 inline bool useStdout (
void)
const {
return DebuggingEnabled();}
1126 typedef map<string, NTV2PluginPtr> NTV2PluginMap;
1130 NTV2PluginMap mPluginMap;
1135 static void Monitor (
AJAThread * pThread,
void * pContext);
1136 void monitor (
void);
1139 static bool sDebugRegistry;
1143 AJALock PluginRegistry::sMutex;
1144 bool PluginRegistry::sDebugRegistry(
false);
1161 void PluginRegistry::Monitor (
AJAThread * pThread,
void * pContext)
1169 : mQuitMonitor(
false)
1171 P_NOTE (
"PluginRegistry " <<
INSTP(
this) <<
" constructed");
1172 mPluginCounts.reserve(256);
1173 for (
size_t num(0); num < 256; num++)
1174 mPluginCounts.push_back(0);
1175 mCompareCounts = mPluginCounts;
1176 mMonitor.
Attach(Monitor,
this);
1183 mQuitMonitor =
true;
1184 while (mMonitor.
Active())
1194 {
P_FAIL(
"empty path");
return false;}
1201 {
P_WARN(
INSTP(
this) <<
": '" << path <<
"': 'pluginForPath' returned false, but 'hasPath' returned true, count=" <<
countForPath(path));}
1204 {
P_FAIL(msg);
return false;}
1205 P_NOTE(
INSTP(
this) <<
": Dynamic/shared library '" << path <<
"' loaded");
1206 mPluginMap[path] = outPtr;
1207 mPluginPaths.push_back(path);
1208 mPluginCounts.at(mPluginPaths.size()-1) = 0;
1219 {
P_FAIL(
INSTP(
this) <<
": '" << path <<
"' requested to unload, but not loaded");
return false;}
1220 mPluginMap.erase(path);
1221 P_NOTE(
INSTP(
this) <<
": '" << path <<
"' unloaded");
1228 return mPluginMap.find(path) != mPluginMap.end();
1234 NTV2PluginMap::const_iterator it(mPluginMap.find(path));
1235 if (it == mPluginMap.end())
1238 outHandle = it->second;
1246 for (NTV2PluginMap::const_iterator it(mPluginMap.begin()); it != mPluginMap.end(); ++it)
1247 result.push_back(it->first);
1255 for (
size_t ndx(0); ndx < mPluginPaths.size(); ndx++)
1257 const string path (mPluginPaths.at(ndx));
1261 oss <<
"\t" << (p->
isLoaded() ?
"loaded" :
"unloaded");
1263 oss <<
"\t" <<
"---";
1264 result.push_back(oss.str());
1278 for (outIndex = 0; outIndex < mPluginPaths.size(); outIndex++)
1279 if (path == mPluginPaths.at(outIndex))
1289 return &mPluginCounts[ndx];
1297 return mPluginCounts.at(ndx);
1301 void PluginRegistry::monitor (
void)
1303 P_NOTE(
"PluginRegistry " <<
INSTP(
this) <<
" monitor started");
1304 while (!mQuitMonitor)
1308 for (
size_t ndx(0); ndx < mPluginPaths.size(); ndx++)
1310 const uint32_t oldCount(mCompareCounts.at(ndx)), newCount(mPluginCounts.at(ndx));
1311 if (newCount != oldCount)
1313 string errMsg, path(mPluginPaths.at(ndx));
1314 if (newCount > oldCount)
1315 {
P_NOTE(
"PluginRegistry " <<
INSTP(
this) <<
": Plugin '" << path <<
"' utilization "
1316 <<
"increased from " <<
DEC(oldCount) <<
" to " <<
DEC(newCount));}
1319 P_NOTE(
"PluginRegistry " <<
INSTP(
this) <<
": Plugin '" << path <<
"' utilization "
1320 <<
"decreased from " <<
DEC(oldCount) <<
" to " <<
DEC(newCount));
1324 mCompareCounts.at(ndx) = newCount;
1330 P_NOTE(
"PluginRegistry " <<
INSTP(
this) <<
" monitor stopped");
1348 void *
refCon (
void)
const;
1352 void *
getSymbolAddress (
const string & inSymbolName,
string & outErrorMsg);
1355 inline bool isOpen (
void) {
return mpPlugin ? mpPlugin->
isLoaded() :
false;}
1366 mutable string errMsg;
1372 static string mbedErrStr (
const int mbedtlsReturnCode);
1400 { cout <<
"## NOTE: Original params for '" <<
pluginPath() <<
"':" << endl;
1401 originalParams.
Print(cout,
false) << endl;
1406 { cout <<
"## NOTE: Final params for '" <<
pluginPath() <<
"':" << endl;
1407 mDict.
Print(cout,
false) << endl;
1423 mbedtls_strerror (mbedtlsReturnCode, errBuff, errBuff);
1435 for (
size_t lineNdx(0); lineNdx < lines.size(); lineNdx++)
1437 string line (lines.at(lineNdx));
1438 const bool indented (line.empty() ?
false : line.at(0) ==
' ');
1443 if (keyValPair.size() != 2)
1445 if (keyValPair.size() == 1)
1447 keyPrefix = keyValPair.at(0);
1452 PLGFAIL(
"cert info line " <<
DEC(lineNdx+1) <<
" '" << line <<
"' has "
1453 <<
DEC(keyValPair.size()) <<
" column(s) -- expected 2");
1456 string key(keyValPair.at(0)), val(keyValPair.at(1));
1458 {
PLGFAIL(
"cert info line " <<
DEC(lineNdx+1) <<
" '" << line <<
"' empty key for value '" << val <<
"'");
continue;}
1459 if (indented && !keyPrefix.empty())
1460 {
aja::strip(key); key = keyPrefix +
": " + key;}
1463 if (outInfo.hasKey(key))
1478 for (
size_t ndx(0); ndx < pairs.size(); ndx++)
1480 string assignment (pairs.at(ndx));
1481 if (assignment.find(
'=') == string::npos)
1483 if (!lastKey.empty())
1489 if (pieces.size() != 2)
1490 {
PLGFAIL(
"'" << inParentKey <<
"' assignment '" << assignment <<
"' has " << pieces.size() <<
" component(s) -- expected 2");
continue;}
1491 lastKey = pieces.at(0);
1492 string val(pieces.at(1));
1504 if (!queryStr.empty())
1505 if (queryStr[0] ==
'?')
1506 queryStr.erase(0,1);
1510 string str(*it), key, value;
1511 if (str.find(
"=") == string::npos)
1514 outQueryParams.
insert(key, value);
1515 PLGDBG(
"'" << key <<
"' = ''");
1522 if (pieces.size() > 1)
1523 value = pieces.at(1);
1525 {
PLGWARN(
"Empty key '" << key <<
"'");
continue;}
1526 if (outQueryParams.hasKey(key))
1527 PLGDBG(
"Param '" << key <<
"' value '" << outQueryParams.
valueForKey(key) <<
"' to be replaced with '" << value <<
"'");
1536 outErrorMsg.clear();
1554 if (outPath.empty())
1556 PLGDBG(
"AJA firmware path is '" << outPath <<
"'");
1558 {
P_FAIL(
"'" << outPath <<
"' doesn't end with '" <<
FIRMWARE_FOLDER <<
"'"); outPath.clear();
return false;}
1562 outPath.erase(outPath.length() - 1, 1);
1563 return !outPath.empty();
1573 {
P_FAIL(
"Missing scheme -- params: " << mDict);
return false;}
1575 if (scheme.find(
"ntv2") != 0)
1576 {
P_FAIL(
"Scheme '" << scheme <<
"' doesn't start with 'ntv2'");
return false;}
1580 return !outName.empty();
1600 ifstream dllF(
pluginPath().c_str(), std::ios::in | std::ios::binary);
1604 {
P_FAIL(
"EOF not reached in plugin file '" <<
pluginPath() <<
"' -- over 500MB in size?");
return fail();}
1605 tmp.
Truncate(
size_t(dllF.gcount()));
1609 ifstream sigF(
pluginSigPath().c_str(), std::ios::in | std::ios::binary);
1613 {
P_FAIL(
"EOF not reached in signature file '" <<
pluginSigPath() <<
"' -- over 500MB in size?");
return fail();}
1614 tmp.
Truncate(
size_t(sigF.gcount()));
1625 NTV2Buffer checksumFromSigFile, x509CertFromSigFile, signature;
1636 mbedtls_x509_crt crt;
1637 mbedtls_x509_crt_init(&crt);
1638 int ret = mbedtls_x509_crt_parse(&crt, x509CertFromSigFile, x509CertFromSigFile);
1641 mbedtls_x509_crt_free(&crt);
1649 int msgLength (mbedtls_x509_crt_info (msgBuff, msgBuff,
"", &crt));
1650 string msg (msgBuff,
size_t(msgLength));
1652 {
P_FAIL(
"'mbedtls_x509_crt_info' returned no info for X509 cert found in '" <<
pluginSigPath() <<
"'");
1656 cout <<
"## DEBUG: Raw X509 certificate info extracted from signature file '" <<
pluginSigPath() <<
"':" << endl
1657 <<
" " << msg << endl;
1661 { cout <<
"## NOTE: X509 certificate info extracted from signature file '" <<
pluginSigPath() <<
"':" << endl;
1662 certInfo.
Print(cout,
false) << endl;
1664 if (certInfo.hasKey(
"issuer name"))
1667 if (certInfo.hasKey(
"subject name"))
1675 { cout <<
"## NOTE: 'issuer name' info:" << endl;
1676 issuerInfo.
Print(cout,
false) << endl;
1678 if (
isVerbose() && !subjectInfo.empty())
1679 { cout <<
"## NOTE: 'subject name' info:" << endl;
1680 subjectInfo.
Print(cout,
false) << endl;
1699 ret = mbedtls_md_file (mbedtls_md_info_from_type(MBEDTLS_MD_SHA256),
pluginPath().c_str(), checksumFromDLL);
1704 if (
isVerbose()) {
string str;
if (checksumFromDLL.
toHexString(str)) cout <<
"## DEBUG: Digest: " << str << endl;}
1707 ret = mbedtls_pk_verify (&crt.pk, MBEDTLS_MD_SHA256,
1709 signature, signature);
1714 mbedtls_x509_crt_free(&crt);
1715 P_DBG(
"'mbedtls_pk_verify' succeeded for '" <<
pluginPath() <<
"' -- signature valid");
1735 if (regInfo.empty())
1744 for (
size_t ndx(0); ndx < reqKeys.size(); ndx++)
1745 if (!regInfo.hasKey(reqKeys.at(ndx)))
1746 missingRegInfoKeys.push_back(reqKeys.at(ndx));
1747 if (!missingRegInfoKeys.empty())
1748 {
P_FAIL(
"'" <<
pluginPath() <<
"': missing key(s) in registration info: '"
1749 <<
aja::join(missingRegInfoKeys,
"','") <<
"'");
1766 if (onReg != onCert)
1769 <<
"') \"" << onCert <<
"\" from X509 certificate 'Issuer' in '" <<
pluginSigPath() <<
"'");
1772 if (cnReg != cnCert)
1775 <<
"') \"" << cnCert <<
"\" from X509 certificate 'Issuer' in '" <<
pluginSigPath() <<
"'");
1778 if (ouReg != ouCert)
1781 <<
"') \"" << ouCert <<
"\" from X509 certificate 'Subject' in '" <<
pluginSigPath() <<
"'");
1784 if (myVers != plVers)
1786 <<
"\" doesn't match client SDK version '" << myVers <<
"'");
1789 if (fingerprint != ajaFingerprint)
1791 <<
"Issuer serial: " << fingerprint <<
"|AJA serial: " << ajaFingerprint);
1820 return mpPlugin && mValidated;
1827 cout <<
"0 plugins" << endl;
1828 else if (paths.size() == 1)
1829 cout <<
"1 plugin: " << paths.at(0) << endl;
1830 else cout <<
DEC(paths.size()) <<
" plugins:" << endl <<
aja::join(paths,
"\n") << endl;
1832 #endif // !defined(NTV2_PREVENT_PLUGIN_LOAD)
1850 {cout << __FILE__ <<
"(" << __LINE__ <<
"):" <<
AJAFUNC <<
":" << endl;
mParams.
Print(cout,
false) << endl;}
1865 size_t oldCount(
mParams.size()), updated(0), added(0);
1875 NBSDBG(
DEC(oldCount) <<
" param(s) removed, replaced with " << inNewParams);
1889 while (nums.size() > 3)
1897 static const string sAJAFingerprint (
"70:1A:37:93:FA:4F:34:30:58:55:51:0C:01:4E:45:7C:BE:5B:41:62");
1898 string result(sAJAFingerprint);
1936 return mParams.hasKey(inParam);
1952 oss << (IsConnected() ?
"Connected" :
"Disconnected");
1953 if (IsConnected() && !Name().empty())
1954 oss <<
" to '" << Name() <<
"'";
1986 { (
void) autoCircData;
1991 { (
void) eInterrupt; (
void) timeOutMs;
1995 #if !defined(NTV2_DEPRECATE_16_3)
1997 { (
void) bitFileType;
1998 ::memset(&bitFileInfo, 0,
sizeof(bitFileInfo));
2004 ::memset(&buildInfo, 0,
sizeof(buildInfo));
2009 const UWord signalMask,
const bool testPatDMAEnb,
const ULWord testPatNum)
2010 { (
void) channel; (
void) testPatternFBF; (
void) signalMask; (
void) testPatDMAEnb; (
void) testPatNum;
2015 { (
void) numRegs; (
void) outFailedRegNum; (
void) outRegs;
2021 outDriverVersion = 0xFFFFFFFF;
2024 #endif // !defined(NTV2_DEPRECATE_16_3)
2028 const ULWord inNumSegments,
const ULWord inSegmentHostPitch,
2029 const ULWord inSegmentCardPitch,
const bool inSynchronous)
2030 { (
void) inDMAEngine; (
void) inIsRead; (
void) inFrameNumber; (
void) inOutFrameBuffer;
2031 (
void) inCardOffsetBytes; (
void) inNumSegments; (
void) inSegmentHostPitch;
2032 (
void) inSegmentCardPitch; (
void) inSynchronous;
2037 { (
void) pInMessage;
2055 outSupported.clear();
2073 #if defined(NTV2_PREVENT_PLUGIN_LOAD)
2101 #if defined(NTV2_PREVENT_PLUGIN_LOAD)
2125 if (parser.HasErrors())
2173 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.
static string mbedErrStr(const int mbedtlsReturnCode)
virtual bool NTV2OpenRemote(void)
enum _INTERRUPT_ENUMS_ INTERRUPT_ENUMS
#define kNTV2PluginRegInfoKey_Vendor
Plugin vendor (manufacturer) name.
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)
#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...
A generic user-space buffer object that has an address and a length. Used most often to share an arbi...
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_)
static uint32_t gBaseDestructCount(0)
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
std::string NTV2GetFirmwareFolderPath(void)
NTV2DeviceID
Identifies a specific AJA NTV2 device model number. The NTV2DeviceID is actually the PROM part number...
NTV2DeviceID DeviceID(void) const
static uint32_t gPluginConstructCount(0)
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.
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
virtual bool NTV2GetDriverVersionRemote(ULWord &outDriverVersion)
AJARefPtr< NTV2Plugin > NTV2PluginPtr
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
#define kConnectParamDevModel
First device of this model (e.g. 'kona4')
static uint32_t gServerDestructCount(0)
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 bool NTV2GetBoolParamRemote(const ULWord inParamID, ULWord &outValue)
virtual std::string ConnectParam(const std::string &inParam) const
#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
static PluginRegistry & Get(void)
static bool ParseQueryParams(const NTV2Dictionary &inParams, NTV2Dictionary &outQueryParams)
static std::string ShortSDKVersion(void)
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
static uint32_t gBaseConstructCount(0)
#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
static bool IsSupportedScheme(const std::string &inScheme)
#define AJA_NTV2_SDK_VERSION
bool useStdout(void) const
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...
static uint32_t gClientConstructCount(0)
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.
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.
Private include file for all ajabase sources.
std::ostream & PrintErrors(std::ostream &oss) const
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
static uint32_t gClientDestructCount(0)
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
static uint32_t gLoaderConstructCount(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.
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[])
static uint32_t gPluginDestructCount(0)
Declares enums and structs used by all platform drivers and the SDK.
bool indexForPath(const string &path, size_t &outIndex)
static uint32_t gServerConstructCount(0)
#define kConnectParamQuery
Query – everything past '?' in URL.
size_t largestKeySize(void) const
virtual AJAStatus Start()
virtual std::ostream & Print(std::ostream &oss) const
#define kNTV2PluginRegInfoKey_Version
Plugin version (string)
static uint32_t gLoaderDestructCount(0)
#define xHEX0N(__x__, __n__)
bool isValidated(void) const
#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)
void * getFunctionAddress(const string &inFuncName)
std::string InfoString(void) const
#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
Everything needed to call CNTV2Card::ReadRegister or CNTV2Card::WriteRegister functions.
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.