Fix the definition of MoQT MAX_SUBSCRIBE_ID.

The provided value is one more than the maximum subscribe ID allowed, not the highest allowed.

PiperOrigin-RevId: 702040595
diff --git a/quiche/quic/moqt/moqt_session.cc b/quiche/quic/moqt/moqt_session.cc
index 5fda82e..772dbff 100644
--- a/quiche/quic/moqt/moqt_session.cc
+++ b/quiche/quic/moqt/moqt_session.cc
@@ -449,7 +449,7 @@
     return false;
   }
   // TODO(martinduke): support authorization info
-  if (next_subscribe_id_ > peer_max_subscribe_id_) {
+  if (next_subscribe_id_ >= peer_max_subscribe_id_) {
     QUIC_DLOG(INFO) << ENDPOINT << "Tried to send SUBSCRIBE with ID "
                     << next_subscribe_id_
                     << " which is greater than the maximum ID "
@@ -624,7 +624,7 @@
     Error(MoqtError::kProtocolViolation, "Received SUBSCRIBE from publisher");
     return false;
   }
-  if (subscribe_id > local_max_subscribe_id_) {
+  if (subscribe_id >= local_max_subscribe_id_) {
     QUIC_DLOG(INFO) << ENDPOINT << "Received SUBSCRIBE with too large ID";
     Error(MoqtError::kTooManySubscribes,
           "Received SUBSCRIBE with too large ID");
diff --git a/quiche/quic/moqt/moqt_session.h b/quiche/quic/moqt/moqt_session.h
index 628f188..33063ba 100644
--- a/quiche/quic/moqt/moqt_session.h
+++ b/quiche/quic/moqt/moqt_session.h
@@ -577,7 +577,7 @@
   uint64_t next_remote_track_alias_ = 0;
   // The next subscribe ID that the local endpoint can send.
   uint64_t next_subscribe_id_ = 0;
-  // The maximum subscribe ID that the local endpoint can send.
+  // The local endpoint can send subscribe IDs less than this value.
   uint64_t peer_max_subscribe_id_ = 0;
 
   // All open incoming subscriptions, indexed by track name, used to check for
@@ -617,7 +617,8 @@
 
   // The minimum subscribe ID the peer can use that is monotonically increasing.
   uint64_t next_incoming_subscribe_id_ = 0;
-  // The maximum subscribe ID sent to the peer.
+  // The maximum subscribe ID sent to the peer. Peer-generated IDs must be less
+  // than this value.
   uint64_t local_max_subscribe_id_ = 0;
 
   // Must be last.  Token used to make sure that the streams do not call into
diff --git a/quiche/quic/moqt/moqt_session_test.cc b/quiche/quic/moqt/moqt_session_test.cc
index 3298cfc..349c147 100644
--- a/quiche/quic/moqt/moqt_session_test.cc
+++ b/quiche/quic/moqt/moqt_session_test.cc
@@ -452,7 +452,7 @@
 
 TEST_F(MoqtSessionTest, TooManySubscribes) {
   MoqtSessionPeer::set_next_subscribe_id(&session_,
-                                         kDefaultInitialMaxSubscribeId);
+                                         kDefaultInitialMaxSubscribeId - 1);
   MockSubscribeRemoteTrackVisitor remote_track_visitor;
   webtransport::test::MockStream mock_stream;
   std::unique_ptr<MoqtControlParserVisitor> stream_input =
@@ -462,7 +462,7 @@
               Writev(ControlMessageOfType(MoqtMessageType::kSubscribe), _));
   EXPECT_TRUE(session_.SubscribeCurrentGroup(FullTrackName("foo", "bar"),
                                              &remote_track_visitor));
-  EXPECT_FALSE(session_.SubscribeCurrentGroup(FullTrackName("foo", "bar"),
+  EXPECT_FALSE(session_.SubscribeCurrentGroup(FullTrackName("foo2", "bar2"),
                                               &remote_track_visitor));
 }
 
@@ -508,7 +508,7 @@
 
 TEST_F(MoqtSessionTest, MaxSubscribeIdChangesResponse) {
   MoqtSessionPeer::set_next_subscribe_id(&session_,
-                                         kDefaultInitialMaxSubscribeId + 1);
+                                         kDefaultInitialMaxSubscribeId);
   MockSubscribeRemoteTrackVisitor remote_track_visitor;
   EXPECT_FALSE(session_.SubscribeCurrentGroup(FullTrackName("foo", "bar"),
                                               &remote_track_visitor));
@@ -552,7 +552,7 @@
   session_.GrantMoreSubscribes(1);
   // Peer subscribes to (0, 0)
   MoqtSubscribe request = {
-      /*subscribe_id=*/kDefaultInitialMaxSubscribeId + 1,
+      /*subscribe_id=*/kDefaultInitialMaxSubscribeId,
       /*track_alias=*/2,
       /*full_track_name=*/FullTrackName({"foo", "bar"}),
       /*subscriber_priority=*/0x80,