public abstract class AVChatManager extends AVChatManagerLite
A unified interface for audio and video calls. All interfaces must run on the main thread.
Android JELLY_BEAN
or later is required All required permissions are granted before calling. Check permissions using checkPermission(Context)
.
Only one session is supported at the same time. If multiple calls comes, you must choose a preferred session and hang out rest calls If system phone call rings or a system phone is connected, it is recommended to hang up the network call.
For the setting of outgoing and incoming timeouts for network calls, use a timer to respond calls. The timeout setting in the SDK has been deprecated and will be removed.
VoIP calls are divided into two categories, P2P calls and group calls.
All audio and video calls have observers: AVChatManagerLite.observeAVChatState(AVChatStateObserverLite, boolean)
P2P calls include signaling and audio and video operations. Signaling handles session initiation, answering, rejecting, and hanging up. Interfaces:
AVChatManagerLite.call2(String, AVChatType, AVChatNotifyOption, AVChatCallback)
initiate a call. AVChatManagerLite.accept2(long, AVChatCallback)
accept a call. AVChatManagerLite.hangUp2(long, AVChatCallback)
hang up a call AVChatManagerLite.sendControlCommand(long, byte, AVChatCallback)
Send control commands. Users can define custom commands We recommend you switch audio and video calls using this interface Observer for P2P calls:
AVChatManagerLite.observeIncomingCall(Observer, boolean)
Observer for incoming calls AVChatManagerLite.observeCalleeAckNotification(Observer, boolean)
Observer for callee responses AVChatManagerLite.observeControlNotification(Observer, boolean)
Observer for all control commands AVChatManagerLite.observeHangUpNotification(Observer, boolean)
Observer for callee hang up AVChatManagerLite.observeOnlineAckNotification(Observer, boolean)
Observer for response from other devices Group calls and interactive live streams belong to this mode This mode does not include all signaling operations, and is customized by the upper layer of the app client. This mode only includes joining and leaving a room, and audio and video operations. Interfaces:
AVChatManagerLite.createRoom(String, String, AVChatCallback)
Create a room for group calls AVChatManagerLite.joinRoom2(String, AVChatType, AVChatCallback)
Join a group room AVChatManagerLite.leaveRoom2(String, AVChatCallback)
Leave a room Interactive live broadcast and group conferencing procdure:
AVChatManagerLite.createRoom(String, String, AVChatCallback)
. If a host creates a room, the server reserves a room name. The room is valid for 30 days if it is not used. The used room will be recycled after all users leave the room. AVChatManagerLite.observeAVChatState(AVChatStateObserverLite, boolean)
AVChatManagerLite.enableRtc()
. AVChatManagerLite.setChannelProfile(int)
. AVChatParameters.KEY_SESSION_LIVE_MODE
, AVChatParameters.KEY_SESSION_LIVE_URL
. AVChatManagerLite.enableVideo()
. AVChatManagerLite.setupVideoCapturer(AVChatVideoCapturer)
. AVChatManagerLite.setupLocalVideoRender(IVideoRender, boolean, int)
. AVChatManagerLite.setParameter(AVChatParameters.Key, Object)
, AVChatManagerLite.setParameters(AVChatParameters)
. AVChatManagerLite.enableVideo()
. AVChatManagerLite.joinRoom2(String, AVChatType, AVChatCallback)
. AVChatManagerLite.stopVideoPreview()
AVChatManagerLite.disableVideo()
()} AVChatManagerLite.leaveRoom2(String, AVChatCallback)
AVChatManagerLite.disableRtc()
。 P2P video call procdure:
AVChatManagerLite.observeAVChatState(AVChatStateObserverLite, boolean)
AVChatManagerLite.enableRtc()
. AVChatManagerLite.setChannelProfile(int)
. AVChatManagerLite.enableVideo()
. AVChatManagerLite.setupVideoCapturer(AVChatVideoCapturer)
. AVChatManagerLite.setupLocalVideoRender(IVideoRender, boolean, int)
AVChatManagerLite.setParameter(AVChatParameters.Key, Object)
, AVChatManagerLite.setParameters(AVChatParameters)
. AVChatManagerLite.enableVideo()
. AVChatManagerLite.call2(String, AVChatType, AVChatNotifyOption, AVChatCallback)
, AVChatManagerLite.accept2(long, AVChatCallback)
. AVChatManagerLite.stopVideoPreview()
AVChatManagerLite.disableVideo()
()} AVChatManagerLite.hangUp2(long, AVChatCallback)
. AVChatManagerLite.disableRtc()
。 Constructor and Description |
---|
AVChatManager() |
Modifier and Type | Method and Description |
---|---|
static java.util.List<java.lang.String> |
checkPermission(Context context)
Check for the required permissions for audio and video modules.
|
abstract boolean |
enableAudienceRole(boolean enable)
Enable the audience role.
|
abstract int |
getConnectStatus()
Get the current connection status
|
static AVChatManager |
getInstance()
Get an instance of an abstract class
|
abstract AVChatNetworkProxy |
getNetworkProxy()
Get the specified network proxy
|
abstract boolean |
isAudienceRole()
Check for the audience role
|
abstract boolean |
isAutoPublishVideo()
Check for the automatic publishing mode for video streams
|
abstract boolean |
isAutoSubscribeAudio()
Check for automatic subscription mode for audio streams
|
abstract boolean |
isAutoSubscribeVideo()
Check for automatic subscription mode for video streams
|
abstract void |
observeTimeoutNotification(Observer<java.lang.Long> observer,
boolean register)
Deprecated.
Users can implement timeout externally. the timeout notification provided by the SDK will be deprecated
|
abstract boolean |
pauseAudioMixing()
Pause audio mixing
|
abstract boolean |
playAudioEffect(int effectId,
int loopback,
boolean send,
float volume)
Play an effect .
|
abstract void |
preloadAudioEffect(int effectId,
java.lang.String audioFilePath)
Preload or unload the effect file.
|
abstract int |
publishVideo()
Manually publish video streams
|
abstract int |
pushExternalAudioData(byte[] data,
int samples,
int sampleRate,
int channel,
int bytesPerSample,
boolean blocking)
External input audio data, a maximum of 40ms data is allowed to be transmitted each time.
|
abstract int |
pushExternalAudioMixingStream(byte[] audioData,
int samplesPerChannel,
int sampleRate,
int channel)
Push external audio mixing streams.
|
abstract void |
registerAVChatRecordObserver(IAVChatRecordObserver observer,
boolean register)
Register the callback for Call detail record (CDR)
|
abstract boolean |
registerPlayAudioCallBack(IAVChatPlayAudioCallBack callback)
Register the callback for PCM audio data before playback
|
abstract boolean |
registerRemoteAudioCallBack(java.lang.String account,
IAVChatRemoteAudioCallBack callback)
Register the callback for PCM audio data from remote users
|
abstract boolean |
resumeAudioMixing()
Resume audio mixing
|
abstract boolean |
seekAudioMixing(long ms)
Set the progress of audio mixing
|
abstract void |
setAsMainArea(java.lang.String account,
AVChatRoomServerCallback callback)
Callback for the canvas
|
abstract boolean |
setAudioMixingPlaybackVolume(float volume)
Set the audio playback volume
|
abstract boolean |
setAudioMixingSendVolume(float volume)
Set the audio sending volume
|
abstract int |
setAutoPublish(boolean autoPub,
boolean autoSub)
Set to automatically or manually publish and subscribe to audio streams.
|
abstract boolean |
setExternalAudioMixingStream(boolean enabled,
boolean asSource,
boolean asSink)
Set the external audio mixing stream
|
abstract boolean |
setExternalAudioSource(boolean enabled)
Specify whether to capture external audio source.
|
abstract int |
setLocalVideoSimulcastModel(int mode)
Set a local video simulcast mode You can choose single stream (default) or simulcast.
|
abstract void |
setNetworkProxy(AVChatNetworkProxy proxy)
Set the network proxy before starting a call
|
abstract boolean |
setPlayCapturedAudioVolume(float volume)
Set the volume for in-ear monitoring.
|
abstract int |
setPublishFallbackOption(int option)
Set the fallback option for the published video stream based on the network conditions.
|
abstract boolean |
startAudioMixing(java.lang.String path,
boolean loopback,
boolean replace,
int cycle,
float volume)
Mix or replace audio streams from local files, URLs or captured from the microphone
|
abstract boolean |
startAudioRecording()
Start recording during the call, including the voice data of all users.
|
abstract boolean |
startAudioRecording(int type)
Start recording during the call, including the voice data of all users.
|
abstract boolean |
startAVRecording(java.lang.String account)
Start recording a user's voice and video data to an MP4 file stored in the local storage on the client.
|
abstract boolean |
startPlayCapturedAudio()
Enable the in-ear monitor
|
abstract boolean |
stopAudioMixing()
Stop audio mixing
|
abstract boolean |
stopAudioRecording()
Stop recording during the call, including the voice data of all users.
|
abstract boolean |
stopAVRecording(java.lang.String account)
Stop recording a user's voice and video data to an MP4 file stored in the local storage on the client.
|
abstract boolean |
stopPlayAudioEffect(int effectId)
Stop playing an effect
|
abstract boolean |
stopPlayCapturedAudio()
diable the in-ear monitor
|
abstract int |
subscribeActiveAudio()
Manually subscribe to audio streams
|
abstract int |
subscribeVideo(java.lang.String account,
int videoType)
Manually subscribe to video streams
|
abstract int |
switchCommunicateMode(int mode)
Switch the communication modes.
|
abstract boolean |
takeSnapshot(java.lang.String account)
Take a snapshot
|
abstract int |
unpublishVideo()
Manually unpublish video streams
|
abstract int |
unsubscribeActiveAudio()
Manually unsubscribe from audio streams
|
abstract int |
unsubscribeVideo(java.lang.String account)
Manually unsubscribe from video streams
|
accept2, call2, createRoom, createRoom, disableRtc, disableVideo, enableRtc, enableRtc, enableRtc, enableRtc, enableRtc, enableRtc, enableVideo, getCurrentChatId, getParameter, getParameters, getUidByAccount, hangUp2, isAllRemoteAudioMuted, isLocalAudioMuted, isLocalVideoMuted, isMicrophoneMute, isRemoteAudioMuted, isRemoteVideoMuted, joinRoom2, leaveRoom2, muteAllRemoteAudio, muteLocalAudio, muteLocalVideo, muteRemoteAudio, muteRemoteVideo, observeAVChatState, observeCalleeAckNotification, observeControlNotification, observeHangUpNotification, observeIncomingCall, observeOnlineAckNotification, rate, selectAudioDevice, sendControlCommand, setChannelProfile, setMicrophoneMute, setParameter, setParameters, setSpeaker, setupLocalVideoRender, setupRemoteVideoRender, setupVideoCapturer, setVideoQualityStrategy, speakerEnabled, startVideoPreview, stopVideoPreview
public static AVChatManager getInstance()
public abstract void setNetworkProxy(AVChatNetworkProxy proxy)
proxy
- proxy infopublic abstract AVChatNetworkProxy getNetworkProxy()
public abstract boolean setExternalAudioSource(boolean enabled)
enabled
- enable or disable external audio capturetrue
: success. false
: failure.public abstract int pushExternalAudioData(byte[] data, int samples, int sampleRate, int channel, int bytesPerSample, boolean blocking) throws java.lang.NullPointerException, java.lang.IllegalArgumentException
data
- audio datasamples
- number of samplessampleRate
- sampling rate. 8000,16000,32000,44100,And 48000 are supportedchannel
- number of channelsbytesPerSample
- bytes of each sample. Only PCM 16 is supportedblocking
- Blocking data writing
If non-blocking data is written, return -100
for insufficient buffer.
If blocking data is written, wait a moment and return the size of the data to be written, or return -100
for unsufficient buffer.0
A value of 0 returned indicates that the method call is successful. Otherwise, the method call fails.java.lang.NullPointerException
java.lang.IllegalArgumentException
setExternalAudioSource(boolean)
public abstract boolean startAVRecording(java.lang.String account)
Note: two users can use recording on the server
account
- User accounttrue
: success. false
: failure.public abstract boolean stopAVRecording(java.lang.String account)
Note: two users can use recording on the server
account
- User accounttrue
: success. false
: failure.public abstract boolean startAudioRecording()
true
: success. false
: failure.public abstract boolean startAudioRecording(int type)
type
- AVChatAudioRecordType
true
: success. false
: failure.public abstract boolean stopAudioRecording()
true
: success. false
: failure.public abstract boolean enableAudienceRole(boolean enable)
Role settings only take effect in group sessions.
Note: User roles are different from the Mute method. The audience role will affect the data capture, processing and publishing; The local Mute
will only affect the published data.
enable
- true
: audience role. false
: standard usertrue
: success. false
: failure.public abstract boolean isAudienceRole()
Role settings only take effect in group sessions.
public static java.util.List<java.lang.String> checkPermission(Context context)
Invoke the method if permissions are required on Android 6.0.
context
- Android contextpublic abstract boolean takeSnapshot(java.lang.String account)
File path: /Sdcard/Android/data/{app_package_name}/files/snapshot
.
account
- User accounttrue
: success. false
: failure.public abstract boolean startAudioMixing(java.lang.String path, boolean loopback, boolean replace, int cycle, float volume)
path
- local file path or URLloopback
- enable or disable loop playbackreplace
- whether to replace the audio data from the microphonecycle
- loop countvolume
- volume [0.0f - 1.0f]true
: success. false
: failure.public abstract boolean setAudioMixingPlaybackVolume(float volume)
volume
- [0.0f - 1.0f]true
: success. false
: failure.public abstract boolean setAudioMixingSendVolume(float volume)
volume
- [0.0f - 1.0f]true
: success. false
: failure.public abstract boolean seekAudioMixing(long ms)
ms
- Target position in milliseconds. For more information, see AudioMixing#getCurrentMs()
true
: success. false
: failure.public abstract boolean stopAudioMixing()
true
: success. false
: failure.public abstract boolean resumeAudioMixing()
true
: success. false
: failure.public abstract boolean pauseAudioMixing()
true
: success. false
: failure.public abstract void preloadAudioEffect(int effectId, java.lang.String audioFilePath)
effectId
- effect ID, user-defined. If an ID is loaded repeatedly, the playback stops and the effect is unloaded.audioFilePath
- Audio file path. if null is passed, unload the audio effect. Unloading the effect during playback stops playback and triggers the playback completion callback. AVChatStateObserver.onAudioEffectPreload(int, int)
public abstract boolean playAudioEffect(int effectId, int loopback, boolean send, float volume)
preloadAudioEffect(int, String)
and the preload result is returned using AVChatStateObserver.onAudioEffectPreload(int effectId, int result)
The AVChatStateObserver.onAudioEffectPlayEvent(int effectId, int event)
callback is triggered after the playback is completed
effectId
- Effect ID used for preloadingloopback
- effect loop count. -1: infinite loopsend
- publish the effectvolume
- playback or sending volume [0.0f - 1.0f]true
: success. false
: failurepublic abstract boolean stopPlayAudioEffect(int effectId)
effectId
- Effect IDtrue
: success. Other values: failure@Deprecated public abstract void observeTimeoutNotification(Observer<java.lang.Long> observer, boolean register)
observer
- The observer. True: outgoing call timeout. False: incoming call timeoutregister
- true
: register the listener, false
: unregister the listenerpublic abstract boolean startPlayCapturedAudio()
Enable the in-ear monitor
You can turn on the in-ear monitor after the call is accepted, and you can hear your own voice from the headset in real time.
true
: success. false
: failure.public abstract boolean stopPlayCapturedAudio()
diable the in-ear monitor
If the in-ear monitoring feature is enabled, you can close the in-ear monitor.
true
: success. false
: failure.public abstract boolean setPlayCapturedAudioVolume(float volume)
Set the volume for in-ear monitoring.
If the in-ear monitoring feature is enabled, you can set the volume.
volume
- playback volume [0.0f - 1.0f]true
: success. false
: failure.public abstract void setAsMainArea(java.lang.String account, AVChatRoomServerCallback callback)
account
- user accountcallback
- callback for statespublic abstract boolean setExternalAudioMixingStream(boolean enabled, boolean asSource, boolean asSink)
enabled
- enable or disable the external audio mixing streamasSource
- mixing sending audio streamsasSink
- mixing playback audio streams0
A value of 0 returned indicates that the method call is successful. Otherwise, the method call fails.public abstract int pushExternalAudioMixingStream(byte[] audioData, int samplesPerChannel, int sampleRate, int channel)
audioData
- audio datasamplesPerChannel
- audio data samples per channelsampleRate
- audio data sample ratechannel
- number of channels0
A value of 0 returned indicates that the method call is successful. Otherwise, the method call fails.public abstract int setAutoPublish(boolean autoPub, boolean autoSub)
autoPub
- true: automatic publishing. False: manual publishingautoSub
- true: automatic subscribing. False: manual subscribingpublic abstract boolean isAutoPublishVideo()
public abstract boolean isAutoSubscribeVideo()
public abstract boolean isAutoSubscribeAudio()
public abstract int setLocalVideoSimulcastModel(int mode)
mode
- the streaming mode. For more information, see NRtcConstants.Subscribe#PUBLISH_MODEL_SINGLE_STREAM
: single streamNRtcConstants.Subscribe#PUBLISH_MODEL_DUAL_STREAM
: dual streampublic abstract int publishVideo()
AVChatStateObserver.onPublishVideoResult(int)
callback RtcCode.Subscribe#VIDEO_IS_MUTED_ERR
: The current video is muted RtcCode.Subscribe#IS_AUDIENCE_ERR
: Audience role error RtcCode.Subscribe#IS_AUDIO_MODE_ERR
: Audio mode error RtcCode.Subscribe#ACTION_DUPLICATE_ERR
: Invalid operation RtcCode.Subscribe#MODE_CONFLICT_ERR
: mode conflict. The current setting is auto modeRtcCode.Subscribe#FORBID_ACTION
: Invalid operation. The subscribe operation takes effect only in conference mode. The peer-to-peer mode does not support the operation.public abstract int unpublishVideo()
AVChatStateObserver.onUnpublishVideoResult(int)
callback RtcCode.Subscribe#VIDEO_IS_MUTED_ERR
: The current video is muted RtcCode.Subscribe#IS_AUDIENCE_ERR
: Audience role error RtcCode.Subscribe#IS_AUDIO_MODE_ERR
: Audio mode error RtcCode.Subscribe#ACTION_DUPLICATE_ERR
: Invalid operation RtcCode.Subscribe#MODE_CONFLICT_ERR
: mode conflict. The current setting is auto modeRtcCode.Subscribe#FORBID_ACTION
: Invalid operation. The subscribe operation takes effect only in conference mode. The peer-to-peer mode does not support the operation.public abstract int subscribeVideo(java.lang.String account, int videoType)
account
- the account that subscribes video streamsvideoType
- stream type. For more information, see NRtcConstants.Subscribe#VIDEO_TYPE_HIGH_RES
: high quality streamNRtcConstants.Subscribe#VIDEO_TYPE_LOW_RES
: low quality streamAVChatStateObserver.onSubscribeVideoResult(String, int, int)
callback RtcCode.Subscribe#ACTION_DUPLICATE_ERR
: Invalid operation RtcCode.Subscribe#MODE_CONFLICT_ERR
: mode conflict. The current setting is auto modeRtcCode.Subscribe#FORBID_ACTION
: Invalid operation. The subscribe operation takes effect only in conference mode. The peer-to-peer mode does not support the operation.RtcCode.Subscribe#TYPE_CONFLICT_ERR
: video type conflict. The subscribed video stream must be unsubscribed firstpublic abstract int unsubscribeVideo(java.lang.String account)
account
- account that unscribes from video streamsAVChatStateObserver.onUnsubscribeVideoResult(String, int, int)
} callback RtcCode.Subscribe#ACTION_DUPLICATE_ERR
: Invalid operation RtcCode.Subscribe#MODE_CONFLICT_ERR
: mode conflict. The current setting is auto modeRtcCode.Subscribe#FORBID_ACTION
: Invalid operation. The subscribe operation takes effect only in conference mode. The peer-to-peer mode does not support the operation.public abstract int subscribeActiveAudio()
AVChatStateObserver.onSubscribeAudioResult(int)
callback RtcCode.Subscribe#ACTION_DUPLICATE_ERR
: Invalid operation RtcCode.Subscribe#MODE_CONFLICT_ERR
: mode conflict. The current setting is auto modeRtcCode.Subscribe#FORBID_ACTION
: Invalid operation. The subscribe operation takes effect only in conference mode. The peer-to-peer mode does not support the operation.public abstract int unsubscribeActiveAudio()
AVChatStateObserver.onUnsubscribeAudioResult(int)
callback RtcCode.Subscribe#ACTION_DUPLICATE_ERR
: Invalid operation RtcCode.Subscribe#MODE_CONFLICT_ERR
: mode conflict. The current setting is auto modeRtcCode.Subscribe#FORBID_ACTION
: Invalid operation. The subscribe operation takes effect only in conference mode. The peer-to-peer mode does not support the operation.public abstract int setPublishFallbackOption(int option)
option:
- fallback option. The default value is NRtcConstants.PublishFallbackOption#STREAM_FALLBACK_AUDIO_ONLY
. For more information, see
NRtcConstants.PublishFallbackOption#STREAM_FALLBACK_DISABLED
NRtcConstants.PublishFallbackOption#STREAM_FALLBACK_AUDIO_ONLY
public abstract boolean registerRemoteAudioCallBack(java.lang.String account, IAVChatRemoteAudioCallBack callback)
account
- the account of a remote user. If the SDK is closed, the callback is automatically unregistered.callback
- callback. A value of null unregistered the previous registered callback.public abstract boolean registerPlayAudioCallBack(IAVChatPlayAudioCallBack callback)
callback
- callback. A value of null unregistered the previous registered callback.
Note: To use a specific sample rate, edit AVChatParameters.KEY_AUDIO_PLAYBACK_DEFAULT_SAMPLE_RATE
public abstract void registerAVChatRecordObserver(IAVChatRecordObserver observer, boolean register)
observer
- observer for CDRregister
- true: register the callback; false: unregister the callbackpublic abstract int getConnectStatus()
AVChatConnectStatus.NONE
,
AVChatConnectStatus.CONNECT_ING
,
AVChatConnectStatus.CONNECTED
,
AVChatConnectStatus.RE_CONNECT_ING
,
AVChatConnectStatus.DISCONNECT
public abstract int switchCommunicateMode(int mode)
mode
- communication modeThe video mode. Audio and video streams can be published at the same time. In manual mode, you need to publish the video stream manually.
,
audio mode that can send audio only.