Skip to content

Commit 0fbe0b0

Browse files
afrindfacebook-github-bot
authored andcommitted
Allow subscribes to clients
Summary: When a client publishes via relay it has to accept subscribes Reviewed By: yuandagits Differential Revision: D64016783 fbshipit-source-id: 18c5849c5e6abedfedee67bf10f48c2c40f1924b
1 parent efb0e6e commit 0fbe0b0

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

moxygen/MoQClient.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,15 @@ folly::coro::Task<void> MoQClient::setupMoQSession(
9292
// Setup MoQSession parameters
9393
moqSession_ = std::move(moqSession.value());
9494
moqSession_->start();
95+
// TODO: maybe let the caller set max subscribes. Any client that publishes
96+
// via relay needs to support subscribes.
97+
const uint32_t kDefaultMaxSubscribeId = 100;
9598
moqSession_->setup(ClientSetup(
9699
{{kVersionDraftCurrent},
97-
{{folly::to_underlying(SetupKey::ROLE),
100+
{{folly::to_underlying(SetupKey::ROLE), "", folly::to_underlying(role)},
101+
{folly::to_underlying(SetupKey::MAX_SUBSCRIBE_ID),
98102
"",
99-
folly::to_underlying(role)}}}));
103+
kDefaultMaxSubscribeId}}}));
100104
co_await moqSession_->setupComplete();
101105
}
102106

moxygen/MoQSession.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ void MoQSession::onClientSetup(ClientSetup clientSetup) {
202202
receivedSetup_.cancel();
203203
return;
204204
}
205+
peerMaxSubscribeID_ = getMaxSubscribeIdIfPresent(clientSetup.params);
205206
receivedSetup_.signal();
206207
controlMessages_.enqueue(std::move(clientSetup));
207208
setupComplete().scheduleOn(evb_).start();
@@ -511,6 +512,12 @@ folly::coro::Task<
511512
MoQSession::subscribe(SubscribeRequest sub) {
512513
XLOG(DBG1) << __func__ << " sess=" << this;
513514
auto fullTrackName = sub.fullTrackName;
515+
if (nextSubscribeID_ >= peerMaxSubscribeID_) {
516+
XLOG(WARN) << "Issuing subscribe that will fail; nextSubscribeID_="
517+
<< nextSubscribeID_
518+
<< " peerMaxSubscribeID_=" << peerMaxSubscribeID_
519+
<< " sess=" << this;
520+
}
514521
auto subID = nextSubscribeID_++;
515522
sub.subscribeID = subID;
516523
sub.trackAlias = sub.subscribeID;

0 commit comments

Comments
 (0)