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
4 changes: 4 additions & 0 deletions dart/moq/MIGRATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ How to update your code for each breaking change, newest first.

## Unreleased

### Catalog renditions carry their warmup ([#7864](https://github.com/moq-dev/moq/pull/7864))

`Video` and `Audio` gain `warmup`, the catalog's decoder warmup; it defaults to `null`, so existing constructors still compile. `TrackConsumer` and the audio and video consumers read it from the rendition and start that much earlier.

### Separate datagram tracks

Use `BroadcastProducer.createDatagrams(name: ..., info: ...)` and `BroadcastConsumer.datagrams(name: ...)` instead of stream-track datagram methods. `DatagramProducer.append(timestamp: ..., payload: ...)` assigns a sequence and `insert(datagram: ...)` preserves one; `DatagramConsumer.recv()` reads its own live cursor. `DatagramInfo` contains priority and optional timescale. Watch `priority()` / `priorityChanged(last: ...)` and serve on-demand tracks through `BroadcastRequests.datagrams()` / `DatagramRequests.requested()`.
Expand Down
30 changes: 29 additions & 1 deletion dart/moq_ffi/lib/src/moq.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1350,6 +1350,7 @@ class MoqAudio {
final bool enabled;
final MoqContainer container;
final Duration? jitter;
final Duration? warmup;
MoqAudio({
this.label = null,
this.broadcast = null,
Expand All @@ -1363,6 +1364,7 @@ class MoqAudio {
this.enabled = true,
required this.container,
this.jitter = null,
this.warmup = null,
});
}

Expand Down Expand Up @@ -1433,6 +1435,11 @@ class FfiConverterMoqAudio {
);
final jitter = jitter_lifted.value;
new_offset += jitter_lifted.bytesRead;
final warmup_lifted = FfiConverterOptionalDuration.read(
Uint8List.view(buf.buffer, new_offset),
);
final warmup = warmup_lifted.value;
new_offset += warmup_lifted.bytesRead;
return LiftRetVal(
MoqAudio(
label: label,
Expand All @@ -1447,6 +1454,7 @@ class FfiConverterMoqAudio {
enabled: enabled,
container: container,
jitter: jitter,
warmup: warmup,
),
new_offset - buf.offsetInBytes,
);
Expand All @@ -1466,6 +1474,7 @@ class FfiConverterMoqAudio {
FfiConverterBool.allocationSize(value.enabled) +
FfiConverterMoqContainer.allocationSize(value.container) +
FfiConverterOptionalDuration.allocationSize(value.jitter) +
FfiConverterOptionalDuration.allocationSize(value.warmup) +
0;
final buf = Uint8List(total_length);
write(value, buf);
Expand Down Expand Up @@ -1522,6 +1531,10 @@ class FfiConverterMoqAudio {
value.jitter,
Uint8List.view(buf.buffer, new_offset),
);
new_offset += FfiConverterOptionalDuration.write(
value.warmup,
Uint8List.view(buf.buffer, new_offset),
);
return new_offset - buf.offsetInBytes;
}

Expand All @@ -1538,6 +1551,7 @@ class FfiConverterMoqAudio {
FfiConverterBool.allocationSize(value.enabled) +
FfiConverterMoqContainer.allocationSize(value.container) +
FfiConverterOptionalDuration.allocationSize(value.jitter) +
FfiConverterOptionalDuration.allocationSize(value.warmup) +
0;
}
}
Expand Down Expand Up @@ -2288,6 +2302,7 @@ class MoqVideo {
final int preference;
final double? framerate;
final MoqContainer container;
final Duration? warmup;
MoqVideo({
this.label = null,
this.broadcast = null,
Expand All @@ -2302,6 +2317,7 @@ class MoqVideo {
this.preference = 0,
this.framerate,
required this.container,
this.warmup = null,
});
}

Expand Down Expand Up @@ -2377,6 +2393,11 @@ class FfiConverterMoqVideo {
);
final container = container_lifted.value;
new_offset += container_lifted.bytesRead;
final warmup_lifted = FfiConverterOptionalDuration.read(
Uint8List.view(buf.buffer, new_offset),
);
final warmup = warmup_lifted.value;
new_offset += warmup_lifted.bytesRead;
return LiftRetVal(
MoqVideo(
label: label,
Expand All @@ -2392,6 +2413,7 @@ class FfiConverterMoqVideo {
preference: preference,
framerate: framerate,
container: container,
warmup: warmup,
),
new_offset - buf.offsetInBytes,
);
Expand All @@ -2412,6 +2434,7 @@ class FfiConverterMoqVideo {
FfiConverterInt32.allocationSize(value.preference) +
FfiConverterOptionalDouble64.allocationSize(value.framerate) +
FfiConverterMoqContainer.allocationSize(value.container) +
FfiConverterOptionalDuration.allocationSize(value.warmup) +
0;
final buf = Uint8List(total_length);
write(value, buf);
Expand Down Expand Up @@ -2472,6 +2495,10 @@ class FfiConverterMoqVideo {
value.container,
Uint8List.view(buf.buffer, new_offset),
);
new_offset += FfiConverterOptionalDuration.write(
value.warmup,
Uint8List.view(buf.buffer, new_offset),
);
return new_offset - buf.offsetInBytes;
}

Expand All @@ -2489,6 +2516,7 @@ class FfiConverterMoqVideo {
FfiConverterInt32.allocationSize(value.preference) +
FfiConverterOptionalDouble64.allocationSize(value.framerate) +
FfiConverterMoqContainer.allocationSize(value.container) +
FfiConverterOptionalDuration.allocationSize(value.warmup) +
0;
}
}
Expand Down Expand Up @@ -24109,7 +24137,7 @@ void _checkApiChecksums() {
throw UniffiInternalError.panicked("UniFFI API checksum mismatch");
}
if (uniffi_moq_ffi_checksum_constructor_moqmediatrackconsumer_subscribe() !=
21132) {
16252) {
throw UniffiInternalError.panicked("UniFFI API checksum mismatch");
}
if (uniffi_moq_ffi_checksum_constructor_moqmediatrackproducer_audio() !=
Expand Down
2 changes: 1 addition & 1 deletion doc/lib/rs/hang.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ catalog for you and decodes any container in group order
(`moq_mux::container::Consumer`). Its `Delay { min, max }` says how far behind
the live edge to play: it skips groups that fall past `max`, and starts at the
group covering the live edge less `min` (your playout delay), plus a rendition's
catalog `warmup` passed to `with_warmup`, waiting up to that long for it when the
catalog `warmup` passed to a `Playout`, waiting up to that long for it when the
newest group arrives first. Both default to zero, which starts at the newest
group at once. A backlog that landed before the first read starts within `max`
of the newest content, keeping the group covering the live edge less `min` and
Expand Down
4 changes: 4 additions & 0 deletions go/wrapper/MIGRATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ How to update your code for each breaking change, newest first.

## Unreleased

### Catalog renditions carry their warmup ([#7864](https://github.com/moq-dev/moq/pull/7864))

`ffi.MoqVideo` and `ffi.MoqAudio` (`media.Video` and `media.Audio`) gain `Warmup`, the catalog's decoder warmup, nil when absent. `media.NewTrackConsumer` and the audio and video `Subscribe` read it from the rendition and start that much earlier; a negative one is refused with an error. Only unkeyed struct literals change.

### Separate datagram tracks

Replace stream-track `AppendDatagram` / `InsertDatagram` / `RecvDatagram` with `BroadcastProducer.CreateDatagrams(name, info)` and `BroadcastConsumer.Datagrams(name)`. `DatagramProducer.Append(timestamp, payload)` assigns a sequence and `Insert(Datagram)` preserves one. `DatagramConsumer.Recv(ctx)` and `All(ctx)` read its independent cursor. `DatagramInfo` carries priority and optional timescale. Watch `Priority()` / `PriorityChanged(ctx, last)` and serve on-demand tracks through `BroadcastRequests.Datagrams()` / `DatagramRequests.Requested(ctx)`.
Expand Down
2 changes: 1 addition & 1 deletion go/wrapper/audio/audio.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ type Consumer struct{ inner *ffi.MoqAudioConsumer }

// Subscribe subscribes to the catalog rendition id, following its broadcast and track.
func Subscribe(ctx context.Context, broadcast *moq.BroadcastConsumer, id string, rendition media.Audio, output DecoderOutput) (*Consumer, error) {
if err := bridge.NonNegative(rendition.Jitter, "jitter"); err != nil {
if err := bridge.Audio(rendition); err != nil {
return nil, err
}
out, err := output.ffi()
Expand Down
5 changes: 4 additions & 1 deletion go/wrapper/audio/audio_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ func TestEncoderOutputFrameDuration(t *testing.T) {
}
}

func TestSubscribeRefusesNegativeJitter(t *testing.T) {
func TestSubscribeRefusesNegativeDurations(t *testing.T) {
negative := -time.Millisecond
if _, err := Subscribe(context.Background(), nil, "audio", media.Audio{Jitter: &negative}, DecoderOutput{}); err == nil {
t.Fatal("a negative jitter was subscribed, want an error")
}
if _, err := Subscribe(context.Background(), nil, "audio", media.Audio{Warmup: &negative}, DecoderOutput{}); err == nil {
t.Fatal("a negative warmup was subscribed, want an error")
}
}
22 changes: 19 additions & 3 deletions go/wrapper/internal/bridge/handles.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,26 @@ func NonNegative(value *time.Duration, name string) error {
return nil
}

// Rendition refuses an audio rendition's negative jitter, for the same reason.
// Rendition refuses a rendition's negative jitter or warmup, for the same reason.
func Rendition(rendition ffi.MoqRendition) error {
if audio, ok := rendition.(ffi.MoqRenditionAudio); ok {
return NonNegative(audio.Config.Jitter, "jitter")
switch rendition := rendition.(type) {
case ffi.MoqRenditionAudio:
return Audio(rendition.Config)
case ffi.MoqRenditionVideo:
return Video(rendition.Config)
}
return nil
}

// Audio refuses an audio rendition's negative jitter or warmup.
func Audio(audio ffi.MoqAudio) error {
if err := NonNegative(audio.Jitter, "jitter"); err != nil {
return err
}
return NonNegative(audio.Warmup, "warmup")
}

// Video refuses a video rendition's negative warmup.
func Video(video ffi.MoqVideo) error {
return NonNegative(video.Warmup, "warmup")
}
8 changes: 8 additions & 0 deletions go/wrapper/media/media_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ func TestRefusesNegativeDurations(t *testing.T) {
if _, err := (&moq.BroadcastConsumer{}).Resolve(ctx, rendition); err == nil {
t.Fatal("a negative jitter was resolved, want an error")
}
for _, warmup := range []media.Rendition{
media.AudioRendition("audio", media.Audio{Warmup: &negative}),
media.VideoRendition("video", media.Video{Warmup: &negative}),
} {
if _, err := media.NewTrackConsumer(ctx, nil, media.TrackConfig{Rendition: warmup}); err == nil {
t.Fatal("a negative warmup was subscribed, want an error")
}
}
}

func TestContainerTimebaseBelongsToOneBroadcast(t *testing.T) {
Expand Down
3 changes: 3 additions & 0 deletions go/wrapper/video/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ type Consumer struct{ inner *ffi.MoqVideoConsumer }

// Subscribe subscribes to the catalog rendition id, following its broadcast and track.
func Subscribe(ctx context.Context, broadcast *moq.BroadcastConsumer, id string, rendition media.Video, output DecoderOutput) (*Consumer, error) {
if err := bridge.Video(rendition); err != nil {
return nil, err
}
out, err := output.ffi()
if err != nil {
return nil, err
Expand Down
17 changes: 17 additions & 0 deletions go/wrapper/video/video_internal_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package video

import (
"context"
"testing"
"time"

"moq.dev/moq/media"
)

// The generated converter panics on a negative duration, so it is refused first.
func TestSubscribeRefusesNegativeWarmup(t *testing.T) {
negative := -time.Millisecond
if _, err := Subscribe(context.Background(), nil, "video", media.Video{Warmup: &negative}, DecoderOutput{}); err == nil {
t.Fatal("a negative warmup was subscribed, want an error")
}
}
2 changes: 1 addition & 1 deletion js/hang/src/container/consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export interface ConsumerProps {
* How much further than the min delay the start reaches, in milliseconds (default: 0), so a
* decoder that needs that much media before its output is clean starts early enough, such as an
* Opus decoder or the max-delay decoder of an intra-refresh rendition. Pass the catalog
* rendition's `warmup`. Mirrors Rust's `Consumer::with_warmup`.
* rendition's `warmup`. Mirrors Rust's `container::Playout`.
*
* Put the max delay plus the warmup on the subscription, since the publisher skips what falls
* outside that budget. The start is no later than the group covering the live edge less
Expand Down
4 changes: 4 additions & 0 deletions kt/moq/MIGRATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ How to update your code for each breaking change, newest first.

## Unreleased

### Catalog renditions carry their warmup ([#7864](https://github.com/moq-dev/moq/pull/7864))

`Video` and `Audio` gain `warmup`, the catalog's decoder warmup; it defaults to `null` as the last field, so existing code keeps working. `TrackConsumer` and the audio and video consumers read it from the rendition and start that much earlier.

### Separate datagram tracks

Replace stream-track `appendDatagram` / `insertDatagram` / `recvDatagram` with `BroadcastProducer.createDatagrams(name, info)` and `BroadcastConsumer.datagrams(name)`. The separate `DatagramProducer` has `append(timestamp, payload)` and `insert(Datagram)`; `DatagramConsumer` has `recv()` and the `datagrams()` flow. Use `priority()` / `priorityChanged(last)` for aggregate demand, and `BroadcastRequests.datagrams()` / `DatagramRequests.requested()` for on-demand tracks. `DatagramInfo` has only publisher priority and optional timescale.
Expand Down
4 changes: 4 additions & 0 deletions py/moq-rs/MIGRATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ How to update your code for each breaking change, newest first.

## Unreleased

### Catalog renditions carry their warmup ([#7864](https://github.com/moq-dev/moq/pull/7864))

`Video` and `Audio` gain `warmup`, the catalog's decoder warmup; it defaults to `None` as the last field, so existing code keeps working. `TrackConsumer` and the audio and video consumers read it from the rendition and start that much earlier.

### Separate datagram tracks

Replace stream-track `append_datagram` / `insert_datagram` / `recv_datagram` with `broadcast.create_datagrams(name, info)` and `broadcast.consume().datagrams(name)`. The returned `DatagramProducer` uses `append(payload, timestamp=...)` and `insert(Datagram(...))`; `DatagramConsumer` supports `recv()` and async iteration. `DatagramInfo` contains priority and optional timescale. Demand is `priority()` / `await priority_changed(last)`; on-demand handlers come from `broadcast.requests().datagrams()`. Stream tracks of the same name are independent.
Expand Down
1 change: 0 additions & 1 deletion quest/m1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ their end report, so an embedder's drain alert pages on real cuts.
- [Ordered reads can skip owed holes, and snapshot latest() does](/quest/m1/ordered-owed-holes.md) - moq-net's `Ordered` gains a read that skips past an owed hole to the newest buffered group, while keeping the reader's bounds
- [The relay reports native sessions it force-closes at the drain deadline](/quest/m1/relay-drain-cuts.md) - the drain's public outcome and live tally separate sessions cut while open from sessions only finishing their end report, so an embedder's drain alert pages on real cuts
- [A Rust relay never replays from group 0 to a lite-03/04 subscriber](/quest/m1/relay-inflight-replay.md) - A Rust relay or publisher serving a lite-03 or lite-04 SUBSCRIBE from a track copy that is still resolving starts at the newest group once the copy resolves
- [Every moq-mux consumer gets the catalog warmup from one entry point](/quest/m1/mux-warmup.md) - one moq-mux call widens the subscription and configures the consumer, adopted by moq-audio, moq-c, moq-ffi's raw consumer, and moqsrc
- [Rename moq-rtc to moq-webrtc](/quest/m1/webrtc-rename.md) - one published `moq-webrtc` crate holds the gateway, the ICE driver, and the data-channel transport
- [Vendor and trim the WebRTC stack](/quest/m1/webrtc-vendor.md) - str0m, dimpl, `is`, and sctp-proto live in moq-webrtc with unused code removed, so moq-rtc can take rind
- [MoQ on rind](/quest/m1/rind/README.md) - every MoQ crate takes its crypto from rind, a pure-Rust graviola fork, so no build compiles C crypto
Expand Down
46 changes: 0 additions & 46 deletions quest/m1/mux-warmup.md

This file was deleted.

18 changes: 6 additions & 12 deletions rs/moq-audio/src/decode/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,19 +200,15 @@ impl Consumer {

let name = name.into();
let warmup = catalog.warmup.unwrap_or_default();
let playout = moq_mux::container::Playout::new(options.delay, warmup);
let track = broadcast.track(hang::catalog::Reference::track(catalog, &name))?;
// The whole delay from the start, as the container keeps it: the transport enforces the
// max too, so a narrower one while joining would drop the groups queued behind a reader
// slow to take its first, and the publisher should never see a stated zero min first.
let mut subscriber = track
.subscribe(
moq_net::track::Subscription::default()
.with_priority(hang::catalog::PRIORITY.audio)
.with_delay(
options
.delay
.with_max(options.delay.max.map(|max| max.saturating_add(warmup))),
),
playout
.subscription(moq_net::track::Subscription::default().with_priority(hang::catalog::PRIORITY.audio)),
)
.await?;
// Latest skips cached history; a warmup is primed by trimming the newest group's
Expand Down Expand Up @@ -247,11 +243,9 @@ impl Consumer {
// wire: `moq import fmp4` publishes CMAF. Reading a moof+mdat fragment as a
// varint timestamp plus a payload decodes to garbage rather than failing.
let container = moq_mux::catalog::hang::Container::try_from(catalog)?;
// The subscription's budget includes the warmup, so the start reaches the playout delay
// plus the warmup back, while the container skips at the max delay alone.
let track = moq_mux::container::Consumer::new(track, container)
.with_warmup(warmup)
.with_delay(options.delay);
// The start reaches the playout delay plus the warmup back, while the container skips at
// the max delay alone.
let track = playout.consumer(track, container);

Ok(Self {
target: Target::new(delay, options.estimate, catalog.jitter),
Expand Down
Loading
Loading