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
13 changes: 0 additions & 13 deletions cpp/moq/include/moq/moq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include <moq/ffi/moq.hpp>

#include <chrono>
#include <functional>
#include <string>
#include <utility>
Expand Down Expand Up @@ -62,18 +61,6 @@ inline void shutdown() noexcept {
::uniffi::shutdown_async_dispatcher();
}

// The wall-clock time an epoch encodes, to the millisecond. Errors unless it is a UUIDv7.
// Millisecond ticks hold every 48-bit UUIDv7 time, where system_clock's nanoseconds overflow in 2262.
inline expected<std::chrono::time_point<std::chrono::system_clock, std::chrono::milliseconds>>
epoch_time(const std::string &epoch) {
auto ms = epoch_time_ms(epoch);
if (!ms) {
return unexpected(std::move(ms).error());
}
return std::chrono::time_point<std::chrono::system_clock, std::chrono::milliseconds>(
std::chrono::milliseconds(static_cast<std::chrono::milliseconds::rep>(*ms)));
}

#ifdef MOQ_COROUTINES
namespace detail {

Expand Down
7 changes: 0 additions & 7 deletions cpp/moq/test/probe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,6 @@ int main() {
// It prints the message Rust's Display gives.
CHECK(fingerprints.error().to_string() == "bind: not listening; call listen() first");

// An epoch's time keeps every 48-bit millisecond, past where system_clock's nanoseconds wrap.
CHECK(ok(moq::epoch_time("018bcfe5-6800-7000-8000-000000000000"), "epoch_time").time_since_epoch() ==
std::chrono::milliseconds(1700000000000));
CHECK(ok(moq::epoch_time("ffffffff-ffff-7000-8000-000000000000"), "epoch_time").time_since_epoch() ==
std::chrono::milliseconds(0xffffffffffff));
CHECK(!moq::epoch_time("not-an-epoch"));

// Publisher: a server whose origin serves one broadcast with one track.
auto origin = moq::OriginProducer::init({});
auto broadcast = ok(origin->create_broadcast("probe"), "create_broadcast");
Expand Down
7 changes: 0 additions & 7 deletions dart/moq/lib/src/epoch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,3 @@ import 'package:moq_ffi/moq_ffi.dart';
/// `AnnounceRoute.epoch`, so viewers see a restart as a new broadcast instead of a
/// stalled one.
String mintEpoch() => moqMintEpoch();

/// The UTC wall-clock time [epoch] encodes, to the millisecond. Throws unless
/// it is a lowercase hyphenated UUIDv7.
DateTime epochTime(String epoch) => DateTime.fromMillisecondsSinceEpoch(
moqEpochTimeMs(epoch: epoch),
isUtc: true,
);
9 changes: 4 additions & 5 deletions dart/moq/test/moq_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -461,10 +461,6 @@ void main() {
final broadcast = origin.createBroadcast(path: 'epoch');

final first = mintEpoch();
expect(
epochTime('018bcfe5-6800-7000-8000-000000000000'),
DateTime.utc(2023, 11, 14, 22, 13, 20),
);
broadcast.announce(route: AnnounceRoute(epoch: first));
final start = await nextRoute(announced) as AnnounceEventStart;
expect(start.announce.route.epoch, first);
Expand All @@ -474,7 +470,10 @@ void main() {
final restart = await nextRoute(announced) as AnnounceEventRestart;
expect(restart.announce.route.epoch, second);

expect(() => epochTime('not-an-epoch'), throwsA(isA<MoqException>()));
expect(
() => broadcast.announce(route: AnnounceRoute(epoch: 'not-an-epoch')),
throwsA(isA<MoqException>()),
);
announced.cancel();
announced.dispose();
});
Expand Down
27 changes: 2 additions & 25 deletions dart/moq_ffi/lib/src/moq.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import "dart:ffi";
import "dart:io" show Platform, File, Directory;
import "dart:isolate";
import "dart:typed_data";

import "package:ffi/ffi.dart";

import "uniffi_runtime.dart";
export "uniffi_runtime.dart";

Expand Down Expand Up @@ -16421,17 +16423,6 @@ void moqLogLevel({required String level}) {
}, moqExceptionErrorHandler);
}

int moqEpochTimeMs({required String epoch}) {
return rustCallWithLifter(
(status) => uniffi_moq_ffi_fn_func_moq_epoch_time_ms(
FfiConverterString.lower(epoch),
status,
),
FfiConverterUInt64.lift,
moqExceptionErrorHandler,
);
}

