public class AgoraMediaRtcRecorder
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private long |
nativeHandle |
| Constructor and Description |
|---|
AgoraMediaRtcRecorder(long handle)
Constructs an AgoraMediaRtcRecorder instance.
|
| Modifier and Type | Method and Description |
|---|---|
int |
disableVideoWatermarks()
Disable the watermark for the stream
|
int |
disableVideoWatermarksByUid(java.lang.String userId)
Disable the watermark for the stream by uid
|
int |
enableAndUpdateVideoWatermarks(WatermarkConfig[] watermarkConfigs)
Add the watermark for the stream
|
int |
enableAndUpdateVideoWatermarksByUid(WatermarkConfig[] watermarkConfigs,
java.lang.String userId)
Add the watermark for the stream by uid
|
int |
enableEncryption(boolean enabled,
EncryptionConfig config)
Enables or disables the built-in encryption.
|
int |
initialize(AgoraService service,
boolean enableMix)
Initializes the recorder with specified service and mixing settings.
|
int |
joinChannel(java.lang.String token,
java.lang.String channelName,
java.lang.String userId)
Joins an Agora RTC channel.
|
int |
leaveChannel()
Leaves the current channel.
|
private int |
nativeDisableVideoWatermarks(long nativeHandle) |
private int |
nativeDisableVideoWatermarksByUid(long nativeHandle,
java.lang.String userId) |
private int |
nativeEnableAndUpdateVideoWatermarks(long nativeHandle,
WatermarkConfig[] watermarkConfigs) |
private int |
nativeEnableAndUpdateVideoWatermarksByUid(long nativeHandle,
WatermarkConfig[] watermarkConfigs,
java.lang.String userId) |
private int |
nativeEnableEncryption(long nativeHandle,
boolean enabled,
EncryptionConfig config) |
private int |
nativeInitialize(long nativeHandle,
long serviceHandle,
boolean enableMix) |
private int |
nativeJoinChannel(long nativeHandle,
java.lang.String token,
java.lang.String channelName,
java.lang.String userId) |
private int |
nativeLeaveChannel(long nativeHandle) |
private int |
nativeRegisterRecorderEventHandler(long nativeHandle,
IAgoraMediaRtcRecorderEventHandler handler) |
private int |
nativeRelease(long nativeHandle) |
private int |
nativeRenewToken(long nativeHandle,
java.lang.String token) |
private int |
nativeSetAudioVolumeIndicationParameters(long nativeHandle,
int intervalInMs) |
private int |
nativeSetRecorderConfig(long nativeHandle,
MediaRecorderConfiguration config) |
private int |
nativeSetRecorderConfigByUid(long nativeHandle,
MediaRecorderConfiguration config,
java.lang.String userId) |
private int |
nativeSetVideoMixingLayout(long nativeHandle,
VideoMixingLayout layout) |
private int |
nativeStartRecording(long nativeHandle) |
private int |
nativeStartSingleRecordingByUid(long nativeHandle,
java.lang.String userId) |
private int |
nativeStopRecording(long nativeHandle) |
private int |
nativeStopSingleRecordingByUid(long nativeHandle,
java.lang.String userId) |
private int |
nativeSubscribeAllAudio(long nativeHandle) |
private int |
nativeSubscribeAllVideo(long nativeHandle,
VideoSubscriptionOptions options) |
private int |
nativeSubscribeAudio(long nativeHandle,
java.lang.String userId) |
private int |
nativeSubscribeVideo(long nativeHandle,
java.lang.String userId,
VideoSubscriptionOptions options) |
private int |
nativeUnregisterRecorderEventHandler(long nativeHandle,
IAgoraMediaRtcRecorderEventHandler handler) |
private int |
nativeUnsubscribeAllAudio(long nativeHandle) |
private int |
nativeUnsubscribeAllVideo(long nativeHandle) |
private int |
nativeUnsubscribeAudio(long nativeHandle,
java.lang.String userId) |
private int |
nativeUnsubscribeVideo(long nativeHandle,
java.lang.String userId) |
int |
registerRecorderEventHandler(IAgoraMediaRtcRecorderEventHandler handler)
Registers an event handler for recording events.
|
int |
release()
Releases the native resources associated with the recorder.
|
int |
renewToken(java.lang.String token)
Renews the token for the current session.
|
int |
setAudioVolumeIndicationParameters(int intervalInMs)
Sets the time interval of the onAudioVolumeIndication callback.
|
int |
setRecorderConfig(MediaRecorderConfiguration config)
Configures the recorder settings.
|
int |
setRecorderConfigByUid(MediaRecorderConfiguration config,
java.lang.String userId)
Configures the recorder settings for a specified user.
|
int |
setVideoMixingLayout(VideoMixingLayout layout)
Sets the layout for mixed video streams.
|
int |
startRecording()
Starts the recording process.
|
int |
startSingleRecordingByUid(java.lang.String userId)
Starts the recording process for a specified user.
|
int |
stopRecording()
Stops the recording process.
|
int |
stopSingleRecordingByUid(java.lang.String userId)
Stops the recording process for a specified user.
|
int |
subscribeAllAudio()
Subscribes to the audio streams of all remote users in the channel.
|
int |
subscribeAllVideo(VideoSubscriptionOptions options)
Subscribes to the video streams of all remote users in the channel.
|
int |
subscribeAudio(java.lang.String userId)
Subscribes to the audio stream of a specified remote user.
|
int |
subscribeVideo(java.lang.String userId,
VideoSubscriptionOptions options)
Subscribes to the video stream of a specified remote user.
|
int |
unregisterRecorderEventHandler(IAgoraMediaRtcRecorderEventHandler handler)
Unregisters a previously registered event handler.
|
int |
unsubscribeAllAudio()
Stops subscribing to the audio streams of all remote users.
|
int |
unsubscribeAllVideo()
Stops subscribing to the video streams of all remote users.
|
int |
unsubscribeAudio(java.lang.String userId)
Stops subscribing to the audio stream of a specified remote user.
|
int |
unsubscribeVideo(java.lang.String userId)
Stops subscribing to the video stream of a specified remote user.
|
public AgoraMediaRtcRecorder(long handle)
handle - The native handle for the recorder instancepublic int initialize(AgoraService service, boolean enableMix)
service - The Agora service instance that must be initialized before
calling this methodenableMix - Whether to enable stream mixing
- true: (Default) Enable the mixing mode when recording.
- false: Do not enable the mixing mode when recordingpublic int joinChannel(java.lang.String token,
java.lang.String channelName,
java.lang.String userId)
token - The token for authentication.channelName - The name of the channel to join. The name must not exceed
64 bytes and can contain:
userId - The user ID for the local user. If null, the system
automatically assigns one.public int leaveChannel()
public int enableEncryption(boolean enabled,
EncryptionConfig config)
For high-security scenarios, it's recommended to enable encryption before joining a channel. All users in the same channel must use the same encryption mode and key. The encryption key is automatically cleared when all users leave the channel.
enabled - Whether to enable the built-in encryption.
- true: Yes.
- false: (Default) No.config - Encryption configuration parameters.public int subscribeAllAudio()
This method automatically subscribes to the audio of any new users who join the channel.
public int subscribeAllVideo(VideoSubscriptionOptions options)
This method automatically subscribes to the video of any new users who join the channel.
options - Video subscription options including stream type and other
parameterspublic int unsubscribeAllAudio()
This method automatically stops subscribing to the audio of any new users
unless
subscribeAudio(java.lang.String) or subscribeAllAudio() is explicitly called.
public int unsubscribeAllVideo()
This method automatically stops subscribing to the video of any new users
unless
subscribeVideo(java.lang.String, io.agora.recording.VideoSubscriptionOptions) or subscribeAllVideo(io.agora.recording.VideoSubscriptionOptions) is explicitly called.
public int subscribeAudio(java.lang.String userId)
userId - The ID of the remote user whose audio you want to subscribe topublic int unsubscribeAudio(java.lang.String userId)
userId - The ID of the remote user whose audio you want to unsubscribe
frompublic int subscribeVideo(java.lang.String userId,
VideoSubscriptionOptions options)
userId - The ID of the remote user whose video you want to subscribe tooptions - Video subscription options including stream type and other
parameterspublic int unsubscribeVideo(java.lang.String userId)
userId - The ID of the remote user whose video you want to unsubscribe
frompublic int setAudioVolumeIndicationParameters(int intervalInMs)
intervalInMs - Sets the time interval(ms) between two consecutive volume
indications. The default
value is 500.
- ≤ 10: Disables the volume indication.
- > 10: The time interval (ms) between two consecutive
callbacks.public int setVideoMixingLayout(VideoMixingLayout layout)
This method configures how different video streams are positioned and sized in the mixed output.
layout - The layout configuration for the mixed video streampublic int setRecorderConfig(MediaRecorderConfiguration config)
This method must be called before starting the recording.
config - The recorder configuration parameterspublic int setRecorderConfigByUid(MediaRecorderConfiguration config, java.lang.String userId)
config - The recorder configuration parametersuserId - The user ID for the user whose recording settings you want to
configurepublic int startRecording()
Make sure to configure the recorder using setRecorderConfig(io.agora.recording.MediaRecorderConfiguration) before
calling this method.
public int stopRecording()
This method stops all ongoing recordings and saves the recorded files.
public int startSingleRecordingByUid(java.lang.String userId)
userId - The user ID for the user whose recording you want to startpublic int stopSingleRecordingByUid(java.lang.String userId)
userId - The user ID for the user whose recording you want to stoppublic int registerRecorderEventHandler(IAgoraMediaRtcRecorderEventHandler handler)
The handler receives callbacks for various recording events such as state changes, errors, and recording progress updates.
handler - The event handler implementing
IAgoraMediaRtcRecorderEventHandler interfacepublic int unregisterRecorderEventHandler(IAgoraMediaRtcRecorderEventHandler handler)
handler - The event handler to unregisterpublic int enableAndUpdateVideoWatermarks(WatermarkConfig[] watermarkConfigs)
watermarkConfigs - The watermark configpublic int disableVideoWatermarks()
public int enableAndUpdateVideoWatermarksByUid(WatermarkConfig[] watermarkConfigs, java.lang.String userId)
watermarkConfigs - The watermark configuserId - The ID of the user whose stream you want to add
watermark.public int disableVideoWatermarksByUid(java.lang.String userId)
userId - The ID of the user whose stream you want to disable watermark.public int renewToken(java.lang.String token)
The token expires after a certain period of time. When the
IAgoraMediaRtcRecorderEventHandler.onError(String, Constants.ErrorCodeType, String)
callback reports (109), or
when
IAgoraMediaRtcRecorderEventHandler.onTokenPrivilegeWillExpire(String, String)
or
IAgoraMediaRtcRecorderEventHandler.onTokenPrivilegeDidExpire(String)
is triggered, you must generate a new token on your server and call this
method to renew it.
Otherwise, the SDK will disconnect from the Agora channel.
token - The new token generated from your server.public int release()
private int nativeInitialize(long nativeHandle,
long serviceHandle,
boolean enableMix)
private int nativeJoinChannel(long nativeHandle,
java.lang.String token,
java.lang.String channelName,
java.lang.String userId)
private int nativeLeaveChannel(long nativeHandle)
private int nativeEnableEncryption(long nativeHandle,
boolean enabled,
EncryptionConfig config)
private int nativeSubscribeAllAudio(long nativeHandle)
private int nativeSubscribeAllVideo(long nativeHandle,
VideoSubscriptionOptions options)
private int nativeUnsubscribeAllAudio(long nativeHandle)
private int nativeUnsubscribeAllVideo(long nativeHandle)
private int nativeSubscribeAudio(long nativeHandle,
java.lang.String userId)
private int nativeUnsubscribeAudio(long nativeHandle,
java.lang.String userId)
private int nativeSubscribeVideo(long nativeHandle,
java.lang.String userId,
VideoSubscriptionOptions options)
private int nativeUnsubscribeVideo(long nativeHandle,
java.lang.String userId)
private int nativeSetAudioVolumeIndicationParameters(long nativeHandle,
int intervalInMs)
private int nativeSetVideoMixingLayout(long nativeHandle,
VideoMixingLayout layout)
private int nativeSetRecorderConfig(long nativeHandle,
MediaRecorderConfiguration config)
private int nativeSetRecorderConfigByUid(long nativeHandle,
MediaRecorderConfiguration config,
java.lang.String userId)
private int nativeStartRecording(long nativeHandle)
private int nativeStopRecording(long nativeHandle)
private int nativeStartSingleRecordingByUid(long nativeHandle,
java.lang.String userId)
private int nativeStopSingleRecordingByUid(long nativeHandle,
java.lang.String userId)
private int nativeRegisterRecorderEventHandler(long nativeHandle,
IAgoraMediaRtcRecorderEventHandler handler)
private int nativeUnregisterRecorderEventHandler(long nativeHandle,
IAgoraMediaRtcRecorderEventHandler handler)
private int nativeEnableAndUpdateVideoWatermarks(long nativeHandle,
WatermarkConfig[] watermarkConfigs)
private int nativeDisableVideoWatermarks(long nativeHandle)
private int nativeEnableAndUpdateVideoWatermarksByUid(long nativeHandle,
WatermarkConfig[] watermarkConfigs,
java.lang.String userId)
private int nativeDisableVideoWatermarksByUid(long nativeHandle,
java.lang.String userId)
private int nativeRenewToken(long nativeHandle,
java.lang.String token)
private int nativeRelease(long nativeHandle)