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
8 changes: 4 additions & 4 deletions c/moq/test/probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,10 @@ int main(void) {

/* Subscriber: resolve the announced broadcast and subscribe to its track. */
moq_origin_consumer *remote_origin = moq_session_consume(session);
moq_announced_broadcast *announced = NULL;
ok(moq_origin_consumer_announced_broadcast(remote_origin, "probe", &announced), "announced_broadcast");
moq_following *following = NULL;
ok(moq_origin_consumer_follow(remote_origin, "probe", NULL, &following), "follow");
result available = {0};
task = moq_announced_broadcast_available(announced, on_broadcast, &available);
task = moq_following_available(following, on_broadcast, &available);
moq_broadcast_consumer *remote = await(&available, "available");
moq_task_free(task);
result subscribed = {0};
Expand Down Expand Up @@ -382,7 +382,7 @@ int main(void) {

moq_track_consumer_free(consumer);
moq_broadcast_consumer_free(remote);
moq_announced_broadcast_free(announced);
moq_following_free(following);
moq_origin_consumer_free(remote_origin);
moq_session_free(session);
moq_session_free(served);
Expand Down
2 changes: 1 addition & 1 deletion cpp/moq/test/probe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ int main() {
auto session = ok(connecting.get(), "connect");

// Subscriber: resolve the announced broadcast and subscribe to its track.
auto announced = ok(session->consume()->announced_broadcast("probe"), "announced_broadcast");
auto announced = ok(session->consume()->follow("probe", std::nullopt), "follow");
auto remote = ok(announced->available().get(), "available");
auto consumer = ok(remote->subscribe_track("data", std::nullopt).get(), "subscribe_track");

Expand Down
4 changes: 2 additions & 2 deletions cpp/obs/src/moq-source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ struct Connection {

std::shared_ptr<moq::Client> client;
std::shared_ptr<moq::Session> session;
std::shared_ptr<moq::AnnouncedBroadcast> announced;
std::shared_ptr<moq::Following> announced;

// How many publisher instances `announced` has handed out; the newest is the one read.
uint64_t instance = 0;
Expand Down Expand Up @@ -417,7 +417,7 @@ static void moq_source_on_connect(struct moq_source *ctx, const std::shared_ptr<
// Wait for the broadcast to be announced. Announcements arrive over the session
// after it connects, so resolving against only what is announced *now* would race
// them and blank the source for a broadcast that is live.
auto announced = conn->session->consume()->announced_broadcast(conn->broadcast);
auto announced = conn->session->consume()->follow(conn->broadcast, std::nullopt);
if (!announced) {
LOG_ERROR("Failed to request broadcast '%s': %s", conn->broadcast.c_str(),
announced.error().to_string().c_str());
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 @@ -214,7 +214,7 @@ void CheckSubscriberDecodes(const char *preset, size_t channels)
init.data = encoder.ExtraData();
auto track = TestOk(moq::MediaTrackProducer::audio(broadcast, moq::MediaTarget::kNamed{}, init), "audio track");

auto announced = TestOk(origin->consume()->announced_broadcast("room"), "announced_broadcast");
auto announced = TestOk(origin->consume()->follow("room", std::nullopt), "follow");
auto consumer = TestOk(announced->available().get(), "available");
auto catalogs = TestOk(moq::MediaCatalogConsumer::subscribe(consumer).get(), "catalog consumer");
std::optional<moq::Catalog> catalog;
Expand Down
2 changes: 1 addition & 1 deletion cpp/obs/test/moq-output-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ encoder_packet audioPacket(std::vector<uint8_t> &payload, int64_t pts)
// The output's broadcast as the relay serves it, or null once the wait times out.
std::shared_ptr<moq::BroadcastConsumer> relayBroadcast(TestRelay &relay)
{
auto announced = TestOk(relay.origin->consume()->announced_broadcast("room"), "announced_broadcast");
auto announced = TestOk(relay.origin->consume()->follow("room", std::nullopt), "follow");
auto available = announced->available();
if (available.wait_for(std::chrono::seconds(10)) != std::future_status::ready)
return nullptr;
Expand Down
4 changes: 2 additions & 2 deletions dart/moq/lib/src/aliases.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ typedef AnnounceConsumer = MoqAnnounceConsumer;
/// A literal prefix, an optional relative pattern, and the hidden-path opt-in for announcement discovery.
typedef AnnounceConfig = MoqAnnounceConfig;

/// A pending wait for a route to cover a specific path.
typedef AnnouncedBroadcast = MoqAnnouncedBroadcast;
/// Follows a specific broadcast path across the publisher instances that serve it.
typedef Following = MoqFollowing;

/// How a broadcast advertises its exact path: its static production cost and publisher epoch.
typedef AnnounceRoute = MoqAnnounceRoute;
Expand Down
16 changes: 9 additions & 7 deletions dart/moq/lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,15 @@ final class Moq {
}) => session.consume().announced(config: options._ffi);

/// Follow the broadcast at exactly [path]: each `available()` resolves the
/// next publisher instance serving it, such as a restarted publisher.
AnnouncedBroadcast announcedBroadcast(String path) =>
session.consume().announcedBroadcast(path: path);

/// Resolve an existing broadcast at [path].
Future<BroadcastConsumer> requestBroadcast(String path) =>
session.consume().requestBroadcast(path: path);
/// next publisher instance serving it, such as a restarted publisher. Pass an
/// [epoch] (UUIDv7 text) to follow only that instance.
Following follow(String path, {String? epoch}) =>
session.consume().follow(path: path, epoch: epoch);

/// Resolve one publisher instance of the broadcast at [path]. Pass an
/// [epoch] (UUIDv7 text) to refuse any other instance.
Future<BroadcastConsumer> request(String path, {String? epoch}) =>
session.consume().request(path: path, epoch: epoch);

/// The session's bandwidth allocator.
///
Expand Down
16 changes: 7 additions & 9 deletions dart/moq/test/moq_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,7 @@ void main() {
(await announcement.timeout(timeout) as AnnounceEventStart).announce;
expect(announced.prefix, 'live');

final requested = await client
.requestBroadcast(announced.prefix)
.timeout(timeout);
final requested = await client.request(announced.prefix).timeout(timeout);
final consumer = await requested
.subscribeTrack(name: 'events', subscription: null)
.timeout(timeout);
Expand Down Expand Up @@ -402,7 +400,7 @@ void main() {
broadcast.publishTrack(name: 'events', info: null);
final consumer = origin.consume();
await expectLater(
consumer.requestBroadcast(path: 'live').timeout(timeout),
consumer.request(path: 'live').timeout(timeout),
throwsA(anything),
);

Expand All @@ -417,17 +415,17 @@ void main() {
expect(retracted, isA<AnnounceEventEnd>());
expect((retracted as AnnounceEventEnd).announce.prefix, 'live');
await expectLater(
consumer.requestBroadcast(path: 'live').timeout(timeout),
consumer.request(path: 'live').timeout(timeout),
throwsA(anything),
);

publication.announce(route: AnnounceRoute());
expect(await nextRoute(announced), isA<AnnounceEventStart>());
await consumer.requestBroadcast(path: 'live').timeout(timeout);
await consumer.request(path: 'live').timeout(timeout);

// Disposing the publication keeps the route; closing the broadcast ends it.
publication.dispose();
await consumer.requestBroadcast(path: 'live').timeout(timeout);
await consumer.request(path: 'live').timeout(timeout);
broadcast.close();
expect(await nextRoute(announced), isA<AnnounceEventEnd>());
announced.cancel();
Expand All @@ -447,7 +445,7 @@ void main() {
throwsA(isA<ClosedMoqException>()),
);
expect(() => stale.unannounce(), throwsA(isA<ClosedMoqException>()));
await origin.consume().requestBroadcast(path: 'live').timeout(timeout);
await origin.consume().request(path: 'live').timeout(timeout);
replacement.broadcast().close();
});

Expand Down Expand Up @@ -490,7 +488,7 @@ void main() {
test('dynamic serves a request under a prefix', () async {
final origin = MoqOriginProducer(config: MoqOriginConfig());
final dynamic = origin.requests(prefix: 'live');
final pending = origin.consume().requestBroadcast(path: 'live/cam');
final pending = origin.consume().request(path: 'live/cam');
final request = await dynamic.requestedBroadcast().timeout(timeout);
expect(request.path(), 'live/cam');
final prepared = request.prepare(epoch: mintEpoch());
Expand Down
Loading
Loading