13 #include <ajabase/network/network.h> 18 #if defined (AJALinux) || defined (AJAMac) 20 #include <sys/socket.h> 21 #include <netinet/in.h> 22 #include <arpa/inet.h> 25 #define RESET_MILLISECONDS 5 56 for (
int i=0; i < 2; i++)
68 firstAudioChannel = 0;
75 return !(*
this == other);
81 if ((localPort[0] == other.
localPort[0]) &&
85 (remoteIP[0] == other.
remoteIP[0]) &&
86 (remoteIP[1] == other.
remoteIP[1]) &&
113 numAudioChannels = 2;
119 return (!(*
this == other));
124 if ( (rxMatch == other.
rxMatch) &&
126 (destIP == other.
destIP) &&
129 (ssrc == other.
ssrc) &&
130 (vlan == other.
vlan) &&
159 _numRxChans = _numRx0Chans + _numRx1Chans;
160 _numTxChans = _numTx0Chans + _numTx1Chans;
162 _biDirectionalChannels =
false;
171 string ip, subnet, gateway;
173 addr.s_addr = (uint32_t)netConfig.
ipc_ip;
174 ip = AJANetwork::aja_inet_ntoa(addr);
176 subnet = AJANetwork::aja_inet_ntoa(addr);
178 gateway = AJANetwork::aja_inet_ntoa(addr);
186 string ip, subnet, gateway;
210 uint32_t addr = AJANetwork::aja_inet_addr(localIPAddress.c_str());
219 macAddressRegister++;
222 uint32_t boardHi = (macHi & 0xffff0000) >>16;
223 uint32_t boardLo = ((macHi & 0x0000ffff) << 16) + ((macLo & 0xffff0000) >> 16);
226 macAddressRegister++;
228 macAddressRegister++;
231 uint32_t boardHi2 = (macHi & 0xffff0000) >>16;
232 uint32_t boardLo2 = ((macHi & 0x0000ffff) << 16) + ((macLo & 0xffff0000) >> 16);
251 if (!rv)
return false;
270 localIPAddress = AJANetwork::aja_inet_ntoa(addr);
274 subnetMask = AJANetwork::aja_inet_ntoa(addr);
278 gateway = AJANetwork::aja_inet_ntoa(addr);
285 localIPAddress = AJANetwork::aja_inet_ntoa(addr);
289 subnetMask = AJANetwork::aja_inet_ntoa(addr);
293 gateway = AJANetwork::aja_inet_ntoa(addr);
341 uint32_t sourceIp = AJANetwork::aja_inet_addr(rxConfig.
sourceIP.c_str());
346 uint32_t destIp = AJANetwork::aja_inet_addr(rxConfig.
destIP.c_str());
505 uint32_t val = (num_samples << 8) + num_channels;
524 uint32_t val = ( (((uint32_t) fr) << 8) |
525 (((uint32_t) fg) << 4) |
556 uint32_t reg, reg2, value;
590 uint32_t depacketizerBaseAddr;
599 char * ip = AJANetwork::aja_inet_ntoa(in);
605 ip = AJANetwork::aja_inet_ntoa(in);
679 uint32_t srcIp, destIp;
684 uint8_t ip0 = (destIp & 0xff000000)>> 24;
685 if (ip0 >= 224 && ip0 <= 239)
740 enabled = (val & 0x01);
752 uint32_t depacketizerBaseAddr;
774 uint32_t depacketizerBaseAddr;
792 uint32_t val_lo, val_hi;
805 bytes = ((uint64_t)val_hi << 32) + val_lo;
830 uint32_t val_lo, val_hi;
843 bytes = ((uint64_t)val_hi << 32) + val_lo;
847 int CNTV2Config2110::LeastCommonMultiple(
int a,
int b)
887 bool interlaced =
false;
913 int componentsPerPixel;
914 int componentsPerUnit;
921 componentsPerPixel = 3;
922 componentsPerUnit = 3;
926 componentsPerPixel = 2;
927 componentsPerUnit = 4;
933 const int bitsPerComponent = 10;
934 const int pixelsPerClock = 1;
935 int activeLineLength = (width * componentsPerPixel * bitsPerComponent)/8;
937 int pixelGroup_root = LeastCommonMultiple((bitsPerComponent * componentsPerUnit), 8);
938 int pixelGroupSize = pixelGroup_root/8;
940 int bytesPerCycle = (pixelsPerClock * bitsPerComponent * componentsPerPixel)/8;
942 int lcm = LeastCommonMultiple(pixelGroupSize,bytesPerCycle);
943 int payloadLength_root = min(activeLineLength,1376)/lcm;
944 int payloadLength = payloadLength_root * lcm;
946 float pktsPerLine = ((float)activeLineLength)/((float)payloadLength);
947 int ipktsPerLine = (int)ceil(pktsPerLine);
949 int payloadLengthLast = activeLineLength - (payloadLength * (ipktsPerLine -1));
951 int ppp = (payloadLength/pixelGroupSize) * 2;
960 payloadLength = 0x0558;
961 payloadLengthLast = 0x03f0;
967 payloadLength = 0x0558;
968 payloadLengthLast = 0x0120;
975 payloadLength = 0x0558;
976 payloadLengthLast = 0x01b0;
1000 int ilace = (interlaced) ? 0x01 : 0x00;
1013 uint32_t plength = audioChans * samples * 3;
1016 uint32_t aselect = ((uint32_t)txConfig.
firstAudioChannel << 16 ) + (audioChans-1);
1017 aselect = (txConfig.
channel << 24) + aselect;
1067 uint32_t val = (txConfig.
tos << 8) | txConfig.
ttl;
1070 int index = (int)sfp;
1072 uint32_t destIp = AJANetwork::aja_inet_addr(txConfig.
remoteIP[index].c_str());
1086 if (!rv)
return false;
1100 uint32_t baseAddrPacketizer;
1164 int index = (int)sfp;
1174 txConfig.
ttl = val & 0xff;
1175 txConfig.
tos = (val & 0xff00) >> 8;
1181 char * ip = AJANetwork::aja_inet_ntoa(in);
1211 GenSDP(enableSfp1, enableSfp2, stream);
1218 if (enableSfp1 || enableSfp2)
1285 uint32_t val = ((uint32_t)
id[0] << 24) | ((uint32_t)
id[1] << 16) | ((uint32_t)
id[2] << 8) | ((uint32_t)
id[3] << 0);
1287 val = ((uint32_t)
id[4] << 24) | ((uint32_t)
id[5] << 16) | ((uint32_t)
id[6] << 8) | ((uint32_t)
id[7] << 0);
1384 enable = val & 0x01;
1413 enable = val & 0x10;
1442 forceReconfig =
true;
1444 forceReconfig =
false;
1451 uint32_t val = (disable) ? 1 : 0;
1475 disabled = (val == 1) ?
true :
false;
1514 uint32_t offset = 0;
1567 uint32_t basePacketizer = 0;
1579 return basePacketizer;
1609 uint32_t basePacketizer = 0;
1631 return basePacketizer;
1643 macAddressRegister += 2;
1646 macAddressRegister++;
1649 uint32_t alignedMACHi = macHi >> 16;
1650 uint32_t alignedMACLo = (macLo >> 16) | ( (macHi & 0xffff) << 16);
1652 uint32_t addr = AJANetwork::aja_inet_addr(localIPAddress.c_str());
1723 while (val &
BIT(1))
1770 uint32_t destIp = AJANetwork::aja_inet_addr(remoteIP.c_str());
1777 uint8_t ip0 = (destIp & 0xff000000)>> 24;
1778 if (ip0 >= 224 && ip0 <= 239)
1781 mac = destIp & 0x7fffff;
1783 macaddr.
mac[0] = 0x01;
1784 macaddr.
mac[1] = 0x00;
1785 macaddr.
mac[2] = 0x5e;
1786 macaddr.
mac[3] = mac >> 16;
1787 macaddr.
mac[4] = (mac & 0xffff) >> 8;
1788 macaddr.
mac[5] = mac & 0xff;
1800 struct in_addr addr;
1802 string gateIp = AJANetwork::aja_inet_ntoa(addr);
1816 istringstream ss(macAddr);
1821 getline (ss, token,
':');
1822 macaddr.
mac[i++] = (uint8_t)strtoul(token.c_str(),
NULL, 16);
1826 hi = macaddr.
mac[0] << 8;
1827 hi += macaddr.
mac[1];
1829 lo = macaddr.
mac[2] << 24;
1830 lo += macaddr.
mac[3] << 16;
1831 lo += macaddr.
mac[4] << 8;
1832 lo += macaddr.
mac[5];
1839 string localIPAddress, subnetMask, gateway;
1840 string preAmble =
"http://";
1841 string namePre =
"tx";
1862 default: namePost =
"";
break;
1865 return preAmble + localIPAddress +
"/" + namePre + namePost;
1870 GenSDP(enabledSfp1, enabledSfp2, stream,
false);
1874 string CNTV2Config2110::To_String(
int val)
1884 stringstream & sdp = txsdp;
1890 sdp <<
"v=0" << endl;
1896 sdp << To_String((
int)t);
1898 sdp <<
" 0 IN IP4 ";
1907 struct in_addr addr;
1909 string localIPAddress = AJANetwork::aja_inet_ntoa(addr);
1910 sdp << localIPAddress << endl;
1913 sdp <<
"s=AJA KonaIP 2110" << endl;
1916 sdp <<
"t=0 0" <<endl;
1923 snprintf(gmInfo,
sizeof(gmInfo),
"%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X:%d",
1951 string filename =
"tx";
1968 default: filename +=
"";
break;
1977 const bool enableSfp2,
const NTV2Stream stream,
char *gmInfo)
1979 bool isDash7 = enableSfp1 && enableSfp2;
1982 sdp <<
"a=group:DUP 1 2" << endl;
1987 sdp <<
"a=mid:" << (isDash7?
"1":
"VID") << endl;
1992 sdp <<
"a=mid:" << (isDash7?
"2":
"VID") << endl;
2021 string rateString = rateToString(frate);
2039 sdp <<
"/" << To_String(config.
ttl) << endl;
2042 sdp <<
"a=source-filter: incl IN IP4 ";
2056 struct in_addr addr;
2058 string localIPAddress = AJANetwork::aja_inet_ntoa(addr);
2059 sdp <<
' ' << localIPAddress << endl;
2064 sdp <<
" raw/90000" << endl;
2070 sdp <<
" sampling=RGB; width=";
2072 sdp <<
" sampling=YCbCr-4:2:2; width=";
2074 sdp << To_String(width);
2076 sdp << To_String(height);
2077 sdp <<
"; exactframerate=";
2079 sdp <<
"; depth=10; TCS=SDR; colorimetry=";
2081 sdp <<
"; PM=2110GPM; SSN=ST2110-20:2017; TP=2110TPN; ";
2084 sdp <<
"interlace; ";
2088 sdp <<
"interlace segmented";
2093 sdp <<
"a=ts-refclk:ptp=IEEE1588-2008:" << gmInfo << endl;
2094 sdp <<
"a=mediaclk:direct=0" << endl;
2102 uint32_t quadSwapOut;
2108 sdp <<
"a=group:MULTI-2SI 1 2 3 4 " << endl;
2111 for (
int i=0; i<4; i++)
2113 if (quadSwapOut != 0)
2154 string rateString = rateToString(frate);
2172 sdp <<
"/" << To_String(config.
ttl) << endl;
2175 sdp <<
"a=source-filter: incl IN IP4 ";
2189 struct in_addr addr;
2191 string localIPAddress = AJANetwork::aja_inet_ntoa(addr);
2192 sdp <<
' ' << localIPAddress << endl;
2197 sdp <<
" raw/90000" << endl;
2202 sdp <<
" sampling=YCbCr-4:2:2; width=";
2203 sdp << To_String(width);
2205 sdp << To_String(height);
2206 sdp <<
"; exactframerate=";
2208 sdp <<
"; depth=10; TCS=SDR; colorimetry=";
2210 sdp <<
"; PM=2110GPM; SSN=ST2110-20:2017; TP=2110TPN; ";
2213 sdp <<
"interlace; ";
2217 sdp <<
"interlace segmented";
2222 sdp <<
"a=ts-refclk:ptp=IEEE1588-2008:" << gmInfo << endl;
2223 sdp <<
"a=mediaclk:direct=0" << endl;
2224 sdp <<
"a=mid:" << i+1 << endl;
2232 const bool enableSfp2,
const NTV2Stream stream,
char *gmInfo)
2234 bool isDash7 = enableSfp1 && enableSfp2;
2237 sdp <<
"a=group:DUP 1 2" << endl;
2242 sdp <<
"a=mid:" << (isDash7?
"1":
"VID") << endl;
2247 sdp <<
"a=mid:" << (isDash7?
"2":
"VID") << endl;
2274 sdp <<
"/" << To_String(config.
ttl) << endl;
2277 sdp <<
"a=source-filter: incl IN IP4 ";
2291 struct in_addr addr;
2293 string localIPAddress = AJANetwork::aja_inet_ntoa(addr);
2294 sdp <<
' ' << localIPAddress << endl;
2299 sdp <<
" L24/48000/";
2305 sdp <<
" channel-order=SMPTE2110.(";
2316 sdp <<
"SGRP,SGRP)";
2319 sdp <<
"SGRP,SGRP,SGRP)";
2322 sdp <<
"SGRP,SGRP,SGRP,SGRP)";
2329 sdp <<
"a=ptime:0.125" << endl;
2333 sdp <<
"a=ptime:1.000" << endl;
2336 sdp <<
"a=ts-refclk:ptp=IEEE1588-2008:" << gmInfo << endl;
2337 sdp <<
"a=mediaclk:direct=0" << endl;
2343 const bool enableSfp2,
const NTV2Stream stream,
char *gmInfo)
2345 bool isDash7 = enableSfp1 && enableSfp2;
2348 sdp <<
"a=group:DUP 1 2" << endl;
2353 sdp <<
"a=mid:" << (isDash7?
"1":
"VID") << endl;
2358 sdp <<
"a=mid:" << (isDash7?
"2":
"VID") << endl;
2384 sdp <<
"/" << To_String(config.
ttl) << endl;
2387 sdp <<
"a=source-filter: incl IN IP4 ";
2401 struct in_addr addr;
2403 string localIPAddress = AJANetwork::aja_inet_ntoa(addr);
2404 sdp <<
' ' << localIPAddress << endl;
2409 sdp <<
" smpte291/90000" << endl;
2412 sdp <<
"a=ts-refclk:ptp=IEEE1588-2008:" << gmInfo << endl;
2413 sdp <<
"a=mediaclk:direct=0" << endl;
2476 int CNTV2Config2110::getDescriptionValue(
int startLine,
string type,
string & value)
2478 for (
unsigned i(startLine); i < sdpLines.size(); i++)
2480 string line = sdpLines[i];
2481 size_t pos = line.find(type);
2482 if (pos != string::npos)
2484 value = line.substr(pos + type.size() + 1);
2491 string CNTV2Config2110::getVideoDescriptionValue(
string type)
2493 vector<string>::iterator it;
2494 for (it = tokens.begin(); it != tokens.end(); it++)
2497 size_t pos = line.find(type);
2498 if (pos != string::npos)
2500 line = line.substr(pos + type.size());
2501 line.erase(
remove(line.begin(), line.end(),
';'), line.end());
2509 vector<string> CNTV2Config2110::split(
const char *str,
char delim)
2511 vector<string> result;
2514 const char *
begin = str;
2515 while(*str != delim && *str)
2519 result.push_back(
string(
begin, str));
2520 }
while (0 != *str++);
2533 sdp.erase(
remove(sdp.begin(), sdp.end(),
'\r'), sdp.end());
2537 stringstream ss(sdp);
2540 while(getline(ss,to,
'\n'))
2542 sdpLines.push_back(to);
2550 index = getDescriptionValue(0,
"v=",value);
2558 index = getDescriptionValue(index,
"a=group",value);
2565 tokens =
split(value.c_str(),
' ');
2566 if (!((tokens.size() != 5) && (tokens[0] ==
"MULTI-2SI")))
2573 for (
int i=0; i<4; i++)
2575 uint32_t rxMatch = 0;
2580 index = getDescriptionValue(index,
"m=video",value);
2587 tokens =
split(value.c_str(),
' ');
2588 if ((tokens.size() >= 1) && !tokens[0].empty())
2593 if ((tokens.size() >= 3) && !tokens[2].empty())
2599 rv = getDescriptionValue(index,
"c=IN",value);
2602 tokens =
split(value.c_str(),
' ');
2603 if (tokens.size() >= 2)
2605 tokens =
split(tokens[1].c_str(),
'/');
2606 if ((tokens.size() >= 1) && !tokens[0].empty())
2615 rv = getDescriptionValue(index,
"a=source-filter:",value);
2618 tokens =
split(value.c_str(),
' ');
2619 if (tokens.size() >= 5 && !tokens[4].empty())
2626 rv = getDescriptionValue(index,
"a=rtpmap",value);
2629 tokens =
split(value.c_str(),
' ');
2630 if ((tokens.size() >= 1) && !tokens[0].empty())
2637 rv = getDescriptionValue(index,
"a=fmtp",value);
2640 tokens =
split(value.c_str(),
' ');
2641 string sampling = getVideoDescriptionValue(
"sampling=");
2642 if (sampling ==
"YCbCr-4:2:2")
2646 string width = getVideoDescriptionValue(
"width=");
2647 string height = getVideoDescriptionValue(
"height=");
2648 string rate = getVideoDescriptionValue(
"exactframerate=");
2649 bool interlace =
false;
2650 bool segmented =
false;
2651 vector<string>::iterator it;
2653 for (it = tokens.begin(); it != tokens.end(); it++)
2661 if (*it ==
"interlace")
2667 if (it->substr(0,10) ==
"interlace;")
2672 if (it->substr(0,11) ==
"interlace=1")
2677 if ((it->substr( 0, 9 ) ==
"segmented") && interlace)
2684 int w = atoi(width.c_str());
2685 int h = atoi(height.c_str());
2707 sdp.erase(
remove(sdp.begin(), sdp.end(),
'\r'), sdp.end());
2711 stringstream ss(sdp);
2714 while(getline(ss,to,
'\n'))
2716 sdpLines.push_back(to);
2724 index = getDescriptionValue(0,
"v=",value);
2732 index = getDescriptionValue(index,
"o=",value);
2739 uint32_t rxMatch = 0;
2741 tokens =
split(value.c_str(),
' ');
2742 if ((tokens.size() >= 6) && (tokens[3] ==
"IN") && (tokens[4] ==
"IP4"))
2744 if (!tokens[5].empty())
2751 int rv = getDescriptionValue(0,
"c=IN",value);
2754 tokens =
split(value.c_str(),
' ');
2755 if (tokens.size() >= 2)
2757 tokens =
split(tokens[1].c_str(),
'/');
2758 if ((tokens.size() >= 1) && !tokens[0].empty())
2760 rxConfig.
destIP = tokens[0];
2766 index = getDescriptionValue(index,
"m=video",value);
2773 tokens =
split(value.c_str(),
' ');
2774 if ((tokens.size() >= 1) && !tokens[0].empty())
2776 rxConfig.
destPort = atoi(tokens[0].c_str());
2779 if ((tokens.size() >= 3) && !tokens[2].empty())
2785 rv = getDescriptionValue(index,
"c=IN",value);
2789 tokens =
split(value.c_str(),
' ');
2790 if (tokens.size() >= 2)
2792 tokens =
split(tokens[1].c_str(),
'/');
2793 if ((tokens.size() >= 1) && !tokens[0].empty())
2795 rxConfig.
destIP = tokens[0];
2802 rv = getDescriptionValue(index,
"a=source-filter:",value);
2805 tokens =
split(value.c_str(),
' ');
2806 if (tokens.size() >= 5 && !tokens[4].empty())
2813 rv = getDescriptionValue(index,
"a=rtpmap",value);
2816 tokens =
split(value.c_str(),
' ');
2817 if ((tokens.size() >= 1) && !tokens[0].empty())
2824 rv = getDescriptionValue(index,
"a=fmtp",value);
2827 tokens =
split(value.c_str(),
' ');
2828 string sampling = getVideoDescriptionValue(
"sampling=");
2829 if (sampling ==
"YCbCr-4:2:2")
2833 string width = getVideoDescriptionValue(
"width=");
2834 string height = getVideoDescriptionValue(
"height=");
2835 string rate = getVideoDescriptionValue(
"exactframerate=");
2836 bool interlace =
false;
2837 bool segmented =
false;
2838 vector<string>::iterator it;
2839 for (it = tokens.begin(); it != tokens.end(); it++)
2847 if (*it ==
"interlace")
2853 if (it->substr(0,10) ==
"interlace;")
2858 if (it->substr(0,11) ==
"interlace=1")
2863 if ((it->substr( 0, 9 ) ==
"segmented") && interlace)
2870 int w = atoi(width.c_str());
2871 int h = atoi(height.c_str());
2889 uint32_t rxMatch = 0;
2892 sdp.erase(
remove(sdp.begin(), sdp.end(),
'\r'), sdp.end());
2897 stringstream ss(sdp);
2900 while(getline(ss,to,
'\n'))
2902 sdpLines.push_back(to);
2910 index = getDescriptionValue(0,
"v=",value);
2918 index = getDescriptionValue(index,
"o=",value);
2925 tokens =
split(value.c_str(),
' ');
2926 if ((tokens.size() >= 6) && (tokens[3] ==
"IN") && (tokens[4] ==
"IP4"))
2928 if (!tokens[5].empty())
2935 int rv = getDescriptionValue(0,
"c=IN",value);
2938 tokens =
split(value.c_str(),
' ');
2939 if (tokens.size() >= 2)
2941 tokens =
split(tokens[1].c_str(),
'/');
2942 if ((tokens.size() >= 1) && !tokens[0].empty())
2944 rxConfig.
destIP = tokens[0];
2951 index = getDescriptionValue(index,
"m=audio",value);
2959 tokens =
split(value.c_str(),
' ');
2960 if ((tokens.size() >= 1) && !tokens[0].empty())
2962 rxConfig.
destPort = atoi(tokens[0].c_str());
2966 if ((tokens.size() >= 3) && !tokens[2].empty())
2972 rv = getDescriptionValue(index,
"c=IN",value);
2976 tokens =
split(value.c_str(),
' ');
2977 if ((tokens.size() >= 2))
2979 tokens =
split(tokens[1].c_str(),
'/');
2980 if ((tokens.size() >= 1)&& !tokens[0].empty())
2982 rxConfig.
destIP = tokens[0];
2989 rv = getDescriptionValue(index,
"a=source-filter:",value);
2992 tokens =
split(value.c_str(),
' ');
2993 if (tokens.size() >= 5 && !tokens[4].empty())
3000 rv = getDescriptionValue(index,
"a=rtpmap",value);
3003 tokens =
split(value.c_str(),
' ');
3004 if ((tokens.size() >= 1)&& !tokens[0].empty())
3009 if ((tokens.size() >= 2))
3011 tokens =
split(tokens[1].c_str(),
'/');
3012 if ((tokens.size() >= 3) && !tokens[2].empty())
3019 rv = getDescriptionValue(index,
"a=ptime",value);
3022 tokens =
split(value.c_str(),
' ');
3023 if ((tokens.size() >= 1)&& !tokens[0].empty())
3025 tokens =
split(tokens[0].c_str(),
'.');
3026 if (tokens.size() >= 2)
3028 if ((atoi(tokens[0].c_str()) == 1) && (atoi(tokens[1].c_str()) == 0))
3030 else if ((atoi(tokens[0].c_str()) == 0) && (atoi(tokens[1].c_str()) == 125))
3050 sdp.erase(
remove(sdp.begin(), sdp.end(),
'\r'), sdp.end());
3054 stringstream ss(sdp);
3057 while(getline(ss,to,
'\n'))
3059 sdpLines.push_back(to);
3067 index = getDescriptionValue(0,
"v=",value);
3075 index = getDescriptionValue(index,
"o=",value);
3082 uint32_t rxMatch = 0;
3084 tokens =
split(value.c_str(),
' ');
3085 if ((tokens.size() >= 6) && (tokens[3] ==
"IN") && (tokens[4] ==
"IP4"))
3087 if (!tokens[5].empty())
3094 int rv = getDescriptionValue(0,
"c=IN",value);
3097 tokens =
split(value.c_str(),
' ');
3098 if (tokens.size() >= 2)
3100 tokens =
split(tokens[1].c_str(),
'/');
3101 if ((tokens.size() >= 1) && !tokens[0].empty())
3103 rxConfig.
destIP = tokens[0];
3109 index = getDescriptionValue(index,
"m=video",value);
3116 tokens =
split(value.c_str(),
' ');
3117 if ((tokens.size() >= 1) && !tokens[0].empty())
3119 rxConfig.
destPort = atoi(tokens[0].c_str());
3122 if ((tokens.size() >= 3) && !tokens[2].empty())
3128 rv = getDescriptionValue(index,
"c=IN",value);
3132 tokens =
split(value.c_str(),
' ');
3133 if (tokens.size() >= 2)
3135 tokens =
split(tokens[1].c_str(),
'/');
3136 if ((tokens.size() >= 1) && !tokens[0].empty())
3138 rxConfig.
destIP = tokens[0];
3145 rv = getDescriptionValue(index,
"a=source-filter:",value);
3148 tokens =
split(value.c_str(),
' ');
3149 if (tokens.size() >= 5 && !tokens[4].empty())
3156 rv = getDescriptionValue(index,
"a=rtpmap",value);
3159 tokens =
split(value.c_str(),
' ');
3160 if ((tokens.size() >= 1) && !tokens[0].empty())
3172 std::string CNTV2Config2110::rateToString(
NTV2FrameRate rate)
3185 rateString =
"60000/1001";
3191 rateString =
"30000/1001";
3200 rateString =
"24000/1001";
3209 rateString =
"48000/1001";
3215 rateString =
"120000/1001";
3221 rateString =
"1500/1001";
3227 NTV2FrameRate CNTV2Config2110::stringToRate(std::string rateString)
3230 if (rateString ==
"60")
3232 else if (rateString ==
"60000/1001")
3234 else if (rateString ==
"30")
3236 else if (rateString ==
"30000/1001")
3238 else if (rateString ==
"25")
3240 else if (rateString ==
"24")
3242 else if (rateString ==
"24000/1001")
3244 else if (rateString ==
"50")
3246 else if (rateString ==
"48")
3248 else if (rateString ==
"48000/1001")
3250 else if (rateString ==
"120")
3252 else if (rateString ==
"120000/1001")
3254 else if (rateString ==
"15")
3256 else if (rateString ==
"1500/1001")
3311 enable = (val & bit);
3318 uint32_t samp = sampling;
3402 std::string &chassisId1, std::string &portId1)
Fractional rate of 15,000 frames per 1,001 seconds.
#define NTV2_IS_SD_VIDEO_FORMAT(__f__)
#define kReg4175_pkt_ctrl
#define kReg3190_pkt_num_samples
#define NTV2_IS_720P_VIDEO_FORMAT(__f__)
NTV2FrameRate GetNTV2FrameRateFromVideoFormat(const NTV2VideoFormat inVideoFormat)
#define kRegPll_swptp_GrandMasterIdHi
#define SAREK_2110_DECAPSULATOR_1
void SetupDecapsulatorStream(const eSFP sfp, const NTV2Stream stream, const rx_2110Config &rxConfig)
bool GenAncStreamSDP(std::stringstream &sdp, const bool enableSfp1, const bool enableSfp2, const NTV2Stream stream, char *gmInfo)
#define SAREK_3190_TX_PACKETIZER_0
#define kRegDecap_match_sel
#define SAREK_2110_AUDIO_ANC_FRAMER_1
#define kReg4175_pkt_payload_len_last
#define SAREK_4175_RX_DEPACKETIZER_4
#define kRegDecap_chan_enable
std::string NTV2IpErrorEnumToString(const NTV2IpError inIpErrorEnumValue)
#define kRegTxNtv2VideoDecode1
#define kRegDecap_match_ssrc
eNTV2PacketInterval audioPktInterval
static uint32_t videoDepacketizers[4]
#define SAREK_3190_RX_DEPACKETIZER_3
#define SAREK_4175_TX_PACKETIZER_RGB12_4
VPIDSampling videoSamples
#define kRegPll_PTP_LclMacHi
#define kSarekRegIGMPDisable2
#define kReg4175_depkt_rx_pkt_cnt
I interrogate and control an AJA video/audio capture/playout device.
uint8_t firstAudioChannel
uint32_t numAudioChannels
NTV2IpError getLastErrorCode(void)
bool PushSDP(std::string filename, std::stringstream &sdpstream)
#define kRegDecap_match_udp_src_port
enum _NTV2VideoFormat NTV2VideoFormat
Identifies a particular video format.
bool GetSDP(std::string url, std::string &sdp)
Fractional rate of 120,000 frames per 1,001 seconds.
#define SAREK_3190_TX_PACKETIZER_2
bool operator!=(const rx_2110Config &other)
#define kRegFramer_udp_src_port
bool GetPTPStatus(PTPStatus &ptpStatus)
uint64_t GetNTPTimestamp(void)
#define NTV2_VIDEO_FORMAT_HAS_PROGRESSIVE_PICTURE(__f__)
#define RX_MATCH_2110_DEST_IP
#define kReg10gemac_rx_bytes_hi
Declares the AJATime class.
bool GetSFPInfo(eSFP port, SFPMSAData &sfpdata)
void GetArbiter(const eSFP sfp, const NTV2Stream stream, bool &enable)
bool GetMACAddress(const eSFP port, const NTV2Stream stream, std::string remoteIP, uint32_t &hi, uint32_t &lo)
bool ExtractRxAudioConfigFromSDP(std::string sdp, rx_2110Config &rxConfig)
#define kSarekRegIGMPDisable
#define SFP_1_NOT_PRESENT
#define kReg10gemac_tx_bytes_lo
#define NTV2_IS_2K_1080_VIDEO_FORMAT(__f__)
4K Video stream using 4 streams
Defines a number of handy byte-swapping macros.
bool GetRxStreamEnable(const eSFP sfp, const NTV2Stream stream, bool &enabled)
bool GenAudioStreamSDPInfo(std::stringstream &sdp, const eSFP sfp, const NTV2Stream stream, char *gmInfo)
bool WriteChannelRegister(ULWord reg, ULWord value, ULWord mask=0xFFFFFFFF, ULWord shift=0x0)
Fractional rate of 60,000 frames per 1,001 seconds.
bool GetPTPDomain(uint8_t &domain)
#define kReg4175_pkt_height
NTV2Channel VideoStreamToChannel(const NTV2Stream stream)
PTPLockStatus PTP_LockedState
#define SAREK_4175_RX_DEPACKETIZER_2
#define kReg4175_pkt_payload_len
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They're also commonly use...
#define kReg4175_pkt_ssrc
uint32_t sourcePort
Specifies the source (sender) port number (if RX_MATCH_2110_SOURCE_PORT set)
#define RX_MATCH_2110_DEST_PORT
#define SAREK_3190_RX_DEPACKETIZER_4
bool SetTxStreamConfiguration(const NTV2Stream stream, const tx_2110Config &txConfig)
uint16_t vlan
Specifies the VLAN TCI (if RX_MATCH_2110_VLAN set)
bool GetSFPActive(eSFP sfp)
uint32_t localPort[2]
Specifies the local (source) port number.
bool GenSDP(bool enableSfp1, bool enableSfp2, const NTV2Stream stream, bool pushit=(!(0)))
bool GetPTPPreferredGrandMasterId(uint8_t(&id)[8])
#define kReg3190_pkt_payload_type
#define SAREK_4175_TX_PACKETIZER_3
uint32_t rxMatch
Bitmap of rxMatch criteria used.
Represents an unknown or invalid frame rate.
void GetFramerStream(const eSFP sfp, const NTV2Stream stream, tx_2110Config &txConfig)
#define kRegSarekLinkStatus
void EnableIGMPGroup(eSFP port, NTV2Stream stream, bool enable)
bool GetIGMPVersion(eIGMPVersion_t &version)
void SelectTxFramerChannel(const NTV2Stream stream, const uint32_t baseAddr)
Fractional rate of 48,000 frames per 1,001 seconds.
void DisableDecapsulatorStream(const eSFP sfp, const NTV2Stream stream)
std::string GetSDPUrl(const eSFP sfp, const NTV2Stream stream)
#define kRegPll_PTP_LclIP
NTV2FrameRate
Identifies a particular video frame rate.
#define kRegFramer_dest_mac_lo
NTV2Standard
Identifies a particular video standard.
#define kRegPll_swptp_Domain
#define kRegPll_PTP_MstrMcast
#define kRegPll_swptp_PreferredGmIdHi
Declares the CNTV2Config2110 class.
void DisableDepacketizerStream(const NTV2Stream stream)
std::string GetGeneratedSDP(bool enabledSfp1, bool enabledSfp2, const NTV2Stream stream)
bool GetLLDPInfo(std::string &chassisId0, std::string &portId0, std::string &chassisId1, std::string &portId1)
bool SetIGMPVersion(const eIGMPVersion_t version)
#define kRegPll_PTP_MstrIP
uint32_t GetDepacketizerAddress(const NTV2Stream stream)
NTV2VideoFormat videoFormat
#define RX_MATCH_2110_PAYLOAD
bool SetFramerStream(const eSFP sfp, const NTV2Stream stream, const tx_2110Config &txConfig)
#define kReg10gemac_tx_bytes_hi
void EnableDepacketizerStream(const NTV2Stream stream)
#define kRegFramer_channel_access
#define kReg3190_depkt_enable
bool SetAudioCombineEnable(const bool enable)
Enables or disables the audio combiner.
void SetIGMPGroup(eSFP port, NTV2Stream stream, uint32_t mcast_addr, uint32_t src_addr, bool enable)
static void Sleep(const int32_t inMilliseconds)
Suspends execution of the current thread for a given number of milliseconds.
bool SetLLDPInfo(std::string sysname)
void split(const std::string &str, const char delim, std::vector< std::string > &elems)
bool GetTxPacketCount(NTV2Stream stream, uint32_t &packets)
bool GetRxByteCount(const NTV2Stream stream, uint32_t &bytes)
#define kRegRxVideoDecode1
#define SAREK_4175_TX_PACKETIZER_RGB12_2
bool SetRxStreamEnable(const eSFP sfp, const NTV2Stream stream, bool enable)
#define RX_MATCH_2110_SOURCE_IP
#define kRegPll_swptp_GrandMasterIdLo
#define NTV2_IS_PSF_VIDEO_FORMAT(__f__)
uint64_t GetNTPTimestamp()
bool GenAudioStreamSDP(std::stringstream &sdp, const bool enableSfp1, const bool enableSfp2, const NTV2Stream stream, char *gmInfo)
bool GetLinkStatus(eSFP port, SFPStatus &sfpStatus)
void SetArbiter(const eSFP sfp, const NTV2Stream stream, bool enable)
VPIDSampling GetSampling(const eSFP sfp, const NTV2Stream stream)
#define SAREK_2110_DECAPSULATOR_0
Configures a SMPTE 2110 Receive Channel.
Configures a SMPTE 2110 Transmit Channel.
bool GetRxPacketCount(const NTV2Stream stream, uint32_t &packets)
Specifies channel or FrameStore 2 (or the 2nd item).
virtual NTV2DeviceID GetDeviceID(void)
NTV2StreamType StreamType(const NTV2Stream stream)
#define SAREK_4175_RX_DEPACKETIZER_1
bool operator==(const rx_2110Config &other)
void SetupDepacketizerStream(const NTV2Stream stream, const rx_2110Config &rxConfig)
bool operator!=(const tx_2110Config &other)
#define kRegFramer_dst_ip
rx_2110Config rx2110Config[4]
#define kRegSarekSFPStatus
#define SAREK_3190_TX_PACKETIZER_1
bool ConfigurePTP(const eSFP sfp, const std::string localIPAddress)
#define SAREK_2110_AUDIO_STREAMSELECT
#define kReg4175_pkt_pkts_per_line
#define kReg4175_depkt_control
bool SetIGMPVersion(uint32_t version)
void SetVideoFormatForRxTx(const NTV2Stream stream, const NTV2VideoFormat format, const bool rx)
#define SAREK_2110_VIDEO_FRAMER_0
#define SAREK_4175_TX_PACKETIZER_4
virtual bool ReadRegister(const ULWord inRegNum, ULWord &outValue, const ULWord inMask=0xFFFFFFFF, const ULWord inShift=0)
Reads all or part of the 32-bit contents of a specific register (real or virtual) on the AJA device...
#define kReg4175_depkt_rx_byte_cnt
static uint32_t GetDecapsulatorAddress(eSFP sfp, NTV2Stream stream)
#define kRegDecap_match_udp_dst_port
#define SAREK_4175_RX_DEPACKETIZER_3
Fractional rate of 30,000 frames per 1,001 seconds.
#define kReg3190_pkt_chan_num
bool GetRxStreamConfiguration(const eSFP sfp, const NTV2Stream stream, rx_2110Config &rxConfig)
#define kRegFramer_udp_dst_port
uint32_t GetPacketizerAddress(const NTV2Stream stream, const VPIDSampling sampling)
#define kRegPll_swptp_MasterIdLo
bool DisableNetworkInterface(const eSFP sfp)
#define kRegDecap_match_src_ip
bool SetRxStreamConfiguration(const eSFP sfp, const NTV2Stream stream, const rx_2110Config &rxConfig)
#define kReg4175_pkt_width
void UnsetIGMPGroup(eSFP port, NTV2Stream stream)
bool SetIGMPDisable(const eSFP sfp, const bool disable)
Disables the automatic (default) joining of multicast groups using IGMP, based on remote IP address f...
bool GetTxStreamConfiguration(const NTV2Stream stream, tx_2110Config &txConfig)
bool SetNetworkConfiguration(const eSFP sfp, const IPVNetConfig &netConfig)
bool GetTxStreamEnable(const NTV2Stream stream, bool &sfp1Enabled, bool &sfp2Enabled)
static uint32_t audioPacketizers[4]
virtual bool AncInsertSetIPParams(const UWord inSDIOutput, const UWord ancChannel, const ULWord payloadID, const ULWord ssrc)
Configures the Anc inserter IP specific params.
bool operator==(const tx_2110Config &other)
NTV2FrameGeometry
Identifies a particular video frame geometry.
bool GetSFPMSAData(eSFP port, SFPMSAData &data)
Declares numerous NTV2 utility functions.
#define PLL_CONFIG_DCO_MODE
std::string remoteIP[2]
Specifies remote (destination) IP address.
#define RESET_MILLISECONDS
bool SetMBNetworkConfiguration(eSFP port, std::string ipaddr, std::string netmask, std::string gateway)
#define kRegDecap_match_payload
#define SAREK_4175_TX_PACKETIZER_2
bool ExtractRxVideoConfigFromSDP(std::string sdp, rx_2110Config &rxConfig)
bool Set4KModeEnable(const bool enable)
#define kRegSarekSampling
#define kReg4175_pkt_pix_per_pkt
#define kRegFramer_chan_ctrl
#define SAREK_2110_AUDIO_ANC_FRAMER_0
bool GenVideoStreamMultiSDPInfo(std::stringstream &sdp, char *gmInfo)
bool GetLLDPInfo(std::string &chassisId0, std::string &portId0, std::string &chassisId1, std::string &portId1)
bool GetIPServicesControl(bool &enable, bool &forceReconfig)
void ResetDepacketizerStream(const NTV2Stream stream)
bool ExtractRxAncConfigFromSDP(std::string sdp, rx_2110Config &rxConfig)
bool GetRemoteMAC(std::string remote_IPAddress, eSFP port, NTV2Stream stream, std::string &MACaddress)
bool GetTxByteCount(const eSFP sfp, uint64_t &bytes)
virtual bool WriteRegister(const ULWord inRegNum, const ULWord inValue, const ULWord inMask=0xFFFFFFFF, const ULWord inShift=0)
Updates or replaces all or part of the 32-bit contents of a specific register (real or virtual) on th...
#define kRegTxVideoDecode1
uint32_t GetFramerAddress(const eSFP sfp, const NTV2Stream stream)
#define kRegDecap_match_dst_ip
Specifies channel or FrameStore 1 (or the first item).
static uint32_t videoRGB12Packetizers[4]
bool GetAudioCombineEnable(bool &outEnabled)
Answers with the enable/disable state of the audio combiner.
#define kReg3190_pkt_num_audio_channels
static uint32_t audioDepacketizers[4]
#define kRegPll_swptp_LockedState
#define kReg3190_depkt_config
#define kRegPll_PTP_EventUdp
#define SFP_2_NOT_PRESENT
#define kReg3190_pkt_payload_len
#define SAREK_2110_TX_ARBITRATOR
static uint32_t videoPacketizers[4]
#define SAREK_4175_TX_PACKETIZER_RGB12_1
NTV2Stream
Identifies a specific IP-based data stream.
bool GetNetworkConfiguration(const eSFP sfp, IPVNetConfig &netConfig)
NTV2VideoFormat GetFirstMatchingVideoFormat(const NTV2FrameRate inFrameRate, const UWord inHeightLines, const UWord inWidthPixels, const bool inIsInterlaced, const bool inIsLevelB, const bool inIsPSF)
void ResetPacketizerStream(const NTV2Stream stream)
Declares the CNTV2Card class.
NTV2VideoFormat videoFormat
Specifies channel or FrameStore 4 (or the 4th item).
void SetSampling(const eSFP sfp, const NTV2Stream stream, const VPIDSampling sampling)
#define kRegPll_swptp_MasterIdHi
bool GenVideoStreamSDP(std::stringstream &sdp, const bool enableSfp1, const bool enableSfp2, const NTV2Stream stream, char *gmInfo)
std::string sourceIP
Specifies the source (sender) IP address (if RX_MATCH_2110_SOURCE_IP set). If it's in the multiclass ...
bool GetActualSDP(std::string url, std::string &sdp)
#define kReg4175_pkt_chan_num
uint32_t remotePort[2]
Specifies the remote (destination) port number.
#define kReg4175_pkt_interlace_ctrl
bool Get4KModeEnable(bool &enable)
static uint32_t Get2110TxStreamIndex(NTV2Stream stream)
void GetVideoFormatForRxTx(const NTV2Stream stream, NTV2VideoFormat &format, uint32_t &hwFormat, const bool rx)
NTV2StreamType
Identifies the kind of data that can be carried by an IP-based data stream.
virtual bool IsMBSystemValid(void)
void ReleaseFramerControlAccess(const uint32_t baseAddr)
#define SAREK_3190_RX_DEPACKETIZER_2
std::string getLastError(void)
#define SAREK_4175_TX_PACKETIZER_1
#define SAREK_2110_VIDEO_FRAMER_1
bool GetIGMPDisable(const eSFP sfp, bool &disabled)
#define kRegFramer_src_mac_lo
#define kRegRxNtv2VideoDecode1
#define kRegPll_PTP_LclMacLo
uint32_t destPort
Specifies the destination (target) port number (if RX_MATCH_2110_DEST_PORT set)
std::string destIP
Specifies the destination (target) IP address (if RX_MATCH_2110_DEST_IP set)
bool SetPTPDomain(const uint8_t domain)
#define kRegSarekIGMPVersion
#define kRegFramer_dest_mac_hi
#define kRegFramer_src_ip
void AcquireFramerControlAccess(const uint32_t baseAddr)
#define kReg4175_pkt_payload_type
virtual bool IsMBSystemReady(void)
#define kReg3190_pkt_ssrc
eNTV2PacketInterval audioPktInterval
bool DisableNetworkInterface(eSFP port)
#define SAREK_3190_TX_PACKETIZER_3
#define kRegPll_swptp_PreferredGmIdLo
void EnableFramerStream(const eSFP sfp, const NTV2Stream stream, bool enable)
#define kRegFramer_control
bool SetIPServicesControl(const bool enable, const bool forceReconfig)
#define kReg10gemac_rx_bytes_lo
#define SAREK_3190_RX_DEPACKETIZER_1
void EnableDecapsulatorStream(const eSFP sfp, const NTV2Stream stream)
VPIDSampling videoSamples
bool SetTxFormat(NTV2Channel chan, NTV2VideoFormat fmt)
CNTV2Config2110(CNTV2Card &device)
uint32_t ssrc
Specifies the SSRC identifier (if RX_MATCH_2110_SSRC set)
bool ReadChannelRegister(const ULWord inReg, ULWord &outValue, const ULWord inMask=0xFFFFFFFF, const ULWord inShift=0x0)
#define kRegFramer_src_mac_hi
#define NTV2EndianSwap32(__val__)
bool SetPTPPreferredGrandMasterId(const uint8_t id[8])
#define kReg4175_pkt_tx_pkt_cnt
#define kRegFramer_status
#define SAREK_4175_TX_PACKETIZER_RGB12_3
bool SetLLDPInfo(std::string sysname)
#define kReg3190_depkt_rx_pkt_count
Fractional rate of 24,000 frames per 1,001 seconds.
bool SetTxStreamEnable(const NTV2Stream stream, bool enableSfp1, bool enableSfp2=(0))
Specifies channel or FrameStore 3 (or the 3rd item).
bool GetTxFormat(NTV2Channel chan, NTV2VideoFormat &fmt)
#define kRegTxAncPayload1
bool GenVideoStreamSDPInfo(std::stringstream &sdp, const eSFP sfp, const NTV2Stream stream, char *gmInfo)
#define kRegSarekServices
#define kReg4175_pkt_vid_fmt
bool GenAncStreamSDPInfo(std::stringstream &sdp, const eSFP sfp, const NTV2Stream stream, char *gmInfo)
#define kRegPll_PTP_Match
NTV2FrameGeometry GetNTV2FrameGeometryFromVideoFormat(const NTV2VideoFormat inVideoFormat)
#define kRegFramer_ip_hdr_media
void SetChannel(ULWord channelOffset, ULWord channelNumber)