70 std::vector<stream_info> results;
71 std::set<std::string> seenUIDs;
77 if (!udpSocket.bind(QHostAddress::AnyIPv4, DISCOVERY_PORT,
78 QAbstractSocket::ShareAddress | QAbstractSocket::ReuseAddressHint)) {
79 qDebug() <<
"[lsl::resolve_streams] Failed to bind UDP socket:" << udpSocket.errorString();
85 if (!udpSocket.joinMulticastGroup(DISCOVERY_MULTICAST_GROUP)) {
86 qDebug() <<
"[lsl::resolve_streams] Failed to join multicast group:" << udpSocket.errorString();
92 int timeoutMs =
static_cast<int>(timeout * 1000.0);
96 while (timer.elapsed() < timeoutMs) {
98 int remainingMs = timeoutMs -
static_cast<int>(timer.elapsed());
99 if (remainingMs <= 0) {
103 if (!udpSocket.waitForReadyRead(remainingMs)) {
108 while (udpSocket.hasPendingDatagrams()) {
109 QNetworkDatagram datagram = udpSocket.receiveDatagram();
110 if (!datagram.isValid()) {
114 QByteArray data = datagram.data();
115 std::string payload(data.constData(), data.size());
121 if (info.
uid().empty() || info.
name().empty()) {
126 if (seenUIDs.count(info.
uid()) > 0) {
131 info.
set_data_host(datagram.senderAddress().toString().toStdString());
133 seenUIDs.insert(info.
uid());
134 results.push_back(info);
140 udpSocket.leaveMulticastGroup(DISCOVERY_MULTICAST_GROUP);
150 const std::string& value,
157 std::vector<stream_info> filtered;
158 for (
const auto& info : all) {
160 if (prop ==
"name") {
161 actual = info.name();
162 }
else if (prop ==
"type") {
163 actual = info.type();
164 }
else if (prop ==
"source_id") {
165 actual = info.source_id();
166 }
else if (prop ==
"uid") {
168 }
else if (prop ==
"hostname") {
169 actual = info.hostname();
174 if (actual == value) {
175 filtered.push_back(info);