Metadata (SEI)

getMaxMetadataSize

Callback triggered when the SDK requests the maximum metadata size.

public abstract int getMaxMetadataSize()

After successfully registering by calling registerMediaMetadataObserver, the SDK triggers this callback for every video frame sent. You need to specify the maximum size of the metadata in the return value of this callback.

Return Values

If the method call succeeds, returns the maximum size (in bytes) of the metadata buffer you want to use. The maximum value is 1024 bytes. Make sure to set the return value.

registerMediaMetadataObserver

Registers a metadata observer.

public abstract int registerMediaMetadataObserver(IMetadataObserver observer, int type);

You need to implement the IMetadataObserver class and specify the metadata type in this method. This method allows you to add synchronized metadata to the video stream, enabling richer interactive live streaming scenarios such as sending shopping links, digital coupons, and online quizzes. After successfully calling this method, the SDK triggers the getMaxMetadataSize callback.

Note: Call this method before calling joinChannel.

Parameters

observer
The metadata observer. See IMetadataObserver.
type
The metadata type. The current SDK only supports the following type:
  • VIDEO_METADATA: Video metadata.

Return Values

  • 0: Success.
  • < 0: Failure.

unregisterMediaMetadataObserver

Unregisters the specified metadata observer.

public abstract int unregisterMediaMetadataObserver(IMetadataObserver observer, int type);

Parameters

observer
The metadata observer. See IMetadataObserver.
type
The metadata type. The current SDK only supports the following type:
  • VIDEO_METADATA: Video metadata.

Return Values

  • 0: Success.
  • < 0: Failure.

onMetadataReceived

Callback triggered when the local user receives metadata.

public abstract void onMetadataReceived(AgoraMetadata metadata)

Trigger Timing

This callback is triggered when the local user receives metadata.

Parameters

metadata
Received metadata. See AgoraMetadata.

onReadyToSendMetadata

Callback triggered when the SDK is ready to send metadata.

public abstract byte[] onReadyToSendMetadata(long timeStampMs, int sourceType)
Note: Make sure the size of the metadata does not exceed the value set in the getMaxMetadataSize callback.

Trigger Timing

This callback is triggered when the SDK is ready to send metadata.

Parameters

timeStampMs
Timestamp.
sourceType
Video data type. See VideoSourceType.

Return Values

If the method call succeeds, returns the metadata to be sent, in byte array format.