 |
AJA NTV2 SDK
17.6.0.2675
NTV2 SDK 17.6.0.2675
|
Go to the documentation of this file.
17 #if !defined(NTV2_PREVENT_PLUGIN_LOAD)
21 #include "mbedtls/x509.h"
22 #include "mbedtls/error.h"
23 #include "mbedtls/md.h"
24 #include "mbedtls/ssl.h"
25 #endif // defined(NTV2_PREVENT_PLUGIN_LOAD)
27 #include <CoreFoundation/CoreFoundation.h>
29 #define DLL_EXTENSION ".dylib"
30 #define PATH_DELIMITER "/"
31 #define FIRMWARE_FOLDER "Firmware"
32 #elif defined(AJALinux)
34 #define DLL_EXTENSION ".so"
35 #define PATH_DELIMITER "/"
36 #define FIRMWARE_FOLDER "firmware"
37 #elif defined(MSWindows)
38 #define DLL_EXTENSION ".dll"
39 #define PATH_DELIMITER "\\"
40 #define FIRMWARE_FOLDER "Firmware"
41 #elif defined(AJABareMetal)
42 #define DLL_EXTENSION ".so"
43 #define PATH_DELIMITER "/"
44 #define FIRMWARE_FOLDER "firmware"
46 #define SIG_EXTENSION ".sig"
50 #define INSTP(_p_) xHEX0N(uint64_t(_p_),16)
51 #define NBFAIL(__x__) AJA_sERROR (AJA_DebugUnit_RPCClient, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
52 #define NBWARN(__x__) AJA_sWARNING(AJA_DebugUnit_RPCClient, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
53 #define NBNOTE(__x__) AJA_sNOTICE (AJA_DebugUnit_RPCClient, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
54 #define NBINFO(__x__) AJA_sINFO (AJA_DebugUnit_RPCClient, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
55 #define NBDBG(__x__) AJA_sDEBUG (AJA_DebugUnit_RPCClient, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
56 #define NBCFAIL(__x__) AJA_sERROR (AJA_DebugUnit_RPCClient, AJAFUNC << ": " << __x__)
57 #define NBCWARN(__x__) AJA_sWARNING(AJA_DebugUnit_RPCClient, AJAFUNC << ": " << __x__)
58 #define NBCNOTE(__x__) AJA_sNOTICE (AJA_DebugUnit_RPCClient, AJAFUNC << ": " << __x__)
59 #define NBCINFO(__x__) AJA_sINFO (AJA_DebugUnit_RPCClient, AJAFUNC << ": " << __x__)
60 #define NBCDBG(__x__) AJA_sDEBUG (AJA_DebugUnit_RPCClient, AJAFUNC << ": " << __x__)
61 #define NBSFAIL(__x__) AJA_sERROR (AJA_DebugUnit_RPCServer, AJAFUNC << ": " << __x__)
62 #define NBSWARN(__x__) AJA_sWARNING(AJA_DebugUnit_RPCServer, AJAFUNC << ": " << __x__)
63 #define NBSNOTE(__x__) AJA_sNOTICE (AJA_DebugUnit_RPCServer, AJAFUNC << ": " << __x__)
64 #define NBSINFO(__x__) AJA_sINFO (AJA_DebugUnit_RPCServer, AJAFUNC << ": " << __x__)
65 #define NBSDBG(__x__) AJA_sDEBUG (AJA_DebugUnit_RPCServer, AJAFUNC << ": " << __x__)
67 #define PLGFAIL(__x__) AJA_sERROR (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
68 #define PLGWARN(__x__) AJA_sWARNING(AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
69 #define PLGNOTE(__x__) AJA_sNOTICE (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
70 #define PLGINFO(__x__) AJA_sINFO (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
71 #define PLGDBG(__x__) AJA_sDEBUG (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
73 #define P_FAIL(__x__) do \
76 _os_ << AJAFUNC << ": " << __x__; \
78 cout << "## ERROR: " << _os_.str() << endl; \
79 AJA_sERROR (AJA_DebugUnit_Plugins, _os_.str()); \
80 errMsg = _os_.str(); \
82 #define P_WARN(__x__) if (useStdout()) cout << "## WARNING: " << AJAFUNC << ": " << __x__ << endl; \
83 AJA_sWARNING(AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
84 #define P_NOTE(__x__) if (useStdout()) cout << "## NOTE: " << AJAFUNC << ": " << __x__ << endl; \
85 AJA_sNOTICE (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
86 #define P_INFO(__x__) if (useStdout()) cout << "## INFO: " << AJAFUNC << ": " << __x__ << endl; \
87 AJA_sINFO (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
88 #define P_DBG(__x__) if (useStdout()) cout << "## DEBUG: " << AJAFUNC << ": " << __x__ << endl; \
89 AJA_sDEBUG (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
90 #define _DEBUGSTATS_ // Define this to log above construct/destruct & open/close tallies
91 #if defined(_DEBUGSTATS_)
92 #define PDBGX(__x__) AJA_sDEBUG (AJA_DebugUnit_Plugins, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
114 if (it == mDict.end())
121 string str(valueForKey(inKey));
124 if (str.find(
"0x") == 0 || str.find(
"0X") == 0)
131 if (str.find(
"x") == 0 || str.find(
"X") == 0)
138 if (str.find(
"o") == 0 || str.find(
"O") == 0)
145 if (str.find(
"b") == 0 || str.find(
"B") == 0)
160 const string & key(it->first), val(it->second), quote(val.find(
' ') != string::npos ?
"'" :
"");
161 oss << key <<
"=" << quote << val << quote;
162 if (++it != mDict.end())
169 const int kyWdth(
int(largestKeySize()+0)), valWdth(
int(largestValueSize()+0));
170 oss << string(
size_t(kyWdth),
'-') <<
" " << string(
size_t(valWdth),
'-') << endl;
173 const string & key(it->first), val(it->second);
174 oss << std::setw(kyWdth) << key <<
" : " << val;
175 if (++it != mDict.end())
184 size_t badKVPairs(0), insertFailures(0);
190 if (keyValPair.size() != 2)
191 {badKVPairs++;
continue;}
192 const string k(keyValPair.at(0)), v(keyValPair.at(1));
196 return !empty() && !badKVPairs && !insertFailures;
205 oss << it->first <<
"\t" << it->second;
206 if (++it != mDict.end())
210 return !outStr.empty();
216 for (
DictConstIter it(mDict.begin()); it != mDict.end(); ++it)
217 result.insert(it->first);
224 for (
DictConstIter it(mDict.begin()); it != mDict.end(); ++it)
225 if (it->first.length() > result)
226 result = it->first.length();
233 for (
DictConstIter it(mDict.begin()); it != mDict.end(); ++it)
234 if (it->second.length() > result)
235 result = it->second.length();
243 if (inKey.find(
"\t") != string::npos)
245 if (inKey.find(
"\n") != string::npos)
247 if (inValue.find(
"\t") != string::npos)
249 if (inValue.find(
"\n") != string::npos)
251 mDict[inKey] = inValue;
257 size_t numUpdated(0);
258 for (
DictConstIter it(inDict.mDict.begin()); it != inDict.mDict.end(); ++it)
259 if (hasKey(it->first))
260 {mDict[it->first] = it->second; numUpdated++;}
267 for (
DictConstIter it(inDict.mDict.begin()); it != inDict.mDict.end(); ++it)
268 if (!hasKey(it->first))
269 {mDict[it->first] = it->second; numAdded++;}
283 mQueryParams.clear();
295 if (!inStripLeadSlash)
297 if (rsrc.at(0) ==
'/')
302 void NTV2DeviceSpecParser::Parse (
void)
311 string tokDevID, tokIndexNum, tokScheme, tokSerial, tokModelName;
312 size_t posDevID(0), posIndexNum(0), posScheme(0), posSerial(0), posModelName(0);
313 bool isSerial(ParseSerialNum(posSerial, tokSerial)), isScheme(ParseScheme(posScheme, tokScheme));
314 bool isIndexNum(ParseDecNumber(posIndexNum, tokIndexNum)), isDeviceID(ParseDeviceID(posDevID, tokDevID));
315 bool isModelName(ParseModelName(posModelName, tokModelName));
318 posDevID = posIndexNum = posSerial = posModelName = posScheme;
319 isSerial = ParseSerialNum(posSerial, tokSerial);
320 isIndexNum = ParseDecNumber(posIndexNum, tokIndexNum);
321 isDeviceID = ParseDeviceID(posDevID, tokDevID);
322 isModelName = ParseModelName(posModelName, tokModelName);
335 bool converted(
false);
337 if (tokSerial.length() == 18)
340 const bool hasLeading0X (tokSerial.find(
"0X") == 0 || tokSerial.find(
"0x") == 0);
341 const string hex64(tokSerial.substr(hasLeading0X ? 2 : 0, 16));
344 for (
size_t ndx(0); ndx < 8; ndx++)
345 serTxt +=
char(serNum64 >> ((7-ndx)*8));
351 for (
size_t ndx(0); ndx < tokSerial.length(); ndx++)
352 {
char ch(tokSerial.at(ndx));
353 if ( ! ( ( (ch >=
'0') && (ch <=
'9') ) ||
354 ( (ch >=
'A') && (ch <=
'Z') ) ||
355 ( (ch >=
'a') && (ch <=
'z') ) ||
356 (ch ==
' ') || (ch ==
'-') ) )
358 err <<
"Illegal serial number character '" << (ch ? ch :
'?') <<
"' (" <<
xHEX0N(
UWord(ch),2) <<
")";
360 mPos -= converted ? 16 : 8; mPos += ndx * (converted ? 2 : 1) + (converted ? 1 : 0);
384 err <<
"Invalid local device specification";
386 mPos += isScheme ? 12 : 0;
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() > 0)
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();
810 bool NTV2DeviceSpecParser::IsUpperLetter (
const char inChar)
811 {
static const string sHexDigits(
"_ABCDEFGHIJKLMNOPQRSTUVWXYZ");
812 return sHexDigits.find(inChar) != string::npos;
815 bool NTV2DeviceSpecParser::IsLowerLetter (
const char inChar)
816 {
static const string sHexDigits(
"abcdefghijklmnopqrstuvwxyz");
817 return sHexDigits.find(inChar) != string::npos;
820 bool NTV2DeviceSpecParser::IsLetter (
const char inChar,
const bool inIncludeUnderscore)
821 {
return (inIncludeUnderscore && inChar ==
'_') || IsUpperLetter(inChar) || IsLowerLetter(inChar);
824 bool NTV2DeviceSpecParser::IsDecimalDigit (
const char inChar)
825 {
static const string sDecDigits(
"0123456789");
826 return sDecDigits.find(inChar) != string::npos;
829 bool NTV2DeviceSpecParser::IsHexDigit (
const char inChar)
830 {
static const string sHexDigits(
"0123456789ABCDEFabcdef");
831 return sHexDigits.find(inChar) != string::npos;
834 bool NTV2DeviceSpecParser::IsLegalSerialNumChar (
const char inChar)
835 {
return IsLetter(inChar) || IsDecimalDigit(inChar);
839 void NTV2DeviceSpecParser::test (
void)
842 specParser.
Reset(
"1");
843 specParser.
Reset(
"00000000000000000000000000000000000000000000000000000000000000000000000000000000000001");
844 specParser.
Reset(
"corvid24");
845 specParser.
Reset(
"corvid88");
846 specParser.
Reset(
"konalhi");
847 specParser.
Reset(
"alpha");
848 specParser.
Reset(
"00T64450");
849 specParser.
Reset(
"00t6-450");
850 specParser.
Reset(
"BLATZBE0");
851 specParser.
Reset(
"0x424C41545A424530");
852 specParser.
Reset(
"0x424C415425424530");
854 specParser.
Reset(
"badscheme://1");
856 specParser.
Reset(
"ntv2local://1");
857 specParser.
Reset(
"NtV2lOcAl://00000000000000000000000000000000000000000000000000000000000000000000000000000000000001");
858 specParser.
Reset(
"NTV2Local://corvid24");
859 specParser.
Reset(
"ntv2local://corvid88");
860 specParser.
Reset(
"ntv2local://konalhi");
861 specParser.
Reset(
"ntv2local://alpha");
862 specParser.
Reset(
"ntv2local://00T64450");
863 specParser.
Reset(
"ntv2local://00t6-450");
864 specParser.
Reset(
"ntv2local://BLATZBE0");
866 specParser.
Reset(
"ntv2nub://1.2.3.4");
867 specParser.
Reset(
"ntv2nub://1.2.3.4/doc");
868 specParser.
Reset(
"ntv2nub://1.2.3.4/doc/");
869 specParser.
Reset(
"ntv2nub://1.2.3.4/doc/alpha?one&two=2&three=&four=4");
870 specParser.
Reset(
"ntv2nub://1.2.3.4/doc/?one&two=2&three=&four=4");
871 specParser.
Reset(
"ntv2nub://1.2.3.4:badport/doc?one&two=2&three=&four=4");
872 specParser.
Reset(
"ntv2nub://1.2.3.4:200/doc?one&two=2&three=&four=4");
873 specParser.
Reset(
"ntv2nub://1.2.3.4:200/doc/?one&two=2&three=&four=4");
874 specParser.
Reset(
"ntv2nub://1.2.3.4:12345");
875 specParser.
Reset(
"ntv2nub://1.2.3.4:65000/doc");
876 specParser.
Reset(
"ntv2nub://1.2.3.4:32767/doc/");
877 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc/");
878 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc/?");
879 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc?");
880 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc/?one");
881 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc?one");
882 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc/?one=");
883 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc?one=");
884 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc/?one=1");
885 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc?one=1");
886 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc/?one=1&two");
887 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc?one=1&two");
888 specParser.
Reset(
"ntv2nub://50.200.250.300");
889 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.com/path/to/doc/?one=1&two");
890 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.edu:badport/path/to/doc/?one=1&two");
891 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.info:5544/path/to/doc/?one=1&two");
892 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.org/path/to/doc/?one=1&two");
893 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.nz:badport/path/to/doc/?one=1&two");
894 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.au:000004/path/to/doc/?one=1&two");
895 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.ch:4/corvid88");
896 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.cn:4/00T64450");
897 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.ru:4/2");
898 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.co.uk:4/00000000000000000000000000000001");
899 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.com:4/0000000000000000000000000000000001");
900 specParser.
Reset(
"ntv2://swdevice/?"
902 "&supportlog=file%3A%2F%2F%2FUsers%2Fdemo%2FDesktop%2FAJAWatcherSupport.log"
903 "&sdram=file%3A%2F%2F%2FUsers%2Fdemo%2FDesktop%2FSDRAMsnapshot.dat");
905 #endif // defined(_DEBUG)
907 #if defined(MSWindows)
908 static string WinErrStr (
const DWORD inErr)
910 string result(
"foo");
912 const DWORD res(FormatMessage ( FORMAT_MESSAGE_ALLOCATE_BUFFER
913 | FORMAT_MESSAGE_FROM_SYSTEM
914 | FORMAT_MESSAGE_IGNORE_INSERTS,
917 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
923 result =
reinterpret_cast<const char *
>(lpMsgBuf);
931 #if !defined(NTV2_PREVENT_PLUGIN_LOAD)
944 static bool LoadPlugin (
const string & path,
const string & folderPath,
NTV2PluginPtr & outPtr,
string & outErrMsg,
const bool inUseStdout);
947 #if defined(MSWindows)
948 NTV2Plugin (HMODULE handle,
const string & path,
const bool useStdout);
949 inline operator HMODULE()
const {
return mHandle;}
951 NTV2Plugin (
void * handle,
const string & path,
const bool useStdout);
952 inline operator void*()
const {
return mHandle;}
955 inline bool isLoaded (
void)
const {
return mHandle && !mPath.empty() ?
true :
false;}
956 void * addressForSymbol (
const string & inSymbol,
string & outErrorMsg);
962 inline bool useStdout(
void) {
return mUseStdout;}
964 #if defined(MSWindows)
976 ostringstream loadErr;
977 #if defined(AJABareMetal)
979 #elif defined(MSWindows)
981 std::wstring dllsFolderW;
983 if (!AddDllDirectory(dllsFolderW.c_str()))
985 loadErr <<
"AddDllDirectory '" << path <<
"' failed: " << WinErrStr(::GetLastError());
988 HMODULE h = ::LoadLibraryExA(LPCSTR(path.c_str()),
AJA_NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
990 loadErr <<
"Unable to open '" << path <<
"': " << WinErrStr(::GetLastError());
991 #else // MacOS or Linux
993 void * h = ::dlopen(path.c_str(), RTLD_LAZY);
996 const char * pErrorStr(::dlerror());
997 const string errStr (pErrorStr ? pErrorStr :
"");
998 loadErr <<
"Unable to open '" << path <<
"': " << errStr;
1000 #endif // MacOS or Linux
1001 if (!loadErr.str().empty())
1002 outErrMsg = loadErr.str();
1005 outPtr =
new NTV2Plugin(h, path, inUseStdout);
1009 NTV2Plugin::NTV2Plugin()
1027 #if defined(MSWindows)
1038 P_NOTE(
"Dynamic/shared library '" << mPath <<
"' (" <<
INSTP(mHandle) <<
") loaded, "
1045 #if defined(AJABareMetal)
1047 #elif !defined(MSWindows)
1049 #else // macOS or Linux
1050 ::FreeLibrary(mHandle);
1053 P_NOTE(
"Dynamic/shared library '" << mPath <<
"' (" <<
INSTP(mHandle) <<
") unloaded, "
1061 outErrorMsg.clear();
1064 if (inSymbolName.empty())
1068 #if defined(AJABareMetal)
1070 #elif defined(MSWindows)
1071 result =
reinterpret_cast<void*
>(::GetProcAddress(
reinterpret_cast<HMODULE
>(mHandle), inSymbolName.c_str()));
1073 err <<
"'GetProcAddress' failed for '" << inSymbolName <<
"': " << WinErrStr(::GetLastError());
1074 #else // MacOS or Linux
1075 result = ::dlsym(mHandle, inSymbolName.c_str());
1077 {
const char * pErrorStr(::dlerror());
1078 const string errStr (pErrorStr ? pErrorStr :
"");
1079 err <<
"'dlsym' failed for '" << inSymbolName <<
"': " << errStr;
1081 #endif // MacOS or Linux
1082 outErrorMsg = err.str();
1101 static void Terminate (
void);
1102 static inline void EnableDebugging (
const bool inEnable =
true) {sDebugRegistry = inEnable;}
1108 bool loadPlugin (
const string & path,
const string & folderPath,
NTV2PluginPtr & outPtr,
string & errMsg,
const bool useStdout);
1109 bool unloadPlugin (
const string & path,
string & errMsg);
1110 bool pluginIsLoaded (
const string & path);
1111 bool pluginForPath (
const string & path,
NTV2PluginPtr & outHandle);
1114 bool hasPath (
const string & path);
1115 bool indexForPath (
const string & path,
size_t & outIndex);
1116 ULWord countForPath (
const string & path);
1117 uint32_t * refConForPath (
const string & path);
1118 inline bool useStdout (
void)
const {
return DebuggingEnabled();}
1121 typedef map<string, NTV2PluginPtr> NTV2PluginMap;
1125 NTV2PluginMap mPluginMap;
1130 static void Monitor (
AJAThread * pThread,
void * pContext);
1131 void monitor (
void);
1134 static bool sDebugRegistry;
1138 AJALock PluginRegistry::sMutex;
1139 bool PluginRegistry::sDebugRegistry(
false);
1156 void PluginRegistry::Monitor (
AJAThread * pThread,
void * pContext)
1164 : mQuitMonitor(
false)
1166 P_NOTE (
"PluginRegistry " <<
INSTP(
this) <<
" constructed");
1167 mPluginCounts.reserve(256);
1168 for (
size_t num(0); num < 256; num++)
1169 mPluginCounts.push_back(0);
1170 mCompareCounts = mPluginCounts;
1171 mMonitor.
Attach(Monitor,
this);
1178 mQuitMonitor =
true;
1179 while (mMonitor.
Active())
1189 {
P_FAIL(
"empty path");
return false;}
1196 {
P_WARN(
INSTP(
this) <<
": '" << path <<
"': 'pluginForPath' returned false, but 'hasPath' returned true, count=" <<
countForPath(path));}
1199 {
P_FAIL(msg);
return false;}
1200 P_NOTE(
INSTP(
this) <<
": Dynamic/shared library '" << path <<
"' loaded");
1201 mPluginMap[path] = outPtr;
1202 mPluginPaths.push_back(path);
1203 mPluginCounts.at(mPluginPaths.size()-1) = 0;
1214 {
P_FAIL(
INSTP(
this) <<
": '" << path <<
"' requested to unload, but not loaded");
return false;}
1215 mPluginMap.erase(path);
1216 P_NOTE(
INSTP(
this) <<
": '" << path <<
"' unloaded");
1223 return mPluginMap.find(path) != mPluginMap.end();
1229 NTV2PluginMap::const_iterator it(mPluginMap.find(path));
1230 if (it == mPluginMap.end())
1233 outHandle = it->second;
1241 for (NTV2PluginMap::const_iterator it(mPluginMap.begin()); it != mPluginMap.end(); ++it)
1242 result.push_back(it->first);
1250 for (
size_t ndx(0); ndx < mPluginPaths.size(); ndx++)
1252 const string path (mPluginPaths.at(ndx));
1256 oss <<
"\t" << (p->
isLoaded() ?
"loaded" :
"unloaded");
1258 oss <<
"\t" <<
"---";
1259 result.push_back(oss.str());
1273 for (outIndex = 0; outIndex < mPluginPaths.size(); outIndex++)
1274 if (path == mPluginPaths.at(outIndex))
1284 return &mPluginCounts[ndx];
1292 return mPluginCounts.at(ndx);
1296 void PluginRegistry::monitor (
void)
1298 P_NOTE(
"PluginRegistry " <<
INSTP(
this) <<
" monitor started");
1299 while (!mQuitMonitor)
1303 for (
size_t ndx(0); ndx < mPluginPaths.size(); ndx++)
1305 const uint32_t oldCount(mCompareCounts.at(ndx)), newCount(mPluginCounts.at(ndx));
1306 if (newCount != oldCount)
1308 string errMsg, path(mPluginPaths.at(ndx));
1309 if (newCount > oldCount)
1310 {
P_NOTE(
"PluginRegistry " <<
INSTP(
this) <<
": Plugin '" << path <<
"' utilization "
1311 <<
"increased from " <<
DEC(oldCount) <<
" to " <<
DEC(newCount));}
1314 P_NOTE(
"PluginRegistry " <<
INSTP(
this) <<
": Plugin '" << path <<
"' utilization "
1315 <<
"decreased from " <<
DEC(oldCount) <<
" to " <<
DEC(newCount));
1319 mCompareCounts.at(ndx) = newCount;
1325 P_NOTE(
"PluginRegistry " <<
INSTP(
this) <<
" monitor stopped");
1343 void *
refCon (
void)
const;
1347 void *
getSymbolAddress (
const string & inSymbolName,
string & outErrorMsg);
1350 inline bool isOpen (
void) {
return mpPlugin ? mpPlugin->
isLoaded() :
false;}
1361 mutable string errMsg;
1367 static string mbedErrStr (
const int mbedtlsReturnCode);
1395 { cout <<
"## NOTE: Original params for '" <<
pluginPath() <<
"':" << endl;
1396 originalParams.
Print(cout,
false) << endl;
1401 { cout <<
"## NOTE: Final params for '" <<
pluginPath() <<
"':" << endl;
1402 mDict.
Print(cout,
false) << endl;
1418 mbedtls_strerror (mbedtlsReturnCode, errBuff, errBuff);
1430 for (
size_t lineNdx(0); lineNdx < lines.size(); lineNdx++)
1432 string line (lines.at(lineNdx));
1433 const bool indented (line.empty() ?
false : line.at(0) ==
' ');
1438 if (keyValPair.size() != 2)
1440 if (keyValPair.size() == 1)
1442 keyPrefix = keyValPair.at(0);
1447 PLGFAIL(
"cert info line " <<
DEC(lineNdx+1) <<
" '" << line <<
"' has "
1448 <<
DEC(keyValPair.size()) <<
" column(s) -- expected 2");
1451 string key(keyValPair.at(0)), val(keyValPair.at(1));
1453 {
PLGFAIL(
"cert info line " <<
DEC(lineNdx+1) <<
" '" << line <<
"' empty key for value '" << val <<
"'");
continue;}
1454 if (indented && !keyPrefix.empty())
1455 {
aja::strip(key); key = keyPrefix +
": " + key;}
1458 if (outInfo.hasKey(key))
1473 for (
size_t ndx(0); ndx < pairs.size(); ndx++)
1475 string assignment (pairs.at(ndx));
1476 if (assignment.find(
'=') == string::npos)
1478 if (!lastKey.empty())
1484 if (pieces.size() != 2)
1485 {
PLGFAIL(
"'" << inParentKey <<
"' assignment '" << assignment <<
"' has " << pieces.size() <<
" component(s) -- expected 2");
continue;}
1486 lastKey = pieces.at(0);
1487 string val(pieces.at(1));
1499 if (!queryStr.empty())
1500 if (queryStr[0] ==
'?')
1501 queryStr.erase(0,1);
1505 string str(*it), key, value;
1506 if (str.find(
"=") == string::npos)
1509 outQueryParams.
insert(key, value);
1510 PLGDBG(
"'" << key <<
"' = ''");
1517 if (pieces.size() > 1)
1518 value = pieces.at(1);
1520 {
PLGWARN(
"Empty key '" << key <<
"'");
continue;}
1521 if (outQueryParams.hasKey(key))
1522 PLGDBG(
"Param '" << key <<
"' value '" << outQueryParams.
valueForKey(key) <<
"' to be replaced with '" << value <<
"'");
1531 outErrorMsg.clear();
1549 if (outPath.empty())
1551 PLGDBG(
"AJA firmware path is '" << outPath <<
"'");
1553 {
P_FAIL(
"'" << outPath <<
"' doesn't end with '" <<
FIRMWARE_FOLDER <<
"'"); outPath.clear();
return false;}
1557 outPath.erase(outPath.length() - 1, 1);
1558 return !outPath.empty();
1568 {
P_FAIL(
"Missing scheme -- params: " << mDict);
return false;}
1572 return !outName.empty();
1593 const size_t maxBufSize = 512*1024*1024;
1596 dllF.open(
pluginPath(), std::ios::in | std::ios::binary);
1601 ifstream::pos_type curOffset(dllF.tellg());
1602 if (
int(curOffset) == -1)
1604 size_t size = size_t(curOffset);
1607 if (size > maxBufSize)
1608 {
P_FAIL(
"EOF not reached in plugin file '" <<
pluginPath() <<
"' -- over 500MB in size?");
return fail();}
1612 if (!dllF.seekg(0, ios_base::beg))
1613 {
P_FAIL(
"Could not seek back to start of plugin file '" <<
pluginPath() <<
"'");
return fail();}
1615 {
P_FAIL(
"EOF not reached in plugin file '" <<
pluginPath() <<
"' -- over 500MB in size?");
return fail();}
1616 tmp.
Truncate(
size_t(dllF.gcount()));
1620 ifstream sigF(
pluginSigPath().c_str(), std::ios::in | std::ios::binary);
1624 {
P_FAIL(
"EOF not reached in signature file '" <<
pluginSigPath() <<
"' -- over 500MB in size?");
return fail();}
1625 tmp.
Truncate(
size_t(sigF.gcount()));
1636 NTV2Buffer checksumFromSigFile, x509CertFromSigFile, signature;
1647 mbedtls_x509_crt crt;
1648 mbedtls_x509_crt_init(&crt);
1649 int ret = mbedtls_x509_crt_parse(&crt, x509CertFromSigFile, x509CertFromSigFile);
1652 mbedtls_x509_crt_free(&crt);
1660 int msgLength (mbedtls_x509_crt_info (msgBuff, msgBuff,
"", &crt));
1661 string msg (msgBuff,
size_t(msgLength));
1663 {
P_FAIL(
"'mbedtls_x509_crt_info' returned no info for X509 cert found in '" <<
pluginSigPath() <<
"'");
1667 cout <<
"## DEBUG: Raw X509 certificate info extracted from signature file '" <<
pluginSigPath() <<
"':" << endl
1668 <<
" " << msg << endl;
1672 { cout <<
"## NOTE: X509 certificate info extracted from signature file '" <<
pluginSigPath() <<
"':" << endl;
1673 certInfo.
Print(cout,
false) << endl;
1675 if (certInfo.hasKey(
"issuer name"))
1678 if (certInfo.hasKey(
"subject name"))
1686 { cout <<
"## NOTE: 'issuer name' info:" << endl;
1687 issuerInfo.
Print(cout,
false) << endl;
1689 if (
isVerbose() && !subjectInfo.empty())
1690 { cout <<
"## NOTE: 'subject name' info:" << endl;
1691 subjectInfo.
Print(cout,
false) << endl;
1710 ret = mbedtls_md_file (mbedtls_md_info_from_type(MBEDTLS_MD_SHA256),
pluginPath().c_str(), checksumFromDLL);
1715 if (
isVerbose()) {
string str;
if (checksumFromDLL.
toHexString(str)) cout <<
"## DEBUG: Digest: " << str << endl;}
1718 ret = mbedtls_pk_verify (&crt.pk, MBEDTLS_MD_SHA256,
1720 signature, signature);
1725 mbedtls_x509_crt_free(&crt);
1726 P_DBG(
"'mbedtls_pk_verify' succeeded for '" <<
pluginPath() <<
"' -- signature valid");
1746 if (regInfo.empty())
1755 for (
size_t ndx(0); ndx < reqKeys.size(); ndx++)
1756 if (!regInfo.hasKey(reqKeys.at(ndx)))
1757 missingRegInfoKeys.push_back(reqKeys.at(ndx));
1758 if (!missingRegInfoKeys.empty())
1759 {
P_FAIL(
"'" <<
pluginPath() <<
"': missing key(s) in registration info: '"
1760 <<
aja::join(missingRegInfoKeys,
"','") <<
"'");
1777 if (onReg != onCert)
1780 <<
"') \"" << onCert <<
"\" from X509 certificate 'Issuer' in '" <<
pluginSigPath() <<
"'");
1783 if (cnReg != cnCert)
1786 <<
"') \"" << cnCert <<
"\" from X509 certificate 'Issuer' in '" <<
pluginSigPath() <<
"'");
1789 if (ouReg != ouCert)
1792 <<
"') \"" << ouCert <<
"\" from X509 certificate 'Subject' in '" <<
pluginSigPath() <<
"'");
1795 if (myVers != plVers)
1797 <<
"\" doesn't match client SDK version '" << myVers <<
"'");
1800 if (fingerprint != ajaFingerprint)
1802 <<
"Issuer serial: " << fingerprint <<
"|AJA serial: " << ajaFingerprint);
1831 return mpPlugin && mValidated;
1838 cout <<
"0 plugins" << endl;
1839 else if (paths.size() == 1)
1840 cout <<
"1 plugin: " << paths.at(0) << endl;
1841 else cout <<
DEC(paths.size()) <<
" plugins:" << endl <<
aja::join(paths,
"\n") << endl;
1843 #endif // !defined(NTV2_PREVENT_PLUGIN_LOAD)
1861 {cout << __FILE__ <<
"(" << __LINE__ <<
"):" <<
AJAFUNC <<
":" << endl;
mParams.
Print(cout,
false) << endl;}
1876 size_t oldCount(
mParams.size()), updated(0), added(0);
1886 NBSDBG(
DEC(oldCount) <<
" param(s) removed, replaced with " << inNewParams);
1900 while (nums.size() > 3)
1908 static const string sAJAFingerprint (
"70:1A:37:93:FA:4F:34:30:58:55:51:0C:01:4E:45:7C:BE:5B:41:65");
1909 string result(sAJAFingerprint);
1947 return mParams.hasKey(inParam);
1963 oss << (IsConnected() ?
"Connected" :
"Disconnected");
1964 if (IsConnected() && !Name().empty())
1965 oss <<
" to '" << Name() <<
"'";
1997 { (
void) autoCircData;
2002 { (
void) eInterrupt; (
void) timeOutMs;
2006 #if !defined(NTV2_DEPRECATE_16_3)
2008 { (
void) bitFileType;
2009 ::memset(&bitFileInfo, 0,
sizeof(bitFileInfo));
2015 ::memset(&buildInfo, 0,
sizeof(buildInfo));
2020 const UWord signalMask,
const bool testPatDMAEnb,
const ULWord testPatNum)
2021 { (
void) channel; (
void) testPatternFBF; (
void) signalMask; (
void) testPatDMAEnb; (
void) testPatNum;
2026 { (
void) numRegs; (
void) outFailedRegNum; (
void) outRegs;
2032 outDriverVersion = 0xFFFFFFFF;
2035 #endif // !defined(NTV2_DEPRECATE_16_3)
2039 const ULWord inNumSegments,
const ULWord inSegmentHostPitch,
2040 const ULWord inSegmentCardPitch,
const bool inSynchronous)
2041 { (
void) inDMAEngine; (
void) inIsRead; (
void) inFrameNumber; (
void) inOutFrameBuffer;
2042 (
void) inCardOffsetBytes; (
void) inNumSegments; (
void) inSegmentHostPitch;
2043 (
void) inSegmentCardPitch; (
void) inSynchronous;
2048 { (
void) pInMessage;
2066 outSupported.clear();
2084 #if defined(NTV2_PREVENT_PLUGIN_LOAD)
2112 #if defined(NTV2_PREVENT_PLUGIN_LOAD)
2136 if (parser.HasErrors())
2184 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)
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)
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
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
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
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
#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 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)
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
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...
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
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 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
#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.