MCPcopy Create free account
hub / github.com/Haivision/srt / UpdateGroupStatus

Method UpdateGroupStatus

testing/testmedia.cpp:1510–1601  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1508
1509#if ENABLE_BONDING
1510void SrtCommon::UpdateGroupStatus(const SRT_SOCKGROUPDATA* grpdata, size_t grpdata_size)
1511{
1512 if (!grpdata)
1513 {
1514 // This happens when you passed too small array. Treat this as error and stop.
1515 cerr << "ERROR: broadcast group update reports " << grpdata_size
1516 << " existing sockets, but app registered only " << m_group_nodes.size() << endl;
1517 Error("Too many unpredicted sockets in the group");
1518 }
1519
1520 // Clear the active flag in all nodes so that they are reactivated
1521 // if they are in the group list, REGARDLESS OF THE STATUS. We need to
1522 // see all connections that are in the nodes, but not in the group,
1523 // and this one would have to be activated.
1524 const SRT_SOCKGROUPDATA* gend = grpdata + grpdata_size;
1525 for (auto& n: m_group_nodes)
1526 {
1527 bool active = (find_if(grpdata, gend,
1528 [&n] (const SRT_SOCKGROUPDATA& sg) { return sg.id == n.socket; }) != gend);
1529 if (!active)
1530 n.socket = SRT_INVALID_SOCK;
1531 }
1532
1533 // Note: sockets are not necessarily in the same order. Find
1534 // the socket by id.
1535 for (size_t i = 0; i < grpdata_size; ++i)
1536 {
1537 const SRT_SOCKGROUPDATA& d = grpdata[i];
1538 SRTSOCKET id = d.id;
1539
1540 SRT_SOCKSTATUS status = d.sockstate;
1541 int result = d.result;
1542 SRT_MEMBERSTATUS mstatus = d.memberstate;
1543
1544 if (result != -1 && status == SRTS_CONNECTED)
1545 {
1546 // Short report with the state.
1547 Verb() << "G@" << id << "<" << MemberStatusStr(mstatus) << "> " << VerbNoEOL;
1548 continue;
1549 }
1550 // id, status, result, peeraddr
1551 Verb() << "\n\tG@" << id << " <" << SockStatusStr(status) << "/" << MemberStatusStr(mstatus) << "> (=" << result << ") PEER:"
1552 << sockaddr_any((sockaddr*)&d.peeraddr, sizeof d.peeraddr).str() << VerbNoEOL;
1553
1554 if (status >= SRTS_BROKEN)
1555 {
1556 Verb() << "NOTE: socket @" << id << " is pending for destruction, waiting for it.";
1557 }
1558 }
1559
1560 // This was only informative. Now we check all nodes if they
1561 // are not active
1562
1563 int i = 1;
1564 for (auto& n: m_group_nodes)
1565 {
1566 if (n.error != SRT_SUCCESS)
1567 {

Callers

nothing calls this directly

Calls 13

VerbFunction · 0.85
MemberStatusStrFunction · 0.85
SockStatusStrFunction · 0.85
srt_strerrorFunction · 0.85
srt_rejectreason_strFunction · 0.85
srt_prepare_endpointFunction · 0.85
srt_connect_groupFunction · 0.85
sockaddr_anyClass · 0.50
CreateAddrFunction · 0.50
sizeMethod · 0.45
strMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected