Remove the default implementation string from incoming parameters. PiperOrigin-RevId: 838905264
diff --git a/quiche/quic/moqt/moqt_messages.h b/quiche/quic/moqt/moqt_messages.h index 6e64394..1d7d846 100644 --- a/quiche/quic/moqt/moqt_messages.h +++ b/quiche/quic/moqt/moqt_messages.h
@@ -46,6 +46,8 @@ }; inline constexpr MoqtVersion kDefaultMoqtVersion = MoqtVersion::kDraft14; +inline constexpr absl::string_view kVersionString = + "Google QUICHE MOQT draft 14"; inline constexpr uint64_t kDefaultInitialMaxRequestId = 100; // TODO(martinduke): Implement an auth token cache. inline constexpr uint64_t kDefaultMaxAuthTokenCacheSize = 0; @@ -111,7 +113,7 @@ // TODO(martinduke): Turn authorization_token into structured data. std::vector<AuthToken> authorization_token; std::string authority; - std::string moqt_implementation = "Google QUICHE MOQT draft 14"; + std::string moqt_implementation; }; // The maximum length of a message, excluding any OBJECT payload. This prevents
diff --git a/quiche/quic/moqt/moqt_parser.cc b/quiche/quic/moqt/moqt_parser.cc index a70244f..60ecf47 100644 --- a/quiche/quic/moqt/moqt_parser.cc +++ b/quiche/quic/moqt/moqt_parser.cc
@@ -1104,7 +1104,6 @@ bool MoqtControlParser::KeyValuePairListToMoqtSessionParameters( const KeyValuePairList& parameters, MoqtSessionParameters& out) { - out.moqt_implementation = ""; return parameters.ForEach( [&](uint64_t key, uint64_t value) { SetupParameter parameter = static_cast<SetupParameter>(key);
diff --git a/quiche/quic/moqt/moqt_session.cc b/quiche/quic/moqt/moqt_session.cc index 7f8abeb..c32f8f2 100644 --- a/quiche/quic/moqt/moqt_session.cc +++ b/quiche/quic/moqt/moqt_session.cc
@@ -120,6 +120,8 @@ } else { next_incoming_request_id_ = 1; } + QUICHE_DCHECK(parameters_.moqt_implementation.empty()); + parameters_.moqt_implementation = kVersionString; } MoqtSession::ControlStream* MoqtSession::GetControlStream() {
diff --git a/quiche/quic/moqt/moqt_session_test.cc b/quiche/quic/moqt/moqt_session_test.cc index 805c39e..ebf1f65 100644 --- a/quiche/quic/moqt/moqt_session_test.cc +++ b/quiche/quic/moqt/moqt_session_test.cc
@@ -133,6 +133,8 @@ MoqtSessionPeer::set_peer_max_request_id(&session_, kDefaultInitialMaxRequestId); ON_CALL(mock_session_, GetStreamById).WillByDefault(Return(&mock_stream_)); + EXPECT_EQ(MoqtSessionPeer::GetImplementationString(&session_), + kVersionString); } ~MoqtSessionTest() { EXPECT_CALL(session_callbacks_.session_deleted_callback, Call());
diff --git a/quiche/quic/moqt/test_tools/moqt_session_peer.h b/quiche/quic/moqt/test_tools/moqt_session_peer.h index 8a40f5b..d16d5a0 100644 --- a/quiche/quic/moqt/test_tools/moqt_session_peer.h +++ b/quiche/quic/moqt/test_tools/moqt_session_peer.h
@@ -12,6 +12,7 @@ #include "absl/status/status.h" +#include "absl/strings/string_view.h" #include "quiche/quic/core/quic_alarm.h" #include "quiche/quic/core/quic_alarm_factory.h" #include "quiche/quic/core/quic_time.h" @@ -253,6 +254,10 @@ ->reset_subgroups() .contains(index); } + + static absl::string_view GetImplementationString(MoqtSession* session) { + return session->parameters_.moqt_implementation; + } }; } // namespace moqt::test
diff --git a/quiche/quic/moqt/test_tools/moqt_test_message.h b/quiche/quic/moqt/test_tools/moqt_test_message.h index a12aedd..909c58a 100644 --- a/quiche/quic/moqt/test_tools/moqt_test_message.h +++ b/quiche/quic/moqt/test_tools/moqt_test_message.h
@@ -62,6 +62,9 @@ return types; } +constexpr absl::string_view kTestImplementationString = + "Moq Test Implementation Type"; + // Base class containing a wire image and the corresponding structured // representation of an example of each message. It allows parser and framer // tests to iterate through all message types without much specialized code. @@ -494,14 +497,16 @@ public: explicit ClientSetupMessage(bool webtrans) : TestMessageBase() { client_setup_.parameters.using_webtrans = webtrans; + client_setup_.parameters.moqt_implementation = kTestImplementationString; if (webtrans) { // Should not send PATH or AUTHORITY. client_setup_.parameters.path = ""; client_setup_.parameters.authority = ""; - raw_packet_[2] = 0x23; // adjust payload length (-17) + raw_packet_[2] = 0x24; // adjust payload length (-17) raw_packet_[6] = 0x02; // only two parameters // Move MoqtImplementation up in the packet. - memmove(raw_packet_ + 9, raw_packet_ + 26, 29); + memmove(raw_packet_ + 9, raw_packet_ + 26, + kTestImplementationString.length() + 2); SetWireImage(raw_packet_, sizeof(raw_packet_) - 17); } else { SetWireImage(raw_packet_, sizeof(raw_packet_)); @@ -546,8 +551,8 @@ // string parameters in order. Unfortunately, this means that // kMoqtImplementation goes last even though it is always present, while // kPath and KAuthority aren't. - uint8_t raw_packet_[55] = { - 0x20, 0x00, 0x34, // type, length + uint8_t raw_packet_[56] = { + 0x20, 0x00, 0x35, // type, length 0x02, 0x01, 0x02, // versions 0x04, // 4 parameters 0x02, 0x32, // max_request_id = 50 @@ -555,9 +560,9 @@ 0x05, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, // authority = "authority" // moqt_implementation: - 0x07, 0x1b, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x20, 0x51, 0x55, 0x49, - 0x43, 0x48, 0x45, 0x20, 0x4d, 0x4f, 0x51, 0x54, 0x20, 0x64, 0x72, 0x61, - 0x66, 0x74, 0x20, 0x31, 0x34}; + 0x07, 0x1c, 0x4d, 0x6f, 0x71, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x49, + 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x20, 0x54, 0x79, 0x70, 0x65}; MoqtClientSetup client_setup_ = { /*supported_versions=*/std::vector<MoqtVersion>( {static_cast<MoqtVersion>(1), static_cast<MoqtVersion>(2)}), @@ -570,6 +575,7 @@ public: explicit ServerSetupMessage(bool webtrans) : TestMessageBase() { server_setup_.parameters.using_webtrans = webtrans; + server_setup_.parameters.moqt_implementation = kTestImplementationString; SetWireImage(raw_packet_, sizeof(raw_packet_)); } @@ -589,17 +595,17 @@ } private: - uint8_t raw_packet_[36] = {0x21, 0x00, - 0x21, // type + uint8_t raw_packet_[37] = {0x21, 0x00, + 0x22, // type 0x01, 0x02, // version, two parameters 0x02, 0x32, // max_subscribe_id = 50 // moqt_implementation: - 0x07, 0x1b, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x20, 0x51, 0x55, 0x49, 0x43, 0x48, 0x45, 0x20, - 0x4d, 0x4f, 0x51, 0x54, 0x20, 0x64, 0x72, 0x61, - 0x66, 0x74, 0x20, 0x31, 0x34}; + 0x07, 0x1c, 0x4d, 0x6f, 0x71, 0x20, 0x54, 0x65, + 0x73, 0x74, 0x20, 0x49, 0x6d, 0x70, 0x6c, 0x65, + 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x20, 0x54, 0x79, 0x70, 0x65}; MoqtServerSetup server_setup_ = { /*selected_version=*/static_cast<MoqtVersion>(1), MoqtSessionParameters(quic::Perspective::IS_SERVER, 50),