Merge branch 'master' of http://gitlab.zhidaoauto.com/ITC/Apps/MoGoAiCloudSdk
This commit is contained in:
1
.idea/gradle.xml
generated
1
.idea/gradle.xml
generated
@@ -26,7 +26,6 @@
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveModulePerSourceSet" value="false" />
|
||||
<option name="useQualifiedModuleNames" value="true" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
|
||||
@@ -116,6 +116,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:textOff="登录第二个房间"
|
||||
android:textOn="退出第二个房间"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/etLookRoomId" />
|
||||
|
||||
|
||||
@@ -17,23 +17,6 @@ public interface ILiveProgressListener {
|
||||
default void onEngineStop() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 正在连接
|
||||
*/
|
||||
void onConnecting();
|
||||
|
||||
/**
|
||||
* 连接成功
|
||||
*
|
||||
* @param roomId 房间ID
|
||||
*/
|
||||
void onConnected(String roomId);
|
||||
|
||||
/**
|
||||
* 断开连接
|
||||
*/
|
||||
void onDisConnect();
|
||||
|
||||
/**
|
||||
* 调试错误信息回调
|
||||
*
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.mogo.cloud.live.listener;
|
||||
|
||||
/**
|
||||
* 直播房间的状态回调
|
||||
*/
|
||||
public interface ILiveRoomStatusListener {
|
||||
|
||||
/**
|
||||
* 自己的房间连接中回调
|
||||
*/
|
||||
void onCurrentRoomConnecting();
|
||||
|
||||
/**
|
||||
* 自己的房间连接成功回调
|
||||
*/
|
||||
void onCurrentRoomConnected();
|
||||
|
||||
/**
|
||||
* 自己的房间断开连接回调
|
||||
*/
|
||||
void onCurrentRoomDisconnected();
|
||||
|
||||
|
||||
////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* 与他人房间连接中回调
|
||||
*/
|
||||
void onMultiRoomConnecting();
|
||||
|
||||
/**
|
||||
* 与他人房间连接成功回调
|
||||
*/
|
||||
void onMultiRoomConnected();
|
||||
|
||||
/**
|
||||
* 与他人房间断开连接回调
|
||||
*/
|
||||
void onMultiRoomDisconnected();
|
||||
|
||||
}
|
||||
@@ -145,6 +145,8 @@ public class LiveStreamManagerImpl implements ILiveStreamManager {
|
||||
@Override
|
||||
public void release() {
|
||||
try {
|
||||
mHandler.removeCallbacks(mCamStatusRun);
|
||||
mHandler = null;
|
||||
mSocketMsgUtils.release();
|
||||
sCam1LiveStatus = 0;
|
||||
sCam2LiveStatus = 0;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.mogo.cloud.live.manager;
|
||||
|
||||
import android.app.Application;
|
||||
import android.os.Environment;
|
||||
import android.text.TextUtils;
|
||||
import android.view.SurfaceView;
|
||||
|
||||
import com.mogo.cloud.live.listener.ILiveProgressListener;
|
||||
import com.mogo.cloud.live.listener.ILiveRoomPersonListener;
|
||||
import com.mogo.cloud.live.listener.ILiveRoomStatusListener;
|
||||
import com.mogo.cloud.live.listener.ILiveStatusListener;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.cloud.utils.logger.Logger;
|
||||
@@ -35,7 +35,6 @@ import im.zego.zegoexpress.constants.ZegoViewMode;
|
||||
import im.zego.zegoexpress.entity.ZegoCanvas;
|
||||
import im.zego.zegoexpress.entity.ZegoCustomVideoCaptureConfig;
|
||||
import im.zego.zegoexpress.entity.ZegoEngineConfig;
|
||||
import im.zego.zegoexpress.entity.ZegoLogConfig;
|
||||
import im.zego.zegoexpress.entity.ZegoRoomConfig;
|
||||
import im.zego.zegoexpress.entity.ZegoRoomExtraInfo;
|
||||
import im.zego.zegoexpress.entity.ZegoUser;
|
||||
@@ -64,7 +63,6 @@ public class MoGoLiveManager {
|
||||
/**
|
||||
* 存储即构的日志路径
|
||||
*/
|
||||
private static final String ZEGO_LOG_PATH = Environment.getExternalStorageDirectory().getAbsolutePath() + "/ZegoLog";
|
||||
private Application mApplication;
|
||||
/**
|
||||
* 直播推送配置对象
|
||||
@@ -95,9 +93,13 @@ public class MoGoLiveManager {
|
||||
*/
|
||||
private ILiveProgressListener mProgressListener;
|
||||
/**
|
||||
* 直播房间状态
|
||||
* 直播房间连接状态
|
||||
*/
|
||||
private ILiveRoomPersonListener mRoomStatusListener;
|
||||
private ILiveRoomStatusListener mRoomStatusListener;
|
||||
/**
|
||||
* 直播房间人员状态
|
||||
*/
|
||||
private ILiveRoomPersonListener mRoomPersonListener;
|
||||
/**
|
||||
* 直播状态回调
|
||||
*/
|
||||
@@ -188,12 +190,6 @@ public class MoGoLiveManager {
|
||||
mLivePushConfig = livePushConfig;
|
||||
// 通过 advancedConfig 设置 uuid 过滤字段,设置之后 SDK 只会抛出前 12 个字节为开发者所设置 uuid 的 SEI
|
||||
ZegoEngineConfig zegoEngineConfig = new ZegoEngineConfig();
|
||||
// 设置即构的直播日志配置
|
||||
ZegoLogConfig zegoLogConfig = new ZegoLogConfig();
|
||||
// 存储日志路径
|
||||
zegoLogConfig.logPath = ZEGO_LOG_PATH;
|
||||
// 配置日志到引擎中
|
||||
zegoEngineConfig.logConfig = zegoLogConfig;
|
||||
// 设置配置到引擎中
|
||||
ZegoExpressEngine.setEngineConfig(zegoEngineConfig);
|
||||
|
||||
@@ -238,19 +234,35 @@ public class MoGoLiveManager {
|
||||
@Override
|
||||
public void onRoomStateUpdate(String roomID, ZegoRoomState state, int errorCode, JSONObject extendedData) {
|
||||
super.onRoomStateUpdate(roomID, state, errorCode, extendedData);
|
||||
// 这里只处理当前设备登录的房间中的用户总数
|
||||
// 这里回调的是当前用户的房间状态
|
||||
if (currentRoomId.equals(roomID)) {
|
||||
Logger.i(TAG, "onRoomStateUpdate roomID : " + roomID +
|
||||
" state:" + state +
|
||||
" errorCode:" + errorCode);
|
||||
//房间状态更新
|
||||
if (mProgressListener != null) {
|
||||
if (mRoomStatusListener != null) {
|
||||
if (state == ZegoRoomState.CONNECTING) {
|
||||
mProgressListener.onConnecting();
|
||||
mRoomStatusListener.onCurrentRoomConnecting();
|
||||
} else if (state == ZegoRoomState.CONNECTED) {
|
||||
mProgressListener.onConnected(roomID);
|
||||
mRoomStatusListener.onCurrentRoomConnected();
|
||||
} else {
|
||||
mProgressListener.onDisConnect();
|
||||
mRoomStatusListener.onCurrentRoomDisconnected();
|
||||
}
|
||||
}
|
||||
}
|
||||
// 这里回调的是登录的他人房间的状态
|
||||
if (multiRoomId.equals(roomID)) {
|
||||
Logger.i(TAG, "onRoomStateUpdate multiRoomId : " + roomID +
|
||||
" state:" + state +
|
||||
" errorCode:" + errorCode);
|
||||
//房间状态更新
|
||||
if (mRoomStatusListener != null) {
|
||||
if (state == ZegoRoomState.CONNECTING) {
|
||||
mRoomStatusListener.onMultiRoomConnecting();
|
||||
} else if (state == ZegoRoomState.CONNECTED) {
|
||||
mRoomStatusListener.onMultiRoomConnected();
|
||||
} else {
|
||||
mRoomStatusListener.onMultiRoomDisconnected();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -265,8 +277,8 @@ public class MoGoLiveManager {
|
||||
onlineNumber = count;
|
||||
Logger.i(TAG, "onRoomOnlineUserCountUpdate roomID : " + roomID +
|
||||
" , online user number : " + onlineNumber);
|
||||
if (mRoomStatusListener != null) {
|
||||
mRoomStatusListener.onRoomOnlineUserCountUpdate(count);
|
||||
if (mRoomPersonListener != null) {
|
||||
mRoomPersonListener.onRoomOnlineUserCountUpdate(count);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -280,8 +292,8 @@ public class MoGoLiveManager {
|
||||
Logger.i(TAG, "onRoomUserUpdate roomId : " + roomID +
|
||||
" , updateType : " + updateType.name() +
|
||||
" , online user number : " + onlineNumber);
|
||||
if (mRoomStatusListener != null) {
|
||||
mRoomStatusListener.onRoomUserUpdate(updateType, userList);
|
||||
if (mRoomPersonListener != null) {
|
||||
mRoomPersonListener.onRoomUserUpdate(updateType, userList);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -339,13 +351,22 @@ public class MoGoLiveManager {
|
||||
this.mProgressListener = liveProgressListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置直播间连接状态监听
|
||||
*
|
||||
* @param roomStatusListener 监听回调用
|
||||
*/
|
||||
public void setLiveRoomPersonListener(ILiveRoomStatusListener roomStatusListener) {
|
||||
this.mRoomStatusListener = roomStatusListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置直播间的人员监听
|
||||
*
|
||||
* @param roomPersonListener 监听回调用
|
||||
*/
|
||||
public void setLiveRoomPersonListener(ILiveRoomPersonListener roomPersonListener) {
|
||||
this.mRoomStatusListener = roomPersonListener;
|
||||
this.mRoomPersonListener = roomPersonListener;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -357,15 +378,6 @@ public class MoGoLiveManager {
|
||||
this.mLiveStatusListener = mLiveStatusListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* 销毁即构引擎
|
||||
*/
|
||||
private void destroyEngine() {
|
||||
ZegoExpressEngine.destroyEngine(() -> {
|
||||
Logger.i(TAG, "销毁ZeGo引擎");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 进入房间
|
||||
*
|
||||
@@ -479,11 +491,13 @@ public class MoGoLiveManager {
|
||||
* 退出房间
|
||||
*/
|
||||
public void logoutRoom() {
|
||||
Logger.i(TAG, "logoutRoom: " + currentRoomId);
|
||||
if (mExpressEngine == null) {
|
||||
return;
|
||||
}
|
||||
if (!TextUtils.isEmpty(currentRoomId)) {
|
||||
mExpressEngine.logoutRoom(currentRoomId);
|
||||
currentRoomId = "";
|
||||
}
|
||||
if (customVideoCaptureConfig == null) {
|
||||
// 创建自定义视频采集对象
|
||||
@@ -499,11 +513,13 @@ public class MoGoLiveManager {
|
||||
* 退出多房间
|
||||
*/
|
||||
public void logoutMultiRoom() {
|
||||
Logger.i(TAG, "logoutMultiRoom: " + multiRoomId);
|
||||
if (mExpressEngine == null) {
|
||||
return;
|
||||
}
|
||||
if (!TextUtils.isEmpty(multiRoomId)) {
|
||||
mExpressEngine.logoutRoom(multiRoomId);
|
||||
multiRoomId = "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -511,7 +527,7 @@ public class MoGoLiveManager {
|
||||
* 开始推送
|
||||
*/
|
||||
public void startPush() {
|
||||
Logger.d(TAG, "startPush currentStreamId: " + currentStreamId);
|
||||
Logger.i(TAG, "startPush currentStreamId: " + currentStreamId);
|
||||
mExpressEngine.startPublishingStream(currentStreamId);
|
||||
}
|
||||
|
||||
@@ -568,7 +584,6 @@ public class MoGoLiveManager {
|
||||
*/
|
||||
public void onDestroyPublish() {
|
||||
stopPublish();
|
||||
destroyEngine();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -616,7 +631,7 @@ public class MoGoLiveManager {
|
||||
* 停止观看直播
|
||||
*/
|
||||
public void onDestroyLive() {
|
||||
destroyEngine();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,13 @@ public class RequestLiveManager {
|
||||
return requestLiveManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求服务器查看指定车机开启或关闭直播
|
||||
*
|
||||
* @param type
|
||||
* @param liveSn
|
||||
* @param requestLiveListener
|
||||
*/
|
||||
public void requestVehicleHeadLive(String type, String liveSn, IRequestLiveListener requestLiveListener) {
|
||||
Gson gson = new Gson();
|
||||
LivePush livePush = new LivePush(liveSn, type, FRONT_CAMERA);
|
||||
|
||||
@@ -30,20 +30,20 @@ PASSWORD=xintai2018
|
||||
RELEASE=false
|
||||
# AI CLOUD 云平台
|
||||
# 工具类
|
||||
MOGO_UTILS_VERSION=1.0.51
|
||||
MOGO_UTILS_VERSION=1.0.54
|
||||
# 网络请求
|
||||
MOGO_NETWORK_VERSION=1.0.51
|
||||
MOGO_NETWORK_VERSION=1.0.54
|
||||
# 网络DNS
|
||||
MOGO_HTTPDNS_VERSION=1.0.51
|
||||
MOGO_HTTPDNS_VERSION=1.0.54
|
||||
# 鉴权
|
||||
MOGO_PASSPORT_VERSION=1.0.51
|
||||
MOGO_PASSPORT_VERSION=1.0.54
|
||||
# 常链接
|
||||
MOGO_SOCKET_VERSION=1.0.51
|
||||
MOGO_SOCKET_VERSION=1.0.54
|
||||
# 数据采集
|
||||
MOGO_REALTIME_VERSION=1.0.53
|
||||
MOGO_REALTIME_VERSION=1.0.54
|
||||
# 探路,道路事件发布,获取
|
||||
MOGO_TANLU_VERSION=1.0.51
|
||||
MOGO_TANLU_VERSION=1.0.54
|
||||
# 直播推流
|
||||
MOGO_LIVE_VERSION=1.0.51
|
||||
MOGO_LIVE_VERSION=1.0.54
|
||||
# 直播拉流
|
||||
MOGO_TRAFFICLIVE_VERSION=1.0.51
|
||||
MOGO_TRAFFICLIVE_VERSION=1.0.54
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.text.TextUtils;
|
||||
import android.view.SurfaceView;
|
||||
|
||||
import com.mogo.cloud.live.listener.ILiveProgressListener;
|
||||
import com.mogo.cloud.live.listener.ILiveRoomStatusListener;
|
||||
import com.mogo.cloud.live.listener.IRequestLiveListener;
|
||||
import com.mogo.cloud.live.manager.MoGoLiveManager;
|
||||
import com.mogo.cloud.live.manager.MoGoLivePushConfig;
|
||||
@@ -18,11 +19,11 @@ import static com.mogo.cloud.live.constant.LiveConstant.LIVE_TYPE_CLOSE;
|
||||
import static com.mogo.cloud.live.constant.LiveConstant.LIVE_TYPE_OPEN;
|
||||
import static com.mogo.cloud.trafficlive.constant.TrafficLiveConstant.TAG;
|
||||
|
||||
public class TrafficLiveManager implements ILiveProgressListener {
|
||||
public class TrafficLiveManager implements ILiveProgressListener, ILiveRoomStatusListener {
|
||||
|
||||
private static volatile TrafficLiveManager mInstance;
|
||||
private final RequestLiveManager requestLiveManager;
|
||||
private ITrafficLiveCallBack callBack;
|
||||
private ITrafficLiveCallBack trafficLiveCallBack;
|
||||
private SurfaceView surfaceView;
|
||||
private String mStreamId;
|
||||
private boolean isLoginSuccess = false;
|
||||
@@ -57,7 +58,7 @@ public class TrafficLiveManager implements ILiveProgressListener {
|
||||
throw new Exception("liveSn can not be null");
|
||||
}
|
||||
|
||||
this.callBack = trafficLiveCallBack;
|
||||
this.trafficLiveCallBack = trafficLiveCallBack;
|
||||
this.surfaceView = surfaceView;
|
||||
Logger.i(TAG, "申请拉流 systemClock :" + SystemClock.elapsedRealtime() + " SystemTime : " + System.currentTimeMillis());
|
||||
requestLiveManager.requestVehicleHeadLive(LIVE_TYPE_OPEN, liveSn, new IRequestLiveListener() {
|
||||
@@ -77,15 +78,15 @@ public class TrafficLiveManager implements ILiveProgressListener {
|
||||
|
||||
// 直接 查看对应SN的直播
|
||||
MoGoLiveManager.getInstance().startLive(surfaceView);
|
||||
if (callBack != null) {
|
||||
callBack.onLive();
|
||||
if (TrafficLiveManager.this.trafficLiveCallBack != null) {
|
||||
TrafficLiveManager.this.trafficLiveCallBack.onLive();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
if (callBack != null) {
|
||||
callBack.onError(e.getMessage());
|
||||
if (TrafficLiveManager.this.trafficLiveCallBack != null) {
|
||||
TrafficLiveManager.this.trafficLiveCallBack.onError(e.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -103,14 +104,14 @@ public class TrafficLiveManager implements ILiveProgressListener {
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
if (callBack != null) {
|
||||
callBack.onError(e.getMessage());
|
||||
if (trafficLiveCallBack != null) {
|
||||
trafficLiveCallBack.onError(e.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
MoGoLiveManager.getInstance().stopLive();
|
||||
surfaceView = null;
|
||||
callBack = null;
|
||||
trafficLiveCallBack = null;
|
||||
isLoginSuccess = false;
|
||||
mStreamId = null;
|
||||
}
|
||||
@@ -121,46 +122,61 @@ public class TrafficLiveManager implements ILiveProgressListener {
|
||||
|
||||
@Override
|
||||
public void onEngineStart() {
|
||||
if (callBack != null) {
|
||||
callBack.onLiveStart();
|
||||
if (trafficLiveCallBack != null) {
|
||||
trafficLiveCallBack.onLiveStart();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEngineStop() {
|
||||
if (callBack != null) {
|
||||
callBack.onLiveStop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnecting() {
|
||||
if (callBack != null) {
|
||||
callBack.onLiveConnecting();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnected(String roomId) {
|
||||
isLoginSuccess = true;
|
||||
if (callBack != null) {
|
||||
callBack.onLiveConnected();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisConnect() {
|
||||
isLoginSuccess = false;
|
||||
if (callBack != null) {
|
||||
callBack.onDisConnect();
|
||||
if (trafficLiveCallBack != null) {
|
||||
trafficLiveCallBack.onLiveStop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDebugError(int errorCode, String funcName, String errorInfo) {
|
||||
Logger.e(TAG, "onDebugError errorCode : " + errorCode + " funcName : " + funcName + " errorInfo : " + errorInfo);
|
||||
if (callBack != null) {
|
||||
callBack.onError(errorInfo);
|
||||
if (trafficLiveCallBack != null) {
|
||||
trafficLiveCallBack.onError(errorInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCurrentRoomConnecting() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCurrentRoomConnected() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCurrentRoomDisconnected() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMultiRoomConnecting() {
|
||||
if (trafficLiveCallBack != null) {
|
||||
trafficLiveCallBack.onLiveConnecting();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMultiRoomConnected() {
|
||||
isLoginSuccess = true;
|
||||
if (trafficLiveCallBack != null) {
|
||||
trafficLiveCallBack.onLiveConnected();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMultiRoomDisconnected() {
|
||||
isLoginSuccess = false;
|
||||
if (trafficLiveCallBack != null) {
|
||||
trafficLiveCallBack.onDisConnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user