SCVideoStreamAnalyzer
An object that monitors a stream of video by analyzing frames for sensitive content.
Declaration
class SCVideoStreamAnalyzerMentioned in
Overview
Use this class to detect senstive content in a video stream, such as on a conference call that your app implements. The class detects senstive content in the video stream from either the device’s camera or the remote devices signed into the call, depending on how you configure the analyzer.
Create an instance of this class for each video stream in the call.
To begin analyzing the stream, pass it to either beginAnalysis(of:) (AVCaptureDeviceInput) or beginAnalysis(of:) (VTDecompressionSession), depending on your video playback implementation.
React to sensitive content
When the framework detects sensitive content in the stream, it calls analysisChangedHandler immediately with an SCSensitivityAnalysis object that includes information about the detection.
You implement the analysisChangedHandler callback to inspect the detection results, which includes confirmation that content is sensitve as well as guidance on next steps your app can take. The framework offers your app suggestions in the handler, which include:
Alerting the person to the presence of sensitive content (shouldIndicateSensitivity)
Interrupting video playback (shouldInterruptVideo)
Muting audio (shouldMuteAudio)
To stop analyzing the stream, call endAnalysis(). If your app implements a custom stream decoder, you can analyze individual frames by passing pixel buffers to analyze(_:).
In the event of an error during analysis, the handler receives an error object that details what went wrong. For more information, see: SCVideoStreamAnalysisChangeHandler.
Add the app entitlement
To use this class, the system requires the com.apple.developer.sensitivecontentanalysis.client entitlement in your app’s code signature. Calls to the framework fail to return positive results without it. You can can add this entitlement to your app by enabling the Sensitive Content Analysis capability in Xcode; see Adding capabilities to your app.
For more information, see Detecting nudity in media and providing intervention options.