[Change]修改推流流程,原因是衡阳环境中Socket下发指令有问题,现在改成了借用ZeGo的房间人数流程大于1人开始直播,否则关闭直播

This commit is contained in:
donghongyu
2021-11-24 16:39:40 +08:00
parent 3f42b0b190
commit e3dfbc8a7b
8 changed files with 42 additions and 15 deletions

17
.idea/deploymentTargetDropDown.xml generated Normal file
View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<runningDeviceTargetSelectedWithDropDown>
<Target>
<type value="RUNNING_DEVICE_TARGET" />
<deviceKey>
<Key>
<type value="SERIAL_NUMBER" />
<value value="HA1C6T8C" />
</Key>
</deviceKey>
</Target>
</runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2021-11-24T08:34:04.958113Z" />
</component>
</project>

6
.idea/misc.xml generated
View File

@@ -11,9 +11,13 @@
<component name="DesignSurface"> <component name="DesignSurface">
<option name="filePathToZoomLevelMap"> <option name="filePathToZoomLevelMap">
<map> <map>
<entry key="app/src/main/res/layout/activity_live_play_and_push.xml" value="0.1" /> <entry key="app/src/main/res/layout/actitity_config_info.xml" value="0.35260416666666666" />
<entry key="app/src/main/res/layout/activity_live_play_and_push.xml" value="0.25" />
<entry key="app/src/main/res/layout/activity_live_push.xml" value="0.3640625" /> <entry key="app/src/main/res/layout/activity_live_push.xml" value="0.3640625" />
<entry key="app/src/main/res/layout/activity_location.xml" value="0.36502448356535333" />
<entry key="app/src/main/res/layout/activity_main.xml" value="0.3640625" /> <entry key="app/src/main/res/layout/activity_main.xml" value="0.3640625" />
<entry key="app/src/main/res/layout/activity_real_time.xml" value="0.1609347442680776" />
<entry key="app/src/main/res/xml/network_security_config.xml" value="0.23854166666666668" />
</map> </map>
</option> </option>
</component> </component>

View File

