Because the Flutter OpenGL environment is isolated from a native environment, you cannot integrate the Tencent Effect SDK directly into Flutter. You need to establish connections between them at the native side.
How It Works
1. Create an API abstraction layer and implement the API at the Tencent Effect SDK side.
2. When the application is launched, register the API with the third-party publisher so that the third-party publisher can use it to create, use, and terminate an effect instance.
3. The third-party publisher exposes the capabilities of creating and terminating effect instances to the Flutter side.
4. Use the Tencent Effect Flutter SDK to configure effects.
Example (TRTC)
API defined at the Tencent Effect side
public interface ITXCustomBeautyProcesserFactory {
ITXCustomBeautyProcesser createCustomBeautyProcesser();
void destroyCustomBeautyProcesser();
}
public interface ITXCustomBeautyProcesser {
TXCustomBeautyPixelFormat getSupportedPixelFormat();
TXCustomBeautyBufferType getSupportedBufferType();
void onProcessVideoFrame(TXCustomBeautyVideoFrame srcFrame, TXCustomBeautyVideoFrame dstFrame);
}
1. TRTC offers a registration method. When the application is launched, register com.tencent.effect.tencent_effect_flutter.XmagicProcesserFactory
, the implementation class of ITXCustomBeautyProcesserFactory
with TRTC (at the native side).
2. At the Flutter
layer, provide Future<V2TXLiveCode> enableCustomVideoProcess(bool enable)
, which is used to enable or disable custom effects.
3. Enable or disable effects at the TRTC native side.
Appendix
The abstraction layer dependency provided by Tencent Effect
implementation 'com.tencent.liteav:custom-video-processor:latest.release'
Was this page helpful?