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
3 changes: 2 additions & 1 deletion .github/ffi.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
`release-shared-ffi.yml` owns the existing `moq-ffi-v*` tag trigger for Go,
Kotlin and Swift. Nightly calls the same coordinator without publisher secrets.
It builds nine distinct default-feature targets, replacing fourteen native
builds across those packages. Dart retains its eleven minimal-feature targets;
builds across those packages. Dart retains its own eleven default-feature
targets, a superset that adds `x86_64-apple-darwin` and `x86_64-apple-ios`;
Python retains its wheel builds and Python-specific environment.

C++ retains source builds as its default and independent `cpp-v*` release tags.
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release-dart-ffi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ jobs:
language: dart
# The raw bindings are checked in under dart/moq_ffi, so none here.
bindings: false
default-features: false
# Full platform packaging remains nightly; PRs keep only Linux/Android.
targets: ${{ github.event_name == 'pull_request' && github.base_ref != 'release' && '["aarch64-linux-android", "armv7-linux-androideabi", "x86_64-linux-android", "x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu"]' || '["aarch64-linux-android", "armv7-linux-androideabi", "x86_64-linux-android", "x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu", "aarch64-apple-darwin", "x86_64-apple-darwin", "aarch64-apple-ios", "aarch64-apple-ios-sim", "x86_64-apple-ios", "x86_64-pc-windows-msvc"]' }}

Expand Down
15 changes: 1 addition & 14 deletions .github/workflows/release-ffi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ on:
description: "Generate and upload the bindings for `language`"
type: boolean
default: true
default-features:
description: "Build moq-ffi with its default features (audio and video)"
type: boolean
default: true
reuse-native:
description: "Consume the coordinator's native libraries and bindings"
type: boolean
Expand Down Expand Up @@ -109,15 +105,10 @@ jobs:
env:
BUILD_TARGET: ${{ matrix.target }}
BUILD_VERSION: ${{ needs.parse-version.outputs.version }}
DEFAULT_FEATURES: ${{ inputs.default-features }}
# Set iOS deployment target to avoid ___chkstk_darwin linker errors.
IPHONEOS_DEPLOYMENT_TARGET: ${{ contains(matrix.target, 'apple-ios') && '16.0' || '' }}
run: |
args=(--target "$BUILD_TARGET" --version "$BUILD_VERSION" --output dist)
if [[ "$DEFAULT_FEATURES" == false ]]; then
args+=(--no-default-features)
fi
just rs package-ffi "${args[@]}"
just rs package-ffi --target "$BUILD_TARGET" --version "$BUILD_VERSION" --output dist

- name: Upload lib
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
Expand Down Expand Up @@ -175,15 +166,11 @@ jobs:
env:
BUILD_VERSION: ${{ needs.parse-version.outputs.version }}
REUSE_LIBRARY: ${{ contains(fromJSON(inputs.targets), 'x86_64-unknown-linux-gnu') }}
DEFAULT_FEATURES: ${{ inputs.default-features }}
run: |
args=(--bindings-only --version "$BUILD_VERSION" --output dist)
if [[ "$REUSE_LIBRARY" == true ]]; then
args+=(--library binding-library/libmoq_ffi.so)
fi
if [[ "$DEFAULT_FEATURES" == false ]]; then
args+=(--no-default-features)
fi
just rs package-ffi "${args[@]}"

- name: Upload bindings
Expand Down
2 changes: 1 addition & 1 deletion dart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This directory contains two packages:
- `moq` is the independently-versioned ergonomic API applications should use.

Run `just dart check` from the repository root. The check rebuilds
`moq-ffi` without optional codec features, verifies the generated source,
`moq-ffi` with its default codec features, verifies the generated source,
analyzes and tests both packages, and validates their publish layout.

