Do not expose the underlying QuicServer in MoqtServer.
QuicServer will probably go away once I add raw QUIC support.
PiperOrigin-RevId: 843370628
diff --git a/quiche/quic/moqt/tools/moq_chat_end_to_end_test.cc b/quiche/quic/moqt/tools/moq_chat_end_to_end_test.cc
index 9af4ae5..e17e8d0 100644
--- a/quiche/quic/moqt/tools/moq_chat_end_to_end_test.cc
+++ b/quiche/quic/moqt/tools/moq_chat_end_to_end_test.cc
@@ -68,15 +68,15 @@
auto if2ptr = std::make_unique<MockChatUserInterface>();
interface1_ = if1ptr.get();
interface2_ = if2ptr.get();
- uint16_t port = relay_.server()->quic_server().port();
+ uint16_t port = relay_.server()->port();
client1_ = std::make_unique<moqt::moq_chat::ChatClient>(
quic::QuicServerId(std::string(kChatHostname), port), true,
std::move(if1ptr), "test_chat", "client1", "device1",
- relay_.server()->quic_server().event_loop());
+ relay_.server()->event_loop());
client2_ = std::make_unique<moqt::moq_chat::ChatClient>(
quic::QuicServerId(std::string(kChatHostname), port), true,
std::move(if2ptr), "test_chat", "client2", "device2",
- relay_.server()->quic_server().event_loop());
+ relay_.server()->event_loop());
}
void SendAndWaitForOutput(MockChatUserInterface* sender,
@@ -89,7 +89,7 @@
});
sender->SendMessage(message);
while (!message_to_output) {
- relay_.server()->quic_server().WaitForEvents();
+ relay_.server()->WaitForEvents();
}
}
@@ -104,7 +104,7 @@
EXPECT_TRUE(client1_->PublishNamespaceAndSubscribeNamespace());
EXPECT_TRUE(client2_->PublishNamespaceAndSubscribeNamespace());
while (client1_->is_syncing() || client2_->is_syncing()) {
- relay_.server()->quic_server().WaitForEvents();
+ relay_.server()->WaitForEvents();
}
SendAndWaitForOutput(interface1_, interface2_, "client1", "Hello");
SendAndWaitForOutput(interface2_, interface1_, "client2", "Hi");
@@ -115,7 +115,7 @@
interface1_->SendMessage("/exit");
EXPECT_CALL(*interface2_, WriteToOutput(_, _)).Times(0);
- relay_.server()->quic_server().WaitForEvents();
+ relay_.server()->WaitForEvents();
}
TEST_F(MoqChatEndToEndTest, EndToEndTestUngracefulClose) {
@@ -124,7 +124,7 @@
EXPECT_TRUE(client1_->PublishNamespaceAndSubscribeNamespace());
EXPECT_TRUE(client2_->PublishNamespaceAndSubscribeNamespace());
while (client1_->is_syncing() || client2_->is_syncing()) {
- relay_.server()->quic_server().WaitForEvents();
+ relay_.server()->WaitForEvents();
}
SendAndWaitForOutput(interface1_, interface2_, "client1", "Hello");
SendAndWaitForOutput(interface2_, interface1_, "client2", "Hi");
@@ -140,7 +140,7 @@
EXPECT_TRUE(client1_->PublishNamespaceAndSubscribeNamespace());
EXPECT_TRUE(client2_->PublishNamespaceAndSubscribeNamespace());
while (client1_->is_syncing() || client2_->is_syncing()) {
- relay_.server()->quic_server().WaitForEvents();
+ relay_.server()->WaitForEvents();
}
SendAndWaitForOutput(interface1_, interface2_, "client1", "Hello");
SendAndWaitForOutput(interface2_, interface1_, "client2", "Hi");
@@ -159,26 +159,26 @@
});
interface1_->SendMessage("/exit");
while (client1_->session_is_open()) {
- relay_.server()->quic_server().WaitForEvents();
+ relay_.server()->WaitForEvents();
}
client1_.reset();
while (!namespace_done) {
// Wait for the relay's session cleanup to send PUBLISH_NAMESPACE_DONE
// and PUBLISH_DONE.
- relay_.server()->quic_server().WaitForEvents();
+ relay_.server()->WaitForEvents();
}
// Create a new client with the same username and Reconnect.
auto if1bptr = std::make_unique<MockChatUserInterface>();
MockChatUserInterface* interface1b_ = if1bptr.get();
- uint16_t port = relay_.server()->quic_server().port();
+ uint16_t port = relay_.server()->port();
client1_ = std::make_unique<moqt::moq_chat::ChatClient>(
quic::QuicServerId(std::string(kChatHostname), port), true,
std::move(if1bptr), "test_chat", "client1", "device1",
- relay_.server()->quic_server().event_loop());
+ relay_.server()->event_loop());
EXPECT_TRUE(client1_->Connect(moqt::moq_chat::kWebtransPath));
EXPECT_TRUE(client1_->PublishNamespaceAndSubscribeNamespace());
while (client1_->is_syncing() || client2_->is_syncing()) {
- relay_.server()->quic_server().WaitForEvents();
+ relay_.server()->WaitForEvents();
}
SendAndWaitForOutput(interface1b_, interface2_, "client1", "Hello again");
SendAndWaitForOutput(interface2_, interface1b_, "client2", "Hi again");
diff --git a/quiche/quic/moqt/tools/moqt_end_to_end_test.cc b/quiche/quic/moqt/tools/moqt_end_to_end_test.cc
index 718dd49..0cb2910 100644
--- a/quiche/quic/moqt/tools/moqt_end_to_end_test.cc
+++ b/quiche/quic/moqt/tools/moqt_end_to_end_test.cc
@@ -46,12 +46,11 @@
: server_(quic::test::crypto_test_utils::ProofSourceForTesting(),
absl::bind_front(&MoqtEndToEndTest::ServerBackend, this)) {
quic::QuicIpAddress host = quic::TestLoopback();
- bool success = server_.quic_server().CreateUDPSocketAndListen(
+ bool success = server_.CreateUDPSocketAndListen(
quic::QuicSocketAddress(host, /*port=*/0));
QUICHE_CHECK(success);
- server_address_ =
- quic::QuicSocketAddress(host, server_.quic_server().port());
- event_loop_ = server_.quic_server().event_loop();
+ server_address_ = quic::QuicSocketAddress(host, server_.port());
+ event_loop_ = server_.event_loop();
}
absl::StatusOr<MoqtConfigureSessionCallback> ServerBackend(
diff --git a/quiche/quic/moqt/tools/moqt_ingestion_server_bin.cc b/quiche/quic/moqt/tools/moqt_ingestion_server_bin.cc
index d75cdb1..2b22e92 100644
--- a/quiche/quic/moqt/tools/moqt_ingestion_server_bin.cc
+++ b/quiche/quic/moqt/tools/moqt_ingestion_server_bin.cc
@@ -264,9 +264,9 @@
quiche::QuicheIpAddress bind_address;
QUICHE_CHECK(bind_address.FromString(
quiche::GetQuicheCommandLineFlag(FLAGS_bind_address)));
- server.quic_server().CreateUDPSocketAndListen(quic::QuicSocketAddress(
+ server.CreateUDPSocketAndListen(quic::QuicSocketAddress(
bind_address, quiche::GetQuicheCommandLineFlag(FLAGS_port)));
- server.quic_server().HandleEventsForever();
+ server.HandleEventsForever();
return 0;
}
diff --git a/quiche/quic/moqt/tools/moqt_relay.cc b/quiche/quic/moqt/tools/moqt_relay.cc
index 648cab5..0d0ea7e 100644
--- a/quiche/quic/moqt/tools/moqt_relay.cc
+++ b/quiche/quic/moqt/tools/moqt_relay.cc
@@ -57,12 +57,12 @@
QUICHE_CHECK(bind_ip_address.FromString(bind_address));
// CreateUDPSocketAndListen() creates the event loop that we will pass to
// MoqtClient.
- server_->quic_server().CreateUDPSocketAndListen(
+ server_->CreateUDPSocketAndListen(
quic::QuicSocketAddress(bind_ip_address, bind_port));
if (!default_upstream.empty()) {
quic::QuicUrl url(default_upstream, "https");
if (client_event_loop == nullptr) {
- client_event_loop = server_->quic_server().event_loop();
+ client_event_loop = server_->event_loop();
}
default_upstream_client_ =
CreateClient(url, ignore_certificate, client_event_loop_);
diff --git a/quiche/quic/moqt/tools/moqt_relay.h b/quiche/quic/moqt/tools/moqt_relay.h
index 4aabde3..a5579eb 100644
--- a/quiche/quic/moqt/tools/moqt_relay.h
+++ b/quiche/quic/moqt/tools/moqt_relay.h
@@ -41,7 +41,7 @@
publisher_.Close();
}
- void HandleEventsForever() { server_->quic_server().HandleEventsForever(); }
+ void HandleEventsForever() { server_->HandleEventsForever(); }
protected: // Constructor for MoqtTestRelay.
// If |client_event_loop| is null, the event loop from |server_| is used. For
diff --git a/quiche/quic/moqt/tools/moqt_relay_test.cc b/quiche/quic/moqt/tools/moqt_relay_test.cc
index 720b63c..ddb4928 100644
--- a/quiche/quic/moqt/tools/moqt_relay_test.cc
+++ b/quiche/quic/moqt/tools/moqt_relay_test.cc
@@ -45,9 +45,7 @@
bind_address, bind_port, default_upstream, ignore_certificate,
event_loop) {}
- quic::QuicEventLoop* server_event_loop() {
- return server()->quic_server().event_loop();
- }
+ quic::QuicEventLoop* server_event_loop() { return server()->event_loop(); }
void RunOneEvent() {
server_event_loop()->RunEventLoopOnce(kEventLoopDuration);
diff --git a/quiche/quic/moqt/tools/moqt_server.h b/quiche/quic/moqt/tools/moqt_server.h
index 0f87f12..a4996f6 100644
--- a/quiche/quic/moqt/tools/moqt_server.h
+++ b/quiche/quic/moqt/tools/moqt_server.h
@@ -11,7 +11,9 @@
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
#include "quiche/quic/core/crypto/proof_source.h"
+#include "quiche/quic/core/io/quic_event_loop.h"
#include "quiche/quic/moqt/moqt_session.h"
+#include "quiche/quic/platform/api/quic_socket_address.h"
#include "quiche/quic/tools/quic_server.h"
#include "quiche/quic/tools/web_transport_only_backend.h"
#include "quiche/common/platform/api/quiche_export.h"
@@ -38,7 +40,13 @@
explicit MoqtServer(std::unique_ptr<quic::ProofSource> proof_source,
MoqtIncomingSessionCallback callback);
- quic::QuicServer& quic_server() { return server_; }
+ bool CreateUDPSocketAndListen(const quic::QuicSocketAddress& address) {
+ return server_.CreateUDPSocketAndListen(address);
+ }
+ void WaitForEvents() { server_.WaitForEvents(); }
+ void HandleEventsForever() { server_.HandleEventsForever(); }
+ quic::QuicEventLoop* event_loop() { return server_.event_loop(); }
+ int port() { return server_.port(); }
private:
friend class test::MoqtServerPeer;
diff --git a/quiche/quic/moqt/tools/moqt_server_test.cc b/quiche/quic/moqt/tools/moqt_server_test.cc
index ec2546e..b654819 100644
--- a/quiche/quic/moqt/tools/moqt_server_test.cc
+++ b/quiche/quic/moqt/tools/moqt_server_test.cc
@@ -42,7 +42,7 @@
quiche::QuicheIpAddress bind_address;
bind_address.FromString("127.0.0.1");
// This will create an event loop that makes alarm factories.
- EXPECT_TRUE(server_.quic_server().CreateUDPSocketAndListen(
+ EXPECT_TRUE(server_.CreateUDPSocketAndListen(
quic::QuicSocketAddress(bind_address, 0)));
}