Snapshot

enableContentInspect

Enables or disables the local snapshot upload feature.

public abstract int enableContentInspect(boolean enabled, ContentInspectConfig config);

The SDK captures and uploads snapshots of the local user's video based on the module type and frequency set in ContentInspectConfig. After completing the capture and upload, the Agora server sends a callback notification to your application server via HTTPS and uploads all snapshots to third-party cloud storage.

Note:
  • Before calling this method, make sure you have enabled the local snapshot upload feature in the Agora Console.
  • If the video moderation module uses the Agora proprietary extension (CONTENT_INSPECT_TYPE_SUPERVISE), you need to use the local snapshot upload dynamic library agora_content_inspect_extension.so. Removing this library disables the snapshot upload feature.

Timing

You can call this method before or after joining a channel.

Parameters

enabled
Whether to enable the local snapshot upload feature:
  • true: Enable the local snapshot upload feature.
  • false: Disable the local snapshot upload feature.
config
The snapshot upload configuration. See ContentInspectConfig.

Return Values

  • 0: Success.
  • < 0: Failure.

enableContentInspectEx

Enables or disables local snapshot upload.

public abstract int enableContentInspectEx(boolean enabled, ContentInspectConfig config, RtcConnection connection);

When enabled, the SDK captures and uploads snapshots of the local user's video based on the module type and frequency set in ContentInspectConfig. After uploading, the Agora server sends a callback notification to your app server via HTTPS and uploads all snapshots to a third-party cloud storage service.

Note: Before calling this method, make sure you have contacted technical support to enable the local snapshot upload service.

Scenario

This method is applicable in multi-channel scenarios.

Timing

You can call this method before or after joining a channel.

Parameters

enabled
Whether to enable local snapshot upload:
  • true: Enable local snapshot upload.
  • false: Disable local snapshot upload.
config
Configuration parameters for snapshot upload. See ContentInspectConfig.
connection
Connection information. See RtcConnection.

Return Values

  • 0: Success.
  • < 0: Failure.

takeSnapshot [1/2]

Captures a snapshot of the specified user's video stream and saves it as a JPG image.

public abstract int takeSnapshot(int uid, String filePath);
Note: This method is asynchronous. When the method returns, the SDK has not yet completed the snapshot operation. When used for a local video snapshot, this method captures the video stream specified in ChannelMediaOptions. If the video has been preprocessed (e.g., watermark or beautification), the snapshot will include the effects.

Timing

Call this method after joining a channel.

Parameters

uid
The user ID. To capture a snapshot of the local user's video, set uid to 0.
filePath
Note: Make sure the specified path exists and is writable.
The local path of the snapshot (including file extension). For example:
  • Android: /storage/emulated/0/Android/data/<package name>/files/example.jpg

Return Values

  • 0: Success.
  • < 0: Failure.

takeSnapshot [2/2]

Captures a video snapshot at the specified observation point.

public abstract int takeSnapshot(int uid, SnapshotConfig config);
Note:
  • This method is asynchronous. When the method returns, the SDK has not yet completed the snapshot operation.
  • When used for a local video snapshot, this method captures the video stream specified in ChannelMediaOptions.

Timing

Call this method after joining a channel.

Parameters

uid
The user ID. To capture a snapshot of the local user's video, set uid to 0.
config
The snapshot configuration. See SnapshotConfig.

Return Values

  • 0: Success.
  • < 0: Failure.

takeSnapshotEx [1/2]

Takes a snapshot of the video stream using the connection ID.

public abstract int takeSnapshotEx(RtcConnection connection, int uid, String filePath);
Note: takeSnapshotEx is an asynchronous call. The SDK does not complete the snapshot immediately. When used for local video, it captures the video stream specified in ChannelMediaOptions. If preprocessing (e.g., watermark, beautification) is applied, the snapshot includes those effects.

Scenario

Applicable in multi-channel scenarios.

Timing

Call this method after calling joinChannelEx.

Parameters

connection
Connection information. See RtcConnection.
uid
User ID. To capture the local user's video, set uid to 0.
filePath
Note: Ensure the specified path exists and is writable.
Local path of the snapshot (including file extension). For example:
  • Android: /storage/emulated/0/Android/data/<package name>/files/example.jpg

Return Values

  • 0: Success.
  • < 0: Failure.

takeSnapshotEx [2/2]

Takes a snapshot of a specified user's video using the connection ID.

public abstract int takeSnapshotEx(RtcConnection connection, int uid, SnapshotConfig config);
Note:
  • This method is asynchronous. The SDK does not complete the snapshot immediately.
  • When used for local video, it captures the video stream specified in ChannelMediaOptions.
  • If preprocessing such as watermarking or beautification is applied, the snapshot includes those effects.

Scenario

Applicable in multi-channel scenarios.

Timing

Call this method after calling joinChannelEx.

Parameters

connection
Connection information. See RtcConnection.
uid
User ID. To capture the local user's video, set uid to 0.
config
Snapshot configuration. See SnapshotConfig.

Return Values

  • 0: Success.
  • < 0: Failure.

onSnapshotTaken

Callback for video snapshot result.

public void onSnapshotTaken(int uid, String filePath, int width, int height, int errCode)

This callback is triggered after the takeSnapshot method is successfully called to report the details and success of the snapshot.

Trigger Timing

This callback is triggered after the takeSnapshot method is successfully called.

Parameters

uid
User ID. uid 0 indicates the local user.
filePath
Local path of the snapshot.
width
Width of the snapshot (in pixels).
height
Height of the snapshot (in pixels).
errCode
Error code of the snapshot result:
  • 0: Success.
  • < 0: Failure:
    • -1: SDK failed to write file or encode JPEG image.
    • -2: The specified user's video stream was not found within 1 second after calling takeSnapshot. Possible reasons include: local capture stopped, remote stopped publishing, or video data processing blocked.
    • -3: takeSnapshot method is called too frequently.