`dart test` drives the Native Assets hook, so the round-trip tests in
Expand Down
76 changes: 76 additions & 0 deletions dart/moq/lib/audio.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/// Native audio encoding, publication, and decoding.
///
/// Import it with a prefix, since `Frame` and `Codec` mean something else in
/// the other libraries:
///
/// ```dart
/// import 'package:moq/audio.dart' as audio;
/// ```
library;

import 'package:moq_ffi/moq_ffi.dart';

/// Encodes PCM and publishes it as a track; construct it from the broadcast's `CatalogProducer`.
typedef Producer = MoqAudioProducer;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Raise the moq_ffi dependency floor

When an existing application has moq_ffi 0.4.3 locked and upgrades moq, the unchanged ^0.4.3 constraint in dart/moq/pubspec.yaml permits that resolution, but that raw binding does not define MoqAudioProducer or the other newly aliased codec types, so the package fails to compile. Raise the dependency floor to the first codec-enabled moq_ffi release so every allowed resolution provides this API.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree with fixing this in this PR. The floor was already stale on main: media.dart aliases MoqMediaCatalogProducer and MoqMediaTimebase, which no published moq_ffi has, 0.4.16 included. The correct floor is a release that hasn't been cut yet, and package versions are bumped at release time. I added the floor bump to /quest/m2/release/dart-publish.md so it lands with the next moq-dart-v* tag.

(written by Claude Opus 5.5)


/// Encodes PCM without publishing it.
typedef Encoder = MoqAudioEncoder;

/// Subscribes to a catalog audio rendition and yields decoded PCM; open one with `Consumer.subscribe`.
typedef Consumer = MoqAudioConsumer;

/// The PCM layout written to a [Producer].
typedef EncoderInput = MoqAudioEncoderInput;

/// The codec side: codec, track name, rate, channels, bitrate, preset, and frame duration (0 takes the codec's own frame).
typedef EncoderOutput = MoqAudioEncoderOutput;

/// The PCM layout a [Consumer] delivers, how stale a group may get, and its playout delay.
typedef DecoderOutput = MoqAudioDecoderOutput;

/// PCM in the configured [SampleFormat], planar or interleaved, with its presentation timestamp.
typedef Frame = MoqAudioFrame;

/// One encoded payload from an [Encoder].
typedef Packet = MoqAudioPacket;

/// The packets an [Encoder] drains on finish and the padded samples to discard.
typedef EncoderFinish = MoqAudioEncoderFinish;

/// The audio codec: `Codec.opus()` or `Codec.aac()`.
typedef Codec = MoqAudioCodec;

/// A raw PCM sample layout.
typedef SampleFormat = MoqAudioSampleFormat;
Comment thread
kixelated marked this conversation as resolved.
Resolved

/// How the encoder trades latency for compression; null in [EncoderOutput] means `balanced`.
typedef Preset = MoqAudioPreset;

/// Duration view over a PCM frame's timestamp.
extension AudioFrameDuration on MoqAudioFrame {
/// Presentation timestamp of the first sample.
Duration get timestamp => Duration(microseconds: timestampUs);
}

/// Duration view over an encoder's frame size.
extension AudioEncoderOutputDuration on MoqAudioEncoderOutput {
/// Encoded frame duration; zero takes the codec's own.
Duration get frameDuration => Duration(microseconds: frameDurationUs);
}

/// Duration view over a decoder's latency bound.
extension AudioDecoderOutputDuration on MoqAudioDecoderOutput {
/// Upper bound on buffering before a stalled group is skipped, or null for the default.
Duration? get maxDelay =>
maxDelayUs == null ? null : Duration(microseconds: maxDelayUs!);

/// Fixed playout delay to hold ahead of the playhead, or null to estimate it from arrival timing.
Duration? get delay =>
delayUs == null ? null : Duration(microseconds: delayUs!);
}

