Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions c/moq/test/probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,7 @@ int main(void)
route_options.hidden = true;
moq_route *route = NULL;
ok(moq_origin_producer_route(origin, "probe", &route_options, &route), "route");
moq_broadcast_producer *broadcast = NULL;
ok(moq_route_broadcast(route, &broadcast), "route broadcast");
moq_broadcast_producer *broadcast = moq_route_broadcast(route);
char *instance = moq_route_instance_id(route);
CHECK(instance && instance[0] != '\0');
moq_string_free(instance);
Expand Down Expand Up @@ -464,8 +463,7 @@ int main(void)
late_options.hidden = true;
moq_route *late_route = NULL;
ok(moq_origin_producer_route(late_origin, "late", &late_options, &late_route), "late route");
moq_broadcast_producer *late_broadcast = NULL;
ok(moq_route_broadcast(late_route, &late_broadcast), "late broadcast");
moq_broadcast_producer *late_broadcast = moq_route_broadcast(late_route);
moq_route_free(late_route);
moq_track_producer *late_track = NULL;
ok(moq_broadcast_producer_publish_track(late_broadcast, "data", &info, &late_track), "late track");
Expand Down
2 changes: 1 addition & 1 deletion cpp/moq/bench/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void throughput(Case c, double budget, std::vector<Result> &results)
moq::RouteOptions hidden;
hidden.hidden = true;
auto route = ok(origin->route("bench", hidden));
auto broadcast = ok(route->broadcast());
auto broadcast = route->broadcast();
std::vector<std::shared_ptr<moq::TrackProducer>> tracks;
std::vector<std::shared_ptr<moq::TrackConsumer>> consumers;
moq::TrackInfo info;
Expand Down
4 changes: 2 additions & 2 deletions cpp/moq/test/probe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,15 +300,15 @@ int main()
hidden.hidden = true;
auto route = ok(origin->route("probe", hidden), "route");
CHECK(!route->instance_id().empty());
auto broadcast = ok(route->broadcast(), "route broadcast");
auto broadcast = route->broadcast();
moq::TrackInfo info;
info.timescale = 1000000;
auto track = ok(broadcast->publish_track("data", info), "publish_track");
ok(route->announce(), "announce");

// A route whose broadcast closed can no longer announce.
auto stale = ok(origin->route("stale", {}), "route");
ok(ok(stale->broadcast(), "stale broadcast")->close(), "close stale broadcast");
ok(stale->broadcast()->close(), "close stale broadcast");
auto reannounced = stale->announce();
CHECK(!reannounced);
CHECK(std::holds_alternative<moq::Error::kClosed>(reannounced.error().get_variant()));
Expand Down
6 changes: 1 addition & 5 deletions cpp/obs/src/moq-output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,6 @@ bool MoQOutput::Start()
return false;
}
auto next_broadcast = (*next_route)->broadcast();
if (!next_broadcast) {
LOG_ERROR("Failed to create broadcast: %s", next_broadcast.error().to_string().c_str());
return false;
}

// Advanced settings live on the service alongside the URL and path. With the group
// switched off the client keeps the library defaults.
Expand Down Expand Up @@ -235,7 +231,7 @@ bool MoQOutput::Start()
std::lock_guard<std::mutex> lock(media_mutex);
origin = next_origin;
route = *next_route;
broadcast = *next_broadcast;
broadcast = next_broadcast;
}

// NOTE: You could publish the same broadcasts to multiple sessions if you want (redundant ingest).
Expand Down
2 changes: 1 addition & 1 deletion cpp/obs/test/moq-audio-encoder-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ void CheckSubscriberDecodes(const char *preset, size_t channels)

auto origin = moq::OriginProducer::init(moq::OriginConfig{});
auto route = TestOk(origin->route("room", {}), "route");
auto broadcast = TestOk(route->broadcast(), "route broadcast");
auto broadcast = route->broadcast();

moq::AudioInit init{};
init.format = moq::AudioFormat::kOpus;
Expand Down
2 changes: 1 addition & 1 deletion cpp/obs/test/moq-source-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ class Publisher {
moq::RouteOptions hidden;
hidden.hidden = true;
route = TestOk(relay.origin->route(path, hidden), "route");
broadcast = TestOk(route->broadcast(), "route broadcast");
broadcast = route->broadcast();
if (video) {
moq::VideoInit init{};
init.format = moq::VideoFormat::kAvc3;
Expand Down
7 changes: 6 additions & 1 deletion dart/moq/lib/src/aliases.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@ typedef CongestionControl = MoqCongestionControl;
/// Certificate trust and the mTLS identity for `ConnectOptions.tls`.
typedef ClientTls = MoqClientTls;

/// The publish side of an origin: create routes so subscribers can discover their broadcasts.
/// The publish side of an origin: create routes and claims so subscribers can discover their broadcasts.
typedef OriginProducer = MoqOriginProducer;

/// A prefix route from `OriginProducer.claim`: a claim that every path beneath a prefix can be
/// served, yielding each request from `requested()`. Cancelling or disposing it retracts it and
/// rejects the requests still waiting.
typedef Claim = MoqClaim;

/// Config for creating an origin, such as its total cache budget.
typedef OriginConfig = MoqOriginConfig;

Expand Down
17 changes: 11 additions & 6 deletions dart/moq/lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,17 @@ extension GrantConsumerUpdates on GrantConsumer {

/// A route's instance under the name the other bindings use.
extension RouteInstance on MoqRoute {
/// The stream this route serves now. A named instance never changes. Unnamed,
/// a prefix route moves to a fresh one each time a job holding its current one
/// ends. A job's route takes its prefix route's current one when it first
/// announces or when this first reads it, so a hidden job route returns it
/// before announcing, and [MoqRoute.announce] fails with `Unroutable` once the
/// prefix route has moved past it.
/// The stream this route serves now. A named instance never changes. A job's
/// route takes its claim's current one when it first announces or when this
/// first reads it, so a hidden job route returns it before announcing, and
/// [MoqRoute.announce] fails with `Unroutable` once the claim has moved past it.
String instance() => instanceId();
}

/// A claim's instance under the name the other bindings use.
extension ClaimInstance on MoqClaim {
/// The stream this claim serves now. A named instance never changes. Unnamed,
/// the claim moves to a fresh one each time a job holding its current one ends.
String instance() => instanceId();
}

Expand Down
5 changes: 2 additions & 3 deletions dart/moq/test/moq_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -688,20 +688,19 @@ void main() {

test('dynamic serves a request under a prefix', () async {
final origin = MoqOriginProducer(config: MoqOriginConfig());
final dynamic = origin.routePrefix(prefix: 'live', options: RouteOptions());
final dynamic = origin.claim(prefix: 'live', options: RouteOptions());
final pending = origin.consume().request(path: 'live/cam');
final request = (await dynamic.requested().timeout(timeout))!;
expect(request.path(), 'live/cam');
// A hidden job route answers nobody until it announces, under the instance its
// prefix route lends.
// claim lends.
final served = request.route(options: RouteOptions(hidden: true));
expect(served.instance(), dynamic.instance());
served.announce();
await pending.timeout(timeout);
// Closing the job's broadcast ends its route.
served.broadcast().close();
expect(() => served.announce(), throwsA(isA<ClosedMoqException>()));
expect(() => dynamic.broadcast(), throwsA(isA<InternalMoqException>()));
dynamic.cancel();
await expectLater(
dynamic.requested(),
Expand Down
Loading
Loading