String moqMintEpoch() {
return rustCallWithLifter(
(status) => uniffi_moq_ffi_fn_func_moq_mint_epoch(status),
Expand Down Expand Up @@ -19115,14 +19106,6 @@ external void uniffi_moq_ffi_fn_func_moq_log_level(
Pointer<RustCallStatus> uniffiStatus,
);

@Native<Uint64 Function(RustBuffer, Pointer<RustCallStatus>)>(
assetId: _uniffiAssetId,
)
external int uniffi_moq_ffi_fn_func_moq_epoch_time_ms(
RustBuffer epoch,
Pointer<RustCallStatus> uniffiStatus,
);

@Native<RustBuffer Function(Pointer<RustCallStatus>)>(assetId: _uniffiAssetId)
external RustBuffer uniffi_moq_ffi_fn_func_moq_mint_epoch(
Pointer<RustCallStatus> uniffiStatus,
Expand Down Expand Up @@ -19470,9 +19453,6 @@ external void ffi_moq_ffi_rust_future_complete_void(
@Native<Uint16 Function()>(assetId: _uniffiAssetId)
external int uniffi_moq_ffi_checksum_func_moq_log_level();

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

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

Expand Down Expand Up @@ -20179,9 +20159,6 @@ void _checkApiChecksums() {
if (uniffi_moq_ffi_checksum_func_moq_log_level() != 24625) {
throw UniffiInternalError.panicked("UniFFI API checksum mismatch");
}
if (uniffi_moq_ffi_checksum_func_moq_epoch_time_ms() != 13125) {
throw UniffiInternalError.panicked("UniFFI API checksum mismatch");
}
if (uniffi_moq_ffi_checksum_func_moq_mint_epoch() != 34550) {
throw UniffiInternalError.panicked("UniFFI API checksum mismatch");
}
Expand Down
8 changes: 3 additions & 5 deletions go/wrapper/moq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1541,9 +1541,6 @@ func TestAnnouncedEpochRestarts(t *testing.T) {
t.Fatal(err)
}
first := moq.MintEpoch()
if at, err := moq.EpochTime("018bcfe5-6800-7000-8000-000000000000"); err != nil || !at.Equal(time.UnixMilli(1_700_000_000_000)) {
t.Fatalf("EpochTime = %v, %v; want 2023-11-14T22:13:20Z", at, err)
}
if err := broadcast.Announce(moq.AnnounceRoute{Epoch: &first}); err != nil {
t.Fatal(err)
}
Expand All @@ -1560,8 +1557,9 @@ func TestAnnouncedEpochRestarts(t *testing.T) {
t.Fatalf("restart = %+v, want epoch %s", restart, second)
}

if _, err := moq.EpochTime("not-an-epoch"); !errors.Is(err, moq.ErrInvalidEpoch) {
t.Fatalf("EpochTime(bad) = %v, want ErrInvalidEpoch", err)
bad := "not-an-epoch"
if err := broadcast.Announce(moq.AnnounceRoute{Epoch: &bad}); !errors.Is(err, moq.ErrInvalidEpoch) {
t.Fatalf("Announce(bad epoch) = %v, want ErrInvalidEpoch", err)
}
}

Expand Down
12 changes: 0 additions & 12 deletions go/wrapper/types.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package moq

import (
"time"

ffi "moq.dev/moq-ffi/moq"
)

Expand Down Expand Up @@ -206,16 +204,6 @@ func MintEpoch() string {
return ffi.MoqMintEpoch()
}

// EpochTime is the wall-clock time an epoch encodes, to the millisecond. It
// returns ErrInvalidEpoch unless epoch is a lowercase hyphenated UUIDv7.
func EpochTime(epoch string) (time.Time, error) {
ms, err := ffi.MoqEpochTimeMs(epoch)
if err != nil {
return time.Time{}, err
}
return time.UnixMilli(int64(ms)), nil
}

// Protocol registries and recognized kinds carried by ProtocolError.
const (
// ErrorScopeSession identifies a session close code.
Expand Down
4 changes: 4 additions & 0 deletions js/net/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

### `Varint.sizeLeadingOnes` is gone

Take the length of `Varint.encodeLeadingOnes(v)`.

### Published names refuse navigation segments

Broadcast creation and route publication now refuse literal `.` and `..` segments, including segments in the producer's root.
Expand Down
Loading
Loading