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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cpp/obs/src/moq-settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,9 @@ std::string Configure(obs_data_t *settings, moq::ClientConfig &config)
// transport free to pick.
if (const char *family = OptionalString(settings, QUIC_CONGESTION_CONTROL)) {
if (strcmp(family, "delay") == 0)
config.quic.congestion_control = moq::CongestionControl::kDelay;
config.quic.congestion_control = moq::CongestionControl::delay();
else if (strcmp(family, "loss") == 0)
config.quic.congestion_control = moq::CongestionControl::kLoss;
config.quic.congestion_control = moq::CongestionControl::loss();
else
Refuse(error, std::string("unknown congestion control: ") + family);
}
Expand Down
3 changes: 2 additions & 1 deletion cpp/obs/test/moq-settings-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ int main()
CHECK(config.timeout == std::chrono::milliseconds(7000));
CHECK(config.race == std::chrono::milliseconds(80));
CHECK(config.tls.host_name == std::string("relay.example"));
CHECK(config.quic.congestion_control == moq::CongestionControl::kLoss);
CHECK(config.quic.congestion_control);
CHECK(config.quic.congestion_control->eq(moq::CongestionControl::loss()));
CHECK(config.quic.idle_timeout == std::chrono::milliseconds(9000));
CHECK(config.quic.keep_alive == std::chrono::nanoseconds::zero());
CHECK(config.quic.gso == false);
Expand Down
4 changes: 3 additions & 1 deletion dart/moq/lib/src/aliases.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ typedef Request = MoqRequest;
/// The network transport carrying an incoming session.
typedef Transport = MoqTransport;

/// The congestion control family for a QUIC connection.
/// The congestion control family for a QUIC connection. Build one with
/// `CongestionControl.delay()`, `.loss()`, or `.none()`; a new algorithm joins as
/// a new constructor.
typedef CongestionControl = MoqCongestionControl;

/// Certificate trust and the mTLS identity for `ConnectOptions.tls`.
Expand Down
2 changes: 1 addition & 1 deletion dart/moq/test/moq_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ void main() {
keepAlive: Duration.zero,
gso: false,
mtuDiscovery: true,
congestionControl: CongestionControl.loss,
congestionControl: CongestionControl.loss(),
keylog: false,
),
once: true,
Expand Down
268 changes: 230 additions & 38 deletions dart/moq_ffi/lib/src/moq.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8751,44 +8751,6 @@ class FfiConverterMoqTransport {
}
}

enum MoqCongestionControl { loss, delay, none }

class FfiConverterMoqCongestionControl {
static LiftRetVal<MoqCongestionControl> read(Uint8List buf) {
final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0);
switch (index) {
case 1:
return LiftRetVal(MoqCongestionControl.loss, 4);
case 2:
return LiftRetVal(MoqCongestionControl.delay, 4);
case 3:
return LiftRetVal(MoqCongestionControl.none, 4);
default:
throw UniffiInternalError(
UniffiInternalError.unexpectedEnumCase,
"Unable to determine enum variant",
);
}
}

static MoqCongestionControl lift(RustBuffer buffer) {
return FfiConverterMoqCongestionControl.read(buffer.asUint8List()).value;
}

static RustBuffer lower(MoqCongestionControl input) {
return toRustBuffer(createUint8ListFromInt(input.index + 1));
}

static int allocationSize(MoqCongestionControl _value) {
return 4;
}

static int write(MoqCongestionControl value, Uint8List buf) {
buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, value.index + 1);
return 4;
}
}

abstract class MoqConnectionPhase {
RustBuffer lower();
int allocationSize();
Expand Down Expand Up @@ -15950,6 +15912,143 @@ class FfiConverterMoqClient {
}
}

abstract class MoqCongestionControlInterface {}

final _MoqCongestionControlFinalizer = Finalizer<Pointer<Void>>((ptr) {
rustCall(
(status) => uniffi_moq_ffi_fn_free_moqcongestioncontrol(ptr, status),
);
});

