public class RongCallClient extends Object
构造器和说明 |
---|
RongCallClient(Context context,
IHandler stub) |
限定符和类型 | 方法和说明 |
---|---|
void |
acceptCall(String callId)
接听通话
接听通话 |
void |
acceptCall(String callId,
int cameraId,
boolean mirror,
StartCameraCallback callback)
打开指定摄像头方式接听通话
打开指定摄像头方式接听通话 |
void |
addParticipants(String callId,
ArrayList<String> userIds,
ArrayList<String> observerUserIds)
邀请用户加入当前通话(仅限讨论组和群组)
邀请用户加入当前通话 |
boolean |
canCallContinued(String callId) |
void |
changeCallMediaType(RongCallCommon.CallMediaType mediaType)
视频通话转音频通话
视频通话转音频通话 |
void |
enableMultiPlatformMode()
开启跨平台模式。
|
RongCallSession |
getCallSession()
获取当前通话实体,通话实体中维护着当前通话的所有信息
获取当前通话实体,通话实体中维护着当前通话的所有信息 |
Context |
getContext() |
static RongCallClient |
getInstance() |
static String |
getVersion() |
void |
hangUpCall()
挂断通话
挂断通话 |
void |
hangUpCall(String callId)
挂断通话
挂断通话 |
boolean |
isLocalAudioEnabled()
本地音频是否开启
本地音频是否开启
|
boolean |
isLocalVideoEnabled()
本地视频是否开启
本地视频是否开启
|
boolean |
isSpeakerphoneEnabled()
扬声器是否开启
扬声器是否开启
|
boolean |
isVoIPEnabled(Context context)
检查音视频引擎是否可用
检查音视频引擎是否可用 |
void |
onPermissionDenied()
拒绝授予权限
android 6.0以上的版本适用,用户拒绝授权之后回调此接口通知CallLib(IRongReceivedCallListener#onCheckPermission(RongCallSession)), audio call需要获取Manifest.permission.RECORD_AUDIO权限 video call需要获取Manifest.permission.RECORD_AUDIO和Manifest.permission.CAMERA两项权限 |
void |
onPermissionGranted()
授予权限
android 6.0以上的版本适用 用户授权通过之后回调此接口通知CallLib(IRongReceivedCallListener#onCheckPermission(RongCallSession))用户授权成功 audio call需要获取Manifest.permission.RECORD_AUDIO和 video call需要获取audio call中权限和Manifest.permission.CAMERA权限 |
void |
publishCustomVideoStream(String tag,
PublishCallBack callBack)
发布自定义音视频流
发布自定义音视频流 ,该方法必须在通话过程中设置有效,如:IRongCallListener#onCallConnected(RongCallSession, SurfaceView) 回调中 |
void |
publishMediaResource(RongCallCommon.CallMediaType callMediaType)
观察者发布资源
仅为观察者身份时发布资源
|
void |
queryJoinedRoom(<any> callBack)
查询本用户是否在其他设备进行音视频通话或调用
RCRTCEngine#joinRoom(String, IRCRTCResultDataCallback) 成功 |
void |
registerAudioFrameListener(IRCRTCAudioDataListener listener)
本地音频流上报监听
用于处理通话中的音频数据。 |
void |
registerVideoFrameListener(IVideoFrameListener listener)
注册本地视频流上报监听
用于处理视频通话中的视频数据。 |
void |
setAudioConfig(RCRTCAudioStreamConfig.Builder builder)
音频相关配置
|
static void |
setCallSignalSender(IRongCallSignalSender signalSender) |
void |
setCameraFrameOrientation(int cameraOrientation,
int frameOrientation)
设置相机采集角度和编码使用到的角度
|
void |
setEnableLocalAudio(boolean enabled)
设置是否打开本地音频
设置是否打开本地音频 |
void |
setEnableLocalVideo(boolean enabled)
设置是否打开本地摄像头
设置是否打开本地摄像头 |
void |
setEnableSpeakerphone(boolean enabled)
设置是否打开免提
设置是否打开扬声器,在 IRongCallListener#onCallConnected(RongCallSession, SurfaceView) 之后调用有效 |
void |
setJoinType(RCRTCJoinType joinType) |
static void |
setMissedCallListener(RongCallMissedListener listener) |
int |
setMultiPlatformVideoView(String userId,
String tag,
RCRTCBaseView videoView)
设置跨平台使用的渲染视图。
|
static void |
setPushConfig(MessagePushConfig startCallPushConfig,
MessagePushConfig hangupPushConfig)
自定义通话推送标题和内容等 pushConfig
自定义音视频通话的推送配置 开发者在调用 #startCall(ConversationType, String, List, List, CallMediaType, String) 发起通话前设置 |
static void |
setReceivedCallListener(IRongReceivedCallListener listener)
设置通话来电监听
设置通话来电监听 |
void |
setRTCConfig(RCRTCConfig.Builder builder)
设置音视频配置
必须在 RongCallClient#startCall 和 RongCallClient#acceptCall(String) 之前调用 |
void |
setVideoConfig(RCRTCVideoStreamConfig.Builder builder)
视频分辨率、码率相关配置
|
void |
setVoIPCallListener(IRongCallListener callListener)
设置通话状态回调
设置通话状态回调 |
String |
startCall(Conversation.ConversationType conversationType,
String targetId,
List<String> userIds,
List<String> observerUserIds,
RongCallCommon.CallMediaType mediaType,
String extra)
发起通话
发起通话 |
String |
startCall(int cameraId,
boolean mirror,
Conversation.ConversationType conversationType,
String targetId,
List<String> userIds,
List<String> observerUserIds,
RongCallCommon.CallMediaType mediaType,
String extra,
StartCameraCallback callback)
打开指定摄像头方式发起通话
打开指定摄像头方式发起通话 |
void |
startCapture()
仅打开本地摄像头
在通话建立(IRongCallListener#onCallConnected)之后打开摄像头,对端不会收到 IRongCallListener#onRemoteCameraDisabled 通知 |
void |
switchCamera()
前后摄像头切换,适用于通过SDK打开默认摄像头的场景
在通话建立(IRongCallListener#onCallConnected)之后切换前后置摄像头,该方法适用于通过SDK打开默认摄像头的场景,配合 RongCallClient#startCall(Conversation.ConversationType, String, List, List, RongCallCommon.CallMediaType, String) 使用,startCall 方法默认打开前置摄像头 |
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) 使用。
|
void |
unInit()
隐藏方法,当 ipc 进程崩溃时,需要注销该实例并释放内存
|
void |
unpublishCustomVideoStream(RCRTCOutputStream outputStream,
IRCRTCResultCallback callBack)
取消发布自定义音视频流
取消发布自定义音视频流 |
void |
unregisterVideoFrameObserver()
取消注册 本地音频流上报监听
在不使用本地视频流时取消注册 |
public RongCallClient(Context context, IHandler stub)
public static RongCallClient getInstance()
public Context getContext()
public void unInit()
public static void setReceivedCallListener(IRongReceivedCallListener listener)
设置通话来电监听
listener
- 来电监听IRongCallListener
public static void setCallSignalSender(IRongCallSignalSender signalSender)
public void setVoIPCallListener(IRongCallListener callListener)
设置通话状态回调
callListener
- 通话状态回调IRongCallListener
public static void setMissedCallListener(RongCallMissedListener listener)
public static void setPushConfig(MessagePushConfig startCallPushConfig, MessagePushConfig hangupPushConfig)
自定义音视频通话的推送配置
开发者在调用#startCall(ConversationType, String, List, List, CallMediaType, String)
发起通话前设置
startCallPushConfig
- 通话发起时推送配置hangupPushConfig
- 通话挂断时的推送配置public String startCall(Conversation.ConversationType conversationType, String targetId, List<String> userIds, List<String> observerUserIds, RongCallCommon.CallMediaType mediaType, String extra)
发起通话
conversationType
- 会话类型, 如果实现的是不基于群组的 VoIP,那此参数必须传 Conversation.ConversationType#NONE
targetId
- 目标会话 id ,单人通话为对方 UserId ,群组通话为 GroupId ,如果实现的是不基于群组的通话,那此参数无意义,传 null 即可userIds
- 邀请参与通话的用户 ID 列表,不能为 null,必须包含 observerUserIds 中除发起者 ID 的所有用户 IDobserverUserIds
- 观察者列表,无观察者可传 null,当音视频发起方是观察者时,observerUserIds 需要包含发起方用户 IDmediaType
- 发起的通话媒体类型extra
- 附加信息,透传至对端,对端通过 RongCallSession.getExtra() 获取public String startCall(int cameraId, boolean mirror, Conversation.ConversationType conversationType, String targetId, List<String> userIds, List<String> observerUserIds, RongCallCommon.CallMediaType mediaType, String extra, StartCameraCallback callback)
打开指定摄像头方式发起通话
cameraId
- 指定打开的摄像头 id,如果希望 SDK 打开的默认前置摄像头 但 需要使用镜像则传 -1 即可mirror
- 是否镜像视频流IRongCallListener.onRemoteUserJoined(String, RongCallCommon.CallMediaType, int,
SurfaceView)
回调中添加如下设置:public void onRemoteUserJoined(String userId, RongCallCommon.CallMediaType mediaType, int userType, SurfaceView remoteVideo) { if (null != remoteVideo) { ((RongRTCVideoView) remoteVideo).setMirror( boolean);//观看对方视频流是否镜像处理 } }
conversationType
- 会话类型, 如果实现的是不基于群组的voip,那此参数必须传 Conversation.ConversationType#NONE
targetId
- 目标会话 id ,单人通话为对方 UserId ,群组通话为 GroupId ,如果实现的是不基于群组的通话,那此参数无意义,传 null 即可userIds
- 邀请参与通话的用户 ID 列表,不能为空,必须包含 observerUserIds 中除发起者 ID 的所有用户 ID observerUserIds
- 观察者列表,无观察者可传 null ,当音视频发起方是观察者时,observerUserIds 需要包含发起方用户 IDmediaType
- 发起的通话媒体类型extra
- 附加信息,透传至对端,对端通过 RongCallSession.getExtra() 获取callback
- 指定摄像头打开回调public void acceptCall(String callId)
接听通话
callId
- 呼叫id,可以从来电监听 RongCallSession.getCallId() 中获取RongCallSession.getCallId()
public void acceptCall(String callId, int cameraId, boolean mirror, StartCameraCallback callback)
打开指定摄像头方式接听通话
callId
- 呼叫id,可以从来电监听 RongCallSession.getCallId() 中获取cameraId
- 指定的摄像头 idIRongCallListener.onRemoteUserJoined(String, RongCallCommon.CallMediaType, int,
SurfaceView)
回调中添加如下设置:public void onRemoteUserJoined(String userId, RongCallCommon.CallMediaType mediaType, int userType, SurfaceView remoteVideo) { if (null != remoteVideo) { ((RongRTCVideoView) remoteVideo).setMirror( boolean);//观看对方视频流是否镜像处理 } }
mirror
- 是否镜像视频流callback
- 指定摄像头打开回调public void hangUpCall(String callId)
挂断通话
callId
- 呼叫id,可以从来电监听 RongCallSession.getCallId()中获取RongCallSession.getCallId()
public void hangUpCall()
挂断通话
public RongCallSession getCallSession()
获取当前通话实体,通话实体中维护着当前通话的所有信息
RongCallSession
public void addParticipants(String callId, ArrayList<String> userIds, ArrayList<String> observerUserIds)
邀请用户加入当前通话
callId
- 通话 iduserIds
- 邀请的用户 id 列表,请一定包含邀请的观察者列表中的人员;observerUserIds
- 邀请的观察者列表,没有观察者可以传 nullpublic void changeCallMediaType(RongCallCommon.CallMediaType mediaType)
视频通话转音频通话
mediaType
- 要切换的媒体类型public void switchCamera()
在通话建立(IRongCallListener#onCallConnected)之后切换前后置摄像头,该方法适用于通过SDK打开默认摄像头的场景,配合 RongCallClient#startCall(Conversation.ConversationType, String, List, List, RongCallCommon.CallMediaType, String) 使用,startCall 方法默认打开前置摄像头
public void switchCamera(int cameraId, boolean mirror, CameraSwitchCallBack callBack)
在通话建立(IRongCallListener#onCallConnected)之后切换指定 ID 的摄像头,该方法适用于通过 SDK 打开指定摄像头的场景,配合 RongCallClient#startCall(int, boolean, Conversation.ConversationType, String, List, List, RongCallCommon.CallMediaType, String, StartCameraCallback) 使用。startCall 方法默认打开前置摄像头
cameraId
- 摄像头 idmirror
- 是否镜像视频流public void onRemoteUserJoined(String userId, RongCallCommon.CallMediaType mediaType, int userType, SurfaceView remoteVideo) { if (null != remoteVideo) { ((RongRTCVideoView) remoteVideo).setMirror( boolean);//观看对方视频流是否镜像处理 } }
callBack
- 摄像头切换回调IRongCallListener.onRemoteUserJoined(String, RongCallCommon.CallMediaType, int,
SurfaceView)
,
IRongCallListener.onCallConnected(io.rong.calllib.RongCallSession, android.view.SurfaceView)
,
startCall(int, boolean, Conversation.ConversationType, String, List,
List, RongCallCommon.CallMediaType, String, StartCameraCallback)
public void setEnableLocalVideo(boolean enabled)
设置是否打开本地摄像头
enabled
- true:打开摄像头 false:关闭摄像头。public void setEnableLocalAudio(boolean enabled)
设置是否打开本地音频
enabled
- true:打开本地音频 false:关闭本地音频public void setEnableSpeakerphone(boolean enabled)
设置是否打开扬声器,在 IRongCallListener#onCallConnected(RongCallSession, SurfaceView) 之后调用有效
enabled
- true:打开免提 false:关闭免提IRongCallListener.onCallConnected(RongCallSession, SurfaceView)
public void onPermissionGranted()
android 6.0以上的版本适用
用户授权通过之后回调此接口通知CallLib(IRongReceivedCallListener#onCheckPermission(RongCallSession))用户授权成功
audio call需要获取Manifest.permission.RECORD_AUDIO和
video call需要获取audio call中权限和Manifest.permission.CAMERA权限
public void onPermissionDenied()
android
6.0以上的版本适用,用户拒绝授权之后回调此接口通知CallLib(IRongReceivedCallListener#onCheckPermission(RongCallSession)),
audio call需要获取Manifest.permission.RECORD_AUDIO权限
video call需要获取Manifest.permission.RECORD_AUDIO和Manifest.permission.CAMERA两项权限
public void registerVideoFrameListener(IVideoFrameListener listener)
用于处理视频通话中的视频数据。请在connect成功之后设置, 回调返回数据类型通过在接听或拨打前的参数设置控制,如下:
RCRTCConfig.Builder config=RCRTCConfig.Builder.create().enableEncoderTexture(true); RongCallClient.getInstance().setRTCConfig(config);
listener
- 视频数据回调IVideoFrameListener
,
RCRTCConfig.Builder#enableEncoderTexture(boolean)
public void registerAudioFrameListener(IRCRTCAudioDataListener listener)
用于处理通话中的音频数据。请在connect成功之后设置
listener
- 音频数据回调IRCRTCAudioDataListener
public void unregisterVideoFrameObserver()
在不使用本地视频流时取消注册
public boolean isVoIPEnabled(Context context)
检查音视频引擎是否可用
context
- 全局上下文 public void publishMediaResource(RongCallCommon.CallMediaType callMediaType)
仅为观察者身份时发布资源
callMediaType
- 需要发布的资源类型,该参数为 RongCallCommon.CallMediaType.Video 时,发布音频+视频RongCallCommon.CallMediaType.VIDEO
public boolean isLocalAudioEnabled()
本地音频是否开启
public boolean isSpeakerphoneEnabled()
扬声器是否开启
public boolean isLocalVideoEnabled()
本地视频是否开启
public void startCapture()
在通话建立(IRongCallListener#onCallConnected)之后打开摄像头,对端不会收到 IRongCallListener#onRemoteCameraDisabled 通知
public void publishCustomVideoStream(String tag, PublishCallBack callBack)
发布自定义音视频流 ,该方法必须在通话过程中设置有效,如:IRongCallListener#onCallConnected(RongCallSession, SurfaceView) 回调中
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)
IRongCallListener.onCallConnected(RongCallSession, SurfaceView)
,
cn.rongcloud.rtc.center.stream.RCFileVideoOutStreamImpl#writeTexture(int, int, int, float[], int, long, Handler)
,
cn.rongcloud.rtc.center.stream.RCFileVideoOutStreamImpl#writeYuvData(byte[], int, int, int)
public void unpublishCustomVideoStream(RCRTCOutputStream outputStream, IRCRTCResultCallback callBack)
取消发布自定义音视频流
outputStream
- 已发布的音视频流对象callBack
- 取消发布public void setRTCConfig(RCRTCConfig.Builder builder)
必须在 RongCallClient#startCall 和 RongCallClient#acceptCall(String) 之前调用
public void setVideoConfig(RCRTCVideoStreamConfig.Builder builder)
builder
- public void setAudioConfig(RCRTCAudioStreamConfig.Builder builder)
builder
- public void setCameraFrameOrientation(int cameraOrientation, int frameOrientation)
cameraOrientation
- 设置相机采集角度:默认为 0 则使用 SDK 中获取的摄像头 id 计算出的采集角度,当开启是手机前置摄像头时,设置该参数会顺时针旋转图像。值必须设置为:0、90、180、270frameOrientation
- 编码使用到的角度:默认:-1,设置为 -1 时将跟随系统角度,当开启是手机前置摄像头时,设置该参数会逆时针旋转图像。值必须设置为:0、90、180、270public boolean canCallContinued(String callId)
public static String getVersion()
public void queryJoinedRoom(<any> callBack)
RCRTCEngine#joinRoom(String, IRCRTCResultDataCallback)
成功callBack
- public void setJoinType(RCRTCJoinType joinType)
public int setMultiPlatformVideoView(String userId, String tag, RCRTCBaseView videoView)
userId
- 要设置视图的用户ID,可以是本地或是远端用户的ID。tag
- stream流的ID,如果是默认情况,传空。videoView
- 要设置的渲染视图public void enableMultiPlatformMode()