|
AJA NTV2 SDK
17.1.3.1410
NTV2 SDK 17.1.3.1410
|
Go to the documentation of this file.
18 #if !defined(NTV2_PREVENT_PLUGIN_LOAD)
20 #include "mbedtls/x509.h"
21 #include "mbedtls/error.h"
22 #include "mbedtls/md.h"
23 #include "mbedtls/ssl.h"
24 #endif // defined(NTV2_PREVENT_PLUGIN_LOAD)
26 #include <CoreFoundation/CoreFoundation.h>
28 #define DLL_EXTENSION ".dylib"
29 #define PATH_DELIMITER "/"
30 #define FIRMWARE_FOLDER "Firmware" PATH_DELIMITER
31 #elif defined(AJALinux)
33 #define DLL_EXTENSION ".so"
34 #define PATH_DELIMITER "/"
35 #define FIRMWARE_FOLDER "firmware" PATH_DELIMITER
36 #elif defined(MSWindows)
37 #define DLL_EXTENSION ".dll"
38 #define PATH_DELIMITER "\\"
39 #define FIRMWARE_FOLDER "Firmware" PATH_DELIMITER
40 #elif defined(AJABareMetal)
41 #define DLL_EXTENSION ".so"
42 #define PATH_DELIMITER "/"
43 #define FIRMWARE_FOLDER "firmware" PATH_DELIMITER
45 #define SIG_EXTENSION ".sig"
49 #define INSTP(_p_) xHEX0N(uint64_t(_p_),16)
50 #define NBFAIL(__x__) AJA_sERROR (AJA_DebugUnit_RPCClient, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
51 #define NBWARN(__x__) AJA_sWARNING(AJA_DebugUnit_RPCClient, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
52 #define NBNOTE(__x__) AJA_sNOTICE (AJA_DebugUnit_RPCClient, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
53 #define NBINFO(__x__) AJA_sINFO (AJA_DebugUnit_RPCClient, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
54 #define NBDBG(__x__) AJA_sDEBUG (AJA_DebugUnit_RPCClient, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
55 #define NBCFAIL(__x__) AJA_sERROR (AJA_DebugUnit_RPCClient, AJAFUNC << ": " << __x__)
56 #define NBCWARN(__x__) AJA_sWARNING(AJA_DebugUnit_RPCClient, AJAFUNC << ": " << __x__)
57 #define NBCNOTE(__x__) AJA_sNOTICE (AJA_DebugUnit_RPCClient, AJAFUNC << ": " << __x__)
58 #define NBCINFO(__x__) AJA_sINFO (AJA_DebugUnit_RPCClient, AJAFUNC << ": " << __x__)
59 #define NBCDBG(__x__) AJA_sDEBUG (AJA_DebugUnit_RPCClient, AJAFUNC << ": " << __x__)
60 #define NBSFAIL(__x__) AJA_sERROR (AJA_DebugUnit_RPCServer, AJAFUNC << ": " << __x__)
61 #define NBSWARN(__x__) AJA_sWARNING(AJA_DebugUnit_RPCServer, AJAFUNC << ": " << __x__)
62 #define NBSNOTE(__x__) AJA_sNOTICE (AJA_DebugUnit_RPCServer, AJAFUNC << ": " << __x__)
63 #define NBSINFO(__x__) AJA_sINFO (AJA_DebugUnit_RPCServer, AJAFUNC << ": " << __x__)
64 #define NBSDBG(__x__) AJA_sDEBUG (AJA_DebugUnit_RPCServer, AJAFUNC << ": " << __x__)
66 #define PLGFAIL(__x__) AJA_sERROR (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
67 #define PLGWARN(__x__) AJA_sWARNING(AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
68 #define PLGNOTE(__x__) AJA_sNOTICE (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
69 #define PLGINFO(__x__) AJA_sINFO (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
70 #define PLGDBG(__x__) AJA_sDEBUG (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
72 #define P_FAIL(__x__) if (useStdout()) cout << "## ERROR: " << AJAFUNC << ": " << __x__ << endl; \
73 AJA_sERROR (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
74 #define P_WARN(__x__) if (useStdout()) cout << "## WARNING: " << AJAFUNC << ": " << __x__ << endl; \
75 AJA_sWARNING(AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
76 #define P_NOTE(__x__) if (useStdout()) cout << "## NOTE: " << AJAFUNC << ": " << __x__ << endl; \
77 AJA_sNOTICE (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
78 #define P_INFO(__x__) if (useStdout()) cout << "## INFO: " << AJAFUNC << ": " << __x__ << endl; \
79 AJA_sINFO (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
80 #define P_DBG(__x__) if (useStdout()) cout << "## DEBUG: " << AJAFUNC << ": " << __x__ << endl; \
81 AJA_sDEBUG (AJA_DebugUnit_Plugins, AJAFUNC << ": " << __x__)
82 #define _DEBUGSTATS_ // Define this to log above construct/destruct & open/close tallies
83 #if defined(_DEBUGSTATS_)
84 #define PDBGX(__x__) AJA_sDEBUG (AJA_DebugUnit_Plugins, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
106 if (it == mDict.end())
113 string str(valueForKey(inKey));
116 if (str.find(
"0x") == 0 || str.find(
"0X") == 0)
123 if (str.find(
"x") == 0 || str.find(
"X") == 0)
130 if (str.find(
"o") == 0 || str.find(
"O") == 0)
137 if (str.find(
"b") == 0 || str.find(
"B") == 0)
152 const string & key(it->first), val(it->second), quote(val.find(
' ') != string::npos ?
"'" :
"");
153 oss << key <<
"=" << quote << val << quote;
154 if (++it != mDict.end())
161 const int kyWdth(
int(largestKeySize()+0)), valWdth(
int(largestValueSize()+0));
162 oss << string(
size_t(kyWdth),
'-') <<
" " << string(
size_t(valWdth),
'-') << endl;
165 const string & key(it->first), val(it->second);
166 oss << std::setw(kyWdth) << key <<
" : " << val;
167 if (++it != mDict.end())
176 size_t badKVPairs(0), insertFailures(0);
182 if (keyValPair.size() != 2)
183 {badKVPairs++;
continue;}
184 const string k(keyValPair.at(0)), v(keyValPair.at(1));
188 return !empty() && !badKVPairs && !insertFailures;
197 oss << it->first <<
"\t" << it->second;
198 if (++it != mDict.end())
202 return !outStr.empty();
208 for (
DictConstIter it(mDict.begin()); it != mDict.end(); ++it)
209 result.insert(it->first);
216 for (
DictConstIter it(mDict.begin()); it != mDict.end(); ++it)
217 if (it->first.length() > result)
218 result = it->first.length();
225 for (
DictConstIter it(mDict.begin()); it != mDict.end(); ++it)
226 if (it->second.length() > result)
227 result = it->second.length();
235 if (inKey.find(
"\t") != string::npos)
237 if (inKey.find(
"\n") != string::npos)
239 if (inValue.find(
"\t") != string::npos)
241 if (inValue.find(
"\n") != string::npos)
243 mDict[inKey] = inValue;
249 size_t numUpdated(0);
250 for (
DictConstIter it(inDict.mDict.begin()); it != inDict.mDict.end(); ++it)
251 if (hasKey(it->first))
252 {mDict[it->first] = it->second; numUpdated++;}
259 for (
DictConstIter it(inDict.mDict.begin()); it != inDict.mDict.end(); ++it)
260 if (!hasKey(it->first))
261 {mDict[it->first] = it->second; numAdded++;}
275 mQueryParams.clear();
287 if (!inStripLeadSlash)
289 if (rsrc.at(0) ==
'/')
294 void NTV2DeviceSpecParser::Parse (
void)
303 string tokDevID, tokIndexNum, tokScheme, tokSerial, tokModelName;
304 size_t posDevID(0), posIndexNum(0), posScheme(0), posSerial(0), posModelName(0);
305 bool isSerial(ParseSerialNum(posSerial, tokSerial)), isScheme(ParseScheme(posScheme, tokScheme));
306 bool isIndexNum(ParseDecNumber(posIndexNum, tokIndexNum)), isDeviceID(ParseDeviceID(posDevID, tokDevID));
307 bool isModelName(ParseModelName(posModelName, tokModelName));
310 posDevID = posIndexNum = posSerial = posModelName = posScheme;
311 isSerial = ParseSerialNum(posSerial, tokSerial);
312 isIndexNum = ParseDecNumber(posIndexNum, tokIndexNum);
313 isDeviceID = ParseDeviceID(posDevID, tokDevID);
314 isModelName = ParseModelName(posModelName, tokModelName);
327 bool converted(
false);
329 if (tokSerial.length() == 18)
332 const bool hasLeading0X (tokSerial.find(
"0X") == 0 || tokSerial.find(
"0x") == 0);
333 const string hex64(tokSerial.substr(hasLeading0X ? 2 : 0, 16));
336 for (
size_t ndx(0); ndx < 8; ndx++)
337 serTxt +=
char(serNum64 >> ((7-ndx)*8));
343 for (
size_t ndx(0); ndx < tokSerial.length(); ndx++)
344 {
char ch(tokSerial.at(ndx));
345 if ( ! ( ( (ch >=
'0') && (ch <=
'9') ) ||
346 ( (ch >=
'A') && (ch <=
'Z') ) ||
347 ( (ch >=
'a') && (ch <=
'z') ) ||
348 (ch ==
' ') || (ch ==
'-') ) )
350 err <<
"Illegal serial number character '" << (ch ? ch :
'?') <<
"' (" <<
xHEX0N(
UWord(ch),2) <<
")";
352 mPos -= converted ? 16 : 8; mPos += ndx * (converted ? 2 : 1) + (converted ? 1 : 0);
376 err <<
"Invalid local device specification";
378 mPos += isScheme ? 12 : 0;
384 if (!IsSupportedScheme(tokScheme))
385 {err <<
"Unsupported scheme '" << tokScheme <<
"'"; AddError(err.str()); mPos -= 3;
break;}
391 size_t posURL(posScheme), posRsrc(0);
392 string host, port, rsrcPath;
393 if (!ParseHostAddressAndPortNumber(posURL, host, port))
394 {mPos = posURL; AddError(
"Bad host address or port number");
break;}
403 if (ParseResourcePath(posRsrc, rsrcPath))
406 size_t posQuery(mPos);
408 if (ParseQuery(posQuery, params))
411 mQueryParams = params;
414 if (mPos < SpecLength())
415 {err <<
"Extra character(s) at " <<
DEC(mPos); AddError(err.str());
break;}
424 #endif // defined(_DEBUG)
430 oss <<
"local device";
431 else if (HasScheme())
432 oss <<
"device '" << Scheme() <<
"'";
436 oss <<
" serial '" << DeviceSerial() <<
"'";
438 oss <<
" model '" << DeviceModel() <<
"'";
440 oss <<
" ID '" << DeviceID() <<
"'";
442 oss <<
" " << DeviceIndex();
452 {oss << endl; Results().Print(oss,
false);}
473 if (devIDStr.find(
"0X") != string::npos)
488 oss <<
DEC(ErrorCount()) << (ErrorCount() == 1 ?
" error" :
" errors") << (HasErrors() ?
":" :
"");
492 << DeviceSpec() << endl
493 << string(mPos ? mPos : 0,
' ') <<
"^" << endl;
494 for (
size_t num(0); num < ErrorCount(); )
497 if (++num < ErrorCount())
504 bool NTV2DeviceSpecParser::ParseHexNumber (
size_t & pos,
string & outToken)
508 while (pos < SpecLength())
510 const char ch(CharAt(pos));
511 if (tokHexNum.length() == 0)
515 ++pos; tokHexNum = ch;
517 else if (tokHexNum.length() == 1)
519 if (ch !=
'x' && ch !=
'X')
521 ++pos; tokHexNum += ch;
527 ++pos; tokHexNum += ch;
530 if (tokHexNum.length() > 2)
531 {
aja::upper(tokHexNum); outToken = tokHexNum;}
532 return !outToken.empty();
535 bool NTV2DeviceSpecParser::ParseDecNumber (
size_t & pos,
string & outToken)
539 while (pos < SpecLength())
541 const char ch(CharAt(pos));
542 if (!IsDecimalDigit(ch))
545 if (ch !=
'0' || tokDecNum !=
"0")
548 if (tokDecNum.length() > 0)
549 outToken = tokDecNum;
550 return !outToken.empty();
553 bool NTV2DeviceSpecParser::ParseAlphaNumeric (
size_t & pos,
string & outToken,
const std::string & inOtherChars)
557 while (pos < SpecLength())
559 const char ch(CharAt(pos));
560 if (!IsLetter(ch) && !IsDecimalDigit(ch) && inOtherChars.find(ch) == string::npos)
562 ++pos; tokAlphaNum += ch;
564 if (tokAlphaNum.length() > 1)
565 outToken = tokAlphaNum;
566 return !outToken.empty();
569 bool NTV2DeviceSpecParser::ParseScheme (
size_t & pos,
string & outToken)
572 string rawScheme, tokScheme;
573 while (ParseAlphaNumeric(pos, rawScheme))
575 tokScheme = rawScheme;
576 char ch(CharAt(pos));
579 ++pos; tokScheme += ch;
584 ++pos; tokScheme += ch;
589 ++pos; tokScheme += ch;
592 if (tokScheme.find(
"://") != string::npos)
593 {
aja::lower(rawScheme); outToken = rawScheme;}
594 return !outToken.empty();
597 bool NTV2DeviceSpecParser::ParseSerialNum (
size_t & pos,
string & outToken)
600 string tokAlphaNum, tokHexNum;
601 size_t posAlphaNum(pos), posHexNum(pos);
604 while (posAlphaNum < SpecLength())
606 const char ch(CharAt(posAlphaNum));
607 if (!IsUpperLetter(ch) && !IsDecimalDigit(ch) && ch !=
'-' && ch !=
' ')
609 ++posAlphaNum; tokAlphaNum += ch;
611 if (tokAlphaNum.length() < 2)
613 else if (tokAlphaNum.length() == 8 || tokAlphaNum.length() == 9)
614 {pos = posAlphaNum; outToken = tokAlphaNum;
break;}
616 if (ParseHexNumber(posHexNum, tokHexNum))
617 if (tokHexNum.length() == 18)
618 {pos = posHexNum; outToken = tokHexNum;}
620 return !outToken.empty();
623 bool NTV2DeviceSpecParser::ParseDeviceID (
size_t & pos,
string & outToken)
627 if (!ParseHexNumber(pos, tokHexNum))
629 if (tokHexNum.length() != 10)
638 ostringstream devID; devID <<
xHEX0N(*it,8);
639 string devIDStr(devID.str());
641 devIDStrs.insert(devIDStr);
643 if (devIDStrs.find(tokHexNum) != devIDStrs.end())
644 outToken = tokHexNum;
645 return !outToken.empty();
648 bool NTV2DeviceSpecParser::ParseModelName (
size_t & pos,
string & outToken)
652 if (!ParseAlphaNumeric(pos, tokName))
663 modelNames.insert(modelName);
665 if (modelNames.find(tokName) != modelNames.end())
667 return !outToken.empty();
670 bool NTV2DeviceSpecParser::ParseDNSName (
size_t & pos,
string & outDNSName)
673 string dnsName, name;
676 while (ParseAlphaNumeric(dnsPos, name,
"_-"))
678 if (!dnsName.empty())
686 if (!dnsName.empty())
688 outDNSName = dnsName;
689 return !outDNSName.empty();
692 bool NTV2DeviceSpecParser::ParseIPv4Address (
size_t & pos,
string & outIPv4)
695 string ipv4Name, num;
698 while (ParseDecNumber(ipv4Pos, num))
700 if (!ipv4Name.empty())
703 ch = CharAt(ipv4Pos);
708 if (!ipv4Name.empty())
711 return !outIPv4.empty();
714 bool NTV2DeviceSpecParser::ParseHostAddressAndPortNumber (
size_t & pos,
string & outAddr,
string & outPort)
716 outAddr.clear(); outPort.clear();
718 string dnsName, ipv4, port;
719 size_t dnsPos(pos), ipv4Pos(pos), portPos(0);
720 bool isDNS(ParseDNSName(dnsPos, dnsName)), isIPv4(ParseIPv4Address(ipv4Pos, ipv4));
721 if (!isDNS && !isIPv4)
722 {pos = dnsPos < ipv4Pos ? ipv4Pos : dnsPos;
return false;}
725 {outAddr = ipv4; pos = portPos = ipv4Pos;}
727 {outAddr = dnsName; pos = portPos = dnsPos;}
730 char ch (CharAt(portPos));
734 if (!ParseDecNumber(portPos, port))
735 {pos = portPos;
return false;}
741 bool NTV2DeviceSpecParser::ParseResourcePath (
size_t & pos,
string & outRsrc)
746 char ch(CharAt(rsrcPos));
751 if (!ParseAlphaNumeric(rsrcPos, name))
754 ch = CharAt(rsrcPos);
759 return !outRsrc.empty();
762 bool NTV2DeviceSpecParser::ParseParamAssignment (
size_t & pos,
string & outKey,
string & outValue)
764 outKey.clear(); outValue.clear();
766 size_t paramPos(pos);
767 char ch(CharAt(paramPos));
769 ch = CharAt(++paramPos);
772 if (!ParseAlphaNumeric(paramPos, key))
774 ch = CharAt(paramPos);
777 ch = CharAt(++paramPos);
778 while (ch != 0 && ch !=
'&')
781 ch = CharAt(++paramPos);
785 {pos = paramPos; outKey =
key; outValue =
value;}
789 bool NTV2DeviceSpecParser::ParseQuery (
size_t & pos,
NTV2Dictionary & outParams)
793 size_t queryPos(pos);
794 char ch(CharAt(queryPos));
799 while (ParseParamAssignment(queryPos, key, value))
801 outParams.
insert(key, value);
802 ch = CharAt(queryPos);
806 if (!outParams.empty())
808 return !outParams.empty();
813 return inScheme.find(
"ntv2") == 0;
816 bool NTV2DeviceSpecParser::IsUpperLetter (
const char inChar)
817 {
static const string sHexDigits(
"_ABCDEFGHIJKLMNOPQRSTUVWXYZ");
818 return sHexDigits.find(inChar) != string::npos;
821 bool NTV2DeviceSpecParser::IsLowerLetter (
const char inChar)
822 {
static const string sHexDigits(
"abcdefghijklmnopqrstuvwxyz");
823 return sHexDigits.find(inChar) != string::npos;
826 bool NTV2DeviceSpecParser::IsLetter (
const char inChar,
const bool inIncludeUnderscore)
827 {
return (inIncludeUnderscore && inChar ==
'_') || IsUpperLetter(inChar) || IsLowerLetter(inChar);
830 bool NTV2DeviceSpecParser::IsDecimalDigit (
const char inChar)
831 {
static const string sDecDigits(
"0123456789");
832 return sDecDigits.find(inChar) != string::npos;
835 bool NTV2DeviceSpecParser::IsHexDigit (
const char inChar)
836 {
static const string sHexDigits(
"0123456789ABCDEFabcdef");
837 return sHexDigits.find(inChar) != string::npos;
840 bool NTV2DeviceSpecParser::IsLegalSerialNumChar (
const char inChar)
841 {
return IsLetter(inChar) || IsDecimalDigit(inChar);
845 void NTV2DeviceSpecParser::test (
void)
848 specParser.
Reset(
"1");
849 specParser.
Reset(
"00000000000000000000000000000000000000000000000000000000000000000000000000000000000001");
850 specParser.
Reset(
"corvid24");
851 specParser.
Reset(
"corvid88");
852 specParser.
Reset(
"konalhi");
853 specParser.
Reset(
"alpha");
854 specParser.
Reset(
"00T64450");
855 specParser.
Reset(
"00t6-450");
856 specParser.
Reset(
"BLATZBE0");
857 specParser.
Reset(
"0x424C41545A424530");
858 specParser.
Reset(
"0x424C415425424530");
860 specParser.
Reset(
"badscheme://1");
862 specParser.
Reset(
"ntv2local://1");
863 specParser.
Reset(
"NtV2lOcAl://00000000000000000000000000000000000000000000000000000000000000000000000000000000000001");
864 specParser.
Reset(
"NTV2Local://corvid24");
865 specParser.
Reset(
"ntv2local://corvid88");
866 specParser.
Reset(
"ntv2local://konalhi");
867 specParser.
Reset(
"ntv2local://alpha");
868 specParser.
Reset(
"ntv2local://00T64450");
869 specParser.
Reset(
"ntv2local://00t6-450");
870 specParser.
Reset(
"ntv2local://BLATZBE0");
872 specParser.
Reset(
"ntv2nub://1.2.3.4");
873 specParser.
Reset(
"ntv2nub://1.2.3.4/doc");
874 specParser.
Reset(
"ntv2nub://1.2.3.4/doc/");
875 specParser.
Reset(
"ntv2nub://1.2.3.4/doc/alpha?one&two=2&three=&four=4");
876 specParser.
Reset(
"ntv2nub://1.2.3.4/doc/?one&two=2&three=&four=4");
877 specParser.
Reset(
"ntv2nub://1.2.3.4:badport/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:200/doc/?one&two=2&three=&four=4");
880 specParser.
Reset(
"ntv2nub://1.2.3.4:12345");
881 specParser.
Reset(
"ntv2nub://1.2.3.4:65000/doc");
882 specParser.
Reset(
"ntv2nub://1.2.3.4:32767/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?");
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=");
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");
892 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc/?one=1&two");
893 specParser.
Reset(
"ntv2nub://1.2.3.4/path/to/doc?one=1&two");
894 specParser.
Reset(
"ntv2nub://50.200.250.300");
895 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.com/path/to/doc/?one=1&two");
896 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.edu:badport/path/to/doc/?one=1&two");
897 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.info:5544/path/to/doc/?one=1&two");
898 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.org/path/to/doc/?one=1&two");
899 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.nz:badport/path/to/doc/?one=1&two");
900 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.au:000004/path/to/doc/?one=1&two");
901 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.ch:4/corvid88");
902 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.cn:4/00T64450");
903 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.ru:4/2");
904 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.co.uk:4/00000000000000000000000000000001");
905 specParser.
Reset(
"ntv2nub://fully.qualified.domain.name.com:4/0000000000000000000000000000000001");
906 specParser.
Reset(
"ntv2://swdevice/?"
908 "&supportlog=file%3A%2F%2F%2FUsers%2Fdemo%2FDesktop%2FAJAWatcherSupport.log"
909 "&sdram=file%3A%2F%2F%2FUsers%2Fdemo%2FDesktop%2FSDRAMsnapshot.dat");
911 #endif // defined(_DEBUG)
913 #if defined(MSWindows)
914 static string WinErrStr (
const DWORD inErr)
916 string result(
"foo");
918 const DWORD res(FormatMessage ( FORMAT_MESSAGE_ALLOCATE_BUFFER
919 | FORMAT_MESSAGE_FROM_SYSTEM
920 | FORMAT_MESSAGE_IGNORE_INSERTS,
923 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
929 result =
reinterpret_cast<const char *
>(lpMsgBuf);
937 #if defined(NTV2_PREVENT_PLUGIN_LOAD)
939 #else // !defined(NTV2_PREVENT_PLUGIN_LOAD)
953 static bool LoadPlugin (
const string & path,
const string & folderPath,
NTV2PluginPtr & outPtr,
string & outErrMsg,
const bool inUseStdout);
956 #if defined(MSWindows)
957 NTV2Plugin (HMODULE handle,
const string & path,
const bool useStdout);
958 inline operator HMODULE()
const {
return mHandle;}
960 NTV2Plugin (
void * handle,
const string & path,
const bool useStdout);
961 inline operator void*()
const {
return mHandle;}
964 inline bool isLoaded (
void)
const {
return mHandle && !mPath.empty() ?
true :
false;}
965 void * addressForSymbol (
const string & inSymbol,
string & outErrorMsg);
971 inline bool useStdout(
void) {
return mUseStdout;}
973 #if defined(MSWindows)
985 ostringstream loadErr;
986 #if defined(AJABareMetal)
988 #elif defined(MSWindows)
990 std::wstring dllsFolderW;
992 if (!AddDllDirectory(dllsFolderW.c_str()))
994 loadErr <<
"AddDllDirectory '" << path <<
"' failed: " << WinErrStr(::GetLastError());
997 HMODULE h = ::LoadLibraryExA(LPCSTR(path.c_str()),
AJA_NULL, LOAD_LIBRARY_SEARCH_USER_DIRS);
999 loadErr <<
"Unable to open '" << path <<
"': " << WinErrStr(::GetLastError());
1000 #else // MacOS or Linux
1002 void * h = ::dlopen(path.c_str(), RTLD_LAZY);
1005 const char * pErrorStr(::dlerror());
1006 const string errStr (pErrorStr ? pErrorStr :
"");
1007 loadErr <<
"Unable to open '" << path <<
"': " << errStr;
1009 #endif // MacOS or Linux
1010 if (!loadErr.str().empty())
1011 outErrMsg = loadErr.str();
1014 outPtr =
new NTV2Plugin(h, path, inUseStdout);
1018 NTV2Plugin::NTV2Plugin()
1036 #if defined(MSWindows)
1047 P_NOTE(
"Dynamic/shared library '" << mPath <<
"' (" <<
INSTP(mHandle) <<
") loaded, "
1054 #if defined(AJABareMetal)
1056 #elif !defined(MSWindows)
1058 #else // macOS or Linux
1059 ::FreeLibrary(mHandle);
1062 P_NOTE(
"Dynamic/shared library '" << mPath <<
"' (" <<
INSTP(mHandle) <<
") unloaded, "
1070 outErrorMsg.clear();
1073 if (inSymbolName.empty())
1077 #if defined(AJABareMetal)
1079 #elif defined(MSWindows)
1080 result =
reinterpret_cast<void*
>(::GetProcAddress(
reinterpret_cast<HMODULE
>(mHandle), inSymbolName.c_str()));
1082 err <<
"'GetProcAddress' failed for '" << inSymbolName <<
"': " << WinErrStr(::GetLastError());
1083 #else // MacOS or Linux
1084 result = ::dlsym(mHandle, inSymbolName.c_str());
1086 {
const char * pErrorStr(::dlerror());
1087 const string errStr (pErrorStr ? pErrorStr :
"");
1088 err <<
"'dlsym' failed for '" << inSymbolName <<
"': " << errStr;
1090 #endif // MacOS or Linux
1091 outErrorMsg = err.str();
1110 static void Terminate (
void);
1111 static inline void EnableDebugging (
const bool inEnable =
true) {sDebugRegistry = inEnable;}
1117 bool loadPlugin (
const string & path,
const string & folderPath,
NTV2PluginPtr & outPtr,
const bool useStdout);
1118 bool unloadPlugin (
const string & path);
1119 bool pluginIsLoaded (
const string & path);
1120 bool pluginForPath (
const string & path,
NTV2PluginPtr & outHandle);
1123 bool hasPath (
const string & path);
1124 bool indexForPath (
const string & path,
size_t & outIndex);
1125 ULWord countForPath (
const string & path);
1126 uint32_t * refConForPath (
const string & path);
1127 inline bool useStdout (
void)
const {
return DebuggingEnabled();}
1130 typedef map<string, NTV2PluginPtr> NTV2PluginMap;
1134 NTV2PluginMap mPluginMap;
1139 static void Monitor (
AJAThread * pThread,
void * pContext);
1140 void monitor (
void);
1143 static bool sDebugRegistry;
1147 AJALock PluginRegistry::sMutex;
1148 bool PluginRegistry::sDebugRegistry(
false);
1165 void PluginRegistry::Monitor (
AJAThread * pThread,
void * pContext)
1173 : mQuitMonitor(
false)
1175 P_NOTE (
"PluginRegistry " <<
INSTP(
this) <<
" constructed");
1176 mPluginCounts.reserve(256);
1177 for (
size_t num(0); num < 256; num++)
1178 mPluginCounts.push_back(0);
1179 mCompareCounts = mPluginCounts;
1180 mMonitor.
Attach(Monitor,
this);
1187 mQuitMonitor =
true;
1188 while (mMonitor.
Active())
1205 {
P_WARN(
INSTP(
this) <<
": '" << path <<
"': 'pluginForPath' returned false, but 'hasPath' returned true, count=" <<
countForPath(path));}
1208 {
P_FAIL(errMsg);
return false;}
1209 P_NOTE(
INSTP(
this) <<
": Dynamic/shared library '" << path <<
"' loaded");
1210 mPluginMap[path] = outPtr;
1211 mPluginPaths.push_back(path);
1212 mPluginCounts.at(mPluginPaths.size()-1) = 0;
1223 {
P_FAIL(
INSTP(
this) <<
": '" << path <<
"' requested to unload, but not loaded");
return false;}
1224 mPluginMap.erase(path);
1225 P_NOTE(
INSTP(
this) <<
": '" << path <<
"' unloaded");
1232 return mPluginMap.find(path) != mPluginMap.end();
1238 NTV2PluginMap::const_iterator it(mPluginMap.find(path));
1239 if (it == mPluginMap.end())
1242 outHandle = it->second;
1250 for (NTV2PluginMap::const_iterator it(mPluginMap.begin()); it != mPluginMap.end(); ++it)
1251 result.push_back(it->first);
1259 for (
size_t ndx(0); ndx < mPluginPaths.size(); ndx++)
1261 const string path (mPluginPaths.at(ndx));
1265 oss <<
"\t" << (p->
isLoaded() ?
"loaded" :
"unloaded");
1267 oss <<
"\t" <<
"---";
1268 result.push_back(oss.str());
1282 for (outIndex = 0; outIndex < mPluginPaths.size(); outIndex++)
1283 if (path == mPluginPaths.at(outIndex))
1293 return &mPluginCounts[ndx];
1301 return mPluginCounts.at(ndx);
1305 void PluginRegistry::monitor (
void)
1307 P_NOTE(
"PluginRegistry " <<
INSTP(
this) <<
" monitor started");
1308 while (!mQuitMonitor)
1312 for (
size_t ndx(0); ndx < mPluginPaths.size(); ndx++)
1314 const uint32_t oldCount(mCompareCounts.at(ndx)), newCount(mPluginCounts.at(ndx));
1315 if (newCount != oldCount)
1317 const string path (mPluginPaths.at(ndx));
1318 if (newCount > oldCount)
1319 {
P_NOTE(
"PluginRegistry " <<
INSTP(
this) <<
": Plugin '" << path <<
"' utilization "
1320 <<
"increased from " <<
DEC(oldCount) <<
" to " <<
DEC(newCount));}
1323 P_NOTE(
"PluginRegistry " <<
INSTP(
this) <<
": Plugin '" << path <<
"' utilization "
1324 <<
"decreased from " <<
DEC(oldCount) <<
" to " <<
DEC(newCount));
1328 mCompareCounts.at(ndx) = newCount;
1334 P_NOTE(
"PluginRegistry " <<
INSTP(
this) <<
" monitor stopped");
1352 void *
refCon (
void)
const;
1356 void *
getSymbolAddress (
const string & inSymbolName,
string & outErrorMsg);
1359 inline bool isOpen (
void) {
return mpPlugin ? mpPlugin->
isLoaded() :
false;}
1374 static string mbedErrStr (
const int mbedtlsReturnCode);
1402 { cout <<
"## NOTE: Original params for '" <<
pluginPath() <<
"':" << endl;
1403 originalParams.
Print(cout,
false) << endl;
1408 { cout <<
"## NOTE: Final params for '" <<
pluginPath() <<
"':" << endl;
1409 mDict.
Print(cout,
false) << endl;
1425 mbedtls_strerror (mbedtlsReturnCode, errBuff, errBuff);
1437 for (
size_t lineNdx(0); lineNdx < lines.size(); lineNdx++)
1439 string line (lines.at(lineNdx));
1440 const bool indented (line.empty() ?
false : line.at(0) ==
' ');
1445 if (keyValPair.size() != 2)
1447 if (keyValPair.size() == 1)
1449 keyPrefix = keyValPair.at(0);
1454 PLGFAIL(
"cert info line " <<
DEC(lineNdx+1) <<
" '" << line <<
"' has "
1455 <<
DEC(keyValPair.size()) <<
" column(s) -- expected 2");
1458 string key(keyValPair.at(0)), val(keyValPair.at(1));
1460 {
PLGFAIL(
"cert info line " <<
DEC(lineNdx+1) <<
" '" << line <<
"' empty key for value '" << val <<
"'");
continue;}
1461 if (indented && !keyPrefix.empty())
1462 {
aja::strip(key); key = keyPrefix +
": " + key;}
1465 if (outInfo.hasKey(key))
1480 for (
size_t ndx(0); ndx < pairs.size(); ndx++)
1482 string assignment (pairs.at(ndx));
1483 if (assignment.find(
'=') == string::npos)
1485 if (!lastKey.empty())
1491 if (pieces.size() != 2)
1492 {
PLGFAIL(
"'" << inParentKey <<
"' assignment '" << assignment <<
"' has " << pieces.size() <<
" component(s) -- expected 2");
continue;}
1493 lastKey = pieces.at(0);
1494 string val(pieces.at(1));
1506 if (!queryStr.empty())
1507 if (queryStr[0] ==
'?')
1508 queryStr.erase(0,1);
1512 string str(*it), key, value;
1513 if (str.find(
"=") == string::npos)
1516 outQueryParams.
insert(key, value);
1517 PLGDBG(
"'" << key <<
"' = ''");
1524 if (pieces.size() > 1)
1525 value = pieces.at(1);
1527 {
PLGWARN(
"Empty key '" << key <<
"'");
continue;}
1528 if (outQueryParams.hasKey(key))
1529 PLGDBG(
"Param '" << key <<
"' value '" << outQueryParams.
valueForKey(key) <<
"' to be replaced with '" << value <<
"'");
1538 outErrorMsg.clear();
1557 {
P_FAIL(
"AJA_SystemInfoTag_Path_Firmware failed");
return false;}
1558 PLGDBG(
"AJA firmware path is '" << outPath <<
"'");
1560 {
P_FAIL(
"'" << outPath <<
"' doesn't end with '" <<
FIRMWARE_FOLDER <<
"'"); outPath.clear();
return false;}
1564 outPath.erase(outPath.length() - 1, 1);
1565 return !outPath.empty();
1575 {
P_FAIL(
"Missing scheme -- params: " << mDict);
return false;}
1577 if (scheme.find(
"ntv2") != 0)
1578 {
P_FAIL(
"Scheme '" << scheme <<
"' doesn't start with 'ntv2'");
return false;}
1582 return !outName.empty();
1592 ifstream dllF(
pluginPath().c_str(), std::ios::in | std::ios::binary);
1596 {
P_WARN(
"EOF not reached in plugin file '" <<
pluginPath() <<
"' -- over 500MB in size?");
return false;}
1597 tmp.
Truncate(
size_t(dllF.gcount()));
1601 ifstream sigF(
pluginSigPath().c_str(), std::ios::in | std::ios::binary);
1605 {
P_WARN(
"EOF not reached in signature file '" <<
pluginSigPath() <<
"' -- over 500MB in size?");
return false;}
1606 tmp.
Truncate(
size_t(sigF.gcount()));
1617 NTV2Buffer checksumFromSigFile, x509CertFromSigFile, signature;
1628 mbedtls_x509_crt crt;
1629 mbedtls_x509_crt_init(&crt);
1630 int ret = mbedtls_x509_crt_parse(&crt, x509CertFromSigFile, x509CertFromSigFile);
1633 mbedtls_x509_crt_free(&crt);
1641 int msgLength (mbedtls_x509_crt_info (msgBuff, msgBuff,
"", &crt));
1642 string msg (msgBuff,
size_t(msgLength));
1644 {
P_FAIL(
"'mbedtls_x509_crt_info' returned no info for X509 cert found in '" <<
pluginSigPath() <<
"'");
1648 cout <<
"## DEBUG: Raw X509 certificate info extracted from signature file '" <<
pluginSigPath() <<
"':" << endl
1649 <<
" " << msg << endl;
1653 { cout <<
"## NOTE: X509 certificate info extracted from signature file '" <<
pluginSigPath() <<
"':" << endl;
1654 certInfo.
Print(cout,
false) << endl;
1656 if (certInfo.hasKey(
"issuer name"))
1659 if (certInfo.hasKey(
"subject name"))
1667 { cout <<
"## NOTE: 'issuer name' info:" << endl;
1668 issuerInfo.
Print(cout,
false) << endl;
1670 if (
isVerbose() && !subjectInfo.empty())
1671 { cout <<
"## NOTE: 'subject name' info:" << endl;
1672 subjectInfo.
Print(cout,
false) << endl;
1691 ret = mbedtls_md_file (mbedtls_md_info_from_type(MBEDTLS_MD_SHA256),
pluginPath().c_str(), checksumFromDLL);
1696 if (
isVerbose()) {
string str;
if (checksumFromDLL.
toHexString(str)) cout <<
"## DEBUG: Digest: " << str << endl;}
1699 ret = mbedtls_pk_verify (&crt.pk, MBEDTLS_MD_SHA256,
1701 signature, signature);
1706 mbedtls_x509_crt_free(&crt);
1707 P_DBG(
"'mbedtls_pk_verify' succeeded for '" <<
pluginPath() <<
"' -- signature valid");
1729 if (regInfo.empty())
1730 {
P_FAIL(
"'" <<
pluginPath() <<
"': no registration info (empty)");
return false;}
1736 for (
size_t ndx(0); ndx < reqKeys.size(); ndx++)
1737 if (!regInfo.hasKey(reqKeys.at(ndx)))
1738 missingRegInfoKeys.push_back(reqKeys.at(ndx));
1739 if (!missingRegInfoKeys.empty())
1740 {
P_FAIL(
"'" <<
pluginPath() <<
"': missing key(s) in registration info: '"
1741 <<
aja::join(missingRegInfoKeys,
"','") <<
"'");
1754 const string ajaFingerprint(
"70:1a:37:93:fa:4f:34:30:58:55:51:0c:01:4e:45:7c:be:5b:41:62");
1757 if (onReg != onCert)
1760 <<
"') \"" << onCert <<
"\" from X509 certificate 'Issuer' in '" <<
pluginSigPath() <<
"'");
1763 if (cnReg != cnCert)
1766 <<
"') \"" << cnCert <<
"\" from X509 certificate 'Issuer' in '" <<
pluginSigPath() <<
"'");
1769 if (ouReg != ouCert)
1772 <<
"') \"" << ouCert <<
"\" from X509 certificate 'Subject' in '" <<
pluginSigPath() <<
"'");
1775 if (myVers != plVers)
1777 <<
"\" doesn't match client SDK version '" << myVers <<
"'");
1780 if (fingerprint != ajaFingerprint)
1781 {
P_FAIL(
pluginPath() <<
" not authorized/signed by AJA: Issuer serial mismatch: " << fingerprint
1782 <<
" vs " << ajaFingerprint);
1812 return mpPlugin && mValidated;
1819 cout <<
"0 plugins" << endl;
1820 else if (paths.size() == 1)
1821 cout <<
"1 plugin: " << paths.at(0) << endl;
1822 else cout <<
DEC(paths.size()) <<
" plugins:" << endl <<
aja::join(paths,
"\n") << endl;
1824 #endif // !defined(NTV2_PREVENT_PLUGIN_LOAD)
1842 {cout << __FILE__ <<
"(" << __LINE__ <<
"):" <<
AJAFUNC <<
":" << endl;
mParams.
Print(cout,
false) << endl;}
1857 size_t oldCount(
mParams.size()), updated(0), added(0);
1867 NBSDBG(
DEC(oldCount) <<
" param(s) removed, replaced with " << inNewParams);
1881 while (nums.size() > 3)
1916 return mParams.hasKey(inParam);
1932 oss << (IsConnected() ?
"Connected" :
"Disconnected");
1933 if (IsConnected() && !Name().empty())
1934 oss <<
" to '" << Name() <<
"'";
1966 { (
void) autoCircData;
1971 { (
void) eInterrupt; (
void) timeOutMs;
1975 #if !defined(NTV2_DEPRECATE_16_3)
1977 { (
void) bitFileType;
1978 ::memset(&bitFileInfo, 0,
sizeof(bitFileInfo));
1984 ::memset(&buildInfo, 0,
sizeof(buildInfo));
1989 const UWord signalMask,
const bool testPatDMAEnb,
const ULWord testPatNum)
1990 { (
void) channel; (
void) testPatternFBF; (
void) signalMask; (
void) testPatDMAEnb; (
void) testPatNum;
1995 { (
void) numRegs; (
void) outFailedRegNum; (
void) outRegs;
2001 outDriverVersion = 0xFFFFFFFF;
2004 #endif // !defined(NTV2_DEPRECATE_16_3)
2008 const ULWord inNumSegments,
const ULWord inSegmentHostPitch,
2009 const ULWord inSegmentCardPitch,
const bool inSynchronous)
2010 { (
void) inDMAEngine; (
void) inIsRead; (
void) inFrameNumber; (
void) inOutFrameBuffer;
2011 (
void) inCardOffsetBytes; (
void) inNumSegments; (
void) inSegmentHostPitch;
2012 (
void) inSegmentCardPitch; (
void) inSynchronous;
2017 { (
void) pInMessage;
2035 outSupported.clear();
2053 #if defined(NTV2_PREVENT_PLUGIN_LOAD)
2081 #if defined(NTV2_PREVENT_PLUGIN_LOAD)
2105 if (parser.HasErrors())
2153 return mParams.hasKey(inParam);
@ AJA_SystemInfoSection_Path
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.
Declares the AJASystemInfo class.
static string mbedErrStr(const int mbedtlsReturnCode)
virtual bool NTV2OpenRemote(void)
enum _INTERRUPT_ENUMS_ INTERRUPT_ENUMS
#define kNTV2PluginRegInfoKey_Vendor
Plugin vendor (manufacturer) name.
@ AJA_SystemInfoMemoryUnit_Megabytes
#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.
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_)
@ AJA_SystemInfoTag_Path_Firmware
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
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...
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 AJAStatus GetValue(const AJASystemInfoTag inTag, std::string &outValue) const
Answers with the host system info value string for the given AJASystemInfoTag.
virtual bool NTV2GetBoolParamRemote(const ULWord inParamID, ULWord &outValue)
virtual std::string ConnectParam(const std::string &inParam) const
#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 StringToSerialNum64(const std::string &inSerNumStr, uint64_t &outSerNum)
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
uint64_t DeviceSerial(void) const
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)
bool unloadPlugin(const string &path)
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__)
#define AJA_FAILURE(_status_)
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.
bool loadPlugin(const string &path, const string &folderPath, NTV2PluginPtr &outPtr, const bool useStdout)
#define kNTV2PluginRegInfoKey_LongName
Plugin long name.