@@ -46,12 +46,12 @@ public class MoGoApplication extends MultiDexApplication {
// 配置云服务API // 配置云服务API
MoGoAiCloudClientConfig clientConfig = MoGoAiCloudClientConfig.getInstance(); MoGoAiCloudClientConfig clientConfig = MoGoAiCloudClientConfig.getInstance();
// 设置网络环境HTTP_DNS_ENV_QA、HTTP_DNS_ENV_RELEASE、HTTP_DNS_ENV_DEV // 设置网络环境HTTP_DNS_ENV_QA、HTTP_DNS_ENV_RELEASE、HTTP_DNS_ENV_DEV
clientConfig.setNetMode(MogoHttpDnsConfig.HTTP_DNS_ENV_QA); clientConfig.setNetMode(MogoHttpDnsConfig.HTTP_DNS_ENV_RELEASE);
// 设置是否是第三APP登录false自有车机 true外部三方车机 // 设置是否是第三APP登录false自有车机 true外部三方车机
clientConfig.setThirdLogin(true); clientConfig.setThirdLogin(true);
// 设置是否输出日志 // 设置是否输出日志
clientConfig.setShowDebugLog(true); clientConfig.setShowDebugLog(true);
// 设置是否是直播推流的主播 // 设置是否是直播推流的主播 true-主播false-观众
clientConfig.setAnchor(false); clientConfig.setAnchor(false);
// 设置从蘑菇AI开放平台获取的APPKey // 设置从蘑菇AI开放平台获取的APPKey
clientConfig.setThirdPartyAppKey("pfieouqg"); clientConfig.setThirdPartyAppKey("pfieouqg");

View File

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

View File

@@ -205,7 +205,7 @@ public class LiveStreamManagerImpl implements ILiveStreamManager {
}; };
/** /**
* * 房间在线人数检测1=只有自己需要关闭推流,>1 代表有观众在观看需要开启推流
*/ */
private final Runnable mOnlineNumRun = () -> { private final Runnable mOnlineNumRun = () -> {
// 判断当前观众的个数,如果没人观看了的情况则停止直播 // 判断当前观众的个数,如果没人观看了的情况则停止直播
@@ -215,6 +215,8 @@ public class LiveStreamManagerImpl implements ILiveStreamManager {
if (mLivePusher.getLiveStatusModel().isPushing() && if (mLivePusher.getLiveStatusModel().isPushing() &&
mLivePusher.getLiveStatusModel().getOnlineNumber() <= 1) { mLivePusher.getLiveStatusModel().getOnlineNumber() <= 1) {
livePushHandler(PUSH_STOP, C1); livePushHandler(PUSH_STOP, C1);
} else {
livePushHandler(PUSH_START, C1);
} }
restartCheckOnlineNumLoop(); restartCheckOnlineNumLoop();
}; };

View File

@@ -12,6 +12,7 @@ import com.mogo.cloud.live.listener.ILiveRoomPersonListener;
import com.mogo.cloud.live.listener.ILiveStatusListener; import com.mogo.cloud.live.listener.ILiveStatusListener;
import com.mogo.cloud.live.listener.IMediaPlayerStateListener; import com.mogo.cloud.live.listener.IMediaPlayerStateListener;
import com.mogo.cloud.live.model.LiveStatusModel; import com.mogo.cloud.live.model.LiveStatusModel;
import com.mogo.cloud.live.server.PushService;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig; import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import org.json.JSONObject; import org.json.JSONObject;
@@ -261,7 +262,9 @@ public class MoGoLiveManager {
if (mLiveStatusModel.getCurrentRoomId().equals(roomID)) { if (mLiveStatusModel.getCurrentRoomId().equals(roomID)) {
// 更新真实的在线人数 // 更新真实的在线人数
mLiveStatusModel.setOnlineNumber(count); mLiveStatusModel.setOnlineNumber(count);
if (count > 2) {
PushService.startService(mApplication, PushService.ACTION_START_RTMP_PUSH);
}
Log.i(TAG, "房间内当前在线用户数量回调 onRoomOnlineUserCountUpdate roomID : " + roomID + Log.i(TAG, "房间内当前在线用户数量回调 onRoomOnlineUserCountUpdate roomID : " + roomID +
" , online user number : " + mLiveStatusModel.getOnlineNumber()); " , online user number : " + mLiveStatusModel.getOnlineNumber());
if (mRoomPersonListener != null) { if (mRoomPersonListener != null) {
@@ -307,12 +310,12 @@ public class MoGoLiveManager {
" , state : " + state.name() + " , state : " + state.name() +
" , errorCode : " + errorCode); " , errorCode : " + errorCode);
// 判断如果处于非播放和非推流状态则进行登出操作,并释放引擎 // // 判断如果处于非播放和非推流状态则进行登出操作,并释放引擎
if (!mLiveStatusModel.isPlaying() // if (!mLiveStatusModel.isPlaying()
&& !mLiveStatusModel.isPushing() // && !mLiveStatusModel.isPushing()
&& mLiveStatusModel.getOnlineNumber() <= 1) { // && mLiveStatusModel.getOnlineNumber() <= 1) {
logoutCurrentRoom(); // logoutCurrentRoom();
} // }
if (mLiveStatusListener != null) { if (mLiveStatusListener != null) {
mLiveStatusListener.onChange(mLiveStatusModel.isPushing() ? 0 : 1); mLiveStatusListener.onChange(mLiveStatusModel.isPushing() ? 0 : 1);
@@ -487,6 +490,7 @@ public class MoGoLiveManager {
mExpressEngine.setVideoConfig(zegoVideoConfig); mExpressEngine.setVideoConfig(zegoVideoConfig);
} }
initCustomVideoCapture(); initCustomVideoCapture();
loginRoom();
} }
/** /**

View File

@@ -100,7 +100,7 @@ public class PushService extends Service
// 设置登录房间的回调监听 // 设置登录房间的回调监听
mLivePusher.addLiveRoomStatusListener(this); mLivePusher.addLiveRoomStatusListener(this);
// 推流之前必须先登录房间 // 推流之前必须先登录房间
mLivePusher.loginRoom(); //mLivePusher.loginRoom();
} else { } else {
realStartPublish(); realStartPublish();
} }
@@ -126,7 +126,7 @@ public class PushService extends Service
// 停止发布 // 停止发布
mLivePusher.stopPublish(); mLivePusher.stopPublish();
// 退出房间 // 退出房间
mLivePusher.logoutCurrentRoom(); //mLivePusher.logoutCurrentRoom();
} }
// 移除视频回碉监听 // 移除视频回碉监听
CameraFrameManager.getInstance().rmYuvDataCallback(this); CameraFrameManager.getInstance().rmYuvDataCallback(this);

View File

@@ -27,7 +27,7 @@ SNAPSHOT_REPOSITORY_URL=http://nexus.zhidaoauto.com/repository/maven-snapshots/
USERNAME=xintai USERNAME=xintai
PASSWORD=xintai2018 PASSWORD=xintai2018
# 编译模式: false - 依赖本地版本, true - 依赖 maven 版本 # 编译模式: false - 依赖本地版本, true - 依赖 maven 版本
RELEASE=true RELEASE=false
# AI CLOUD 云平台 # AI CLOUD 云平台
# 工具类 # 工具类
MOGO_UTILS_VERSION=1.1.55-live MOGO_UTILS_VERSION=1.1.55-live