解决了直播SDK针对不同应用集成后出现被踢掉线的问题

1.0.58
This commit is contained in:
董宏宇
2021-03-15 12:42:39 +08:00
parent 6459885a2f
commit b5aa3c7af7
7 changed files with 50 additions and 17 deletions

View File

@@ -107,7 +107,7 @@ public class MainActivity extends AppCompatActivity {
* 初始化令牌信息
*/
private void initPassportInfo() {
tvAppKey.setText("AppKey" + MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getThirdPartyDeviceId());
tvAppKey.setText("AppKey" + MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getThirdPartyAppKey());
tvDevicesId.setText("DevicesId" + MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getThirdPartyDeviceId());
String sn = MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getSn();

View File

@@ -43,18 +43,19 @@ public class MoGoApplication extends MultiDexApplication {
MoGoAiCloudClientConfig clientConfig = MoGoAiCloudClientConfig.getInstance();
// 设置网络环境HTTP_DNS_ENV_QA、HTTP_DNS_ENV_RELEASE、HTTP_DNS_ENV_DEV
clientConfig.setNetMode(MogoHttpDnsConfig.HTTP_DNS_ENV_QA);
// 设置是否是第三APP登录false自有车机 true外部三方车机
clientConfig.setThirdLogin(false);
// 设置是否输出日志
clientConfig.setShowDebugLog(true);
// 设置是否是直播推流的主播
clientConfig.setAnchor(true);
// 设置从蘑菇AI开放平台获取的APPKey
clientConfig.setThirdPartyAppKey("wbvpzgar");
// 设置AI云平台分配给三方应用的签名密钥需要从AI云平台申请
// 设置车机设备的唯一标识(这些表识必须是通过后台录入的设备)
clientConfig.setThirdPartyDeviceId(Devices.getSn());
// 设置应用服务AppId 长链、鉴权 //todo 需要卸载智慧驾驶、行车记录仪
clientConfig.setServiceAppId("com.mogo.launcher");
clientConfig.setServiceAppId("com.zhidao.carcorder");
// 设置循环检测间隔时间
clientConfig.setLoopCheckDelay(15 * 1000);
// 设置是否属于高精定位设备

View File

@@ -104,7 +104,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="请输入要查看的车机SN"
android:text="F803EB2046PZD00149"
android:text="F803BB2037EZD00007"
android:textColor="#FFFF"
app:layout_constraintBottom_toTopOf="@+id/liveToggleBtn"
app:layout_constraintEnd_toEndOf="parent"

View File

@@ -480,9 +480,16 @@ public class MoGoLiveManager {
*/
public synchronized void loginRoom() {
// 当前用户ID
String userId = mLivePushConfig.getDevicesId();
mLiveStatusModel.setCurrentRoomId(ROOM_ID_PREFIX + mLivePushConfig.getDevicesId());
mLiveStatusModel.setCurrentStreamId(STREAM_ID_PREFIX + mLivePushConfig.getDevicesId());
String userId;
if (MoGoAiCloudClientConfig.getInstance().isAnchor()) {
// 这里为了方便直接使用原始的车机SN
userId = mLivePushConfig.getDevicesId();
} else {
// 这里对观众添加标记防止与主播的ID相同导致踢下线的情况发生
userId = "Audience_" + mLivePushConfig.getDevicesId();
}
mLiveStatusModel.setCurrentRoomId(ROOM_ID_PREFIX + userId);
mLiveStatusModel.setCurrentStreamId(STREAM_ID_PREFIX + userId);
Logger.i(TAG,
"尝试进入自己房间 loginRoom userId : " + userId
+ " currentRoomId" + mLiveStatusModel.getCurrentRoomId()

View File

@@ -42,7 +42,6 @@ public class PushService extends Service
Logger.i(TAG, "初始化推流服务……");
if (mLivePusher == null) {
mLivePusher = MoGoLiveManager.getInstance();
mLivePusher.addLiveRoomStatusListener(this);
}
}
@@ -98,6 +97,8 @@ public class PushService extends Service
return;
}
if (mLivePusher != null && !mLivePusher.getLiveStatusModel().isLoginCurrentRoom()) {
// 设置登录房间的回调监听
mLivePusher.addLiveRoomStatusListener(this);
// 推流之前必须先登录房间
mLivePusher.loginRoom();
} else {
@@ -118,6 +119,8 @@ public class PushService extends Service
*/
private void stopPush() {
try {
// 移除登录房间回调
mLivePusher.removeLiveRoomStatusListener(this);
// 是否处于发布状态
if (mLivePusher != null && mLivePusher.getLiveStatusModel().isPushing()) {
// 停止发布

View File

@@ -62,6 +62,12 @@ public class MoGoAiCloudClientConfig {
*/
private boolean isShowDebugLog = true;
/**
* 因为ZeGo的房间限制这里需要区分出SDK提供给的是观众还是主播
* true-主播false-观众
*/
private boolean isAnchor = true;
/**
* 服务器分配给应用的令牌,用于网络请求校验
*/
@@ -350,6 +356,22 @@ public class MoGoAiCloudClientConfig {
mServiceAppId = serviceAppId;
}
/**
* @return true-主播false-观众
*/
public boolean isAnchor() {
return isAnchor;
}
/**
* 设置是否是主播
*
* @param anchor true-主播false-观众
*/
public void setAnchor(boolean anchor) {
isAnchor = anchor;
}
/**
* 返回HttpDns的位置信息必须设置否则将无法使用网络请求
*

View File

@@ -27,23 +27,23 @@ SNAPSHOT_REPOSITORY_URL=http://nexus.zhidaoauto.com/repository/maven-snapshots/
USERNAME=xintai
PASSWORD=xintai2018
# 编译模式: false - 依赖本地版本, true - 依赖 maven 版本
RELEASE=false
RELEASE=true
# AI CLOUD 云平台
# 工具类
MOGO_UTILS_VERSION=1.0.57
MOGO_UTILS_VERSION=1.0.58
# 网络请求
MOGO_NETWORK_VERSION=1.0.57
MOGO_NETWORK_VERSION=1.0.58
# 网络DNS
MOGO_HTTPDNS_VERSION=1.0.57
MOGO_HTTPDNS_VERSION=1.0.58
# 鉴权
MOGO_PASSPORT_VERSION=1.0.57
MOGO_PASSPORT_VERSION=1.0.58
# 常链接
MOGO_SOCKET_VERSION=1.0.57
MOGO_SOCKET_VERSION=1.0.58
# 数据采集
MOGO_REALTIME_VERSION=1.0.58
# 探路,道路事件发布,获取
MOGO_TANLU_VERSION=1.0.57
MOGO_TANLU_VERSION=1.0.58
# 直播推流
MOGO_LIVE_VERSION=1.0.57
MOGO_LIVE_VERSION=1.0.58
# 直播拉流
MOGO_TRAFFICLIVE_VERSION=1.0.57
MOGO_TRAFFICLIVE_VERSION=1.0.58