diff --git a/NLiteAVDemo-Android-Java/app/src/main/AndroidManifest.xml b/NLiteAVDemo-Android-Java/app/src/main/AndroidManifest.xml
index a091268..b1c3825 100644
--- a/NLiteAVDemo-Android-Java/app/src/main/AndroidManifest.xml
+++ b/NLiteAVDemo-Android-Java/app/src/main/AndroidManifest.xml
@@ -28,6 +28,7 @@
+
diff --git a/NLiteAVDemo-Android-Java/app/src/main/java/com/netease/yunxin/app/videocall/DemoApplication.java b/NLiteAVDemo-Android-Java/app/src/main/java/com/netease/yunxin/app/videocall/DemoApplication.java
index 05a17af..78b05b8 100644
--- a/NLiteAVDemo-Android-Java/app/src/main/java/com/netease/yunxin/app/videocall/DemoApplication.java
+++ b/NLiteAVDemo-Android-Java/app/src/main/java/com/netease/yunxin/app/videocall/DemoApplication.java
@@ -1,44 +1,114 @@
+// Copyright (c) 2022 NetEase, Inc. All rights reserved.
+// Use of this source code is governed by a MIT license that can be
+// found in the LICENSE file.
+
package com.netease.yunxin.app.videocall;
import android.app.Application;
-import android.text.TextUtils;
-
+import android.content.Intent;
import com.netease.nimlib.sdk.NIMClient;
import com.netease.nimlib.sdk.SDKOptions;
-import com.netease.nimlib.sdk.auth.LoginInfo;
import com.netease.nimlib.sdk.util.NIMUtil;
-import com.netease.yunxin.app.videocall.login.model.ProfileManager;
-import com.netease.yunxin.app.videocall.login.model.UserModel;
+import com.netease.yunxin.app.videocall.nertc.ui.CallModeType;
+import com.netease.yunxin.app.videocall.nertc.ui.NERTCSelectCallUserActivity;
+import com.netease.yunxin.app.videocall.nertc.ui.SettingActivity;
import com.netease.yunxin.nertc.nertcvideocall.utils.NetworkUtils;
+import com.netease.yunxin.nertc.ui.CallKitUI;
+import com.netease.yunxin.nertc.ui.CallKitUIOptions;
+import com.netease.yunxin.nertc.ui.NECallUILanguage;
+import com.netease.yunxin.nertc.ui.base.TransHelper;
+import java.util.ArrayList;
public class DemoApplication extends Application {
- public static DemoApplication app;
+ private static final int CODE_REQUEST_INVITE_USERS = 9101;
+ public static DemoApplication app;
- @Override
- public void onCreate() {
- super.onCreate();
- if (NIMUtil.isMainProcess(this)) {
- NetworkUtils.init(this);
- app = this;
- }
- NIMClient.init(this, loginInfo(), options());
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ if (NIMUtil.isMainProcess(this)) {
+ app = this;
}
-
- // 如果返回值为 null,则全部使用默认参数。
- private SDKOptions options() {
- SDKOptions options = new SDKOptions();
- //此处仅设置appkey,其他设置请自行参看信令文档设置 :https://dev.yunxin.163.com/docs/product/信令/SDK开发集成/Android开发集成/初始化
- options.appKey = BuildConfig.APP_KEY;
- return options;
+ NIMClient.initV2(this, options());
+ if (NIMUtil.isMainProcess(this)) {
+ NetworkUtils.init(this);
+ // 预收到离线消息时需在 IM 初始化后立即注册群组
+ CallKitUI.preGroupConfig();
+ initCallKit();
}
+ }
- // 如果已经存在用户登录信息,返回LoginInfo,否则返回null即可
- private LoginInfo loginInfo() {
- UserModel userModel = ProfileManager.getInstance().getUserModel();
- if (userModel != null && !TextUtils.isEmpty(userModel.imToken) && !TextUtils.isEmpty(userModel.imAccid)) {
- return new LoginInfo(String.valueOf(userModel.imAccid), userModel.imToken);
- }
- return null;
- }
+ // 如果返回值为 null,则全部使用默认参数。
+ private SDKOptions options() {
+ SDKOptions options = new SDKOptions();
+ //此处仅设置appkey,其他设置请自行参看信令文档设置 :https://dev.yunxin.163.com/docs/product/信令/SDK开发集成/Android开发集成/初始化
+ options.appKey = BuildConfig.APP_KEY;
+ return options;
+ }
+
+ private void initCallKit() {
+ // 预收到离线消息时需在 IM 初始化后立即注册群组
+ CallKitUI.preGroupConfig();
+ CallKitUIOptions options =
+ new CallKitUIOptions.Builder()
+ // 音视频通话 sdk appKey,用于通话中使用
+ .rtcAppKey(BuildConfig.APP_KEY)
+ .currentUserRtcUId(SettingActivity.RTC_CHANNEL_UID)
+ // 通话接听成功的超时时间单位 毫秒,默认30s
+ .timeOutMillisecond(30 * 1000L)
+ // 当系统版本为 Android Q及以上时,若应用在后台系统限制不直接展示页面
+ // 而是展示 notification,通过点击 notification 跳转呼叫页面
+ // 此处为 notification 相关配置,如图标,提示语等。
+ .notificationConfigFetcher(new DemoSelfNotificationConfigFetcher<>())
+ .notificationConfigFetcherForGroup(new DemoSelfNotificationConfigFetcher<>())
+ // 收到被叫时若 app 在后台,在恢复到前台时是否自动唤起被叫页面,默认为 true
+ .resumeBGInvitation(true)
+ .enableGroup(true)
+ .enableAutoJoinWhenCalled(SettingActivity.ENABLE_AUTO_JOIN)
+ // 设置用户信息
+ .userInfoHelper(new SelfUserInfoHelper())
+ // rtc 初始化模式
+ .initRtcMode(SettingActivity.RTC_INIT_MODE)
+ // 注册自定义通话页面
+ .p2pVideoActivity(TestActivity.class)
+ .p2pAudioActivity(TestActivity.class)
+ // 主叫加入 rtc 的时机
+ .joinRtcWhenCall(SettingActivity.ENABLE_JOIN_RTC_WHEN_CALL)
+ .contactSelector(
+ (context, groupId, strings, listNEResultObserver) -> {
+ if (listNEResultObserver == null) {
+ return null;
+ }
+ TransHelper.launchTask(
+ context,
+ CODE_REQUEST_INVITE_USERS,
+ (innerContext, code) -> {
+ NERTCSelectCallUserActivity.startSelectUser(
+ innerContext,
+ CODE_REQUEST_INVITE_USERS,
+ CallModeType.RTC_GROUP_INVITE,
+ strings);
+ return null;
+ },
+ intentResultInfo -> {
+ if (intentResultInfo == null || intentResultInfo.getValue() == null) {
+ return null;
+ }
+ Intent data = intentResultInfo.getValue();
+ if (intentResultInfo.getSuccess()) {
+ ArrayList selectorList =
+ data.getStringArrayListExtra(
+ NERTCSelectCallUserActivity.KEY_CALL_USER_LIST);
+ listNEResultObserver.onResult(selectorList);
+ }
+ return null;
+ });
+ return null;
+ })
+ .language(NECallUILanguage.AUTO)
+ .build();
+ // 初始化
+ CallKitUI.init(getApplicationContext(), options);
+ }
}
diff --git a/NLiteAVDemo-Android-Java/app/src/main/java/com/netease/yunxin/app/videocall/MainActivity.java b/NLiteAVDemo-Android-Java/app/src/main/java/com/netease/yunxin/app/videocall/MainActivity.java
index 3a198f6..e1db5c3 100644
--- a/NLiteAVDemo-Android-Java/app/src/main/java/com/netease/yunxin/app/videocall/MainActivity.java
+++ b/NLiteAVDemo-Android-Java/app/src/main/java/com/netease/yunxin/app/videocall/MainActivity.java
@@ -1,3 +1,7 @@
+// Copyright (c) 2022 NetEase, Inc. All rights reserved.
+// Use of this source code is governed by a MIT license that can be
+// found in the LICENSE file.
+
package com.netease.yunxin.app.videocall;
import android.Manifest;
@@ -5,31 +9,40 @@
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
+import android.text.TextUtils;
+import android.util.Log;
+import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
-
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
-
+import com.netease.lava.nertc.foreground.ForegroundKit;
import com.netease.lava.nertc.sdk.NERtc;
-import com.netease.lava.nertc.sdk.NERtcOption;
+import com.netease.lava.nertc.sdk.NERtcEx;
import com.netease.nimlib.sdk.NIMClient;
-import com.netease.nimlib.sdk.Observer;
-import com.netease.nimlib.sdk.StatusCode;
-import com.netease.nimlib.sdk.auth.AuthServiceObserver;
-import com.netease.yunxin.app.videocall.login.model.ProfileManager;
+import com.netease.nimlib.sdk.v2.V2NIMError;
+import com.netease.nimlib.sdk.v2.auth.V2NIMLoginListener;
+import com.netease.nimlib.sdk.v2.auth.V2NIMLoginService;
+import com.netease.nimlib.sdk.v2.auth.enums.V2NIMLoginClientChange;
+import com.netease.nimlib.sdk.v2.auth.enums.V2NIMLoginStatus;
+import com.netease.nimlib.sdk.v2.auth.model.V2NIMKickedOfflineDetail;
+import com.netease.nimlib.sdk.v2.auth.model.V2NIMLoginClient;
+import com.netease.yunxin.app.videocall.login.model.AuthManager;
import com.netease.yunxin.app.videocall.login.ui.LoginActivity;
import com.netease.yunxin.app.videocall.nertc.biz.CallOrderManager;
+import com.netease.yunxin.app.videocall.nertc.ui.CallModeType;
import com.netease.yunxin.app.videocall.nertc.ui.NERTCSelectCallUserActivity;
+import com.netease.yunxin.app.videocall.nertc.ui.SettingActivity;
import com.netease.yunxin.nertc.ui.CallKitUI;
-import com.netease.yunxin.nertc.ui.CallKitUIOptions;
+import java.util.Collections;
+import java.util.List;
public class MainActivity extends AppCompatActivity {
- private final int NOTIFICATION_PERMISSION_REQUEST_CODE = 1001;
+ private static final int NOTIFICATION_PERMISSION_REQUEST_CODE = 1001;
private TextView tvVersion;
@Override
@@ -40,6 +53,31 @@ protected void onCreate(Bundle savedInstanceState) {
initView();
checkLogin();
initG2();
+ dumpTest();
+ }
+
+ private void dumpTest() {
+ if (BuildConfig.DEBUG) {
+ findViewById(R.id.btn)
+ .setOnClickListener(
+ v -> {
+ Toast.makeText(MainActivity.this, "开始dump音频", Toast.LENGTH_LONG).show();
+ NERtcEx.getInstance().startAudioDump();
+ });
+ findViewById(R.id.btn2)
+ .setOnClickListener(
+ v -> {
+ Toast.makeText(
+ MainActivity.this,
+ "dump已结束,请到/sdcard/Android/data/com.netease.videocall.demo/files/dump目录查看dump文件",
+ Toast.LENGTH_LONG)
+ .show();
+ NERtcEx.getInstance().stopAudioDump();
+ });
+ } else {
+ findViewById(R.id.btn).setVisibility(View.GONE);
+ findViewById(R.id.btn2).setVisibility(View.GONE);
+ }
}
@Override
@@ -54,102 +92,167 @@ protected void onDestroy() {
private void initG2() {
- NIMClient.getService(AuthServiceObserver.class).observeOnlineStatus((Observer) statusCode -> {
- if (statusCode == StatusCode.LOGINED) {
-
- CallKitUIOptions options = new CallKitUIOptions.Builder()
- // 音视频通话 sdk appKey,用于通话中使用
- .rtcAppKey(BuildConfig.APP_KEY)
- // 当前用户 accId
- .currentUserAccId(ProfileManager.getInstance().getUserModel().imAccid)
- // 通话接听成功的超时时间单位 毫秒,默认30s
- .timeOutMillisecond(30 * 1000L)
- // 当系统版本为 Android Q及以上时,若应用在后台系统限制不直接展示页面
- // 而是展示 notification,通过点击 notification 跳转呼叫页面
- // 此处为 notification 相关配置,如图标,提示语等。
- .notificationConfigFetcher(new SelfNotificationConfigFetcher())
- // 收到被叫时若 app 在后台,在恢复到前台时是否自动唤起被叫页面,默认为 true
- .resumeBGInvitation(true)
- // 设置初始化 rtc sdk 相关配置,按照所需进行配置
- .rtcSdkOption(new NERtcOption())
- // 设置用户信息
- .userInfoHelper(new SelfUserInfoHelper())
- // 自定义通话页面
- .p2pAudioActivity(TestActivity.class)
- .p2pVideoActivity(TestActivity.class)
- .build();
- // 若重复初始化会销毁之前的初始化实例,重新初始化
- CallKitUI.init(getApplicationContext(), options);
- }
- }, true);
+ NIMClient.getService(V2NIMLoginService.class)
+ .addLoginListener(
+ new V2NIMLoginListener() {
+ @Override
+ public void onLoginStatus(V2NIMLoginStatus status) {
+ if (status == V2NIMLoginStatus.V2NIM_LOGIN_STATUS_LOGINED) {
+ if (TextUtils.equals(
+ AuthManager.getInstance().getUserModel().imAccid,
+ NIMClient.getCurrentAccount())) {
+ return;
+ }
+ Log.e("======", "init " + AuthManager.getInstance().getUserModel().imAccid);
+ SettingActivity.toInit();
+ }
+ }
+
+ @Override
+ public void onLoginFailed(V2NIMError error) {}
+
+ @Override
+ public void onKickedOffline(V2NIMKickedOfflineDetail detail) {}
+
+ @Override
+ public void onLoginClientChanged(
+ V2NIMLoginClientChange change, List clients) {}
+ });
}
private void checkLogin() {
- if (ProfileManager.getInstance().isLogin()) {
+ if (AuthManager.getInstance().isLogin()) {
return;
}
+
//此处注册之后会立刻回调一次
- NIMClient.getService(AuthServiceObserver.class).observeOnlineStatus((Observer) statusCode -> {
- if (statusCode == StatusCode.LOGINED) {
- ProfileManager.getInstance().setLogin(true);
- CallOrderManager.getInstance().init();
- }
- }, true);
+ NIMClient.getService(V2NIMLoginService.class)
+ .addLoginListener(
+ new V2NIMLoginListener() {
+ @Override
+ public void onLoginStatus(V2NIMLoginStatus status) {
+ if (status == V2NIMLoginStatus.V2NIM_LOGIN_STATUS_LOGINED) {
+ AuthManager.getInstance().setLogin(true);
+ CallOrderManager.getInstance().init();
+ }
+ }
+
+ @Override
+ public void onLoginFailed(V2NIMError error) {}
+ @Override
+ public void onKickedOffline(V2NIMKickedOfflineDetail detail) {}
+ @Override
+ public void onLoginClientChanged(
+ V2NIMLoginClientChange change, List clients) {}
+ });
+ if (NIMClient.getService(V2NIMLoginService.class).getLoginStatus()
+ != V2NIMLoginStatus.V2NIM_LOGIN_STATUS_LOGINED) {
+ if (AuthManager.getInstance().getUserModel() != null
+ && !TextUtils.isEmpty(AuthManager.getInstance().getUserModel().imAccid)
+ && !TextUtils.isEmpty(AuthManager.getInstance().getUserModel().imToken)) {
+ NIMClient.getService(V2NIMLoginService.class)
+ .login(
+ AuthManager.getInstance().getUserModel().imAccid,
+ AuthManager.getInstance().getUserModel().imToken,
+ null,
+ null,
+ null);
+ }
+ }
}
private void initView() {
ImageView ivAccountIcon = findViewById(R.id.iv_account);
RelativeLayout rlyVideoCall = findViewById(R.id.rly_video_call);
+ RelativeLayout rlyConvergedCall = findViewById(R.id.rly_converged_call);
+ RelativeLayout rlyGroupCall = findViewById(R.id.rly_group_call);
+
tvVersion = findViewById(R.id.tv_version);
- ivAccountIcon.setOnClickListener(view -> {
- if (ProfileManager.getInstance().isLogin()) {
- showLogoutDialog();
- } else {
- LoginActivity.startLogin(this);
- }
- });
+ ivAccountIcon.setOnClickListener(
+ view -> {
+ if (AuthManager.getInstance().isLogin()) {
+ showLogoutDialog();
+ } else {
+ LoginActivity.startLogin(this);
+ }
+ });
- rlyVideoCall.setOnClickListener(view -> {
- if (!ProfileManager.getInstance().isLogin()) {
- LoginActivity.startLogin(this);
- } else {
- NERTCSelectCallUserActivity.startSelectUser(this);
- }
- });
+ rlyVideoCall.setOnClickListener(
+ view -> {
+ if (!AuthManager.getInstance().isLogin()) {
+ LoginActivity.startLogin(this);
+ } else {
+ NERTCSelectCallUserActivity.startSelectUser(this, CallModeType.RTC_1V1_VIDEO_CALL);
+ }
+ });
+
+ rlyGroupCall.setOnClickListener(
+ v -> {
+ if (!AuthManager.getInstance().isLogin()) {
+ LoginActivity.startLogin(this);
+ } else {
+ NERTCSelectCallUserActivity.startSelectUser(
+ this,
+ CallModeType.RTC_GROUP_CALL,
+ Collections.singletonList(AuthManager.getInstance().getUserModel().imAccid));
+ }
+ });
+ rlyGroupCall.setVisibility(View.VISIBLE);
+
+ rlyConvergedCall.setOnClickListener(
+ v -> {
+ if (!AuthManager.getInstance().isLogin()) {
+ LoginActivity.startLogin(this);
+ } else {
+ NERTCSelectCallUserActivity.startSelectUser(this, CallModeType.PSTN_1V1_AUDIO_CALL);
+ }
+ });
+ rlyConvergedCall.setVisibility(View.GONE);
+
+ RelativeLayout rlPermission = findViewById(R.id.rl_goto_permission_setting);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ rlPermission.setVisibility(View.VISIBLE);
+ } else {
+ rlPermission.setVisibility(View.GONE);
+ }
+ rlPermission.setOnClickListener(v -> ForegroundKit.getInstance(this).requestFloatPermission());
initVersionInfo();
}
private void initVersionInfo() {
- String versionInfo = "NIM sdk version:" + NIMClient.getSDKVersion() + "\nnertc sdk version:" +
- NERtc.version().versionName + "\ncallKit version:" + CallKitUI.INSTANCE.currentVersion();
+ String versionInfo =
+ "NIM sdk version:"
+ + NIMClient.getSDKVersion()
+ + "\nnertc sdk version:"
+ + NERtc.version().versionName
+ + "\ncallKit version:"
+ + CallKitUI.INSTANCE.currentVersion();
tvVersion.setText(versionInfo);
}
private void showLogoutDialog() {
- final AlertDialog.Builder confirmDialog =
- new AlertDialog.Builder(MainActivity.this);
- confirmDialog.setTitle("注销账户:" + ProfileManager.getInstance().getUserModel().mobile);
+ final AlertDialog.Builder confirmDialog = new AlertDialog.Builder(MainActivity.this);
+ confirmDialog.setTitle("注销账户:" + AuthManager.getInstance().getUserModel().mobile);
confirmDialog.setMessage("确认注销当前登录账号?");
- confirmDialog.setPositiveButton("是",
+ confirmDialog.setPositiveButton(
+ "是",
(dialog, which) -> {
- ProfileManager.getInstance().logout();
- Toast.makeText(MainActivity.this, "已经退出登录", Toast.LENGTH_SHORT).show();
+ AuthManager.getInstance().logout();
+ Toast.makeText(MainActivity.this, "已经退出登录", Toast.LENGTH_LONG).show();
});
- confirmDialog.setNegativeButton("否",
- (dialog, which) -> {
+ confirmDialog.setNegativeButton("否", (dialog, which) -> {});
- });
confirmDialog.show();
}
private void checkAndRequestNotificationPermission(Context context) {
// 检查是否需要请求通知权限
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
- if (ContextCompat.checkSelfPermission(context, Manifest.permission.POST_NOTIFICATIONS)
+ if (ContextCompat.checkSelfPermission(context, android.Manifest.permission.POST_NOTIFICATIONS)
!= PackageManager.PERMISSION_GRANTED) {
// 请求权限
ActivityCompat.requestPermissions(
@@ -159,4 +262,4 @@ private void checkAndRequestNotificationPermission(Context context) {
}
}
}
-}
\ No newline at end of file
+}
diff --git a/NLiteAVDemo-Android-Java/build.gradle b/NLiteAVDemo-Android-Java/build.gradle
index 6263904..2119883 100644
--- a/NLiteAVDemo-Android-Java/build.gradle
+++ b/NLiteAVDemo-Android-Java/build.gradle
@@ -4,11 +4,10 @@ buildscript {
google()
mavenCentral()
maven { url 'https://maven.faceunity.com/repository/maven-public/' }
- maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21"
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@@ -20,7 +19,6 @@ allprojects {
google()
mavenCentral()
maven { url 'https://maven.faceunity.com/repository/maven-public/' }
- maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}
}
@@ -30,7 +28,7 @@ task clean(type: Delete) {
ext {
compileSdkVersion = 34
- buildToolsVersion = "34.0.0"
+ buildToolsVersion = "30.0.0"
minSdkVersion = 21
targetSdkVersion = 34
@@ -44,6 +42,7 @@ ext {
BaseUrl = ''
libs = new Libs()
libs.nertc = new Libs.Nertc()
+ libs.im = new Libs.Im()
}
class Libs{
@@ -60,7 +59,7 @@ class Libs{
static def alog = "com.netease.yunxin.kit:alog:1.1.0"
static def kotlinxCoroutinesCore = "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4"
static def kotlinxCoroutinesAndroid = "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"
- static def call = "com.netease.yunxin.kit.call:call:2.5.1"
+ static def call = "com.netease.yunxin.kit.call:call:3.3.0"
static def okhttp = "com.squareup.okhttp3:okhttp:4.9.3"
static def okhttpLoggingInterceptor = "com.squareup.okhttp3:logging-interceptor:4.9.3"
static def retrofitCore = "com.squareup.retrofit2:retrofit:2.9.0"
@@ -71,5 +70,13 @@ class Libs{
def segment = "com.netease.yunxin:nertc-segment:5.5.2"
}
+ static class Im {
+ def basesdk = "com.netease.nimlib:basesdk:10.6.0"
+ def chatroom = "com.netease.nimlib:chatroom:10.6.0"
+ def push = "com.netease.nimlib:push:10.6.0"
+ def avsignalling = "com.netease.nimlib:avsignalling:10.6.0"
+ }
+
static def nertc
+ static def im
}
\ No newline at end of file
diff --git a/NLiteAVDemo-Android-Java/call-ui/src/main/AndroidManifest.xml b/NLiteAVDemo-Android-Java/call-ui/src/main/AndroidManifest.xml
index e8893e1..2c6663b 100644
--- a/NLiteAVDemo-Android-Java/call-ui/src/main/AndroidManifest.xml
+++ b/NLiteAVDemo-Android-Java/call-ui/src/main/AndroidManifest.xml
@@ -6,13 +6,14 @@
-->
+ xmlns:tools="http://schemas.android.com/tools">
+
+
@@ -36,6 +37,12 @@
android:configChanges="uiMode|screenSize|smallestScreenSize|orientation|keyboardHidden|keyboard|navigation|screenLayout|fontScale|locale|layoutDirection|density"
android:theme="@style/TranslucentStyle" />
+
+
?
): Boolean {
val calledID = params[Constants.KEY_CALLED_ACC_ID] as String
- val callerID = params[Constants.KEY_CALLER_ACC_ID] as String
val callerType = params[Constants.KEY_CALL_TYPE] as Int
val pushConfig = params[Constants.KEY_CALL_PUSH_CONFIG] as? NECallPushConfig
val extraInfo = params[Constants.KEY_CALL_EXTRA_INFO] as? String
@@ -81,7 +80,6 @@ class CallKitUIService : XKitService {
params[Constants.KEY_CALL_PAGE_EXTRAS] as? MutableMap
val param = CallParam.Builder()
.callType(callerType)
- .callerAccId(callerID)
.calledAccId(calledID).apply {
if (extraInfo != null) {
callExtraInfo(extraInfo)
diff --git a/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/base/CallParam.kt b/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/base/CallParam.kt
index bbd7ffc..7e95c32 100644
--- a/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/base/CallParam.kt
+++ b/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/base/CallParam.kt
@@ -8,9 +8,9 @@ package com.netease.yunxin.nertc.ui.base
import android.os.Parcel
import android.os.Parcelable
+import com.netease.nimlib.sdk.NIMClient
import com.netease.yunxin.kit.call.p2p.model.NECallPushConfig
import com.netease.yunxin.kit.call.p2p.model.NECallType
-import com.netease.yunxin.nertc.ui.CallKitUI
/**
* 呼叫参数,用户群组呼叫/P2P 呼叫
@@ -18,7 +18,6 @@ import com.netease.yunxin.nertc.ui.CallKitUI
class CallParam @JvmOverloads constructor(
val isCalled: Boolean,
var callType: Int = NECallType.AUDIO,
- val callerAccId: String? = null,
val calledAccId: String? = null,
val callExtraInfo: String? = null,
val globalExtraCopy: String? = null,
@@ -27,14 +26,13 @@ class CallParam @JvmOverloads constructor(
var extras: MutableMap? = null
) : Parcelable {
- val currentAccId: String? = CallKitUI.currentUserAccId
+ val currentAccId: String? = NIMClient.getCurrentAccount()
val otherAccId: String?
- get() = if (isCalled) callerAccId else calledAccId
+ get() = if (isCalled) currentAccId else calledAccId
constructor(
callType: Int,
- callerAccId: String? = null,
calledAccId: String? = null,
callExtraInfo: String? = null,
globalExtraCopy: String? = null,
@@ -44,7 +42,6 @@ class CallParam @JvmOverloads constructor(
) : this(
false,
callType,
- callerAccId,
calledAccId,
callExtraInfo = callExtraInfo,
globalExtraCopy = globalExtraCopy,
@@ -60,7 +57,6 @@ class CallParam @JvmOverloads constructor(
parcel.readString(),
parcel.readString(),
parcel.readString(),
- parcel.readString(),
parcel.readParcelable(NECallPushConfig::class.java.classLoader),
HashMap().apply {
parcel.readMap(this, javaClass.classLoader)
@@ -70,7 +66,6 @@ class CallParam @JvmOverloads constructor(
override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeByte(if (isCalled) 1 else 0)
parcel.writeInt(callType)
- parcel.writeString(callerAccId)
parcel.writeString(calledAccId)
parcel.writeString(callExtraInfo)
parcel.writeString(globalExtraCopy)
@@ -84,7 +79,7 @@ class CallParam @JvmOverloads constructor(
}
override fun toString(): String {
- return "CallParam(isCalled=$isCalled, callType=$callType, callerAccId=$callerAccId, calledAccId=$calledAccId, callExtraInfo=$callExtraInfo, globalExtraCopy=$globalExtraCopy, rtcChannelName=$rtcChannelName, pushConfig=$pushConfig, extras=$extras, currentAccId=$currentAccId, otherAccId=$otherAccId)"
+ return "CallParam(isCalled=$isCalled, callType=$callType, calledAccId=$calledAccId, callExtraInfo=$callExtraInfo, globalExtraCopy=$globalExtraCopy, rtcChannelName=$rtcChannelName, pushConfig=$pushConfig, extras=$extras, currentAccId=$currentAccId, otherAccId=$otherAccId)"
}
override fun equals(other: Any?): Boolean {
@@ -95,7 +90,6 @@ class CallParam @JvmOverloads constructor(
if (isCalled != other.isCalled) return false
if (callType != other.callType) return false
- if (callerAccId != other.callerAccId) return false
if (calledAccId != other.calledAccId) return false
if (callExtraInfo != other.callExtraInfo) return false
if (globalExtraCopy != other.globalExtraCopy) return false
@@ -109,7 +103,6 @@ class CallParam @JvmOverloads constructor(
override fun hashCode(): Int {
var result = isCalled.hashCode()
result = 31 * result + callType
- result = 31 * result + (callerAccId?.hashCode() ?: 0)
result = 31 * result + (calledAccId?.hashCode() ?: 0)
result = 31 * result + (callExtraInfo?.hashCode() ?: 0)
result = 31 * result + (globalExtraCopy?.hashCode() ?: 0)
@@ -132,7 +125,6 @@ class CallParam @JvmOverloads constructor(
class Builder {
private var callType: Int = NECallType.AUDIO
private var isCalled: Boolean = false
- private var callerAccId: String? = CallKitUI.currentUserAccId
private var calledAccId: String? = null
private var callExtraInfo: String? = null
private var globalExtraCopy: String? = null
@@ -144,8 +136,6 @@ class CallParam @JvmOverloads constructor(
fun isCalled(called: Boolean) = apply { this.isCalled = called }
- fun callerAccId(accId: String) = apply { this.callerAccId = accId }
-
fun calledAccId(accId: String) = apply { this.calledAccId = accId }
fun callExtraInfo(extraInfo: String) = apply { this.callExtraInfo = extraInfo }
@@ -172,7 +162,6 @@ class CallParam @JvmOverloads constructor(
return CallParam(
isCalled,
callType,
- callerAccId,
calledAccId,
callExtraInfo,
globalExtraCopy,
diff --git a/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/base/CommonGroupCallActivity.kt b/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/base/CommonGroupCallActivity.kt
index 8a5f14e..c99d128 100644
--- a/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/base/CommonGroupCallActivity.kt
+++ b/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/base/CommonGroupCallActivity.kt
@@ -15,6 +15,7 @@ import android.view.Window
import android.view.WindowManager
import androidx.appcompat.app.AppCompatActivity
import com.netease.lava.nertc.sdk.NERtcEx
+import com.netease.nimlib.sdk.NIMClient
import com.netease.yunxin.kit.alog.ALog
import com.netease.yunxin.kit.alog.ParameterMap
import com.netease.yunxin.kit.call.group.GroupCallHangupEvent
@@ -27,7 +28,6 @@ import com.netease.yunxin.kit.call.group.param.GroupCallParam
import com.netease.yunxin.kit.call.group.param.GroupHangupParam
import com.netease.yunxin.nertc.nertcvideocall.model.impl.NERtcCallbackExTemp
import com.netease.yunxin.nertc.nertcvideocall.model.impl.NERtcCallbackProxyMgr
-import com.netease.yunxin.nertc.ui.CallKitUI
import com.netease.yunxin.nertc.ui.base.Constants.PARAM_KEY_GROUP_CALL
import com.netease.yunxin.nertc.ui.base.Constants.PARAM_KEY_GROUP_CALL_ID
import com.netease.yunxin.nertc.ui.service.DefaultIncomingCallEx
@@ -186,7 +186,7 @@ abstract class CommonGroupCallActivity : AppCompatActivity() {
callParam =
intent.getSerializableExtra(PARAM_KEY_GROUP_CALL) as? GroupCallParam
callId = intent.getStringExtra(PARAM_KEY_GROUP_CALL_ID)
- currentUserAccId = CallKitUI.currentUserAccId!!
+ currentUserAccId = NIMClient.getCurrentAccount()
ALog.d(
tag,
ParameterMap("prepareData")
diff --git a/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/base/Others.kt b/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/base/Others.kt
index d03e528..402a725 100644
--- a/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/base/Others.kt
+++ b/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/base/Others.kt
@@ -8,17 +8,15 @@ package com.netease.yunxin.nertc.ui.base
import android.content.Context
import android.content.Intent
-import android.text.TextUtils
import com.netease.yunxin.kit.call.group.NEGroupCallInfo
import com.netease.yunxin.kit.call.p2p.NECallEngine
import com.netease.yunxin.kit.call.p2p.model.NECallType
import com.netease.yunxin.kit.call.p2p.model.NEInviteInfo
import com.netease.yunxin.nertc.nertcvideocall.utils.CallParams
-import com.netease.yunxin.nertc.ui.CallKitUI
import com.netease.yunxin.nertc.ui.service.UIServiceManager
fun CallParam.currentUserIsCaller(): Boolean {
- return !TextUtils.isEmpty(callerAccId) && TextUtils.equals(callerAccId, currentAccId)
+ return true
}
fun CallParam.getChannelId(): String? {
@@ -41,7 +39,6 @@ fun NEInviteInfo.toCallParam(): CallParam {
true,
callType,
callerAccId,
- CallKitUI.currentUserAccId,
callExtraInfo = extraInfo,
globalExtraCopy = NECallEngine.sharedInstance().callInfo.signalInfo.globalExtraCopy,
rtcChannelName = NECallEngine.sharedInstance().callInfo.rtcInfo.channelName,
diff --git a/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/group/GroupCallActivity.kt b/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/group/GroupCallActivity.kt
index 104389c..8269c36 100644
--- a/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/group/GroupCallActivity.kt
+++ b/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/group/GroupCallActivity.kt
@@ -22,6 +22,7 @@ import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.netease.lava.nertc.sdk.NERtcConstants
import com.netease.lava.nertc.sdk.NERtcEx
+import com.netease.nimlib.sdk.NIMClient
import com.netease.yunxin.kit.alog.ALog
import com.netease.yunxin.kit.call.NEResultObserver
import com.netease.yunxin.kit.call.group.GroupCallMember
@@ -225,13 +226,13 @@ open class GroupCallActivity : CommonGroupCallActivity() {
initCalleeUI()
} else if (callParam != null) { // 发起呼叫
val list = mutableListOf().apply {
- add(CallKitUI.currentUserAccId!!)
+ add(NIMClient.getCurrentAccount())
callParam?.calleeList?.let {
addAll(it)
}
}
callInfo = GroupHelperUtils.generateGroupCallInfo(
- CallKitUI.currentUserAccId,
+ NIMClient.getCurrentAccount(),
CallKitUI.currentUserRtcUid,
callParam,
null
@@ -486,7 +487,7 @@ open class GroupCallActivity : CommonGroupCallActivity() {
return@groupCall
}
callInfo = GroupHelperUtils.generateGroupCallInfo(
- CallKitUI.currentUserAccId,
+ NIMClient.getCurrentAccount(),
CallKitUI.currentUserRtcUid,
param,
result
diff --git a/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/group/GroupMemberPageView.kt b/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/group/GroupMemberPageView.kt
index b358da2..c35ecf2 100644
--- a/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/group/GroupMemberPageView.kt
+++ b/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/group/GroupMemberPageView.kt
@@ -14,9 +14,9 @@ import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.TextView
import com.bumptech.glide.Glide
+import com.netease.nimlib.sdk.NIMClient
import com.netease.yunxin.kit.alog.ALog
import com.netease.yunxin.kit.call.group.NEGroupConstants
-import com.netease.yunxin.nertc.ui.CallKitUI
import com.netease.yunxin.nertc.ui.R
import com.netease.yunxin.nertc.ui.utils.dip2Px
import com.netease.yunxin.nertc.ui.utils.image.RoundedCornersCenterCrop
@@ -70,7 +70,7 @@ class GroupMemberPageView(context: Context) : FrameLayout(context) {
holder.tvUserName.text = data.name
holder.tipToAccept.visibility = View.GONE
holder.focusFlag.visibility = if (data.focus) View.VISIBLE else View.GONE
- if (data.accId == CallKitUI.currentUserAccId) {
+ if (data.accId == NIMClient.getCurrentAccount()) {
if (data.enableVideo) {
holder.userVideoViewGroup.visibility = View.VISIBLE
videoViewPool.obtainRtcVideo(data.uid, true).run {
diff --git a/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/p2p/CallUIOperationsMgr.kt b/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/p2p/CallUIOperationsMgr.kt
index 4d0cb88..9e864da 100644
--- a/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/p2p/CallUIOperationsMgr.kt
+++ b/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/p2p/CallUIOperationsMgr.kt
@@ -162,6 +162,13 @@ object CallUIOperationsMgr {
this.foregroundServiceConfig?.startService()
}
+ /**
+ * 启动前台服务
+ */
+ fun startService() {
+ this.foregroundServiceConfig?.startService()
+ }
+
/**
* 释放呼叫信息及状态
*/
diff --git a/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/p2p/NERtcCallDelegateForP2P.kt b/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/p2p/NERtcCallDelegateForP2P.kt
index 62e88e1..6fe89ff 100644
--- a/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/p2p/NERtcCallDelegateForP2P.kt
+++ b/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/p2p/NERtcCallDelegateForP2P.kt
@@ -6,9 +6,9 @@
package com.netease.yunxin.nertc.ui.p2p
-import com.netease.nimlib.sdk.avsignalling.constant.ChannelType
import com.netease.nimlib.sdk.util.Entry
import com.netease.yunxin.kit.alog.ALog
+import com.netease.yunxin.kit.call.p2p.model.NECallTypeChangeInfo
import com.netease.yunxin.nertc.nertcvideocall.bean.InvitedInfo
import com.netease.yunxin.nertc.nertcvideocall.model.AbsNERtcCallingDelegate
@@ -83,7 +83,7 @@ open class NERtcCallDelegateForP2P : AbsNERtcCallingDelegate() {
override fun onUserNetworkQuality(stats: Array>?) {
}
- override fun onCallTypeChange(type: ChannelType?, switchCallState: Int) {
+ override fun onCallTypeChange(info: NECallTypeChangeInfo) {
}
override fun timeOut() {
diff --git a/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/p2p/P2PCallActivity.kt b/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/p2p/P2PCallActivity.kt
index 4226b8c..22bcdbf 100644
--- a/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/p2p/P2PCallActivity.kt
+++ b/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/p2p/P2PCallActivity.kt
@@ -22,10 +22,10 @@ import com.bumptech.glide.Glide
import com.netease.lava.nertc.sdk.NERtcConstants
import com.netease.lava.nertc.sdk.NERtcConstants.ErrorCode.ENGINE_ERROR_DEVICE_PREVIEW_ALREADY_STARTED
import com.netease.lava.nertc.sdk.NERtcEx
+import com.netease.nimlib.sdk.NIMClient
import com.netease.nimlib.sdk.ResponseCode
import com.netease.yunxin.kit.alog.ALog
import com.netease.yunxin.kit.call.NEResultObserver
-import com.netease.yunxin.kit.call.p2p.internal.NECallEngineImpl
import com.netease.yunxin.kit.call.p2p.model.NECallEndInfo
import com.netease.yunxin.kit.call.p2p.model.NECallInfo
import com.netease.yunxin.kit.call.p2p.model.NECallInitRtcMode
@@ -488,10 +488,8 @@ open class P2PCallActivity : CommonCallActivity() {
binding.tvSwitchTipClose.setOnClickListener {
binding.switchTypeTipGroup.visibility = View.GONE
}
- val enableAutoJoinWhenCalled = (callEngine as? NECallEngineImpl)?.recorder?.isEnableAutoJoinWhenCalled == true
binding.calledSwitchGroup.visibility = View.GONE
- binding.callerSwitchGroup.visibility =
- if (enableAutoJoinWhenCalled) View.VISIBLE else View.GONE
+ binding.callerSwitchGroup.visibility = View.GONE
}
open fun renderForCalled() {
@@ -499,12 +497,7 @@ open class P2PCallActivity : CommonCallActivity() {
binding.switchTypeTipGroup.visibility = View.GONE
}
binding.callerSwitchGroup.visibility = View.GONE
- val enableAutoJoinWhenCalled = (callEngine as? NECallEngineImpl)?.recorder?.isEnableAutoJoinWhenCalled == true
- if (enableAutoJoinWhenCalled) {
- binding.calledSwitchGroup.visibility = View.VISIBLE
- } else {
- binding.calledSwitchGroup.visibility = View.GONE
- }
+ binding.calledSwitchGroup.visibility = View.GONE
}
open fun renderForOnTheCall(userAccId: String? = null) {
@@ -576,7 +569,7 @@ open class P2PCallActivity : CommonCallActivity() {
override fun renderForCalled() {
super.renderForCalled()
- forUserInfoUI(NECallType.AUDIO, callParam.callerAccId)
+ forUserInfoUI(NECallType.AUDIO, NIMClient.getCurrentAccount())
binding.ivAccept.setImageResource(R.drawable.icon_call_audio_accept)
binding.ivSwitchType.setImageResource(R.drawable.icon_call_tip_audio_to_video)
@@ -677,7 +670,7 @@ open class P2PCallActivity : CommonCallActivity() {
override fun renderForCalled() {
super.renderForCalled()
- forUserInfoUI(NECallType.VIDEO, callParam.callerAccId)
+ forUserInfoUI(NECallType.VIDEO, NIMClient.getCurrentAccount())
binding.videoViewPreview.visibility = View.GONE
binding.videoViewBig.visibility = View.GONE
diff --git a/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/service/CallKitUIBridgeService.kt b/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/service/CallKitUIBridgeService.kt
index 3042b24..409c441 100644
--- a/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/service/CallKitUIBridgeService.kt
+++ b/NLiteAVDemo-Android-Java/call-ui/src/main/java/com/netease/yunxin/nertc/ui/service/CallKitUIBridgeService.kt
@@ -7,6 +7,7 @@ package com.netease.yunxin.nertc.ui.service
import android.content.Context
import android.text.TextUtils
+import com.netease.nimlib.sdk.NIMClient
import com.netease.nimlib.sdk.ResponseCode
import com.netease.yunxin.kit.alog.ALog
import com.netease.yunxin.kit.alog.ParameterMap
@@ -35,7 +36,6 @@ import com.netease.yunxin.nertc.nertcvideocall.model.CallErrorCode
import com.netease.yunxin.nertc.nertcvideocall.model.CallLocalAction
import com.netease.yunxin.nertc.nertcvideocall.model.SwitchCallState
import com.netease.yunxin.nertc.nertcvideocall.model.impl.state.CallState
-import com.netease.yunxin.nertc.ui.CallKitUI
import com.netease.yunxin.nertc.ui.base.AVChatSoundPlayer
/**
@@ -161,7 +161,7 @@ open class CallKitUIBridgeService @JvmOverloads constructor(
bgGroupInvitedInfo!!.callId
) && userList != null
) {
- val index = userList.indexOf(GroupCallMember(CallKitUI.currentUserAccId))
+ val index = userList.indexOf(GroupCallMember(NIMClient.getCurrentAccount()))
if (index < 0) {
return
}
@@ -209,7 +209,7 @@ open class CallKitUIBridgeService @JvmOverloads constructor(
open fun onLocalAction(actionId: Int, resultCode: Int) {
ALog.d(logTag, "onLocalAction actionId is $actionId, resultCode is $resultCode.")
if (actionId == CallLocalAction.ACTION_CALL && NECallEngine.sharedInstance().callInfo.callStatus == CallState.STATE_CALL_OUT) {
- callerAccId = CallKitUI.currentUserAccId
+ callerAccId = NIMClient.getCurrentAccount()
canStopAudioPlay = true
AVChatSoundPlayer.play(context, AVChatSoundPlayer.RingerTypeEnum.CONNECTING)
} else if (canStopAudioPlay && callerAccId != null &&
@@ -275,19 +275,19 @@ open class CallKitUIBridgeService @JvmOverloads constructor(
ALog.dApi(logTag, ParameterMap("onCallEnd").append("info", info))
incomingCallEx.onIncomingCallInvalid(bgInvitedInfo)
when (info.reasonCode) {
- NEHangupReasonCode.CALLER_REJECTED -> if (callerAccId == CallKitUI.currentUserAccId) {
+ NEHangupReasonCode.CALLER_REJECTED -> if (callerAccId == NIMClient.getCurrentAccount()) {
playStopAudio(AVChatSoundPlayer.RingerTypeEnum.PEER_REJECT)
} else {
AVChatSoundPlayer.stop(context)
}
- NEHangupReasonCode.BUSY -> if (callerAccId == CallKitUI.currentUserAccId) {
+ NEHangupReasonCode.BUSY -> if (callerAccId == NIMClient.getCurrentAccount()) {
playStopAudio(AVChatSoundPlayer.RingerTypeEnum.PEER_BUSY)
} else {
AVChatSoundPlayer.stop(context)
}
- NEHangupReasonCode.TIME_OUT -> if (callerAccId == CallKitUI.currentUserAccId) {
+ NEHangupReasonCode.TIME_OUT -> if (callerAccId == NIMClient.getCurrentAccount()) {
playStopAudio(AVChatSoundPlayer.RingerTypeEnum.NO_RESPONSE)
} else {
AVChatSoundPlayer.stop(context)
@@ -342,7 +342,7 @@ open class CallKitUIBridgeService @JvmOverloads constructor(
) {
return false
}
- val index = invitedInfo.memberList.indexOf(GroupCallMember(CallKitUI.currentUserAccId))
+ val index = invitedInfo.memberList.indexOf(GroupCallMember(NIMClient.getCurrentAccount()))
if (index < 0) {
return false
}
diff --git a/NLiteAVDemo-Android-Java/gradle/wrapper/gradle-wrapper.properties b/NLiteAVDemo-Android-Java/gradle/wrapper/gradle-wrapper.properties
index e676d7b..3d20344 100644
--- a/NLiteAVDemo-Android-Java/gradle/wrapper/gradle-wrapper.properties
+++ b/NLiteAVDemo-Android-Java/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-bin.zip
+distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-7.6.3-bin.zip
diff --git a/NLiteAVDemo-iOS-ObjC/CallKit/NECallKitPstn/NECallKitPstn/Classes/NECallKitPstn.m b/NLiteAVDemo-iOS-ObjC/CallKit/NECallKitPstn/NECallKitPstn/Classes/NECallKitPstn.m
index 793f2ce..4d2219e 100644
--- a/NLiteAVDemo-iOS-ObjC/CallKit/NECallKitPstn/NECallKitPstn/Classes/NECallKitPstn.m
+++ b/NLiteAVDemo-iOS-ObjC/CallKit/NECallKitPstn/NECallKitPstn/Classes/NECallKitPstn.m
@@ -140,7 +140,7 @@ - (void)onCallingTimeOut {
[self.pstnDelegate pstnWillStart];
}
[self setCallKitStatusCalling];
- NSString *accid = [[NIMSDK sharedSDK].loginManager currentAccount];
+ NSString *accid = [[NIMSDK sharedSDK].v2LoginService getLoginUser];
if (accid.length <= 0) {
[self callKitErrorWithMsg:@"get im accid is empty" withCode:kNERtcCallKitPstnAccidError];
return;
diff --git a/NLiteAVDemo-iOS-ObjC/CallKit/NERtcCallUIKit/NERtcCallUIKit.podspec b/NLiteAVDemo-iOS-ObjC/CallKit/NERtcCallUIKit/NERtcCallUIKit.podspec
index 5dace5c..117d02b 100644
--- a/NLiteAVDemo-iOS-ObjC/CallKit/NERtcCallUIKit/NERtcCallUIKit.podspec
+++ b/NLiteAVDemo-iOS-ObjC/CallKit/NERtcCallUIKit/NERtcCallUIKit.podspec
@@ -8,7 +8,7 @@
Pod::Spec.new do |s|
s.name = 'NERtcCallUIKit'
- s.version = '2.5.0'
+ s.version = '3.0.0'
s.summary = 'Netease XKit'
s.homepage = 'http://netease.im'
s.license = { :'type' => "Copyright", :'text' => " Copyright 2022 Netease " }
@@ -19,7 +19,7 @@ Pod::Spec.new do |s|
s.resource = 'NERtcCallUIKit/Assets/**/*'
s.subspec 'NOS' do |nos|
- nos.dependency 'NERtcCallKit/NOS','2.5.0'
+ nos.dependency 'NERtcCallKit/NOS','3.0.0'
nos.dependency 'SDWebImage'
nos.dependency 'NECoreKit'
nos.dependency 'NECommonKit'
@@ -28,7 +28,7 @@ Pod::Spec.new do |s|
end
s.subspec 'NOS_Special' do |nos|
- nos.dependency 'NERtcCallKit/NOS_Special', '2.5.0'
+ nos.dependency 'NERtcCallKit/NOS_Special', '3.0.0'
nos.dependency 'SDWebImage'
nos.dependency 'NECoreKit'
nos.dependency 'NECommonKit'
@@ -38,7 +38,7 @@ Pod::Spec.new do |s|
end
s.subspec 'FCS' do |fcs|
- fcs.dependency 'NERtcCallKit/FCS','2.5.0'
+ fcs.dependency 'NERtcCallKit/FCS','3.0.0'
fcs.dependency 'SDWebImage'
fcs.dependency 'NECoreKit'
fcs.dependency 'NECommonKit'
@@ -48,7 +48,7 @@ Pod::Spec.new do |s|
end
s.subspec 'FCS_Special' do |fcs|
- fcs.dependency 'NERtcCallKit/FCS_Special', '2.5.0'
+ fcs.dependency 'NERtcCallKit/FCS_Special', '3.0.0'
fcs.dependency 'SDWebImage'
fcs.dependency 'NECoreKit'
fcs.dependency 'NECommonKit'
diff --git a/NLiteAVDemo-iOS-ObjC/CallKit/NERtcCallUIKit/NERtcCallUIKit/Classes/Controller/NECallUIStateController.m b/NLiteAVDemo-iOS-ObjC/CallKit/NERtcCallUIKit/NERtcCallUIKit/Classes/Controller/NECallUIStateController.m
index f9849b0..9368174 100644
--- a/NLiteAVDemo-iOS-ObjC/CallKit/NERtcCallUIKit/NERtcCallUIKit/Classes/Controller/NECallUIStateController.m
+++ b/NLiteAVDemo-iOS-ObjC/CallKit/NERtcCallUIKit/NERtcCallUIKit/Classes/Controller/NECallUIStateController.m
@@ -385,7 +385,7 @@ - (void)refreshVideoView {
NSLog(@"show my big view");
self.smallVideoView.maskView.hidden = !self.mainController.isRemoteMute;
self.bigVideoView.maskView.hidden = !self.operationView.cameraBtn.selected;
- self.bigVideoView.userID = NIMSDK.sharedSDK.loginManager.currentAccount;
+ self.bigVideoView.userID = [[NIMSDK sharedSDK].v2LoginService getLoginUser];
self.smallVideoView.userID = self.callParam.remoteUserAccid;
} else {
[[NECallEngine sharedInstance] setupLocalView:self.smallVideoView.videoView];
@@ -394,7 +394,7 @@ - (void)refreshVideoView {
self.bigVideoView.maskView.hidden = !self.mainController.isRemoteMute;
self.smallVideoView.maskView.hidden = !self.operationView.cameraBtn.selected;
self.bigVideoView.userID = self.callParam.remoteUserAccid;
- self.smallVideoView.userID = NIMSDK.sharedSDK.loginManager.currentAccount;
+ self.smallVideoView.userID = [[NIMSDK sharedSDK].v2LoginService getLoginUser];
}
}
diff --git a/NLiteAVDemo-iOS-ObjC/CallKit/NERtcCallUIKit/NERtcCallUIKit/Classes/Controller/NECallViewController.m b/NLiteAVDemo-iOS-ObjC/CallKit/NERtcCallUIKit/NERtcCallUIKit/Classes/Controller/NECallViewController.m
index 4dfc897..14ca7ee 100644
--- a/NLiteAVDemo-iOS-ObjC/CallKit/NERtcCallUIKit/NERtcCallUIKit/Classes/Controller/NECallViewController.m
+++ b/NLiteAVDemo-iOS-ObjC/CallKit/NERtcCallUIKit/NERtcCallUIKit/Classes/Controller/NECallViewController.m
@@ -148,7 +148,7 @@ - (void)setupSDK {
});
}
weakSelf.videoCallingController.bigVideoView.userID =
- NIMSDK.sharedSDK.loginManager.currentAccount;
+ [[NIMSDK sharedSDK].v2LoginService getLoginUser];
}
if (error) {
@@ -540,7 +540,7 @@ - (void)cameraBtnClick:(UIButton *)button {
[[NECallEngine sharedInstance] muteLocalVideo:button.selected];
}
[self changeDefaultImage:button.selected];
- [self cameraAvailble:!button.selected userId:NIMSDK.sharedSDK.loginManager.currentAccount];
+ [self cameraAvailble:!button.selected userId:[[NIMSDK sharedSDK].v2LoginService getLoginUser]];
}
- (void)hangupBtnClick:(UIButton *)button {
diff --git a/NLiteAVDemo-iOS-ObjC/CallKit/NERtcCallUIKit/NERtcCallUIKit/Classes/NERtcCallUIKit.m b/NLiteAVDemo-iOS-ObjC/CallKit/NERtcCallUIKit/NERtcCallUIKit/Classes/NERtcCallUIKit.m
index 89d09f5..a240b8a 100644
--- a/NLiteAVDemo-iOS-ObjC/CallKit/NERtcCallUIKit/NERtcCallUIKit/Classes/NERtcCallUIKit.m
+++ b/NLiteAVDemo-iOS-ObjC/CallKit/NERtcCallUIKit/NERtcCallUIKit/Classes/NERtcCallUIKit.m
@@ -140,10 +140,11 @@ - (instancetype)init {
[self.uiConfigDic setObject:NEVideoCallingController.class forKey:kVideoCalling];
[self.uiConfigDic setObject:NEVideoInCallController.class forKey:kVideoInCall];
[self registerRouter];
- [NERtcCallKit sharedInstance].recordHandler = ^(NIMMessage *message) {
+
+ [NERtcCallKit sharedInstance].recordHandler = ^(V2NIMMessage *message) {
if ([[NetManager shareInstance] isClose] == YES) {
- NIMRtcCallRecordObject *object = (NIMRtcCallRecordObject *)message.messageObject;
- object.callStatus = NIMRtcCallStatusCanceled;
+ V2NIMMessageCallAttachment *recordObject = (V2NIMMessageCallAttachment *)message.attachment;
+ recordObject.status = 2; // 表示取消
}
};
@@ -771,7 +772,7 @@ - (void)pictureInPictureController:(AVPictureInPictureController *)pictureInPict
#pragma mark - Version
+ (NSString *)version {
- return @"2.5.0";
+ return @"3.0.0";
}
@end
diff --git a/NLiteAVDemo-iOS-ObjC/NLiteAVDemo.xcodeproj/project.pbxproj b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo.xcodeproj/project.pbxproj
index 07946d6..8947c6d 100644
--- a/NLiteAVDemo-iOS-ObjC/NLiteAVDemo.xcodeproj/project.pbxproj
+++ b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo.xcodeproj/project.pbxproj
@@ -29,6 +29,7 @@
4B9F0F2D275E2A5300EACC04 /* NERtcSettingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B9F0F2C275E2A5300EACC04 /* NERtcSettingViewController.m */; };
4BA14012271E50E200B7148C /* NSArray+NTES.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BA14011271E50E200B7148C /* NSArray+NTES.m */; };
4BD10274271D12D600ACA3E4 /* NESectionHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BD10273271D12D600ACA3E4 /* NESectionHeaderView.m */; };
+ 54AD12862CE3514C00F0F370 /* NECallUISettingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 54AD12852CE3514B00F0F370 /* NECallUISettingViewController.m */; };
65F51E0653EC27F8380D7A83 /* Pods_NLiteAVDemo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 890A3C73BFF223F57ED1181D /* Pods_NLiteAVDemo.framework */; };
C758CCDA24EB7F5A003C406A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = C758CCD924EB7F5A003C406A /* AppDelegate.m */; };
C758CCE324EB7F5A003C406A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C758CCE124EB7F5A003C406A /* Main.storyboard */; };
@@ -114,6 +115,8 @@
4BA14011271E50E200B7148C /* NSArray+NTES.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSArray+NTES.m"; sourceTree = ""; };
4BD10272271D12D600ACA3E4 /* NESectionHeaderView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NESectionHeaderView.h; sourceTree = ""; };
4BD10273271D12D600ACA3E4 /* NESectionHeaderView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NESectionHeaderView.m; sourceTree = ""; };
+ 54AD12842CE3514B00F0F370 /* NECallUISettingViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NECallUISettingViewController.h; sourceTree = ""; };
+ 54AD12852CE3514B00F0F370 /* NECallUISettingViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NECallUISettingViewController.m; sourceTree = ""; };
6AFFCCD18BE65F0020ACC0E8 /* Pods-OTODemo-NLiteAVDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OTODemo-NLiteAVDemo.debug.xcconfig"; path = "Target Support Files/Pods-OTODemo-NLiteAVDemo/Pods-OTODemo-NLiteAVDemo.debug.xcconfig"; sourceTree = ""; };
890A3C73BFF223F57ED1181D /* Pods_NLiteAVDemo.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_NLiteAVDemo.framework; sourceTree = BUILT_PRODUCTS_DIR; };
9C3E631E57C6DCADE269362E /* Pods-NLiteAVDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NLiteAVDemo.debug.xcconfig"; path = "Target Support Files/Pods-NLiteAVDemo/Pods-NLiteAVDemo.debug.xcconfig"; sourceTree = ""; };
@@ -352,6 +355,8 @@
C7664E762511AE1D005E26A2 /* ViewController */ = {
isa = PBXGroup;
children = (
+ 54AD12842CE3514B00F0F370 /* NECallUISettingViewController.h */,
+ 54AD12852CE3514B00F0F370 /* NECallUISettingViewController.m */,
C7664E7A2511AE1D005E26A2 /* NEPSTNViewController.h */,
C7664E772511AE1D005E26A2 /* NEPSTNViewController.m */,
C7664E792511AE1D005E26A2 /* NERtcContactsViewController.h */,
@@ -673,6 +678,7 @@
01C0D04D288687E900B796BA /* GroupUserViewCell.m in Sources */,
C7664ED92511AE1E005E26A2 /* UIView+NTES.m in Sources */,
C7664ECC2511AE1E005E26A2 /* NESendSmsCodeTask.m in Sources */,
+ 54AD12862CE3514C00F0F370 /* NECallUISettingViewController.m in Sources */,
C758CCDA24EB7F5A003C406A /* AppDelegate.m in Sources */,
01C0D03F288501D700B796BA /* NEGroupCallViewController.m in Sources */,
DD5D75E52A246E3600DA41B2 /* CustomVideoCallingController.m in Sources */,
diff --git a/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/AppDelegate.m b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/AppDelegate.m
index bf689db..67e1457 100644
--- a/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/AppDelegate.m
+++ b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/AppDelegate.m
@@ -41,7 +41,6 @@ - (void)initWindow {
self.window.rootViewController = nav;
[NENavigator shared].navigationController = nav;
[self.window makeKeyAndVisible];
-
/*
// 外部注册自定义UI示例代码
NSMutableDictionary *> *stateConfigDic =
@@ -62,11 +61,40 @@ - (void)initWindow {
*/
}
-- (void)setupSDK {
+/*
+- (void)setupCallKit {
+
+ // 美颜设置
+ NERtcEngine *coreEngine = [NERtcEngine sharedEngine];
+ NSDictionary *params = @{
+ kNERtcKeyPublishSelfStreamEnabled: @YES, // 打开推流
+ kNERtcKeyVideoCaptureObserverEnabled: @YES // 将摄像头采集的数据回调给用户
+ };
+ [coreEngine setParameters:params];
+
+ // 呼叫组件初始化
+ NERtcCallOptions *option = [NERtcCallOptions new];
+ option.APNSCerName = @"your apns cer name";
+ NERtcCallKit *callkit = [NERtcCallKit sharedInstance];
+ [callkit setupAppKey:@"your app key" options:option];
+
+ //呼叫组件设置rtc代理中转
+ callkit.engineDelegate = self;
+}
+// 在代理方法中对视频数据进行处理
+- (void)onNERtcEngineVideoFrameCaptured:(CVPixelBufferRef)bufferRef
+rotation:(NERtcVideoRotationType)rotation
+{
+ // 对视频数据 bufferRef 进行处理, 务必保证 CVPixelBufferRef 的地址值不变,分辨率不变
+}*/
+
+- (void)setupSDK {
NIMSDKOption *option = [NIMSDKOption optionWithAppKey:kAppKey];
option.apnsCername = kAPNSCerName;
- [NIMSDK.sharedSDK registerWithOption:option];
+ option.v2 = YES;
+
+ [NIMSDK.sharedSDK registerWithOptionV2:option v2Option:nil];
NESetupConfig *setupConfig = [[NESetupConfig alloc] initWithAppkey:kAppKey];
[[NECallEngine sharedInstance] setup:setupConfig];
@@ -74,10 +102,9 @@ - (void)setupSDK {
NECallUIKitConfig *config = [[NECallUIKitConfig alloc] init];
config.uiConfig.showCallingSwitchCallType = YES;
- config.uiConfig.enableVideoToAudio = YES;
- config.uiConfig.enableAudioToVideo = YES;
- config.uiConfig.enableFloatingWindow = YES;
- config.uiConfig.enableFloatingWindowOutOfApp = YES;
+ config.uiConfig.enableFloatingWindow = YES;
+ config.uiConfig.enableFloatingWindowOutOfApp = YES;
+ config.uiConfig.language = NECallUILanguageAuto;
[[NERtcCallUIKit sharedInstance] setupWithConfig:config];
[NERtcCallUIKit sharedInstance].delegate = self;
@@ -92,7 +119,6 @@ - (void)setupSDK {
param.appid = kAppKey;
param.rtcSafeMode = YES;
[[NEGroupCallKit sharedInstance] setupGroupCall:param];
-
}
- (void)didCallComingWithInviteInfo:(NEInviteInfo *)inviteInfo
@@ -116,8 +142,6 @@ - (void)registerAPNS {
[UIApplication.sharedApplication.keyWindow
ne_makeToast:@"请到设置中开启推送功能"];
});
- //[UIApplication.sharedApplication.keyWindow
- // ne_makeToast:@"请到设置中开启推送功能"];
}
}];
} else {
@@ -137,20 +161,13 @@ - (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[[NERtcCallKit sharedInstance] updateApnsToken:deviceToken];
[[NSUserDefaults standardUserDefaults] setObject:deviceToken forKey:deviceTokenKey];
- // [self.window ne_makeToast:@"注册devicetoken成功"];
}
+
- (void)application:(UIApplication *)application
didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
[self.window ne_makeToast:[NSString stringWithFormat:@"注册devicetoken失败,Error%@", error]];
}
-// 4.接收通知
-// iOS 10.0 在前台收到通知
-//- (void)userNotificationCenter:(UNUserNotificationCenter *)center
-// willPresentNotification:(UNNotification *)notification withCompletionHandler:(void
-//(^)(UNNotificationPresentationOptions options))completionHandler {
-//}
-
// 在后收到通知
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
@@ -168,5 +185,4 @@ - (void)application:(UIApplication *)application
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
}
-
@end
diff --git a/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/AppKey.h b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/AppKey.h
index 16d502b..4cc1be7 100644
--- a/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/AppKey.h
+++ b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/AppKey.h
@@ -9,6 +9,6 @@
///p12文件,推送证书导出方式需同时包含私钥和公钥
static NSString * const kAPNSCerName = @"<#请输入远程推送证书名字#>";
static NSString * const VoIPCerName = @"<#请输入您的VoIP推送证书#>";
- static NSString * const kApiHost = @"<#App服务器域名#>";
+ static NSString * const kApiHost = @"https://yiyong.netease.im/";
#endif /* AppKey_h */
diff --git a/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/GroupUI/Controller/GroupSettingViewController.m b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/GroupUI/Controller/GroupSettingViewController.m
index 8b40b7a..7b5c760 100644
--- a/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/GroupUI/Controller/GroupSettingViewController.m
+++ b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/GroupUI/Controller/GroupSettingViewController.m
@@ -86,7 +86,8 @@ - (void)setupUI {
- (void)saveSetting {
[[SettingManager shareInstance] setCustomPushContent:self.pushContent.text];
[self.navigationController popViewControllerAnimated:YES];
- [[UIApplication sharedApplication].keyWindow ne_makeToast:NSLocalizedString(@"save_success", nil)];
+ [[UIApplication sharedApplication].keyWindow
+ ne_makeToast:NSLocalizedString(@"save_success", nil)];
}
- (UILabel *)createLabelWithText:(NSString *)text {
diff --git a/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/GroupUI/Controller/NEGroupCallViewController.m b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/GroupUI/Controller/NEGroupCallViewController.m
index 0457b48..3c5bdf6 100644
--- a/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/GroupUI/Controller/NEGroupCallViewController.m
+++ b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/GroupUI/Controller/NEGroupCallViewController.m
@@ -3,12 +3,10 @@
// found in the LICENSE file.
#import "NEGroupCallViewController.h"
-#import
#import "NEGroupCalledViewController.h"
#import "NEGroupContactsController.h"
#import "NEGroupInCallViewController.h"
#import "NEGroupUserController.h"
-#import
@interface NEGroupCallViewController ()
@@ -69,6 +67,7 @@ - (void)viewDidLoad {
make.centerX.equalTo(self.view);
make.top.equalTo(self.view).offset(60 * self.factor);
}];
+
if (self.isCalled == YES) {
[self setupCalledMaskUI];
} else {
@@ -229,7 +228,7 @@ - (void)setLocalVideoEnable:(BOOL)enable {
for (int i = 0; i < self.datas.count; i++) {
NEUser *user = [self.datas objectAtIndex:i];
if (user.imAccid.length > 0 &&
- [user.imAccid isEqualToString:NIMSDK.sharedSDK.loginManager.currentAccount]) {
+ [user.imAccid isEqualToString:[NIMSDK.sharedSDK.v2LoginService getLoginUser]]) {
user.isOpenVideo = enable;
user.isShowLocalVideo = enable;
NSLog(@"setLocalVideoEnable %d", enable);
@@ -459,7 +458,7 @@ - (void)onGroupUserDidChange:(NSArray *)members {
completion:^(NSError *_Nullable error, NSArray *_Nonnull users) {
for (NEUser *user in users) {
if ([user.imAccid
- isEqualToString:NIMSDK.sharedSDK.loginManager.currentAccount]) {
+ isEqualToString:[NIMSDK.sharedSDK.v2LoginService getLoginUser]]) {
user.isShowLocalVideo = !self.operationView.cameraBtn.isSelected;
user.isOpenVideo = !self.operationView.cameraBtn.isSelected;
}
@@ -470,7 +469,7 @@ - (void)onGroupUserDidChange:(NSArray *)members {
}];
}
-- (void)onGroupEndCallWithReason:(NSInteger)reason withCallId:(NSString *)callId {
+- (void)onGroupEndCallWithReason:(NSString *)reason withCallId:(NSString *)callId{
NSLog(@"controller onGroupEndCallWithReason :%@ parameter call id : %@", self.callId, callId);
if ([self.callId isEqualToString:callId]) {
[self didBack];
diff --git a/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/GroupUI/Controller/NEGroupCalledViewController.m b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/GroupUI/Controller/NEGroupCalledViewController.m
index 325c465..9962379 100644
--- a/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/GroupUI/Controller/NEGroupCalledViewController.m
+++ b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/GroupUI/Controller/NEGroupCalledViewController.m
@@ -3,7 +3,6 @@
// found in the LICENSE file.
#import "NEGroupCalledViewController.h"
-#import
#import "NEGroupUserController.h"
@interface NEGroupCalledViewController ()
diff --git a/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/GroupUI/Controller/NEGroupContactsController.m b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/GroupUI/Controller/NEGroupContactsController.m
index 45a3c46..5775684 100644
--- a/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/GroupUI/Controller/NEGroupContactsController.m
+++ b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/GroupUI/Controller/NEGroupContactsController.m
@@ -17,7 +17,6 @@
#import "NESectionHeaderView.h"
#import "NSArray+NTES.h"
#import "NSMacro.h"
-#import
@interface NEGroupContactsController ()
+ V2NIMMessageListener>
@property(nonatomic, strong) UIView *searchBarView;
@property(nonatomic, strong) UITextField *textField;
@@ -69,7 +68,7 @@ - (instancetype)init {
[self loadHistoryData];
self.totalCount = GroupCallUserLimit;
self.hasJoinCount = 1;
- [[[NIMSDK sharedSDK] chatManager] addDelegate:self];
+ [[[NIMSDK sharedSDK] v2MessageService] addMessageListener:self];
}
return self;
}
@@ -88,7 +87,7 @@ - (void)viewDidLoad {
}
[self setupContent];
[self setSetting];
- NSLog(@"current accid : %@", NIMSDK.sharedSDK.loginManager.currentAccount);
+ NSLog(@"current accid : %@", [[NIMSDK sharedSDK].v2LoginService getLoginUser]);
}
- (void)setSetting {
@@ -378,26 +377,41 @@ - (void)didCall {
} else {
NSLog(@"current user : %@", [NEAccount shared].userModel);
NEUser *caller = [[NEUser alloc] init];
- caller.imAccid = [NIMSDK.sharedSDK.loginManager currentAccount];
- caller.avatar = [NIMSDK.sharedSDK.userManager userInfo:caller.imAccid].userInfo.avatarUrl;
- caller.state = GroupMemberStateInChannel;
-
- NEGroupCallViewController *callController =
- [[NEGroupCallViewController alloc] initWithCalled:NO withCaller:caller];
-
- NSMutableArray *calledUsers = [[NSMutableArray alloc] init];
- NSArray *allValues = [self.flagDic allValues];
- for (NEUser *user in allValues) {
- NEUser *copyUser = [user getCopy];
- copyUser.state = GroupMemberStateWaitting;
- [calledUsers addObject:copyUser];
- }
-
- [calledUsers insertObject:caller atIndex:0];
+ caller.imAccid = [NIMSDK.sharedSDK.v2LoginService getLoginUser];
+
+ [NIMSDK.sharedSDK.v2UserService
+ getUserList:@[ caller.imAccid ]
+ success:^(NSArray *_Nonnull result) {
+ if (result.count < 1) {
+ return;
+ }
+
+ V2NIMUser *user = result.firstObject;
+ caller.avatar = user.avatar;
+ caller.state = GroupMemberStateInChannel;
+
+ NEGroupCallViewController *callController =
+ [[NEGroupCallViewController alloc] initWithCalled:NO withCaller:caller];
+
+ NSMutableArray *calledUsers = [[NSMutableArray alloc] init];
+ NSArray *allValues = [self.flagDic allValues];
+ for (NEUser *user in allValues) {
+ NEUser *copyUser = [user getCopy];
+ copyUser.state = GroupMemberStateWaitting;
+ [calledUsers addObject:copyUser];
+ }
+
+ [calledUsers insertObject:caller atIndex:0];
+
+ [callController addUser:calledUsers];
+ callController.modalPresentationStyle = UIModalPresentationFullScreen;
+ [self.navigationController presentViewController:callController
+ animated:YES
+ completion:nil];
+ }
+ failure:^(V2NIMError *_Nonnull error){
- [callController addUser:calledUsers];
- callController.modalPresentationStyle = UIModalPresentationFullScreen;
- [self.navigationController presentViewController:callController animated:YES completion:nil];
+ }];
}
}
@@ -461,7 +475,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
user = self.searchHistoryData[indexPath.row];
}
}
- if ([user.imAccid isEqualToString:NIMSDK.sharedSDK.loginManager.currentAccount]) {
+ if ([user.imAccid isEqualToString:[NIMSDK.sharedSDK.v2LoginService getLoginUser]]) {
[UIApplication.sharedApplication.keyWindow ne_makeToast:@"不能呼叫自己"];
return;
}
@@ -624,22 +638,6 @@ - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger
}
- (void)testAccid:(NSString *)accid {
- NIMSession *session = [NIMSession session:accid type:NIMSessionTypeP2P];
-
- // 构造自定义消息附件
- NIMCustomObject *object = [[NIMCustomObject alloc] init];
- Attachment *attachment = [[Attachment alloc] init];
- object.attachment = attachment;
-
- // 构造出具体消息并注入附件
- NIMMessage *message = [[NIMMessage alloc] init];
- message.messageObject = object;
-
- // 错误反馈对象
- NSError *error = nil;
-
- // 发送消息
- [[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:&error];
}
#pragma mark - call view status delegate
@@ -648,19 +646,4 @@ - (void)didEndCallWithStatusModel:(NECallStatusRecordModel *)model {
[[NSNotificationCenter defaultCenter] postNotificationName:NERECORDADD object:model];
}
-//- (void)sendMessage:(NIMMessage *)message didCompleteWithError:(NSError *)error {
-// NSLog(@"send complete : %@", error);
-// if (error == nil) {
-// [[UIApplication sharedApplication].keyWindow ne_makeToast:@"自定义消息发送成功"];
-// }
-//}
-//
-//- (void)onRecvMessages:(NSArray *)messages {
-// NSLog(@"contacts onRecvMessages : %lu", (unsigned long)messages.count);
-// for (NIMMessage *message in messages) {
-// if (message.messageType == NIMMessageTypeCustom) {
-// [[UIApplication sharedApplication].keyWindow ne_makeToast:@"收到消息"];
-// }
-// }
-//}
@end
diff --git a/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/GroupUI/View/UserInCallCell.m b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/GroupUI/View/UserInCallCell.m
index 818d07d..ed8fc6b 100644
--- a/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/GroupUI/View/UserInCallCell.m
+++ b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/GroupUI/View/UserInCallCell.m
@@ -139,7 +139,7 @@ - (void)configure:(NEUser *)user {
forUserID:user.uid
streamType:kNERtcRemoteVideoStreamTypeHigh];
} else {
- if ([NIMSDK.sharedSDK.loginManager.currentAccount isEqualToString:user.imAccid]) {
+ if ([[NIMSDK.sharedSDK.v2LoginService getLoginUser] isEqualToString:user.imAccid]) {
[NERtcEngine.sharedEngine setupLocalVideoCanvas:nil];
[NERtcEngine.sharedEngine stopPreview];
self.preview.hidden = YES;
diff --git a/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/UI/View/NEMenuViewController.m b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/UI/View/NEMenuViewController.m
index b3c7512..34dca67 100644
--- a/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/UI/View/NEMenuViewController.m
+++ b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/UI/View/NEMenuViewController.m
@@ -14,13 +14,12 @@
#import "NERtcContactsViewController.h"
#import "NEUser.h"
#import "NSArray+NTES.h"
-#import
@interface NEMenuViewController ()
+ NEGroupCallKitDelegate,
+ V2NIMMessageListener>
@property(strong, nonatomic) UITableView *tableView;
@property(strong, nonatomic) UIImageView *bgImageView;
@end
@@ -90,7 +89,9 @@ - (void)setupUI {
- (void)addObserver {
[[NERtcCallKit sharedInstance] addDelegate:self];
- [[NIMSDK sharedSDK].chatManager addDelegate:self];
+ // [[NIMSDK sharedSDK].chatManager addDelegate:self];
+ [[[NIMSDK sharedSDK] v2MessageService] addMessageListener:self];
+
[[NEGroupCallKit sharedInstance] addDelegate:self];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(recordAddNotification:)
@@ -110,7 +111,7 @@ - (void)addObserver {
if (error) {
[self.view
ne_makeToast:[NSString stringWithFormat:@"IM登录失败%@",
- error.localizedDescription]];
+ error.localizedDescription]];
} else {
// 首次登录成功之后上传deviceToken
NSData *deviceToken =
@@ -126,22 +127,23 @@ - (void)addObserver {
}
}];
}
+
- (void)updateUserInfo:(NEUser *)user {
- NSMutableDictionary *ext = [NSMutableDictionary dictionary];
- if (user.mobile) {
- [ext setObject:user.mobile forKey:@(NIMUserInfoUpdateTagMobile)];
- }
- if (user.avatar) {
- [ext setObject:user.avatar forKey:@(NIMUserInfoUpdateTagAvatar)];
- }
- [NIMSDK.sharedSDK.userManager updateMyUserInfo:ext.copy
- completion:^(NSError *_Nullable error) {
- if (error) {
- NSLog(@"updateUserInfo error:%@", error);
- return;
- }
- }];
+ V2NIMUserUpdateParams *param = [[V2NIMUserUpdateParams alloc] init];
+ param.avatar = user.avatar;
+ param.mobile = user.mobile;
+
+ [[NIMSDK sharedSDK].v2UserService updateSelfUserProfile:param
+ success:^{
+ }
+ failure:^(V2NIMError *_Nonnull error) {
+ if (error) {
+ NSLog(@"updateUserInfo error:%@", error);
+ return;
+ }
+ }];
}
+
- (void)removeObserver {
[[NERtcCallKit sharedInstance] removeDelegate:self];
[NEAccount removeObserverForObject:self];
@@ -225,66 +227,71 @@ - (void)onInvited:(NSString *)invitor
NSLog(@"callee view show in call ui kit");
return;
}
- [NIMSDK.sharedSDK.userManager
- fetchUserInfos:@[ invitor ]
- completion:^(NSArray *_Nullable users, NSError *_Nullable error) {
- if (error) {
- [self.view ne_makeToast:error.description];
- return;
- } else {
- NIMUser *imUser = users.firstObject;
-
- NEUser *remoteUser = [[NEUser alloc] init];
- remoteUser.imAccid = imUser.userId;
- remoteUser.mobile = imUser.userInfo.mobile;
- remoteUser.avatar = imUser.userInfo.avatarUrl;
-
- NEPSTNViewController *callVC = [[NEPSTNViewController alloc] init];
- callVC.localUser = [NEAccount shared].userModel;
- callVC.remoteUser = remoteUser;
- callVC.status = NERtcCallStatusCalled;
- callVC.callType = type;
- callVC.isCaller = NO;
- if (type == NERtcCallTypeAudio) {
- callVC.callKitType = PSTN;
- } else {
- callVC.callKitType = CALLKIT;
- }
- callVC.modalPresentationStyle = UIModalPresentationOverFullScreen;
- [self.navigationController presentViewController:callVC animated:YES completion:nil];
-
- /*
- if (type == NERtcCallTypeAudio) {
- NEUser *remoteUser = [[NEUser alloc] init];
- remoteUser.imAccid = imUser.userId;
- remoteUser.mobile = imUser.userInfo.mobile;
- remoteUser.avatar = imUser.userInfo.avatarUrl;
-
- NEPSTNViewController *callVC = [[NEPSTNViewController alloc] init];
- callVC.localUser = [NEAccount shared].userModel;
- callVC.remoteUser = remoteUser;
- callVC.status = NERtcCallStatusCalled;
- callVC.callType = type;
- callVC.isCaller = NO;
- callVC.callKitType = PSTN;
- callVC.modalPresentationStyle = UIModalPresentationOverFullScreen;
- [self.navigationController presentViewController:callVC animated:YES
- completion:nil]; }else { NECallViewController *callVC = [[NECallViewController
- alloc] init]; NEUICallParam *callParam = [[NEUICallParam alloc] init];
- callParam.remoteUserAccid = imUser.userId;
- callParam.remoteShowName = imUser.userInfo.mobile;
- callParam.remoteAvatar = imUser.userInfo.avatarUrl;
- callParam.currentUserAccid = [NEAccount shared].userModel.imAccid;
- callVC.callParam = callParam;
- callVC.isCaller = NO;
- callVC.status = NERtcCallStatusCalled;
- callVC.callType = type;
- callVC.modalPresentationStyle = UIModalPresentationOverFullScreen;
- [self.navigationController presentViewController:callVC animated:YES
- completion:nil];
- }*/
- }
- }];
+
+ [NIMSDK.sharedSDK.v2UserService getUserListFromCloud:@[ invitor ]
+ success:^(NSArray *_Nonnull result) {
+ if (result.count < 1) {
+ return;
+ }
+
+ V2NIMUser *user = result.firstObject;
+
+ NEUser *remoteUser = [[NEUser alloc] init];
+ remoteUser.imAccid = user.accountId;
+ remoteUser.mobile = user.mobile;
+ remoteUser.avatar = user.avatar;
+
+ NEPSTNViewController *callVC = [[NEPSTNViewController alloc] init];
+ callVC.localUser = [NEAccount shared].userModel;
+ callVC.remoteUser = remoteUser;
+ callVC.status = NERtcCallStatusCalled;
+ callVC.callType = type;
+ callVC.isCaller = NO;
+ if (type == NERtcCallTypeAudio) {
+ callVC.callKitType = PSTN;
+ } else {
+ callVC.callKitType = CALLKIT;
+ }
+ callVC.modalPresentationStyle = UIModalPresentationOverFullScreen;
+ [self.navigationController presentViewController:callVC animated:YES completion:nil];
+ }
+ failure:^(V2NIMError *_Nonnull error) {
+ if (error) {
+ [self.view ne_makeToast:error.description];
+ return;
+ }
+ }];
+
+ /*
+ if (type == NERtcCallTypeAudio) {
+ NEUser *remoteUser = [[NEUser alloc] init];
+ remoteUser.imAccid = imUser.userId;
+ remoteUser.mobile = imUser.userInfo.mobile;
+ remoteUser.avatar = imUser.userInfo.avatarUrl;
+
+ NEPSTNViewController *callVC = [[NEPSTNViewController alloc] init];
+ callVC.localUser = [NEAccount shared].userModel;
+ callVC.remoteUser = remoteUser;
+ callVC.status = NERtcCallStatusCalled;
+ callVC.callType = type;
+ callVC.isCaller = NO;
+ callVC.callKitType = PSTN;
+ callVC.modalPresentationStyle = UIModalPresentationOverFullScreen;
+ [self.navigationController presentViewController:callVC animated:YES
+ completion:nil]; }else { NECallViewController *callVC = [[NECallViewController
+ alloc] init]; NEUICallParam *callParam = [[NEUICallParam alloc] init];
+ callParam.remoteUserAccid = imUser.userId;
+ callParam.remoteShowName = imUser.userInfo.mobile;
+ callParam.remoteAvatar = imUser.userInfo.avatarUrl;
+ callParam.currentUserAccid = [NEAccount shared].userModel.imAccid;
+ callVC.callParam = callParam;
+ callVC.isCaller = NO;
+ callVC.status = NERtcCallStatusCalled;
+ callVC.callType = type;
+ callVC.modalPresentationStyle = UIModalPresentationOverFullScreen;
+ [self.navigationController presentViewController:callVC animated:YES
+ completion:nil];
+ }*/
}
- (void)onGroupInvitedWithInfo:(NEGroupCallInfo *)info {
@@ -326,7 +333,7 @@ - (void)onGroupInvitedWithInfo:(NEGroupCallInfo *)info {
}
#pragma mark - IM delegate
-
+/* v1
- (void)willSendMessage:(NIMMessage *)message {
[self assmebleRecordWithMessage:message withCaller:YES];
}
@@ -334,8 +341,9 @@ - (void)willSendMessage:(NIMMessage *)message {
- (void)sendMessage:(NIMMessage *)message progress:(float)progress {
}
+
- (void)onRecvMessages:(NSArray *)messages {
- NSLog(@"onRecvMessages current account : %@", [NIMSDK.sharedSDK.loginManager currentAccount]);
+ NSLog(@"onRecvMessages current account : %@", [NIMSDK.sharedSDK.v2LoginService getLoginUser]);
for (NIMMessage *message in messages) {
if ([message.from isEqualToString:[NEAccount shared].userModel.imAccid]) {
[self assmebleRecordWithMessage:message withCaller:YES];
@@ -344,10 +352,29 @@ - (void)onRecvMessages:(NSArray *)messages {
[self assmebleRecordWithMessage:message withCaller:NO];
}
}
+*/
+
+- (void)onSendMessage:(V2NIMMessage *)message {
+ if (message.sendingState == V2NIM_MESSAGE_SENDING_STATE_SENDING) {
+ [self assmebleRecordWithV2Message:message withCaller:YES];
+ }
+}
+
+- (void)onReceiveMessages:(NSArray *)messages;
+{
+ NSLog(@"onRecvMessages current account : %@", [NIMSDK.sharedSDK.v2LoginService getLoginUser]);
+ for (V2NIMMessage *message in messages) {
+ if ([message.senderId isEqualToString:[NEAccount shared].userModel.imAccid]) {
+ [self assmebleRecordWithV2Message:message withCaller:YES];
+ return;
+ }
+ [self assmebleRecordWithV2Message:message withCaller:NO];
+ }
+}
#pragma mark - UITableViewDelegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return 1;
+ return 2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
@@ -460,38 +487,86 @@ - (void)assmebleRecordWithMessage:(NIMMessage *)message withCaller:(BOOL)isCalle
option.searchContent = message.from;
}
- [[[NIMSDK sharedSDK] userManager]
- fetchUserInfos:@[ record.imAccid ]
- completion:^(NSArray *_Nullable users, NSError *_Nullable error) {
- NIMUser *user = users.firstObject;
- NSLog(@"serch user : %lu", (unsigned long)users.count);
- if (user) {
- record.mobile = user.userInfo.mobile;
- record.avatar = user.userInfo.avatarUrl;
- NSLog(@"on call happen");
- [[NSNotificationCenter defaultCenter] postNotificationName:NERECORDADD
- object:record];
- } else {
- NSLog(@"search error : %@", error);
- }
- }];
-
- // [[[NIMSDK sharedSDK] userManager] searchUserWithOption:option
- // completion:^(NSArray * _Nullable users, NSError * _Nullable error) {
- // NIMUser *user = users.firstObject;
- // NSLog(@"serch user : %lu", (unsigned long)users.count);
- // if (user) {
- // record.mobile = user.userInfo.mobile;
- // record.avatar = user.userInfo.avatarUrl;
- // NSLog(@"on call happen");
- // [[NSNotificationCenter defaultCenter] postNotificationName:NERECORDADD
- // object:record];
- // }else {
- // NSLog(@"search error : %@", error);
- // }
- // }];
+ [NIMSDK.sharedSDK.v2UserService getUserListFromCloud:@[ record.imAccid ]
+ success:^(NSArray *_Nonnull result) {
+ if (result.count < 1) {
+ return;
+ }
+
+ V2NIMUser *user = result.firstObject;
+ NSLog(@"serch user : %lu", (unsigned long)result.count);
+ if (user) {
+ record.mobile = user.mobile;
+ record.avatar = user.avatar;
+ NSLog(@"on call happen");
+ [[NSNotificationCenter defaultCenter] postNotificationName:NERECORDADD object:record];
+ }
+ }
+ failure:^(V2NIMError *_Nonnull error) {
+ if (error) {
+ NSLog(@"search error : %@", error);
+ }
+ }];
}
}
}
+- (void)assmebleRecordWithV2Message:(V2NIMMessage *)message withCaller:(BOOL)isCaller {
+ if (message.messageType == V2NIM_MESSAGE_TYPE_CALL) {
+ NECallStatusRecordModel *record = [[NECallStatusRecordModel alloc] init];
+
+ if ([message.attachment isKindOfClass:[V2NIMMessageCallAttachment class]]) {
+ V2NIMMessageCallAttachment *recordObject = (V2NIMMessageCallAttachment *)message.attachment;
+ NSTimeInterval startTime = message.createTime;
+ record.isCaller = isCaller;
+ record.status = recordObject.status;
+ record.isVideoCall = recordObject.type == NIMRtcCallTypeVideo ? YES : NO;
+
+ if (recordObject.durations.count > 0) {
+ for (V2NIMMessageCallDuration *duration in recordObject.durations) {
+ if ([duration.accountId isEqualToString:[NEAccount shared].userModel.imAccid]) {
+ record.duration = duration.duration;
+ startTime = startTime - record.duration;
+ }
+ }
+ }
+ record.startTime = [NSDate dateWithTimeIntervalSince1970:startTime];
+
+ NIMUserSearchOption *option = [[NIMUserSearchOption alloc] init];
+ option.searchRange = NIMUserSearchRangeOptionAll;
+ option.searchContentOption = NIMUserSearchContentOptionUserId;
+
+ if (isCaller == YES) {
+ option.searchContent = message.receiverId;
+ record.imAccid = message.receiverId;
+
+ } else {
+ record.imAccid = message.senderId;
+ option.searchContent = message.senderId;
+ }
+ }
+
+ [NIMSDK.sharedSDK.v2UserService getUserListFromCloud:@[ record.imAccid ]
+ success:^(NSArray *_Nonnull result) {
+ if (result.count < 1) {
+ return;
+ }
+
+ V2NIMUser *user = result.firstObject;
+ NSLog(@"serch user : %lu", (unsigned long)result.count);
+ if (user) {
+ record.mobile = user.mobile;
+ record.avatar = user.avatar;
+ NSLog(@"on call happen");
+ [[NSNotificationCenter defaultCenter] postNotificationName:NERECORDADD object:record];
+ }
+ }
+ failure:^(V2NIMError *_Nonnull error) {
+ if (error) {
+ NSLog(@"search error : %@", error);
+ }
+ }];
+ }
+}
+
@end
diff --git a/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/UI/ViewController/NECallUISettingViewController.h b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/UI/ViewController/NECallUISettingViewController.h
new file mode 100644
index 0000000..106c23a
--- /dev/null
+++ b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/UI/ViewController/NECallUISettingViewController.h
@@ -0,0 +1,13 @@
+//// Copyright (c) 2022 NetEase, Inc. All rights reserved.
+// Use of this source code is governed by a MIT license that can be
+// found in the LICENSE file.
+
+#import "NECallBaseViewController.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface NECallUISettingViewController : NECallBaseViewController
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/UI/ViewController/NECallUISettingViewController.m b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/UI/ViewController/NECallUISettingViewController.m
new file mode 100644
index 0000000..5b0c7ab
--- /dev/null
+++ b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/UI/ViewController/NECallUISettingViewController.m
@@ -0,0 +1,186 @@
+//// Copyright (c) 2022 NetEase, Inc. All rights reserved.
+// Use of this source code is governed by a MIT license that can be
+// found in the LICENSE file.
+
+#import "NECallUISettingViewController.h"
+
+@interface NECallUISettingViewController ()
+
+@end
+
+@implementation NECallUISettingViewController
+
+- (void)viewDidLoad {
+ [super viewDidLoad];
+ // Do any additional setup after loading the view.
+ self.view.backgroundColor = [UIColor colorWithRed:36 / 255.0
+ green:36 / 255.0
+ blue:45 / 255.0
+ alpha:1.0];
+ self.navigationItem.leftBarButtonItem.title = @"返回";
+ self.navigationItem.title = @"UI设置";
+ [self setupUI];
+}
+
+- (void)setupUI {
+ // 生成一个居左的标签,显示是否开启小窗功能
+ UILabel *floatWindow = [[UILabel alloc] init];
+ floatWindow.translatesAutoresizingMaskIntoConstraints = NO;
+ floatWindow.textColor = [UIColor whiteColor];
+ floatWindow.text = @"小窗功能";
+ [self.view addSubview:floatWindow];
+ [NSLayoutConstraint activateConstraints:@[
+ [floatWindow.topAnchor constraintEqualToAnchor:self.view.topAnchor constant:80],
+ [floatWindow.leftAnchor constraintEqualToAnchor:self.view.leftAnchor constant:20],
+ [floatWindow.heightAnchor constraintEqualToConstant:30]
+ ]];
+
+ // 生成一个 UISwitch,用于控制是否开启小窗功能
+ UISwitch *floatSwitch = [[UISwitch alloc] init];
+ floatSwitch.translatesAutoresizingMaskIntoConstraints = NO;
+ [floatSwitch addTarget:self
+ action:@selector(floatSwitchAction:)
+ forControlEvents:UIControlEventValueChanged];
+ [self.view addSubview:floatSwitch];
+ [NSLayoutConstraint activateConstraints:@[
+ [floatSwitch.rightAnchor constraintEqualToAnchor:self.view.rightAnchor constant:-20],
+ [floatSwitch.centerYAnchor constraintEqualToAnchor:floatWindow.centerYAnchor],
+ ]];
+
+ // 生成一个标签,显示是否开启应用外浮窗功能
+ UILabel *floatWindowOutApp = [[UILabel alloc] init];
+ floatWindowOutApp.translatesAutoresizingMaskIntoConstraints = NO;
+ floatWindowOutApp.textColor = [UIColor whiteColor];
+ floatWindowOutApp.text = @"应用外浮窗功能";
+ [self.view addSubview:floatWindowOutApp];
+ [NSLayoutConstraint activateConstraints:@[
+ [floatWindowOutApp.topAnchor constraintEqualToAnchor:floatWindow.bottomAnchor constant:20],
+ [floatWindowOutApp.leftAnchor constraintEqualToAnchor:self.view.leftAnchor constant:20],
+ [floatWindowOutApp.heightAnchor constraintEqualToConstant:30]
+ ]];
+
+ // 生成一个 UISwitch,用于控制是否开启应用外浮窗功能
+ UISwitch *floatSwitchOutApp = [[UISwitch alloc] init];
+ floatSwitchOutApp.translatesAutoresizingMaskIntoConstraints = NO;
+ [floatSwitchOutApp addTarget:self
+ action:@selector(floatSwitchOutAppAction:)
+ forControlEvents:UIControlEventValueChanged];
+ [self.view addSubview:floatSwitchOutApp];
+ [NSLayoutConstraint activateConstraints:@[
+ [floatSwitchOutApp.rightAnchor constraintEqualToAnchor:self.view.rightAnchor constant:-20],
+ [floatSwitchOutApp.centerYAnchor constraintEqualToAnchor:floatWindowOutApp.centerYAnchor],
+ ]];
+
+ // 生成一个label,是否开启被叫预览功能
+ UILabel *calleePreview = [[UILabel alloc] init];
+ calleePreview.translatesAutoresizingMaskIntoConstraints = NO;
+ calleePreview.textColor = [UIColor whiteColor];
+ calleePreview.text = @"被叫预览功能";
+ [self.view addSubview:calleePreview];
+ [NSLayoutConstraint activateConstraints:@[
+ [calleePreview.topAnchor constraintEqualToAnchor:floatWindowOutApp.bottomAnchor constant:20],
+ [calleePreview.leftAnchor constraintEqualToAnchor:self.view.leftAnchor constant:20],
+ [calleePreview.heightAnchor constraintEqualToConstant:30]
+ ]];
+
+ // 生成一个 UISwitch,用于控制是否开启被叫预览功能
+ UISwitch *calleePreviewSwitch = [[UISwitch alloc] init];
+ calleePreviewSwitch.translatesAutoresizingMaskIntoConstraints = NO;
+ [calleePreviewSwitch addTarget:self
+ action:@selector(calleePreviewSwitchAction:)
+ forControlEvents:UIControlEventValueChanged];
+ [self.view addSubview:calleePreviewSwitch];
+ [NSLayoutConstraint activateConstraints:@[
+ [calleePreviewSwitch.rightAnchor constraintEqualToAnchor:self.view.rightAnchor constant:-20],
+ [calleePreviewSwitch.centerYAnchor constraintEqualToAnchor:calleePreview.centerYAnchor],
+ ]];
+
+ // 生成一个 label,显示是否开启虚化
+ UILabel *blur = [[UILabel alloc] init];
+ blur.translatesAutoresizingMaskIntoConstraints = NO;
+ blur.textColor = [UIColor whiteColor];
+ blur.text = @"虚化";
+ [self.view addSubview:blur];
+ [NSLayoutConstraint activateConstraints:@[
+ [blur.topAnchor constraintEqualToAnchor:calleePreview.bottomAnchor constant:20],
+ [blur.leftAnchor constraintEqualToAnchor:self.view.leftAnchor constant:20],
+ [blur.heightAnchor constraintEqualToConstant:30]
+ ]];
+
+ // 生成一个 UISwitch,用于控制是否开启虚化
+ UISwitch *blurSwitch = [[UISwitch alloc] init];
+ blurSwitch.translatesAutoresizingMaskIntoConstraints = NO;
+ [blurSwitch addTarget:self
+ action:@selector(blurSwitchAction:)
+ forControlEvents:UIControlEventValueChanged];
+ [self.view addSubview:blurSwitch];
+ [NSLayoutConstraint activateConstraints:@[
+ [blurSwitch.rightAnchor constraintEqualToAnchor:self.view.rightAnchor constant:-20],
+ [blurSwitch.centerYAnchor constraintEqualToAnchor:blur.centerYAnchor],
+ ]];
+
+ // 获取小窗配置,设置小窗switch值
+ BOOL floatWindowValue = [[[NERtcCallUIKit sharedInstance]
+ valueForKeyPath:@"config.uiConfig.enableFloatingWindow"] boolValue];
+ [floatSwitch setOn:floatWindowValue];
+
+ // 获取应用外浮窗配置,设置应用外浮窗switch值
+ BOOL floatWindowOutAppValue = [[[NERtcCallUIKit sharedInstance]
+ valueForKeyPath:@"config.uiConfig.enableFloatingWindowOutOfApp"] boolValue];
+ [floatSwitchOutApp setOn:floatWindowOutAppValue];
+
+ // 获取被叫预览配置,设置被叫预览switch值
+ BOOL calleePreviewValue = [[[NERtcCallUIKit sharedInstance]
+ valueForKeyPath:@"config.uiConfig.enableCalleePreview"] boolValue];
+ [calleePreviewSwitch setOn:calleePreviewValue];
+
+ // 获取虚化配置,设置虚化switch值
+ BOOL blurValue = [[[NERtcCallUIKit sharedInstance]
+ valueForKeyPath:@"config.uiConfig.enableVirtualBackground"] boolValue];
+ [blurSwitch setOn:blurValue];
+}
+
+// 小窗开关的响应函数
+- (void)floatSwitchAction:(UISwitch *)sender {
+ // 设置 NECallUIConfig 的 enableFloatingWindow 属性
+ // 用于控制是否开启小窗功能
+ [[NERtcCallUIKit sharedInstance] setValue:[NSNumber numberWithBool:sender.on]
+ forKeyPath:@"config.uiConfig.enableFloatingWindow"];
+}
+
+// 应用外浮窗开关的响应函数
+- (void)floatSwitchOutAppAction:(UISwitch *)sender {
+ // 设置 NECallUIConfig 的 enableFloatingWindowOutApp 属性
+ // 用于控制是否开启应用外浮窗功能
+ [[NERtcCallUIKit sharedInstance] setValue:[NSNumber numberWithBool:sender.on]
+ forKeyPath:@"config.uiConfig.enableFloatingWindowOutOfApp"];
+}
+
+// 被叫预览开关的响应函数
+- (void)calleePreviewSwitchAction:(UISwitch *)sender {
+ // 设置 NECallUIConfig 的 enableCalleePreview 属性
+ // 用于控制是否开启被叫预览功能
+ [[NERtcCallUIKit sharedInstance] setValue:[NSNumber numberWithBool:sender.on]
+ forKeyPath:@"config.uiConfig.enableCalleePreview"];
+}
+
+// 虚化开关的响应函数
+- (void)blurSwitchAction:(UISwitch *)sender {
+ // 设置 NECallUIConfig 的 enableBlur 属性
+ // 用于控制是否开启虚化
+ [[NERtcCallUIKit sharedInstance] setValue:[NSNumber numberWithBool:sender.on]
+ forKeyPath:@"config.uiConfig.enableVirtualBackground"];
+}
+
+/*
+#pragma mark - Navigation
+
+// In a storyboard-based application, you will often want to do a little preparation before
+navigation
+- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
+ // Get the new view controller using [segue destinationViewController].
+ // Pass the selected object to the new view controller.
+}
+*/
+
+@end
diff --git a/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/UI/ViewController/NEPSTNViewController.m b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/UI/ViewController/NEPSTNViewController.m
index 5b63c47..704a6b1 100644
--- a/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/UI/ViewController/NEPSTNViewController.m
+++ b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/UI/ViewController/NEPSTNViewController.m
@@ -3,11 +3,7 @@
// found in the LICENSE file.
#import "NEPSTNViewController.h"
-#import
#import "NERtcCallKit+Demo.h"
-#import
-#import
-#import
#import "SettingManager.h"
@interface NEPSTNViewController ()
@@ -335,36 +331,9 @@ - (void)setupUI {
}];
[self.speakerBtn setHidden:YES];
- /*
- [[self.mediaSwitchBtn.maskBtn rac_signalForControlEvents:UIControlEventTouchUpInside]
- subscribeNext:^(__kindof UIControl *_Nullable x) {
- if ([[NetManager shareInstance] isClose] == YES) {
- [weakSelf.view ne_makeToast:@"网络连接异常,请稍后再试"];
- return;
- }
- weakSelf.mediaSwitchBtn.maskBtn.enabled = NO;
- NERtcCallType type =
- weakSelf.callType == NERtcCallTypeVideo ? NERtcCallTypeAudio : NERtcCallTypeVideo;
- [[NERtcCallKit sharedInstance]
- switchCallType:type
- withState:NERtcSwitchStateInvite
- completion:^(NSError *_Nullable error) {
- weakSelf.mediaSwitchBtn.maskBtn.enabled = YES;
- if (error == nil) {
- NSLog(@"切换成功 : %lu", type);
- if (type == NERtcCallTypeVideo &&
- [SettingManager.shareInstance isVideoConfirm]) {
- [weakSelf showBannerView];
- } else if (type == NERtcCallTypeAudio &&
- [SettingManager.shareInstance isAudioConfirm]) {
- [weakSelf showBannerView];
- }
- } else {
- [weakSelf.view ne_makeToast:[NSString stringWithFormat:@"切换失败:%@", error]];
- }
- }];
- }];
- */
+ [self.mediaSwitchBtn.maskBtn addTarget:self
+ action:@selector(mediaSwitchClick)
+ forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:self.timerLabel];
[self.timerLabel mas_makeConstraints:^(MASConstraintMaker *make) {
@@ -375,6 +344,35 @@ - (void)setupUI {
self.mediaSwitchBtn.hidden = ![[SettingManager shareInstance] supportAutoJoinWhenCalled];
}
+- (void)mediaSwitchClick {
+ if ([[NetManager shareInstance] isClose] == YES) {
+ [self.view ne_makeToast:@"网络连接异常,请稍后再试"];
+ return;
+ }
+ self.mediaSwitchBtn.maskBtn.enabled = NO;
+ NERtcCallType type =
+ self.callType == NERtcCallTypeVideo ? NERtcCallTypeAudio : NERtcCallTypeVideo;
+ __weak typeof(self) weakSelf = self;
+
+ [[NERtcCallKit sharedInstance]
+ switchCallType:type
+ withState:NERtcSwitchStateInvite
+ completion:^(NSError *_Nullable error) {
+ weakSelf.mediaSwitchBtn.maskBtn.enabled = YES;
+ if (error == nil) {
+ NSLog(@"切换成功 : %lu", type);
+ if (type == NERtcCallTypeVideo && [SettingManager.shareInstance isVideoConfirm]) {
+ [weakSelf showBannerView];
+ } else if (type == NERtcCallTypeAudio &&
+ [SettingManager.shareInstance isAudioConfirm]) {
+ [weakSelf showBannerView];
+ }
+ } else {
+ [weakSelf.view ne_makeToast:[NSString stringWithFormat:@"切换失败:%@", error]];
+ }
+ }];
+}
+
- (void)setupPSTNUI {
self.mediaSwitchBtn.hidden = YES;
self.remoteAvatorView.hidden = YES;
@@ -1053,7 +1051,8 @@ - (void)onCallTypeChange:(NERtcCallType)callType withState:(NERtcSwitchState)sta
break;
case NERtcSwitchStateReject:
[self hideBannerView];
- [UIApplication.sharedApplication.keyWindow ne_makeToast:NSLocalizedString(@"reject_tip", nil)];
+ [UIApplication.sharedApplication.keyWindow
+ ne_makeToast:NSLocalizedString(@"reject_tip", nil)];
break;
default:
break;
@@ -1232,11 +1231,10 @@ - (UIView *)bannerView {
closeBtn.backgroundColor = [UIColor clearColor];
[closeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[closeBtn setTitle:@"X" forState:UIControlStateNormal];
- __weak typeof(self) weakSelf = self;
-// [[closeBtn rac_signalForControlEvents:UIControlEventTouchUpInside]
-// subscribeNext:^(__kindof UIControl *_Nullable x) {
-// [weakSelf hideBannerView];
-// }];
+
+ [closeBtn addTarget:self
+ action:@selector(closeEvent)
+ forControlEvents:UIControlEventTouchUpInside];
[closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.bottom.right.equalTo(_bannerView);
make.width.mas_equalTo(40);
@@ -1256,6 +1254,10 @@ - (UIView *)bannerView {
return _bannerView;
}
+- (void)closeEvent {
+ [self hideBannerView];
+}
+
- (NEVideoView *)bigVideoView {
if (!_bigVideoView) {
_bigVideoView = [[NEVideoView alloc] init];
diff --git a/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/UI/ViewController/NERtcContactsViewController.m b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/UI/ViewController/NERtcContactsViewController.m
index 6739933..d8f8d2e 100644
--- a/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/UI/ViewController/NERtcContactsViewController.m
+++ b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/NERtcVideoCall/UI/ViewController/NERtcContactsViewController.m
@@ -6,6 +6,7 @@
#import
#import "NEAccount.h"
#import "NECallStatusRecordCell.h"
+#import "NECallUISettingViewController.h"
#import "NEPSTNViewController.h"
#import "NERtcSettingViewController.h"
#import "NESearchResultCell.h"
@@ -13,7 +14,6 @@
#import "NESectionHeaderView.h"
#import "NSArray+NTES.h"
#import "NSMacro.h"
-#import
@interface NERtcContactsViewController () 3) {
+ [UIApplication.sharedApplication.keyWindow ne_makeToast:@"初始化模式值为1-3区间整数"];
+ return;
+ }
+
+ [[NECallEngine sharedInstance] setValue:[NSNumber numberWithInteger:initModeInt]
+ forKeyPath:@"context.initRtcMode"];
+
NSString *time = self.timeoutField.text;
if (time.length <= 0) {
[self.timeoutField resignFirstResponder];
@@ -588,10 +601,6 @@ - (void)uploadIMLog {
- (UIScrollView *)contentScroll {
if (!_contentScroll) {
_contentScroll = [[UIScrollView alloc] init];
- // [_contentScroll addSubview:self.stackView];
- // [self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.edges.equalTo(_contentScroll);
- // }];
_contentScroll.bounces = YES;
}
return _contentScroll;
diff --git a/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/Utils/Manager/DataManager.m b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/Utils/Manager/DataManager.m
index 1fcaa23..3839f05 100644
--- a/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/Utils/Manager/DataManager.m
+++ b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/Utils/Manager/DataManager.m
@@ -25,23 +25,28 @@ - (void)fetchUserWithMembers:(NSArray *)members
[accids addObject:member.imAccid];
[dict setObject:member forKey:member.imAccid];
}
- [NIMSDK.sharedSDK.userManager
- fetchUserInfos:accids
- completion:^(NSArray *_Nullable users, NSError *_Nullable error) {
- NSMutableArray *usersArray = [[NSMutableArray alloc] init];
- for (NIMUser *user in users) {
- NEUser *neUser = [[NEUser alloc] init];
- neUser.imAccid = user.userId;
- neUser.mobile = user.userInfo.mobile;
- neUser.avatar = user.userInfo.avatarUrl;
- GroupCallMember *member = [dict objectForKey:neUser.imAccid];
- neUser.uid = member.rtcUid;
- neUser.state = member.state;
- neUser.isOpenVideo = member.isOpenVideo;
- [usersArray addObject:neUser];
- }
- completion(error, usersArray);
- }];
+
+ [NIMSDK.sharedSDK.v2UserService getUserList:accids
+ success:^(NSArray *_Nonnull result) {
+ NSMutableArray *usersArray = [[NSMutableArray alloc] init];
+ for (V2NIMUser *user in result) {
+ NEUser *neUser = [[NEUser alloc] init];
+ neUser.imAccid = user.accountId;
+ neUser.mobile = user.mobile;
+ neUser.avatar = user.avatar;
+ GroupCallMember *member = [dict objectForKey:neUser.imAccid];
+ neUser.uid = member.rtcUid;
+ neUser.state = member.state;
+ neUser.isOpenVideo = member.isOpenVideo;
+ [usersArray addObject:neUser];
+ }
+ completion(nil, usersArray);
+ }
+ failure:^(V2NIMError *_Nonnull error) {
+ NSMutableArray *usersArray = [[NSMutableArray alloc] init];
+ completion(error.nserror, usersArray);
+ }];
}
+
@end
diff --git a/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/Utils/Manager/SettingManager.m b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/Utils/Manager/SettingManager.m
index aaca022..bf791fd 100644
--- a/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/Utils/Manager/SettingManager.m
+++ b/NLiteAVDemo-iOS-ObjC/NLiteAVDemo/Utils/Manager/SettingManager.m
@@ -56,6 +56,8 @@ - (uint64_t)getCallKitUid {
- (void)setAutoJoin:(BOOL)autoJoin {
[[NECallEngine sharedInstance] setValue:[NSNumber numberWithBool:autoJoin]
forKeyPath:@"context.supportAutoJoinWhenCalled"];
+ [[NERtcCallUIKit sharedInstance] setValue:[NSNumber numberWithInt:autoJoin]
+ forKeyPath:@"config.uiConfig.showCallingSwitchCallType"];
self.supportAutoJoinWhenCalled = autoJoin;
}
@@ -75,7 +77,7 @@ - (instancetype)init {
if (showCname != nil) {
self.incallShowCName = [showCname boolValue];
}
- NSLog(@"current accid : %@", NIMSDK.sharedSDK.loginManager.currentAccount);
+ NSLog(@"current accid : %@", [NIMSDK.sharedSDK.v2LoginService getLoginUser]);
}
return self;
}
diff --git a/NLiteAVDemo-iOS-ObjC/Podfile b/NLiteAVDemo-iOS-ObjC/Podfile
index c56f1db..5eb349c 100644
--- a/NLiteAVDemo-iOS-ObjC/Podfile
+++ b/NLiteAVDemo-iOS-ObjC/Podfile
@@ -5,8 +5,8 @@ source 'https://github.com/CocoaPods/Specs.git'
target 'NLiteAVDemo' do
use_frameworks!
# 云信基础SDK
- pod 'NERtcSDK', '5.5.2'
- pod 'NIMSDK_LITE', '9.16.1'
+ pod 'NERtcSDK', '5.6.50'
+ pod 'NIMSDK_LITE', '10.6.0'
pod 'NECallKitPstn', :path => 'CallKit/NECallKitPstn/NECallKitPstn.podspec'
@@ -14,12 +14,10 @@ target 'NLiteAVDemo' do
pod 'Masonry'
#呼叫组件API组件
- pod 'NERtcCallKit', '2.5.0'
+ pod 'NERtcCallKit', '3.3.0'
#呼叫组件UI组件
- pod 'NERtcCallUIKit', '2.5.0'
-
- pod 'NETranscodingKit'
+ pod 'NERtcCallUIKit', '3.3.0'
#如果需要查看呼叫组件UI组件源码请注释远端引用,打开下面本地引用
#pod 'NERtcCallUIKit', :path => 'CallKit/NERtcCallUIKit/NERtcCallUIKit.podspec'