This page describes how to implement Agora Content Moderation in your Android, iOS, macOS, Windows apps.
The following figure shows the basic workflow of integrating content moderation in the app:
The process of applying real-time content moderation to the video of a user streaming in a channel is as follows:
enableContentInspect
to enable content moderation, the content moderation module of the SDK takes a screenshot of the video stream and inspects it. If the inspection result of the picture is confirmed, the SDK triggers the onContentInspectResult
callback and returns the content moderation results: neutral
, sexy
, or porn
.onContentInspectResult
callback and returns the inspection result.Before you start using Agora Content Moderationensure that the following requirements are met:
"AppId": {
"desc": "Description",
"score_threshold": [
{"scene": "porn or sexy or neutral", "threshold": "Judgment threshold, which range is [0,1]"} // Set the threshold of different types, support setting up to 2 thresholds
],
"moderation_upload_policy": ["porn", "sexy", "neutral"], // Set the types of the images to be stored, if not set, the porn and sexy images are stored by default
"callback_url": "The address of the server that receives the content moderation result",
"callback_url_supervisor": "The address of the server that receives the screenshot callback",
"aws_oss_access_key_id": "AWS-OSS-AccessKeyId",
"aws_oss_access_key_secret": "AWS-OSS-AccessKeySecret",
"aws_oss_bucket_name": "AWS-OSS-BucketName",
"aws_oss_endpoint": "AWS-OSS-Endpoint",
"aws_oss_region": "AWS-OSS-region",
"aws_oss_fileName_prefix": "The storage location of the screenshots in AWS OSS"
},
Call the enableContentInspect
method to enable the content moderation. Set the type
in ContentInspectConfig
to MODERATION (1)
, and call enableContentInspect
to enable the content moderation. The SDK takes screenshots according to the set frequency and uploads the screenshots to the Agora Content Moderation cloud server. Sample code:
ContentInspectConfig config = new ContentInspectConfig();
config.moduleCount = 1;
// The type of the function module is content moderation.
config.modules[0].type = ContentInspectConfig.CONTENT_INSPECT_TYPE_MODERATION;
// The frequency of content moderation is 2 seconds between image captures.
config.modules[0].interval = 2;
mRtcEngine.enableContentInspect(true, config);
let inspectExtraConfig = AgoraContentInspectConfig()
var modules = [AgoraContentInspectModule]()
let module1 = AgoraContentInspectModule()
// The type of the function module is content moderation.
module1.type = .moderation
// The frequency of content moderation is 2 seconds between image captures.
module1.interval = 2
modules.append(module1)
inspectExtraConfig.modules = modules
agoraKit.enableContentInspect(true, config:inspectExtraConfig)
void CMainFrame::OnBtnEnableContentInspect()
{
if (CAgoraObject::GetEngine() == NULL) {
return;
}
ContentInspectConfig config;
ContentInspectModule module1;
// The type of the function module is content moderation.
module1.type = kContentInspectModeration;
// The frequency of content moderation is 2 seconds between image captures.
module1.interval = 2;
config.moduleCount = 1;
config.modules[0] = module1;
CAgoraObject::GetEngine()->enableContentInspect(true, config);
}
After the client-side content moderation is completed, the SDK triggers the onContentInspectResult
callback and returns the inspection result. Refer to the following sample code to monitor the content moderation callback.
public void onContentInspectResult(int result) {
}
// OC
(void)rtcEngine:(AgoraRtcEngineKit* _Nonnull)engine contentInspectResult:(AgoraContentInspectResult)result{
}
// Swift
func rtcEngine(_ engine: AgoraRtcEngineKit, contentInspectResult result: AgoraContentInspectResult) {
}
void onContentInspectResult(CONTENT_INSPECT_RESULT result){
}
enableContentInspect
onContentInspectResult
enableContentInspect
contentInspectResult
enableContentInspect
onContentInspectResult
The following table shows the dynamic library name for each platform and the increase in app size after integration:
Platform | Architecture | Library name | Increase in app size after integration (KB) |
---|---|---|---|
Android | arm64-v8a | Android: libagora_ci_extension.so |
1,116 |
Android | armeabi-v7a | Android: libagora_ci_extension.so |
986 |
iOS | arm64 | AgoraCIExtension.xcframework |
1,344 |
iOS | armv7 | AgoraCIExtension.xcframework |
1,104 |
macOS | arm64 | AgoraCIExtension.xcframework |
1,328 |
macOS | x86_64 | AgoraCIExtension.xcframework |
1,324 |
Windows | x86 | libagora_ci_extension.dll |
2,229 |
Windows | x86_64 | libagora_ci_extension.dll |
2,633 |