Connect Cast Streaming to UdpSocket.
Changes the cast_streaming::Environment to create/bind/own the UDP
socket for the session, rather than have it passed-in to its
constructor. This allows it to become a UdpSocket::Client to be able to
dispatch inbound UDP packets to the rest of the system.
Updated downstream interfaces to support a zero-copy path for the packet
data, now that the upstream API has settled on the platform::UdpPacket
class.
Also, noted one bug in udp_socket.cc, and then fixed a subtle bug in
udp_socket_posix.cc (return after OnError).
Bug: openscreen:56
Change-Id: Ic71518ab88fc39b45d526fb6396aaf740e16f921
Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/1779588
Reviewed-by: Yuri Wiitala <miu@chromium.org>
Reviewed-by: Ryan Keane <rwkeane@google.com>
Commit-Queue: Yuri Wiitala <miu@chromium.org>
diff --git a/platform/api/udp_socket.cc b/platform/api/udp_socket.cc
index 56b2f05..263d300 100644
--- a/platform/api/udp_socket.cc
+++ b/platform/api/udp_socket.cc
@@ -38,24 +38,29 @@
}
task_runner_->PostTask([e = std::move(error), this]() mutable {
+ // TODO(issues/71): |this| may be invalid at this point.
this->client_->OnError(this, std::move(e));
});
}
+
void UdpSocket::OnSendError(Error error) {
if (!client_) {
return;
}
task_runner_->PostTask([e = std::move(error), this]() mutable {
+ // TODO(issues/71): |this| may be invalid at this point.
this->client_->OnSendError(this, std::move(e));
});
}
+
void UdpSocket::OnRead(ErrorOr<UdpPacket> read_data) {
if (!client_) {
return;
}
task_runner_->PostTask([data = std::move(read_data), this]() mutable {
+ // TODO(issues/71): |this| may be invalid at this point.
this->client_->OnRead(this, std::move(data));
});
}