Skip to content

Repository for the federal organized opus_flutter plugin, which is needed to easily obtain a DynamicLibrary of opus for the use in opus_dart on flutter platforms.

License

Notifications You must be signed in to change notification settings

Corkscrews/opus_flutter

 
 

Repository files navigation

opus_codec

A Flutter plugin that provides the Opus audio codec as a DynamicLibrary for use with opus_codec_dart on Flutter platforms.

Overview

This monorepo contains a federated Flutter plugin that loads libopus on each supported platform. The plugin follows the federated plugin architecture, splitting platform implementations into separate packages.

Packages

Package Directory Version
opus_codec opus_flutter 3.0.5
opus_codec_dart opus_dart 3.0.5
opus_codec_platform_interface opus_flutter_platform_interface 3.0.5
opus_codec_android opus_flutter_android 3.0.5
opus_codec_ios opus_flutter_ios 3.0.5
opus_codec_linux opus_flutter_linux 3.0.5
opus_codec_macos opus_flutter_macos 3.0.5
opus_codec_web opus_flutter_web 3.0.5
opus_codec_windows opus_flutter_windows 3.0.5

Platform support

Android iOS Linux macOS Web Windows

Getting started

Add opus_codec to your pubspec.yaml:

dependencies:
  opus_codec: ^3.0.5
  opus_codec_dart: ^3.0.5

Platform packages are automatically included through the federated plugin system -- you don't need to add them individually.

Usage

import 'package:opus_codec/opus_codec.dart' as opus_codec;
import 'package:opus_codec_dart/opus_codec_dart.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  initOpus(await opus_codec.load());
  // opus_codec_dart functions are now available
}

The load() function returns a DynamicLibrary on native platforms (via dart:ffi) or a wasm_ffi DynamicLibrary on the web. See the example app for a complete encoding/decoding demo.

Why are opus_codec_dart and opus_codec separate packages?

Dart is more than just Flutter. With this split, Flutter developers get a convenient way to load opus, while opus_codec_dart can still be used without Flutter (e.g. on headless servers). Developers are also free to load opus themselves without using opus_codec_dart.

Opus version

Currently, opus 1.5.2 is bundled (on Linux, the system-installed version is used).

How opus is included per platform

Platform Method
Android Built from source via CMake (details)
iOS Prebuilt XCFramework, supports CocoaPods and Swift Package Manager (details)
Linux System library libopus.so.0 (details)
macOS Prebuilt XCFramework, supports CocoaPods and Swift Package Manager (details)
Web Compiled to WebAssembly with Emscripten (details)
Windows Prebuilt DLLs for x86/x64 (details)

Scripts

The scripts/ directory contains helper scripts for local development.

Script Description
scripts/unit_tests.sh Runs all unit tests across every package and collects per-package lcov coverage reports. When lcov is available, all reports are merged into a single coverage/lcov.info at the repository root and an HTML report is generated at coverage/html/index.html.
scripts/analyze.sh Runs static analysis (flutter analyze / dart analyze) across every package and prints a pass/fail summary. Exits with a non-zero code if any package has analysis errors.
scripts/format.sh Checks that all Dart code is formatted correctly (dart format --set-exit-if-changed). Exits with a non-zero code if any file needs formatting.
scripts/check_dependencies.sh Reports outdated dependencies and checks pub.dev for discontinued or abandoned packages. Requires curl and python3 for the discontinued-package checks.
scripts/publish.sh Publishes all packages to pub.dev in dependency order (three tiers). Runs in dry-run mode by default; pass --publish to push to pub.dev.

Running unit tests

./scripts/unit_tests.sh

The script automatically runs dart run build_runner build --delete-conflicting-outputs for opus_codec_dart before executing its tests, so Mockito mock classes are always up to date.

Requirements:

  • flutter (stable channel) with dart bundled
  • lcov (optional, for merged HTML coverage report) — brew install lcov
  • dart pub global activate coverage (for opus_codec_dart pure-Dart coverage)

Running static analysis

./scripts/analyze.sh

Requirements:

  • flutter (stable channel) with dart bundled

Requirements

  • Dart SDK >=3.4.0
  • Flutter >=3.22.0

License

BSD-2-Clause. See LICENSE for details.

About

Repository for the federal organized opus_flutter plugin, which is needed to easily obtain a DynamicLibrary of opus for the use in opus_dart on flutter platforms.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 55.5%
  • Dart 32.0%
  • Shell 5.6%
  • C++ 2.8%
  • CMake 2.2%
  • Ruby 0.5%
  • Other 1.4%