加入了多房间登录操作来解决同一设备推流同时拉流

This commit is contained in:
董宏宇
2021-03-02 18:30:44 +08:00
parent 5e5980886d
commit c7b610efc8
13 changed files with 429 additions and 119 deletions

View File

@@ -8,6 +8,7 @@ import android.view.SurfaceView;
import com.mogo.cloud.live.listener.ILiveProgressListener;
import com.mogo.cloud.live.listener.IRequestLiveListener;
import com.mogo.cloud.live.manager.MoGoLiveManager;
import com.mogo.cloud.live.manager.MoGoLivePushConfig;
import com.mogo.cloud.live.manager.RequestLiveManager;
import com.mogo.cloud.passport.MoGoAiCloudClient;
import com.mogo.cloud.trafficlive.api.ITrafficLiveCallBack;
@@ -65,18 +66,27 @@ public class TrafficLiveManager implements ILiveProgressListener {
Logger.i(TAG, "主播开始直播了 systemClock :" + SystemClock.elapsedRealtime() + " SystemTime : " + System.currentTimeMillis());
String sn = MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getSn();
mStreamId = MoGoLiveManager.STREAM_ID_PREFIX + liveSn;
MoGoLiveManager.getInstance().init(application, null);
MoGoLiveManager.getInstance().loginRoom(sn, liveSn);
// 初始化配置文件
MoGoLivePushConfig mLivePushConfig = MoGoLivePushConfig.getInstance();
mLivePushConfig.setDevicesId(sn);
MoGoLiveManager.getInstance().init(application, mLivePushConfig);
MoGoLiveManager.getInstance().loginMultiRoom(liveSn);
MoGoLiveManager.getInstance().setLiveProgressListener(TrafficLiveManager.this);
// 直接 查看对应SN的直播
MoGoLiveManager.getInstance().startLive(surfaceView);
callBack.onLive();
if (callBack != null) {
callBack.onLive();
}
}
@Override
public void onError(Throwable e) {
callBack.onError(e.getMessage());
if (callBack != null) {
callBack.onError(e.getMessage());
}
}
});
}
@@ -93,7 +103,9 @@ public class TrafficLiveManager implements ILiveProgressListener {
@Override
public void onError(Throwable e) {
callBack.onError(e.getMessage());
if (callBack != null) {
callBack.onError(e.getMessage());
}
}
});
MoGoLiveManager.getInstance().stopLive();
@@ -109,34 +121,46 @@ public class TrafficLiveManager implements ILiveProgressListener {
@Override
public void onEngineStart() {
callBack.onLiveStart();
if (callBack != null) {
callBack.onLiveStart();
}
}
@Override
public void onEngineStop() {
callBack.onLiveStop();
if (callBack != null) {
callBack.onLiveStop();
}
}
@Override
public void onConnecting() {
callBack.onLiveConnecting();
if (callBack != null) {
callBack.onLiveConnecting();
}
}
@Override
public void onConnected(String roomId) {
isLoginSuccess = true;
callBack.onLiveConnected();
if (callBack != null) {
callBack.onLiveConnected();
}
}
@Override
public void onDisConnect() {
isLoginSuccess = false;
callBack.onDisConnect();
if (callBack != null) {
callBack.onDisConnect();
}
}
@Override
public void onDebugError(int errorCode, String funcName, String errorInfo) {
Logger.e(TAG, "onDebugError errorCode : " + errorCode + " funcName : " + funcName + " errorInfo : " + errorInfo);
callBack.onError(errorInfo);
if (callBack != null) {
callBack.onError(errorInfo);
}
}
}