class MoqCongestionControl implements MoqCongestionControlInterface {
late final Pointer<Void> _ptr;
bool _isDisposed = false;
MoqCongestionControl._(this._ptr) {
_MoqCongestionControlFinalizer.attach(this, _ptr, detach: this);
}
MoqCongestionControl.delay()
: _ptr = rustCall(
(status) =>
uniffi_moq_ffi_fn_constructor_moqcongestioncontrol_delay(status),
null,
) {
_MoqCongestionControlFinalizer.attach(this, _ptr, detach: this);
}
MoqCongestionControl.loss()
: _ptr = rustCall(
(status) =>
uniffi_moq_ffi_fn_constructor_moqcongestioncontrol_loss(status),
null,
) {
_MoqCongestionControlFinalizer.attach(this, _ptr, detach: this);
}
MoqCongestionControl.none()
: _ptr = rustCall(
(status) =>
uniffi_moq_ffi_fn_constructor_moqcongestioncontrol_none(status),
null,
) {
_MoqCongestionControlFinalizer.attach(this, _ptr, detach: this);
}
factory MoqCongestionControl.lift(Pointer<Void> ptr) {
return MoqCongestionControl._(ptr);
}
Pointer<Void> uniffiClonePointer() {
if (_isDisposed) {
throw StateError("Object has already been disposed");
}
return rustCall(
(status) => uniffi_moq_ffi_fn_clone_moqcongestioncontrol(_ptr, status),
);
}

void dispose() {
if (_isDisposed) {
return;
}
final status = calloc<RustCallStatus>();
_isDisposed = true;
_MoqCongestionControlFinalizer.detach(this);
try {
uniffi_moq_ffi_fn_free_moqcongestioncontrol(_ptr, status);
checkCallStatus(NullRustCallStatusErrorHandler(), status);
} finally {
calloc.free(status);
}
}

String debugString() {
return rustCallWithLifter(
(status) =>
uniffi_moq_ffi_fn_method_moqcongestioncontrol_uniffi_trait_debug(
uniffiClonePointer(),
status,
),
FfiConverterString.lift,
null,
);
}

@override
bool operator ==(Object other) {
if (identical(this, other)) {
return true;
}
if (other is! MoqCongestionControl) {
return false;
}
return rustCallWithLifter(
(status) =>
uniffi_moq_ffi_fn_method_moqcongestioncontrol_uniffi_trait_eq_eq(
uniffiClonePointer(),
FfiConverterMoqCongestionControl.lower(other),
status,
),
FfiConverterBool.lift,
null,
);
}

@override
int get hashCode {
return rustCallWithLifter(
(status) =>
uniffi_moq_ffi_fn_method_moqcongestioncontrol_uniffi_trait_hash(
uniffiClonePointer(),
status,
),
FfiConverterUInt64.lift,
null,
);
}
}

class FfiConverterMoqCongestionControl {
static MoqCongestionControl lift(Pointer<Void> ptr) {
return MoqCongestionControl.lift(ptr);
}

static Pointer<Void> lower(MoqCongestionControl value) {
return value.uniffiClonePointer();
}

static int allocationSize(MoqCongestionControl value) {
return 8;
}

static LiftRetVal<MoqCongestionControl> read(Uint8List buf) {
final handle = buf.buffer.asByteData(buf.offsetInBytes).getInt64(0);
final pointer = Pointer<Void>.fromAddress(handle);
return LiftRetVal(MoqCongestionControl.lift(pointer), 8);
}

static int write(MoqCongestionControl value, Uint8List buf) {
final handle = lower(value);
buf.buffer.asByteData(buf.offsetInBytes).setInt64(0, handle.address);
return 8;
}
}

