Docs / Flutter / Agora

Agora on Flutter

Beautify the published camera of an agora_rtc_engine 6.x call. Facevity registers a native frame observer on Agora's engine; Dart makes one call.

Demo app: facevity-flutter-demo on GitHub

agora_rtc_engine captures and encodes natively, so Facevity attaches natively too: it registers a video frame observer (IVideoFrameObserver on Android, AgoraVideoFrameDelegate on iOS, post-capture, I420 read-write), processes each frame in place, and Agora encodes the result. The local view and every remote participant receive the beautified frames.

1. Requirements

  • facevity_flutter set up as in the quick start
  • agora_rtc_engine 6.x (Agora RTC 4.x)
  • iOS: 'agora' in $FacevityRtcHooks in the Podfile. Android detects it automatically.
  • Licence feature buffer.path (I420 frames)

Facevity creates Agora’s native engine and hands its handle to Dart; this is Agora’s own pattern for native raw-data processing.

final fv = await Facevity.initialize(licenseAsset: 'assets/facevity/license.fvl', params: BeautyParams.natural);

final handle = await fv.rtc.agora.createSharedEngine(appId: agoraAppId);
final engine = createAgoraRtcEngine(sharedNativeHandle: handle);
await engine.initialize(RtcEngineContext(appId: agoraAppId));
await engine.enableVideo();
await engine.startPreview();
await engine.joinChannel(token: token, channelId: channel, uid: 0, options: const ChannelMediaOptions());

3. Or attach to an engine created in Dart

Agora’s native engine is a process singleton, so Facevity can also register on the engine Dart created:

final engine = createAgoraRtcEngine();
await engine.initialize(RtcEngineContext(appId: agoraAppId));
await fv.rtc.agora.attach(appId: agoraAppId);   // before startPreview / joinChannel

4. Tear down

await engine.leaveChannel();
await engine.release();
await fv.rtc.agora.detach();   // shared handle: also destroys the native engine; attach: only unregisters

Notes

  • Show Agora’s own local view (AgoraVideoView) during the call, not FacevityPreview: most devices give the camera to one client only.
  • setParams, setLipstick, setProp and the other settings apply to the call live.
  • await fv.rtc.status() shows the frames seen and processed by the hook.

Next: ZEGOCLOUD on Flutter · all platforms

Need help with an integration? Contact the Facevity team. We answer integration questions during trials.