71 std::vector<stream_info> results;
72 std::set<std::string> seenUIDs;
78 if (!udpSocket.bind(QHostAddress::AnyIPv4, DISCOVERY_PORT,
79 QAbstractSocket::ShareAddress | QAbstractSocket::ReuseAddressHint)) {
80 qDebug() <<
"[lsl::resolve_streams] Failed to bind UDP socket:" << udpSocket.errorString();
86 if (!udpSocket.joinMulticastGroup(DISCOVERY_MULTICAST_GROUP)) {
87 qDebug() <<
"[lsl::resolve_streams] Failed to join multicast group:" << udpSocket.errorString();
93 int timeoutMs =
static_cast<int>(timeout * 1000.0);
97 while (timer.elapsed() < timeoutMs) {
99 int remainingMs = timeoutMs -
static_cast<int>(timer.elapsed());
100 if (remainingMs <= 0) {
104 if (!udpSocket.waitForReadyRead(remainingMs)) {
109 while (udpSocket.hasPendingDatagrams()) {
110 QNetworkDatagram datagram = udpSocket.receiveDatagram();
111 if (!datagram.isValid()) {
115 QByteArray data = datagram.data();
116 std::string payload(data.constData(), data.size());
122 if (info.
uid().empty() || info.
name().empty()) {
127 if (seenUIDs.count(info.
uid()) > 0) {
132 info.
set_data_host(datagram.senderAddress().toString().toStdString());
134 seenUIDs.insert(info.
uid());
135 results.push_back(info);
141 udpSocket.leaveMulticastGroup(DISCOVERY_MULTICAST_GROUP);
151 const std::string& value,
158 std::vector<stream_info> filtered;
159 for (
const auto& info : all) {
161 if (prop ==
"name") {
162 actual = info.name();
163 }
else if (prop ==
"type") {
164 actual = info.type();
165 }
else if (prop ==
"source_id") {
166 actual = info.source_id();
167 }
else if (prop ==
"uid") {
169 }
else if (prop ==
"hostname") {
170 actual = info.hostname();
175 if (actual == value) {
176 filtered.push_back(info);