Commit 353d4088 by 刘鹏

Merge branch 'feat/qj/netease5' into 'd/4.4.10'

网易呼叫组件2.0升级sdk适配

See merge request app_android_lib/YDL-Component!348
parents c2689a91 9729ce70
......@@ -60,7 +60,7 @@ dependencies {
api rootProject.ext.dependencies["ydl-user-router"]
implementation rootProject.ext.dependencies["BaseRecyclerViewAdapterHelper"]
implementation('com.netease.yunxin.kit:call-ui:1.5.9-SNAPSHOT') {
implementation('com.netease.yunxin.kit:call-ui:1.6.3') {
exclude group: "com.netease.nimlib", module: "avsignalling"
exclude group: "com.netease.nimlib", module: "basesdk"
}
......
......@@ -2,18 +2,20 @@ package com.yidianling.im.helper;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Looper;
import android.text.TextUtils;
import com.netease.lava.nertc.sdk.NERtcConstants;
import com.netease.lava.nertc.sdk.NERtcEx;
import com.netease.lava.nertc.sdk.NERtcOption;
import com.netease.lava.nertc.sdk.video.NERtcEncodeConfig;
import com.netease.lava.nertc.sdk.video.NERtcVideoConfig;
import com.netease.nimlib.sdk.RequestCallback;
import com.netease.yunxin.nertc.nertcvideocall.bean.InvitedInfo;
import com.netease.yunxin.nertc.nertcvideocall.model.NERtcCallExtension;
import com.netease.yunxin.nertc.ui.CallKitNotificationConfig;
import com.netease.yunxin.nertc.ui.CallKitUI;
import com.netease.yunxin.nertc.ui.CallKitUIOptions;
import com.netease.yunxin.nertc.ui.extension.SelfConfigExtension;
import com.netease.yunxin.nertc.ui.service.DefaultIncomingCallEx;
import com.ydl.ydlcommon.modular.ModularServiceManagerKt;
import com.ydl.ydlcommon.utils.log.XLog;
......@@ -42,7 +44,9 @@ public class NimUICallInit {
UserResponseBean.UserInfo userInfo = ModularServiceManagerKt.findRouteService(IUserService.class).getUserInfo();
if (userInfo == null) return;
String userId = userInfo.getUid();
android.util.Log.e("qwert", userId);
//防止网络波动的情况下多次触发LOGINED状态,导致呼叫组件重新初始化
if (TextUtils.equals(userId, CallKitUI.INSTANCE.getCurrentUserAccId())) return;
android.util.Log.e("qwert", userId + (Looper.myLooper() == Looper.getMainLooper()));
String appKey = NimApplication.getInstance().getAppKey();
CallKitUIOptions options = new CallKitUIOptions.Builder()
// 必要:音视频通话 sdk appKey,用于通话中使用
......@@ -53,15 +57,20 @@ public class NimUICallInit {
.currentUserRtcUId(Long.parseLong(userId))
// 通话接听成功的超时时间单位 毫秒,默认30s
.timeOutMillisecond(30 * 1000L)
.rtcCallExtension(new SelfConfigExtension(){
.rtcCallExtension(new NERtcCallExtension(){
@Override
public void configVideoConfig() {
protected int joinChannel(String token, String channelName, long rtcUid) {
NERtcVideoConfig videoConfig = new NERtcVideoConfig();
videoConfig.frameRate = NERtcEncodeConfig.NERtcVideoFrameRate.FRAME_RATE_FPS_15;
videoConfig.bitrate = 600;
videoConfig.width = 640;
videoConfig.height = 480;
videoConfig.degradationPrefer = NERtcVideoConfig.NERtcDegradationPreference.DEGRADATION_MAINTAIN_FRAMERATE;
NERtcEx.getInstance().setLocalVideoConfig(videoConfig);
// 音频设置 standard + speech
NERtcEx.getInstance().setAudioProfile(NERtcConstants.AudioProfile.STANDARD, NERtcConstants.AudioScenario.SPEECH);
// 设置 channel profile
NERtcEx.getInstance().setChannelProfile(NERtcConstants.RTCChannelProfile.COMMUNICATION);
return NERtcEx.getInstance().joinChannel(token, channelName, rtcUid);
}
})
// 此处为 收到来电时展示的 notification 相关配置,如图标,提示语等。
......@@ -80,9 +89,12 @@ public class NimUICallInit {
// .p2pAudioActivity(TestActivity.class)
// .p2pVideoActivity(TestActivity.class)
// 请求 rtc token 服务,若非安全模式则不需设置
.rtcTokenService((uid, callback) -> requestRtcToken(uid, callback)) // 自己实现的 token 请求方法
.rtcTokenService((uid, channel, callback) -> requestRtcToken(uid, channel, callback)) // 自己实现的 token 请求方法
// 设置初始化 rtc sdk 相关配置,按照所需进行配置
.rtcSdkOption(new NERtcOption())
.enableMsgFilter(false)
.enableCustomParser(false)
.audio2VideoConfirm(true)
// 呼叫组件初始化 rtc 范围,true-全局初始化,false-每次通话进行初始化以及销毁
// 全局初始化有助于更快进入首帧页面,当结合其他组件使用时存在rtc初始化冲突可设置false
.rtcInitScope(true)
......@@ -92,10 +104,10 @@ public class NimUICallInit {
}
@SuppressLint("CheckResult")
private static void requestRtcToken(long uid, RequestCallback<String> callback) {
private static void requestRtcToken(long uid, String channel, RequestCallback<String> callback) {
Map<String, String> body = new HashMap<>();
if (curChannelName != null) {
body.put("channelName", curChannelName);
if (channel != null) {
body.put("channelName", channel);
}
body.put("uid", String.valueOf(uid));
ImHttpImpl.Companion.getInstance().getImApi().nim2Token(body)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment