72 std::vector<stream_info> results;
73 std::set<std::string> seenUIDs;
79 if (!udpSocket.bind(QHostAddress::AnyIPv4, DISCOVERY_PORT,
80 QAbstractSocket::ShareAddress | QAbstractSocket::ReuseAddressHint)) {
81 qDebug() <<
"[lsl::resolve_streams] Failed to bind UDP socket:" << udpSocket.errorString();
87 if (!udpSocket.joinMulticastGroup(DISCOVERY_MULTICAST_GROUP)) {
88 qDebug() <<
"[lsl::resolve_streams] Failed to join multicast group:" << udpSocket.errorString();
94 int timeoutMs =
static_cast<int>(timeout * 1000.0);
98 while (timer.elapsed() < timeoutMs) {
100 int remainingMs = timeoutMs -
static_cast<int>(timer.elapsed());
101 if (remainingMs <= 0) {
105 if (!udpSocket.waitForReadyRead(remainingMs)) {
110 while (udpSocket.hasPendingDatagrams()) {
111 QNetworkDatagram datagram = udpSocket.receiveDatagram();
112 if (!datagram.isValid()) {
116 QByteArray data = datagram.data();
117 std::string payload(data.constData(), data.size());
123 if (info.
uid().empty() || info.
name().empty()) {
128 if (seenUIDs.count(info.
uid()) > 0) {
133 info.
set_data_host(datagram.senderAddress().toString().toStdString());
135 seenUIDs.insert(info.
uid());
136 results.push_back(info);
142 udpSocket.leaveMulticastGroup(DISCOVERY_MULTICAST_GROUP);
152 const std::string& value,
159 std::vector<stream_info> filtered;
160 for (
const auto& info : all) {
162 if (prop ==
"name") {
163 actual = info.name();
164 }
else if (prop ==
"type") {
165 actual = info.type();
166 }
else if (prop ==
"source_id") {
167 actual = info.source_id();
168 }
else if (prop ==
"uid") {
170 }
else if (prop ==
"hostname") {
171 actual = info.hostname();
176 if (actual == value) {
177 filtered.push_back(info);