abstract class MoqSessionInterface {
MoqAllocator allocator();
void cancel({required int code});
Expand Down Expand Up @@ -23045,6 +23144,78 @@ external Pointer<Void> uniffi_moq_ffi_fn_method_moqclient_connect(
RustBuffer url,
);

@Native<Pointer<Void> Function(Pointer<Void>, Pointer<RustCallStatus>)>(
assetId: _uniffiAssetId,
)
external Pointer<Void> uniffi_moq_ffi_fn_clone_moqcongestioncontrol(
Pointer<Void> handle,
Pointer<RustCallStatus> uniffiStatus,
);

@Native<Void Function(Pointer<Void>, Pointer<RustCallStatus>)>(
assetId: _uniffiAssetId,
)
external void uniffi_moq_ffi_fn_free_moqcongestioncontrol(
Pointer<Void> handle,
Pointer<RustCallStatus> uniffiStatus,
);

@Native<Pointer<Void> Function(Pointer<RustCallStatus>)>(
assetId: _uniffiAssetId,
)
external Pointer<Void> uniffi_moq_ffi_fn_constructor_moqcongestioncontrol_delay(
Pointer<RustCallStatus> uniffiStatus,
);

@Native<Pointer<Void> Function(Pointer<RustCallStatus>)>(
assetId: _uniffiAssetId,
)
external Pointer<Void> uniffi_moq_ffi_fn_constructor_moqcongestioncontrol_loss(
Pointer<RustCallStatus> uniffiStatus,
);

@Native<Pointer<Void> Function(Pointer<RustCallStatus>)>(
assetId: _uniffiAssetId,
)
external Pointer<Void> uniffi_moq_ffi_fn_constructor_moqcongestioncontrol_none(
Pointer<RustCallStatus> uniffiStatus,
);

@Native<RustBuffer Function(Pointer<Void>, Pointer<RustCallStatus>)>(
assetId: _uniffiAssetId,
)
external RustBuffer
uniffi_moq_ffi_fn_method_moqcongestioncontrol_uniffi_trait_debug(
Pointer<Void> ptr,
Pointer<RustCallStatus> uniffiStatus,
);

@Native<Int8 Function(Pointer<Void>, Pointer<Void>, Pointer<RustCallStatus>)>(
assetId: _uniffiAssetId,
)
external int uniffi_moq_ffi_fn_method_moqcongestioncontrol_uniffi_trait_eq_eq(
Pointer<Void> ptr,
Pointer<Void> other,
Pointer<RustCallStatus> uniffiStatus,
);

@Native<Int8 Function(Pointer<Void>, Pointer<Void>, Pointer<RustCallStatus>)>(
assetId: _uniffiAssetId,
)
external int uniffi_moq_ffi_fn_method_moqcongestioncontrol_uniffi_trait_eq_ne(
Pointer<Void> ptr,
Pointer<Void> other,
Pointer<RustCallStatus> uniffiStatus,
);

@Native<Uint64 Function(Pointer<Void>, Pointer<RustCallStatus>)>(
assetId: _uniffiAssetId,
)
external int uniffi_moq_ffi_fn_method_moqcongestioncontrol_uniffi_trait_hash(
Pointer<Void> ptr,
Pointer<RustCallStatus> uniffiStatus,
);

@Native<Pointer<Void> Function(Pointer<Void>, Pointer<RustCallStatus>)>(
assetId: _uniffiAssetId,
)
Expand Down Expand Up @@ -24833,6 +25004,15 @@ external int uniffi_moq_ffi_checksum_constructor_moqserver_new();
@Native<Uint16 Function()>(assetId: _uniffiAssetId)
external int uniffi_moq_ffi_checksum_constructor_moqclient_new();

@Native<Uint16 Function()>(assetId: _uniffiAssetId)
external int uniffi_moq_ffi_checksum_constructor_moqcongestioncontrol_delay();

@Native<Uint16 Function()>(assetId: _uniffiAssetId)
external int uniffi_moq_ffi_checksum_constructor_moqcongestioncontrol_loss();

@Native<Uint16 Function()>(assetId: _uniffiAssetId)
external int uniffi_moq_ffi_checksum_constructor_moqcongestioncontrol_none();

@Native<Uint16 Function()>(assetId: _uniffiAssetId)
external int uniffi_moq_ffi_checksum_constructor_moqsocketendpoint_new();

Expand Down Expand Up @@ -25753,6 +25933,18 @@ void _checkApiChecksums() {
if (uniffi_moq_ffi_checksum_constructor_moqclient_new() != 48355) {
throw UniffiInternalError.panicked("UniFFI API checksum mismatch");
}
if (uniffi_moq_ffi_checksum_constructor_moqcongestioncontrol_delay() !=
62385) {
throw UniffiInternalError.panicked("UniFFI API checksum mismatch");
}
if (uniffi_moq_ffi_checksum_constructor_moqcongestioncontrol_loss() !=
53409) {
throw UniffiInternalError.panicked("UniFFI API checksum mismatch");
}
if (uniffi_moq_ffi_checksum_constructor_moqcongestioncontrol_none() !=
50250) {
throw UniffiInternalError.panicked("UniFFI API checksum mismatch");
}
if (uniffi_moq_ffi_checksum_constructor_moqsocketendpoint_new() != 25288) {
throw UniffiInternalError.panicked("UniFFI API checksum mismatch");
}
Expand Down
2 changes: 1 addition & 1 deletion doc/bin/relay/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Transport tuning, applied to accepted and dialed connections alike.

```toml
[quic]
congestion_control = "delay" # "delay" (BBR, the default), "loss" (CUBIC), or "none".
congestion_control = "delay" # "delay" (BBR v3, the default), "loss" (CUBIC), or "none".
max_streams = 10000 # Concurrent streams per connection, bidi and uni; 0 is refused. Default.
idle_timeout = "10s" # Drop a connection after this long with nothing on it. Default.
# keep_alive = "3s" # Ping interval; unset or "0s" derives it from the idle timeout.
Expand Down
4 changes: 2 additions & 2 deletions go/wrapper/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ type QUICConfig struct {
GSO *bool
// MTUDiscovery toggles path MTU discovery.
MTUDiscovery *bool
// CongestionControl picks the congestion control family.
// CongestionControl picks the congestion control family; nil leaves the choice to the backend.
CongestionControl *CongestionControl
// Qlog is a directory, which must exist, to write qlog traces into. Dial
// fails unless QlogSupported.
Expand Down Expand Up @@ -185,7 +185,7 @@ func (c ClientConfig) ffi() (ffi.MoqClientConfig, error) {
KeepAlive: c.QUIC.KeepAlive,
Gso: c.QUIC.GSO,
MtuDiscovery: c.QUIC.MTUDiscovery,
CongestionControl: c.QUIC.CongestionControl,
CongestionControl: optional(c.QUIC.CongestionControl),
Qlog: str(c.QUIC.Qlog),
Keylog: keylog,
},
Expand Down
8 changes: 4 additions & 4 deletions go/wrapper/origin.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ func (o RouteOptions) ffi() ffi.MoqRouteOptions {
return ffi.MoqRouteOptions{Hidden: o.Hidden, Cost: o.Cost, Instance: optional(o.Instance), Epoch: o.Epoch}
}

// optional lowers a nil instance to the ffi's None.
func optional(instance *Instance) **ffi.MoqInstance {
if instance == nil {
// optional lowers a nil ffi object to the ffi's None.
func optional[T any](object *T) **T {
if object == nil {
return nil
}
return &instance
return &object
}

// Route creates a route at exactly path, owning a new broadcast to fill.
Expand Down
Loading