Repository navigation
feat(dart): ship codecs and expose audio and video namespaces #5839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
569aacd
quest(m2): claim dart-codecs
kixelated ad81e41
feat(dart): ship codecs and expose audio and video namespaces
kixelated 2d82462
quest(m2): raise the moq_ffi floor when cutting the Dart release
kixelated 52accb0
chore(dart): regenerate bindings on latest main
kixelated 5f6de2b
fix(dart): alias the audio Preset and describe planar PCM frames
kixelated 0a4b0f6
chore(dart): regenerate bindings and follow the rendition id rename
kixelated 332cad7
feat(dart): expose the audio playout delay
kixelated 6091baf
fix(dart): build iOS from source at the release deployment target
kixelated File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
|
|
||
| /// 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; | ||
|
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()); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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!); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When an existing application has
moq_ffi0.4.3 locked and upgradesmoq, the unchanged^0.4.3constraint indart/moq/pubspec.yamlpermits that resolution, but that raw binding does not defineMoqAudioProduceror the other newly aliased codec types, so the package fails to compile. Raise the dependency floor to the first codec-enabledmoq_ffirelease so every allowed resolution provides this API.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
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.dartaliasesMoqMediaCatalogProducerandMoqMediaTimebase, which no publishedmoq_ffihas, 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 nextmoq-dart-v*tag.(written by Claude Opus 5.5)