Class RongCallClient
-
- All Implemented Interfaces:
public class RongCallClient
切换指定id的摄像头 该接口配合startCall使用
-
-
Constructor Summary
Constructors Constructor Description RongCallClient(String appKey, Context context, IHandler stub)
-
Method Summary
Modifier and Type Method Description static RongCallClient
getInstance()
Context
getContext()
void
unInit()
隐藏方法,当 ipc 进程崩溃时,需要注销该实例并释放内存 static void
setReceivedCallListener(IRongReceivedCallListener listener)
设置通话来电监听设置通话来电监听 static void
setCallSignalSender(IRongCallSignalSender signalSender)
void
setVoIPCallListener(IRongCallListener callListener)
设置通话状态回调设置通话状态回调 static void
setMissedCallListener(RongCallMissedListener listener)
static void
setPushConfig(MessagePushConfig startCallPushConfig, MessagePushConfig hangupPushConfig)
自定义通话推送标题和内容等 pushConfig 自定义音视频通话的推送配置 开发者在调用startCall发起通话前设置 String
startCall(ConversationType conversationType, String targetId, List<String> userIds, List<String> observerUserIds, RongCallCommon.CallMediaType mediaType, String extra)
发起通话发起通话 String
startCrossCall(ConversationType conversationType, String targetId, List<String> userIds, List<String> observerUserIds, RongCallCommon.CallMediaType mediaType, String extra)
发起跨应用通话发起通话 String
startCall(int cameraId, boolean mirror, ConversationType conversationType, String targetId, List<String> userIds, List<String> observerUserIds, RongCallCommon.CallMediaType mediaType, String extra, StartCameraCallback callback)
打开指定摄像头方式发起通话打开指定摄像头方式发起通话 void
acceptCall(String callId)
接听通话接听通话 void
acceptCall(String callId, int cameraId, boolean mirror, StartCameraCallback callback)
打开指定摄像头方式接听通话打开指定摄像头方式接听通话 void
hangUpCall(String callId)
挂断通话挂断通话 void
hangUpCall()
挂断通话挂断通话 RongCallSession
getCallSession()
获取当前通话实体,通话实体中维护着当前通话的所有信息获取当前通话实体,通话实体中维护着当前通话的所有信息 void
addParticipants(String callId, ArrayList<String> userIds, ArrayList<String> observerUserIds)
邀请用户加入当前通话(仅限讨论组和群组)邀请用户加入当前通话 void
changeCallMediaType(RongCallCommon.CallMediaType mediaType)
视频通话转音频通话视频通话转音频通话 void
switchCamera()
前后摄像头切换,适用于通过SDK打开默认摄像头的场景在通话建立(IRongCallListener#onCallConnected)之后切换前后置摄像头,该方法适用于通过SDK打开默认摄像头的场景,配合 RongCallClient#startCall(Conversation.ConversationType, String, List, List, RongCallCommon. void
switchCamera(int cameraId, boolean mirror, CameraSwitchCallBack callBack)
切换指定 id 摄像头 在通话建立(IRongCallListener#onCallConnected)之后切换指定 ID 的摄像头,该方法适用于通过 SDK 打开指定摄像头的场景,配合 RongCallClient#startCall(int, boolean, Conversation.ConversationType, String, List, List, RongCallCommon. void
setEnableLocalVideo(boolean enabled)
设置是否打开本地摄像头设置是否打开本地摄像头 void
setEnableLocalAudio(boolean enabled)
设置是否打开本地音频设置是否打开本地音频 void
setEnableSpeakerphone(boolean enabled)
设置是否打开免提设置是否打开扬声器,在 IRongCallListener#onCallConnected(RongCallSession, SurfaceView) 之后调用有效 void
onPermissionGranted()
授予权限android 6. void
onPermissionDenied()
拒绝授予权限android 6.0以上的版本适用,用户拒绝授权之后回调此接口通知CallLib(IRongReceivedCallListener#onCheckPermission(RongCallSession)), audio call需要获取Manifest.permission. void
registerVideoFrameListener(IVideoFrameListener listener)
注册本地视频流上报监听用于处理视频通话中的视频数据。请在connect成功之后设置, 回调返回数据类型通过在接听或拨打前的参数设置控制,如下: RCRTCConfig.Builder config=RCRTCConfig.Builder.create().enableEncoderTexture(true); RongCallClient.getInstance().setRTCConfig(config);
void
registerAudioFrameListener(IRCRTCAudioDataListener listener)
本地音频流上报监听用于处理通话中的音频数据。请在connect成功之后设置 void
unregisterVideoFrameObserver()
取消注册 本地音频流上报监听在不使用本地视频流时取消注册 boolean
isVoIPEnabled(Context context)
检查音视频引擎是否可用检查音视频引擎是否可用 void
publishMediaResource(RongCallCommon.CallMediaType callMediaType)
观察者发布资源 仅为观察者身份时发布资源 boolean
isLocalAudioEnabled()
本地音频是否开启 本地音频是否开启 boolean
isSpeakerphoneEnabled()
扬声器是否开启 扬声器是否开启 boolean
isLocalVideoEnabled()
本地视频是否开启 本地视频是否开启 void
resetAVStatus()
void
startCapture()
仅打开本地摄像头在通话建立(IRongCallListener#onCallConnected)之后打开摄像头,对端不会收到 IRongCallListener#onRemoteCameraDisabled 通知 void
startIncomingPreview(StartIncomingPreviewCallback callback)
void
publishCustomVideoStream(String tag, PublishCallBack callBack)
发布自定义音视频流发布自定义音视频流 ,该方法必须在通话过程中设置有效,如:IRongCallListener#onCallConnected(RongCallSession, SurfaceView) 回调中 void
unpublishCustomVideoStream(RCRTCOutputStream outputStream, IRCRTCResultCallback callBack)
取消发布自定义音视频流取消发布自定义音视频流 void
setRTCConfig(Builder builder)
设置音视频配置 必须在 RongCallClient#startCall 和 RongCallClient#acceptCall(String) 之前调用 void
setVideoConfig(Builder builder)
视频分辨率、码率相关配置 void
setAudioConfig(Builder builder)
音频相关配置 void
setCameraFrameOrientation(int cameraOrientation, int frameOrientation)
设置相机采集角度和编码使用到的角度 boolean
canCallContinued(String callId)
static String
getVersion()
void
)>queryJoinedRoom(IRCRTCResultDataCallback<RCRTCJoinedRoomInfo[]> callBack)
查询本用户是否在其他设备进行音视频通话或调用joinRoom 成功 void
setJoinType(RCRTCJoinType joinType)
int
setMultiPlatformVideoView(String userId, String tag, RCRTCBaseView videoView)
设置跨平台使用的渲染视图。调用此接口前需要先调用 static void
enableMultiPlatformMode()
开启跨平台模式。目前主要是创建渲染视图的流程会有变化 static void
setPreconnectEnabled(boolean enabled)
是否打开http 预热开关,打开 true 不打开 false 默认 true static void
setCheckPermission(boolean check)
是否需要检查权限 -
-
Method Detail
-
getInstance
static RongCallClient getInstance()
-
getContext
Context getContext()
-
unInit
void unInit()
隐藏方法,当 ipc 进程崩溃时,需要注销该实例并释放内存
-
setReceivedCallListener
static void setReceivedCallListener(IRongReceivedCallListener listener)
设置通话来电监听
设置通话来电监听
- Parameters:
listener
- 来电监听
-
setCallSignalSender
static void setCallSignalSender(IRongCallSignalSender signalSender)
-
setVoIPCallListener
void setVoIPCallListener(IRongCallListener callListener)
设置通话状态回调
设置通话状态回调
- Parameters:
callListener
- 通话状态回调
-
setMissedCallListener
static void setMissedCallListener(RongCallMissedListener listener)
-
setPushConfig
static void setPushConfig(MessagePushConfig startCallPushConfig, MessagePushConfig hangupPushConfig)
自定义通话推送标题和内容等 pushConfig
自定义音视频通话的推送配置 开发者在调用startCall发起通话前设置
- Parameters:
startCallPushConfig
- 通话发起时推送配置hangupPushConfig
- 通话挂断时的推送配置
-
startCall
String startCall(ConversationType conversationType, String targetId, List<String> userIds, List<String> observerUserIds, RongCallCommon.CallMediaType mediaType, String extra)
发起通话
发起通话
- Parameters:
conversationType
- 会话类型, 如果实现的是不基于群组的 VoIP,那此参数必须传 NONE安卓端如何实现不依赖群组的实时音视频通话?targetId
- 目标会话 id ,单人通话为对方 UserId ,群组通话为 GroupId ,如果实现的是不基于群组的通话,那此参数无意义,传 null 即可userIds
- 邀请参与通话的用户 ID 列表,不能为 null,必须包含 observerUserIds 中除发起者 ID 的所有用户 IDobserverUserIds
- 观察者列表,无观察者可传 null,当音视频发起方是观察者时,observerUserIds 需要包含发起方用户 IDmediaType
- 发起的通话媒体类型extra
- 附加信息,透传至对端,对端通过 RongCallSession.- Returns:
呼叫id
-
startCrossCall
String startCrossCall(ConversationType conversationType, String targetId, List<String> userIds, List<String> observerUserIds, RongCallCommon.CallMediaType mediaType, String extra)
发起跨应用通话
发起通话
- Parameters:
conversationType
- 会话类型, 目前仅支持单聊targetId
- 目标会话 id ,单人通话为对方 UserIduserIds
- 邀请参与通话的用户 ID 列表,不能为 null,必须包含 observerUserIds 中除发起者 ID 的所有用户 IDobserverUserIds
- 观察者列表,无观察者可传 null,当音视频发起方是观察者时,observerUserIds 需要包含发起方用户 IDmediaType
- 发起的通话媒体类型extra
- 附加信息,透传至对端,对端通过 RongCallSession.- Returns:
呼叫id
-
startCall
String startCall(int cameraId, boolean mirror, ConversationType conversationType, String targetId, List<String> userIds, List<String> observerUserIds, RongCallCommon.CallMediaType mediaType, String extra, StartCameraCallback callback)
打开指定摄像头方式发起通话
打开指定摄像头方式发起通话
- Parameters:
cameraId
- 指定打开的摄像头 id,如果希望 SDK 打开的默认前置摄像头 但 需要使用镜像则传 -1 即可mirror
- 是否镜像视频流某些特殊设备将后置摄像头安装在设备的前面时,当打开后置摄像头时为了正常显示,请使用镜像处理;该参数设置仅对本地有效(发送出去的数据依然是未处理数据),如果本地视频流做了镜像处理,为了对端观看体验可以在onRemoteUserJoined回调中添加如下设置:public void onRemoteUserJoined(String userId, RongCallCommon.CallMediaType mediaType, int userType, SurfaceView remoteVideo) { if (null != remoteVideo) { ((RongRTCVideoView) remoteVideo).setMirror( boolean);//观看对方视频流是否镜像处理 } }
conversationType
- 会话类型, 如果实现的是不基于群组的voip,那此参数必须传 NONEtargetId
- 目标会话 id ,单人通话为对方 UserId ,群组通话为 GroupId ,如果实现的是不基于群组的通话,那此参数无意义,传 null 即可userIds
- 邀请参与通话的用户 ID 列表,不能为空,必须包含 observerUserIds 中除发起者 ID 的所有用户 IDobserverUserIds
- 观察者列表,无观察者可传 null ,当音视频发起方是观察者时,observerUserIds 需要包含发起方用户 IDmediaType
- 发起的通话媒体类型extra
- 附加信息,透传至对端,对端通过 RongCallSession.callback
- 指定摄像头打开回调- Returns:
呼叫id
-
acceptCall
void acceptCall(String callId)
接听通话
接听通话
- Parameters:
callId
- 呼叫id,可以从来电监听 RongCallSession.
-
acceptCall
void acceptCall(String callId, int cameraId, boolean mirror, StartCameraCallback callback)
打开指定摄像头方式接听通话
打开指定摄像头方式接听通话
- Parameters:
callId
- 呼叫id,可以从来电监听 RongCallSession.cameraId
- 指定的摄像头 id某些特殊设备将后置摄像头安装在设备的前面时,当打开后置摄像头时为了正常显示,请使用镜像处理;该参数设置仅对本地有效(发送出去的数据依然是未处理数据),如果本地视频流做了镜像处理,为了对端观看体验可以在onRemoteUserJoined回调中添加如下设置:public void onRemoteUserJoined(String userId, RongCallCommon.CallMediaType mediaType, int userType, SurfaceView remoteVideo) { if (null != remoteVideo) { ((RongRTCVideoView) remoteVideo).setMirror( boolean);//观看对方视频流是否镜像处理 } }
mirror
- 是否镜像视频流callback
- 指定摄像头打开回调
-
hangUpCall
void hangUpCall(String callId)
挂断通话
挂断通话
- Parameters:
callId
- 呼叫id,可以从来电监听 RongCallSession.
-
hangUpCall
void hangUpCall()
挂断通话
挂断通话
-
getCallSession
RongCallSession getCallSession()
获取当前通话实体,通话实体中维护着当前通话的所有信息
获取当前通话实体,通话实体中维护着当前通话的所有信息
- Returns:
当前通话实体
-
addParticipants
void addParticipants(String callId, ArrayList<String> userIds, ArrayList<String> observerUserIds)
邀请用户加入当前通话(仅限讨论组和群组)
邀请用户加入当前通话
- Parameters:
callId
- 通话 iduserIds
- 邀请的用户 id 列表,请一定包含邀请的观察者列表中的人员;observerUserIds
- 邀请的观察者列表,没有观察者可以传 null
-
changeCallMediaType
void changeCallMediaType(RongCallCommon.CallMediaType mediaType)
视频通话转音频通话
视频通话转音频通话
- Parameters:
mediaType
- 要切换的媒体类型
-
switchCamera
void switchCamera()
前后摄像头切换,适用于通过SDK打开默认摄像头的场景
在通话建立(IRongCallListener#onCallConnected)之后切换前后置摄像头,该方法适用于通过SDK打开默认摄像头的场景,配合 RongCallClient#startCall(Conversation.ConversationType, String, List, List, RongCallCommon.CallMediaType, String) 使用,startCall 方法默认打开前置摄像头
-
switchCamera
void switchCamera(int cameraId, boolean mirror, CameraSwitchCallBack callBack)
切换指定 id 摄像头
在通话建立(IRongCallListener#onCallConnected)之后切换指定 ID 的摄像头,该方法适用于通过 SDK 打开指定摄像头的场景,配合 RongCallClient#startCall(int, boolean, Conversation.ConversationType, String, List, List, RongCallCommon.CallMediaType, String, StartCameraCallback) 使用。startCall 方法默认打开前置摄像头
- Parameters:
cameraId
- 摄像头 idmirror
- 是否镜像视频流某些特殊设备将后置摄像头安装在设备的前面时,当打开后置摄像头时为了正常显示,请使用镜像处理;该参数设置仅对本地有效(发送出去的数据依然是未处理数据),如果本地视频流做了镜像处理,为了对端观看体验可以在 IRongCallListener#onRemoteUserJoined(String, RongCallCommon.callBack
- 摄像头切换回调
-
setEnableLocalVideo
void setEnableLocalVideo(boolean enabled)
设置是否打开本地摄像头
设置是否打开本地摄像头
- Parameters:
enabled
- true:打开摄像头 false:关闭摄像头。
-
setEnableLocalAudio
void setEnableLocalAudio(boolean enabled)
设置是否打开本地音频
设置是否打开本地音频
- Parameters:
enabled
- true:打开本地音频 false:关闭本地音频
-
setEnableSpeakerphone
void setEnableSpeakerphone(boolean enabled)
设置是否打开免提
设置是否打开扬声器,在 IRongCallListener#onCallConnected(RongCallSession, SurfaceView) 之后调用有效
- Parameters:
enabled
- true:打开免提 false:关闭免提
-
onPermissionGranted
void onPermissionGranted()
授予权限
android 6.0以上的版本适用 用户授权通过之后回调此接口通知CallLib(IRongReceivedCallListener#onCheckPermission(RongCallSession))用户授权成功 audio call需要获取Manifest.permission.RECORD_AUDIO和权限 video call需要获取audio call中权限和Manifest.permission.CAMERA权限
-
onPermissionDenied
void onPermissionDenied()
拒绝授予权限
android 6.0以上的版本适用,用户拒绝授权之后回调此接口通知CallLib(IRongReceivedCallListener#onCheckPermission(RongCallSession)), audio call需要获取Manifest.permission.RECORD_AUDIO权限 video call需要获取Manifest.permission.RECORD_AUDIO和Manifest.permission.CAMERA两项权限
-
registerVideoFrameListener
void registerVideoFrameListener(IVideoFrameListener listener)
注册本地视频流上报监听
用于处理视频通话中的视频数据。请在connect成功之后设置, 回调返回数据类型通过在接听或拨打前的参数设置控制,如下:
RCRTCConfig.Builder config=RCRTCConfig.Builder.create().enableEncoderTexture(true); RongCallClient.getInstance().setRTCConfig(config);
- Parameters:
listener
- 视频数据回调
-
registerAudioFrameListener
void registerAudioFrameListener(IRCRTCAudioDataListener listener)
本地音频流上报监听
用于处理通话中的音频数据。请在connect成功之后设置
- Parameters:
listener
- 音频数据回调
-
unregisterVideoFrameObserver
void unregisterVideoFrameObserver()
取消注册 本地音频流上报监听
在不使用本地视频流时取消注册
-
isVoIPEnabled
boolean isVoIPEnabled(Context context)
检查音视频引擎是否可用
检查音视频引擎是否可用
- Parameters:
context
- 全局上下文- Returns:
音视频服务是否可用
-
publishMediaResource
void publishMediaResource(RongCallCommon.CallMediaType callMediaType)
观察者发布资源
仅为观察者身份时发布资源
- Parameters:
callMediaType
- 需要发布的资源类型,该参数为 RongCallCommon.CallMediaType.
-
isLocalAudioEnabled
boolean isLocalAudioEnabled()
本地音频是否开启
本地音频是否开启
- Returns:
本地音频是否开启
-
isSpeakerphoneEnabled
boolean isSpeakerphoneEnabled()
扬声器是否开启
扬声器是否开启
- Returns:
扬声器是否开启
-
isLocalVideoEnabled
boolean isLocalVideoEnabled()
本地视频是否开启
本地视频是否开启
- Returns:
本地视频是否开启
-
resetAVStatus
void resetAVStatus()
-
startCapture
void startCapture()
仅打开本地摄像头
在通话建立(IRongCallListener#onCallConnected)之后打开摄像头,对端不会收到 IRongCallListener#onRemoteCameraDisabled 通知
-
startIncomingPreview
void startIncomingPreview(StartIncomingPreviewCallback callback)
-
publishCustomVideoStream
void publishCustomVideoStream(String tag, PublishCallBack callBack)
发布自定义音视频流
发布自定义音视频流 ,该方法必须在通话过程中设置有效,如:IRongCallListener#onCallConnected(RongCallSession, SurfaceView) 回调中
- Parameters:
tag
- 自定义视频流唯一标示,不允许带下划线;callBack
- 发布回调,请在成功回调中调用 RongRTCAVOutputStream#writeByteBuffer 或 RongRTCAVOutputStream#writeTextureFrame 写入流//发送YUV数据,当前仅支持 NV21 格式。 data NV21 格式的视频数据 width 视频的实际宽度 height 视频的实际高度 rotation 旋转角度。一般为 90° 或 270° ,取决于设备。 RongRTCAVOutputStream#writeByteBuffer(byte[] data, int width, int height, int rotation) //发送texture数据 android.opengl.GLES11Ext#GL_TEXTURE_EXTERNAL_OES 类型 width 视频的实际宽度 height 视频的实际高度 oesTextureId 纹理 id android.opengl.GLES11Ext#GL_TEXTURE_EXTERNAL_OES 类型 transformMatrix 矩阵 rotation 旋转角度 timestamp 当前时间戳:surfaceTexture.getTimestamp() RongRTCAVOutputStream#writeTextureFrame(int width, int height, int oesTextureId, float[] transformMatrix, int rotation, long timestamp)
-
unpublishCustomVideoStream
void unpublishCustomVideoStream(RCRTCOutputStream outputStream, IRCRTCResultCallback callBack)
取消发布自定义音视频流
取消发布自定义音视频流
- Parameters:
outputStream
- 已发布的音视频流对象callBack
- 取消发布
-
setRTCConfig
void setRTCConfig(Builder builder)
设置音视频配置
必须在 RongCallClient#startCall 和 RongCallClient#acceptCall(String) 之前调用
-
setVideoConfig
void setVideoConfig(Builder builder)
视频分辨率、码率相关配置
-
setAudioConfig
void setAudioConfig(Builder builder)
音频相关配置
-
setCameraFrameOrientation
void setCameraFrameOrientation(int cameraOrientation, int frameOrientation)
设置相机采集角度和编码使用到的角度
- Parameters:
cameraOrientation
- 设置相机采集角度:默认为 0 则使用 SDK 中获取的摄像头 id 计算出的采集角度,当开启是手机前置摄像头时,设置该参数会顺时针旋转图像。值必须设置为:0、90、180、270frameOrientation
- 编码使用到的角度:默认:-1,设置为 -1 时将跟随系统角度,当开启是手机前置摄像头时,设置该参数会逆时针旋转图像。值必须设置为:0、90、180、270
-
canCallContinued
boolean canCallContinued(String callId)
-
getVersion
static String getVersion()
-
queryJoinedRoom
void )>queryJoinedRoom(IRCRTCResultDataCallback<RCRTCJoinedRoomInfo[]> callBack)
查询本用户是否在其他设备进行音视频通话或调用joinRoom 成功
-
setJoinType
void setJoinType(RCRTCJoinType joinType)
-
setMultiPlatformVideoView
int setMultiPlatformVideoView(String userId, String tag, RCRTCBaseView videoView)
设置跨平台使用的渲染视图。调用此接口前需要先调用
- Parameters:
userId
- 要设置视图的用户ID,可以是本地或是远端用户的ID。tag
- stream流的ID,如果是默认情况,传空。videoView
- 要设置的渲染视图- Returns:
0代表成功,-1代表失败。当返回-1时,可能是没有开启跨平台模式的情况下调用了该接口。
-
enableMultiPlatformMode
static void enableMultiPlatformMode()
开启跨平台模式。目前主要是创建渲染视图的流程会有变化
-
setPreconnectEnabled
static void setPreconnectEnabled(boolean enabled)
是否打开http 预热开关,打开 true 不打开 false 默认 true
-
setCheckPermission
static void setCheckPermission(boolean check)
是否需要检查权限
- Parameters:
check
- true: 检查 false: 不检查
-
-
-
-