flutter_track_recorder_livekit 0.1.0-dev.2
flutter_track_recorder_livekit: ^0.1.0-dev.2 copied to clipboard
Records existing local LiveKit camera and microphone tracks through native track adapters.
flutter_track_recorder_livekit #
Record an existing local LiveKit camera and microphone with
flutter_track_recorder.
The adapter attaches native sample sinks to borrowed tracks, without opening
another camera or microphone, connecting a room, or changing audio-session policy.
This is a development preview for iOS and Android. Physical synchronization, interruptions and long-duration recording still require validation on target devices.
Usage #
Supply active, unmuted LocalVideoTrack and LocalAudioTrack instances owned by
your application. They must have camera and microphone sources respectively.
import 'package:flutter_track_recorder/flutter_track_recorder.dart';
import 'package:flutter_track_recorder_livekit/flutter_track_recorder_livekit.dart';
final recorder = LiveKitTrackRecorder();
final capabilities = await recorder.queryCapabilities();
if (!capabilities.supported) {
// Explain that recording is unavailable for this source or device.
return;
}
final subscription = recorder.recorder.states.listen((event) {
// Update the recording indicator, progress and terminal result.
});
await recorder.start(
videoTrack: localCamera,
audioTrack: localMicrophone,
configuration: const RecordingConfiguration(width: 1280, height: 720),
);
// The application can continue transmitting after the recorder stops.
final recording = await recorder.stop();
if (recording.isPlayable) {
// Keep the private file, or export it through an optional exporter.
}
await subscription.cancel();
await recorder.dispose();
The native writer announces RecordingState.recording only after receiving
audio and video. An acknowledgement from start() alone is not proof of captured
media. recorder.recorder also exposes the core's local inventory and lifecycle
API.
When configuration is omitted, the adapter derives an even-sized output canvas
from the camera settings, limiting its longest side to 1280 pixels. Native fitting
preserves source proportions. The recorder applies source rotation and does not
add the mirror used only by a front-camera preview widget.
Ownership and source changes #
- The application owns the tracks. Stop recording before disposing or replacing them; the adapter never closes a track, capture device or LiveKit room.
- Stopping detaches sample listeners while the writer finalizes. File completion does not command the broadcast to end.
- Repeated operations are serialized. Repeating
start()with the same active sources does not allocate another recording. - Source replacement, unavailable frames or unsupported dimension/orientation changes stop the recording with a typed reason. The application can start a new recording after the source is ready.
- Only the local camera and microphone are recorded. Remote participants, shared screens, chat, widgets and the mixed room output are excluded.
Compatibility #
The native integration targets livekit_client 2.13.2 and flutter_webrtc
1.6.3. Native sample-tap APIs are version-sensitive; compatibility with other
versions must be checked before changing these dependencies.
The core and adapter require Dart 3.8 or later and Flutter 3.44 or later. Implementations are provided for iOS and Android only. Other platforms report unsupported capabilities. Capture permissions belong to the application that already owns the tracks. No server-side recording is invoked.
Audio and timing limits #
WebRTC exposes a factory-wide local microphone tap. The application must ensure exclusive microphone ownership and stop recording before transferring capture to another call or session. iOS additionally checks the native microphone inventory; Android's SDK does not expose an equivalent public inventory, so global exclusivity cannot be verified independently there.
Muted microphone samples are suppressed. iOS receives postprocessed PCM, whereas Android's tap can precede the software processing applied to transmitted audio. Recorded processing can therefore differ from what remote participants hear.
When a source does not expose its original microphone capture timestamp, audio uses a sample clock anchored to monotonic delivery time. Actual lip sync, route changes and long-term drift require device measurements. Background recording is not guaranteed when the operating system suspends capture.
Privacy #
This adapter does not add analytics, tracking or network uploads. It observes tracks from a room owned by the host app; it does not connect that room. An iOS privacy manifest is bundled with the adapter. The core, LiveKit and WebRTC dependencies retain their own privacy declarations, and the host app remains responsible for its recording consent and data practices.
License #
MIT. See LICENSE.