MoQ is under active development. APIs and protocols may change between releases.

Skip to content

Dart and Flutter

pub.dev

The moq package on pub.dev wraps the generated moq_ffi bindings in Dart futures and streams. A Native Assets hook supplies the Rust core for Android (API 24+), iOS (16+), Linux, macOS, and Windows. Flutter web is not supported, since it can't load a native library.

bash
dart pub add moq        # or: flutter pub add moq
dart
import 'package:moq/moq.dart';

final moq = await Moq.connect('https://relay.example.com');

// Subscribe. The stream is live, so listen to it rather than awaiting its end.
moq.announcements(prefix: 'live/').listen((announcement) {
  print(announcement.path());
});
final broadcast = await moq.requestBroadcast('live/camera');
dart
// Publish. bytes comes from your encoder or application source.
final mine = moq.createBroadcast('live/camera');
final track = mine.publishTrack(name: 'video', info: null);
track.appendGroup().writeFrame(frame: MoqFrame(payload: bytes));

moq.close();

Cancelling a stream releases the native cursor. The package re-exports moq_ffi, so the full generated API is available without a second import.

Unlike the other bindings, the published Dart binaries carry no codecs: catalog and container types are there, so already-encoded frames flow through MoqMediaProducer/MoqMediaConsumer, but encoding is up to package:camera, platform channels, or another codec package.

Licensed under MIT or Apache-2.0