struct CallContainer<Factory: ViewFactory>: View {
@StateObject var viewModel: CallViewModel
var body: some View {
Group {
// Body content
// ...
}
.moderationWarning(call: viewModel.call)
}
}Moderation
This cookbook shows how to handle moderation events in your video call application. These events are automatically emitted by Stream’s moderation system when content violates your configured moderation policies. You can configure moderation policies through the Stream Dashboard or via the moderation API.
The Stream API emits the following moderation events:
call.moderation_warning- Emitted when a moderation warning is issued to the usercall.moderation_blur- Emitted when a blur effect should be applied to the user’s cameracall.ended- Emitted when a call ends, withreason: PolicyViolationModerationwhen the call is terminated due to a moderation policy violation
Moderation Notification
The following is an example of a custom ModerationNotification component that listens for moderation warning events and displays a notification to the user.
Moderation Blur
The SDK comes with out-of-the box support for moderation blur events. The behaviour is being described from Moderation.VideoPolicy. In this policy you can define the VideoFilter that will be used in order to blur/cover the stream. Optionally, you can define the duration for which the VideoFilter will be applied for. Below you can see an example where we customise the Moderation.VideoPolicy to use the .blur VideoFilter for 10 seconds.
let call = streamVideo.call(callType: "default", callId: "my-call-id")
let videoPolicy = Moderation.VideoPolicy(duration: 10, videoFilter: .blur)
call.moderation.setVideoPolicy(videoPolicy)It’s worth noting that the default Moderation.VideoPolicy the SDK uses, has a duration of 20 seconds and uses the .blur VideoFilter.