1 // Copyright 2023 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef QUICHE_QUIC_MOQT_TOOLS_MOQT_SERVER_H_ 6 7 #define QUICHE_QUIC_MOQT_TOOLS_MOQT_SERVER_H_ 8 9 #include <memory> 10 11 #include "absl/status/statusor.h" 12 #include "absl/strings/string_view.h" 13 #include "quiche/quic/core/crypto/proof_source.h" 14 #include "quiche/quic/moqt/moqt_session.h" 15 #include "quiche/quic/tools/quic_server.h" 16 #include "quiche/quic/tools/web_transport_only_backend.h" 17 #include "quiche/common/platform/api/quiche_export.h" 18 #include "quiche/common/quiche_callbacks.h" 19 20 namespace moqt { 21 22 // A callback to configure an already created MoQT session. 23 using MoqtConfigureSessionCallback = 24 quiche::SingleUseCallback<void(MoqtSession* session)>; 25 26 // A callback to provide MoQT handler based on the path in the request. 27 using MoqtIncomingSessionCallback = 28 quiche::MultiUseCallback<absl::StatusOr<MoqtConfigureSessionCallback>( 29 absl::string_view path)>; 30 31 // A simple MoQT server. 32 class QUICHE_EXPORT MoqtServer { 33 public: 34 explicit MoqtServer(std::unique_ptr<quic::ProofSource> proof_source, 35 MoqtIncomingSessionCallback callback); 36 quic_server()37 quic::QuicServer& quic_server() { return server_; } 38 39 private: 40 quic::WebTransportOnlyBackend backend_; 41 quic::QuicServer server_; 42 }; 43 44 } // namespace moqt 45 46 #endif // QUICHE_QUIC_MOQT_TOOLS_MOQT_SERVER_H_ 47