A flutter plugin that demostrate how to processing rawdata with agora_rtc_engine.
The example plugin only exports four methods to the dart layer that can register or unregister the observer.
class AgoraRtcRawdata {
static const MethodChannel _channel =
const MethodChannel('agora_rtc_rawdata');
static Future<void> registerAudioFrameObserver(int engineHandle) {
return _channel.invokeMethod('registerAudioFrameObserver', engineHandle);
}
static Future<void> unregisterAudioFrameObserver() {
return _channel.invokeMethod('unregisterAudioFrameObserver');
}
static Future<void> registerVideoFrameObserver(int engineHandle) {
return _channel.invokeMethod('registerVideoFrameObserver', engineHandle);
}
static Future<void> unregisterVideoFrameObserver() {
return _channel.invokeMethod('unregisterVideoFrameObserver');
}
}
The example plugin changes the color of the video stream by the default:
- Change local video to green
- Change remote video to pink
You can find the code at:
- Android: AgoraRtcRawdataPlugin.kt
- Local video:
onCaptureVideoFrame
- Remote video:
onRenderVideoFrame
- Local video:
- iOS: AgoraRawdata.swift
- Local video:
onCapture
- Remote video:
onRenderVideoFrame
- Local video:
If you can program with C++, you should process raw data on the C++ layer to remove code about calling Android and iOS.
You can find the code at:
- Android:
- Audio: AudioFrameObserver.cpp
- Video: VideoFrameObserver.cpp
- iOS:
- Audio: AgoraAudioFrameObserver.mm
- Video: AgoraVideoFrameObserver.mm
You should fork this repository, and modify the code to implement your requirement, such as use third-party beauty SDK.
import 'package:agora_rtc_engine/rtc_engine.dart';
import 'package:agora_rtc_rawdata/agora_rtc_rawdata.dart';
_initEngine() async {
var engine = await RtcEngine.create(config.appId);
await AgoraRtcRawdata.registerAudioFrameObserver(
await engine.getNativeHandle());
await AgoraRtcRawdata.registerVideoFrameObserver(
await engine.getNativeHandle());
}
MIT