/// Duration view over a consumer's playout delay.
extension AudioConsumerDuration on MoqAudioConsumer {
/// Playout delay to hold ahead of the playhead: the fixed one, or the estimate from every frame read so far.
Duration get delay => Duration(microseconds: delayUs());
}
90 changes: 90 additions & 0 deletions dart/moq/lib/video.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/// Native video encoding, publication, and decoding.
///
/// Import it with a prefix, since `Frame` and `Codec` mean something else in
/// the other libraries:
///
/// ```dart
/// import 'package:moq/video.dart' as video;
/// ```
library;

import 'package:moq_ffi/moq_ffi.dart';

/// Encodes raw pictures and publishes them as a track; construct it from the broadcast's `CatalogProducer`.
typedef Producer = MoqVideoProducer;

/// Encodes raw pictures without publishing them.
typedef Encoder = MoqVideoEncoder;

/// Subscribes to a catalog video rendition and yields decoded frames; open one with `Consumer.subscribe`.
typedef Consumer = MoqVideoConsumer;

/// The pixel layout, resolution, and framerate written to a [Producer].
typedef EncoderInput = MoqVideoEncoderInput;

/// The track name, codec, bitrate, group mode, and backend preference.
typedef EncoderOutput = MoqVideoEncoderOutput;

/// What a [Consumer] delivers: an optional resize, a max delay, and whether to keep the decoder's surface (macOS and iOS).
typedef DecoderOutput = MoqVideoDecoderOutput;

/// One raw picture with its presentation timestamp.
typedef Frame = MoqVideoFrame;

/// A decoded picture from a [Consumer]; `dispose()` it promptly, since held frames stall the decoder.
typedef DecodedFrame = MoqVideoDecodedFrame;

/// The platform image backing a [DecodedFrame], when [DecoderOutput] asked for one.
typedef Surface = MoqVideoSurface;

/// A borrowed `CVPixelBufferRef` address (macOS and iOS), valid while its [DecodedFrame] lives.
typedef PixelBuffer = PixelBufferMoqVideoSurface;

/// One encoded access unit from an [Encoder].
typedef Packet = MoqVideoPacket;

/// How pictures are split into independently decodable groups.
typedef Gop = MoqVideoGop;

/// A keyframe every `interval` pictures.
typedef Keyframe = KeyframeMoqVideoGop;

/// H.264 or H.265.
typedef Codec = MoqVideoCodec;

/// A CPU pixel layout (I420 or RGBA).
typedef PixelFormat = MoqVideoPixelFormat;

/// The encoder backend preference.
typedef EncoderKind = MoqVideoEncoderKind;

/// Prefer a platform hardware encoder, falling back to software.
typedef AutoEncoder = AutoMoqVideoEncoderKind;

/// Hardware only; fails if none is available.
typedef HardwareEncoder = HardwareMoqVideoEncoderKind;

/// Software only (openh264, H.264 only).
typedef SoftwareEncoder = SoftwareMoqVideoEncoderKind;

/// A specific backend by name, such as `videotoolbox`, `mediafoundation`, or `openh264`.
typedef NamedEncoder = NamedMoqVideoEncoderKind;

/// Duration view over a raw picture's timestamp.
extension VideoFrameDuration on MoqVideoFrame {
/// Presentation timestamp.
Duration get timestamp => Duration(microseconds: timestampUs);
}

/// Duration view over a decoded picture's timestamp.
extension VideoDecodedFrameDuration on MoqVideoDecodedFrame {
/// Presentation timestamp.
Duration get timestamp => Duration(microseconds: timestampUs());
}

/// Duration view over a decoder's latency bound.
extension VideoDecoderOutputDuration on MoqVideoDecoderOutput {
/// Upper bound on buffering before a stalled group is skipped, or null for the default.
Duration? get maxDelay =>
maxDelayUs == null ? null : Duration(microseconds: maxDelayUs!);
}
2 changes: 2 additions & 0 deletions dart/moq/test/docs/prelude.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ import 'package:moq/moq.dart';

Moq get moq => throw UnimplementedError();
Uint8List get bytes => throw UnimplementedError();
Uint8List get rgba => throw UnimplementedError();
int get pts => throw UnimplementedError();
Loading
Loading