1、升级ZeGo直播SDK
2、修复直播拉流播放状态,

    /**
     * 连接失败,播放失败,都走这里,可以展示播失败信息
     *
     * @param errorMsg
     */
    void onError(String errorMsg);

    /**
     * 拉流成功且处于播放中
     */
    void onPlaying();

    /**
     * 拉流重试中,还没成功,可以做Loading
     */
    void onPlaRequesting();
This commit is contained in:
donghongyu
2023-04-12 21:05:14 +08:00
parent a2777bb514
commit 2ad446c7b1
24 changed files with 265 additions and 119 deletions

View File

@@ -20,7 +20,7 @@ import com.mogo.cloud.wifi.WifiStateManager;
public class LivePlayActivity extends AppCompatActivity implements ITrafficCarLiveCallBack, IWifiStateListener {
private String TAG = "LiveActivity";
private String TAG = "LivePlayActivity";
private TextView tvWifiState;
private SurfaceView surfaceView0;
@@ -206,9 +206,19 @@ public class LivePlayActivity extends AppCompatActivity implements ITrafficCarLi
Log.w(TAG, "失去连接 onDisConnect");
}
@Override
public void onPlaying() {
Log.i(TAG, "拉流状态:拉流成功,播放中 …………");
}
@Override
public void onPlaRequesting() {
Log.i(TAG, "拉流状态:拉流还没成功,努力加载中 …………");
}
@Override
public void onError(String errorMsg) {
Log.e(TAG, "发生错误 onError msg: " + errorMsg);
Log.d(TAG, "拉流状态:发生错误 onError msg: " + errorMsg);
}
@Override

View File

@@ -5,7 +5,7 @@ import android.os.Bundle;
import android.util.Log;
import android.view.View;
import com.mogo.cloud.live.listener.ILiveStatusListener;
import com.mogo.cloud.live.listener.ILivePushStatusListener;
import com.mogo.cloud.live.manager.LiveStreamManagerImpl;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import com.mogo.cloud.trafficlive.api.ITrafficCarLiveCallBack;
@@ -34,7 +34,7 @@ public class LivePlayAndPushActivity extends BaseLiveActivity
MoGoAiCloudClientConfig.getInstance().getSn(),true);
// 设置状态回调
liveStreamManager.setLiveStatusChangeCallback(new ILiveStatusListener() {
liveStreamManager.setLivePushStatusChangeCallback(new ILivePushStatusListener() {
@Override
public void onChange(int status) {
tvLiveStatus.post(new Runnable() {
@@ -135,9 +135,19 @@ public class LivePlayAndPushActivity extends BaseLiveActivity
Log.d(TAG, "失去连接 onDisConnect");
}
@Override
public void onPlaying() {
Log.i(TAG, "拉流状态:拉流成功,播放中 …………");
}
@Override
public void onPlaRequesting() {
Log.i(TAG, "拉流状态:拉流还没成功,努力加载中 …………");
}
@Override
public void onError(String errorMsg) {
Log.d(TAG, "发生错误 onError msg: " + errorMsg);
Log.d(TAG, "拉流状态:发生错误 onError msg: " + errorMsg);
}
@Override

View File

@@ -24,7 +24,7 @@ import com.mogo.cloud.wifi.WifiStateManager;
* @author mogoauto
*/
public class LivePlayOneActivity extends AppCompatActivity implements ITrafficCarLiveCallBack, IWifiStateListener {
private String TAG = "LiveActivity";
private String TAG = "LivePlayOneActivity";
private TextView tvWifiState;
private SurfaceView surfaceView;
@@ -84,9 +84,19 @@ public class LivePlayOneActivity extends AppCompatActivity implements ITrafficCa
Log.w(TAG, "失去连接 onDisConnect");
}
@Override
public void onPlaying() {
Log.i(TAG, "拉流状态:拉流成功,播放中 …………");
}
@Override
public void onPlaRequesting() {
Log.i(TAG, "拉流状态:拉流还没成功,努力加载中 …………");
}
@Override
public void onError(String errorMsg) {
Log.e(TAG, "发生错误 onError msg: " + errorMsg);
Log.d(TAG, "拉流状态:发生错误 onError msg: " + errorMsg);
}
@Override

View File

@@ -3,7 +3,7 @@ package com.mogo.cloud;
import android.os.Bundle;
import android.util.Log;
import com.mogo.cloud.live.listener.ILiveStatusListener;
import com.mogo.cloud.live.listener.ILivePushStatusListener;
import com.mogo.cloud.live.manager.ILiveStreamManager;
import com.mogo.cloud.live.manager.LiveStreamManagerImpl;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
@@ -25,7 +25,7 @@ public class LivePushActivity extends BaseLiveActivity {
MoGoAiCloudClientConfig.getInstance().getSn(), true);
// 设置状态回调
liveStreamManager.setLiveStatusChangeCallback(new ILiveStatusListener() {
liveStreamManager.setLivePushStatusChangeCallback(new ILivePushStatusListener() {
@Override
public void onChange(int status) {
tvLiveStatus.post(new Runnable() {

View File

@@ -200,9 +200,19 @@ public class MainActivity extends AppCompatActivity {
Log.e(TAG, "onDisConnect");
}
@Override
public void onPlaying() {
Log.i(TAG, "拉流状态:拉流成功,播放中 …………");
}
@Override
public void onPlaRequesting() {
Log.i(TAG, "拉流状态:拉流还没成功,努力加载中 …………");
}
@Override
public void onError(String errorMsg) {
Log.e(TAG, "errorMsg");
Log.d(TAG, "拉流状态:发生错误 onError msg: " + errorMsg);
}
});
});

View File

@@ -26,7 +26,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入要查看的车机SN"
android:text="F803EB2046PZD00190"
android:text="F803EB2046PZD00164"
android:textColor="#850808"
android:textSize="16sp"
app:layout_constraintBottom_toTopOf="@+id/liveToggleBtn"

View File

@@ -4,7 +4,7 @@ apply from: "config.gradle"
buildscript {
ext.kotlin_version = "1.4.31"
repositories {
maven { url 'https://storage.zego.im/maven' }
maven {
url 'http://maven.aliyun.com/nexus/content/groups/public/'
}
@@ -31,6 +31,7 @@ buildscript {
allprojects {
repositories {
maven { url 'https://storage.zego.im/maven' }
maven {
url 'http://maven.aliyun.com/nexus/content/groups/public/'
}

View File

@@ -59,7 +59,7 @@ ext {
videoprocessor : "com.zhidao.video:video-processor:1.0.2.1",
// 直播SDK
live_sdk_zego : "im.zego:express-video:2.2.0",
live_sdk_zego : "im.zego:express-video:2.19.0",
adasapi : "com.zhidao.autopilot.support:adas:1.0.6.6",
adasconfigapi : "com.zhidao.adasconfig:adasconfig:1.1.5.2",

View File

@@ -42,8 +42,8 @@ android {
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation rootProject.ext.dependencies.androidxappcompat
// implementation rootProject.ext.dependencies.live_sdk_zego
implementation files('libs/ZegoExpressEngine.jar')
implementation rootProject.ext.dependencies.live_sdk_zego
// implementation files('libs/ZegoExpressEngine.jar')
api 'com.zhidao.libyuv:libyuv:1.0.1.0'
implementation 'com.zhidao.ptech:connsvr-protoco:0.1.23'

View File

@@ -0,0 +1,26 @@
package com.mogo.cloud.live.listener;
import im.zego.zegoexpress.constants.ZegoPlayerState;
/**
* 直播拉流状态监听
*/
public interface ILivePullStateListener {
/**
* 第一帧渲染
*/
void onVideoFirstFrame();
/**
* 拉流播放状态
*
* @param statusCode 0-没播放1-请求中2-播放中
* @see ZegoPlayerState
*/
void onPlayerStateUpdate(int statusCode);
/**
* 设备错误
*/
void onDeviceError(int errorCode);
}

View File

@@ -1,8 +1,8 @@
package com.mogo.cloud.live.listener;
/**
* 直播状态回调用
* 直播推流状态回调用
*/
public interface ILiveStatusListener {
public interface ILivePushStatusListener {
void onChange(int status);
}

View File

@@ -1,21 +0,0 @@
package com.mogo.cloud.live.listener;
public interface IMediaPlayerStateListener {
void onVideoFirstFrame();
/**
* 远程设备异常
*/
void remoteDeviceError();
/**
* 拉流出现错误
* @param errorCode
*/
void onPullStreamError(int errorCode);
/**
* 设备错误
*/
void onDeviceError(int errorCode);
}

View File

@@ -1,7 +1,7 @@
package com.mogo.cloud.live.manager;
import com.mogo.cloud.live.listener.ILiveStatusListener;
import com.mogo.cloud.live.listener.ILivePushStatusListener;
public interface ILiveStreamManager {
/**
@@ -38,10 +38,10 @@ public interface ILiveStreamManager {
void notifyYUVData(byte[] data, int width, int height, int type);
/**
* 直播状态改变时回调
* 直播推流状态改变时回调
* @param changeCallback live status change callback
*/
void setLiveStatusChangeCallback(ILiveStatusListener changeCallback);
void setLivePushStatusChangeCallback(ILivePushStatusListener changeCallback);
/**
* 释放资源

View File

@@ -7,7 +7,7 @@ import android.os.SystemClock;
import android.util.Log;
import com.mogo.cloud.live.listener.ILiveRoomPersonListener;
import com.mogo.cloud.live.listener.ILiveStatusListener;
import com.mogo.cloud.live.listener.ILivePushStatusListener;
import com.mogo.cloud.live.model.CommandModel;
import com.mogo.cloud.live.server.PushService;
import com.mogo.cloud.live.socket.SocketMsgUtils;
@@ -163,9 +163,9 @@ public class LiveStreamManagerImpl implements ILiveStreamManager, ILiveRoomPerso
}
@Override
public void setLiveStatusChangeCallback(ILiveStatusListener liveStatusListener) {
public void setLivePushStatusChangeCallback(ILivePushStatusListener liveStatusListener) {
if (mMoGoLiveManager != null) {
mMoGoLiveManager.setLiveStatusListener(liveStatusListener);
mMoGoLiveManager.addLivePushStatusListener(liveStatusListener);
}
}

View File

@@ -1,6 +1,5 @@
package com.mogo.cloud.live.manager;
import static im.zego.zegoexpress.constants.ZegoRemoteDeviceState.OPEN;
import static im.zego.zegoexpress.constants.ZegoRoomState.DISCONNECTED;
import android.app.Application;
@@ -12,9 +11,9 @@ import android.view.TextureView;
import com.mogo.cloud.live.listener.ILiveCurrentRoomStatusListener;
import com.mogo.cloud.live.listener.ILiveMultiRoomStatusListener;
import com.mogo.cloud.live.listener.ILiveProgressListener;
import com.mogo.cloud.live.listener.ILivePullStateListener;
import com.mogo.cloud.live.listener.ILivePushStatusListener;
import com.mogo.cloud.live.listener.ILiveRoomPersonListener;
import com.mogo.cloud.live.listener.ILiveStatusListener;
import com.mogo.cloud.live.listener.IMediaPlayerStateListener;
import com.mogo.cloud.live.model.LiveStatusModel;
import com.mogo.cloud.live.server.PushService;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
@@ -29,13 +28,14 @@ import im.zego.zegoexpress.ZegoExpressEngine;
import im.zego.zegoexpress.callback.IZegoCustomVideoCaptureHandler;
import im.zego.zegoexpress.callback.IZegoEventHandler;
import im.zego.zegoexpress.constants.ZegoEngineState;
import im.zego.zegoexpress.constants.ZegoPlayerMediaEvent;
import im.zego.zegoexpress.constants.ZegoPlayerState;
import im.zego.zegoexpress.constants.ZegoPublishChannel;
import im.zego.zegoexpress.constants.ZegoPublisherState;
import im.zego.zegoexpress.constants.ZegoRemoteDeviceState;
import im.zego.zegoexpress.constants.ZegoRoomMode;
import im.zego.zegoexpress.constants.ZegoRoomState;
import im.zego.zegoexpress.constants.ZegoScenario;
import im.zego.zegoexpress.constants.ZegoStreamEvent;
import im.zego.zegoexpress.constants.ZegoUpdateType;
import im.zego.zegoexpress.constants.ZegoVideoBufferType;
import im.zego.zegoexpress.constants.ZegoVideoCodecID;
@@ -46,6 +46,7 @@ import im.zego.zegoexpress.entity.ZegoCanvas;
import im.zego.zegoexpress.entity.ZegoCustomVideoCaptureConfig;
import im.zego.zegoexpress.entity.ZegoEngineConfig;
import im.zego.zegoexpress.entity.ZegoEngineProfile;
import im.zego.zegoexpress.entity.ZegoPlayStreamQuality;
import im.zego.zegoexpress.entity.ZegoPlayerConfig;
import im.zego.zegoexpress.entity.ZegoPublisherConfig;
import im.zego.zegoexpress.entity.ZegoRoomConfig;
@@ -114,9 +115,13 @@ public class MoGoLiveManager {
*/
private static final List<ILiveRoomPersonListener> mRoomPersonListener = new ArrayList<>();
/**
* 直播状态回调
* 直播推流状态回调
*/
private static final List<ILiveStatusListener> mLiveStatusListener = new ArrayList<>();
private static final List<ILivePushStatusListener> mLiveStatusListener = new ArrayList<>();
/**
* 直播拉流观看状态回调
*/
private static final List<ILivePullStateListener> mLivePullStateListener = new ArrayList<>();
/**
* 直播数据
*/
@@ -125,7 +130,6 @@ public class MoGoLiveManager {
* 房间配置
*/
private final ZegoRoomConfig zeGoRoomConfig;
private IMediaPlayerStateListener mMediaPlayerStateListener;
private ZegoUser zegoUserCurrent;
private static final class Holder {
@@ -259,7 +263,10 @@ public class MoGoLiveManager {
}
}
// 这里回调的是登录的他人房间的状态
if (mLiveStatusModel.getMultiRoomId().equals(roomID)) {
else if (mLiveStatusModel.getMultiRoomId().equals(roomID)) {
// 1. 当收到该回调通知且 state 为 PLAYING 时,表示拉流成功
// 2. 当收到该回调通知且 state 为 PLAY_REQUESTING 时,表示可能是正在拉流或者由于网络中断等原因导致 SDK 正在重试拉流
// 3. 当收到该回调通知且 state 为 NO_PLAY 时,表示拉流停止
Log.i(TAG, "这里回调的是登录的他人房间的状态 onRoomStateUpdate multiRoomId : " + roomID +
" state:" + state +
" errorCode:" + errorCode +
@@ -287,14 +294,14 @@ public class MoGoLiveManager {
@Override
public void onRoomOnlineUserCountUpdate(String roomID, int count) {
super.onRoomOnlineUserCountUpdate(roomID, count);
// 这里只处理当前设备登录的房间中的用户总数
// 这里只处理当前设备-观看者」登录的房间中的用户总数
if (mLiveStatusModel.getCurrentRoomId().equals(roomID)) {
// 更新真实的在线人数
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());
for (ILiveRoomPersonListener iLiveRoomPersonListener : mRoomPersonListener) {
if (iLiveRoomPersonListener != null) {
@@ -302,6 +309,11 @@ public class MoGoLiveManager {
}
}
}
// 这里只处理登录的「他人-被直播者」房间中的用户总数
else if (mLiveStatusModel.getMultiRoomId().equals(roomID)) {
Log.i(TAG, "「他人」房间内当前在线用户数量回调 onRoomOnlineUserCountUpdate roomID : " + roomID +
" , online user number : " + count);
}
}
// 房间内其他用户增加或减少的通知回调
@@ -317,7 +329,7 @@ public class MoGoLiveManager {
mLiveStatusModel.setOnlineNumber(mLiveStatusModel.getOnlineNumber() - userList.size());
}
Log.i(TAG, "房间内其他用户增加或减少的通知回调 onRoomUserUpdate roomId : " + roomID +
Log.i(TAG, "「自己」房间内其他用户增加或减少的通知回调 onRoomUserUpdate roomId : " + roomID +
" , updateType : " + updateType.name() +
" , online user number : " + mLiveStatusModel.getOnlineNumber());
for (ILiveRoomPersonListener iLiveRoomPersonListener : mRoomPersonListener) {
@@ -326,6 +338,12 @@ public class MoGoLiveManager {
}
}
}
// 这里查看的是别人的房间
else if (mLiveStatusModel.getMultiStreamId().equals(roomID)) {
Log.i(TAG, "「他人」房间内其他用户增加或减少的通知回调 onRoomUserUpdate roomId : " + roomID +
" , updateType : " + updateType.name() +
" , online user number : " + mLiveStatusModel.getOnlineNumber());
}
}
}
@@ -339,6 +357,7 @@ public class MoGoLiveManager {
// 判断不是非推流状态则为推流
mLiveStatusModel.setPushing(state != ZegoPublisherState.NO_PUBLISH);
Log.i(TAG, "推流状态回调 onPublisherStateUpdate streamID : " + streamID +
" , isPlaying : " + mLiveStatusModel.isPlaying() +
" , isPushing : " + mLiveStatusModel.isPushing() +
" , state : " + state.name() +
" , errorCode : " + errorCode +
@@ -350,36 +369,91 @@ public class MoGoLiveManager {
// && mLiveStatusModel.getOnlineNumber() <= 1) {
// logoutCurrentRoom();
// }
for (ILiveStatusListener iLiveStatusListener : mLiveStatusListener) {
if (iLiveStatusListener != null) {
iLiveStatusListener.onChange(mLiveStatusModel.isPushing() ? 0 : 1);
for (ILivePushStatusListener iLivePushStatusListener : mLiveStatusListener) {
if (iLivePushStatusListener != null) {
iLivePushStatusListener.onChange(mLiveStatusModel.isPushing() ? 0 : 1);
}
}
}
// 这里查看的是别人的房间
else if (mLiveStatusModel.getMultiStreamId().equals(streamID)) {
}
}
// 拉流状态变更回调
@Override
public void onPlayerStateUpdate(String streamID, ZegoPlayerState state, int errorCode, JSONObject extendedData) {
super.onPlayerStateUpdate(streamID, state, errorCode, extendedData);
// 这里查看的是别的房间
// 这里查看的是别的房间
if (mLiveStatusModel.getMultiStreamId().equals(streamID)) {
// 如果不是非播放状态则判定为直播状态
mLiveStatusModel.setPlaying(state != ZegoPlayerState.NO_PLAY);
if (mMediaPlayerStateListener != null && errorCode != 0) {
mMediaPlayerStateListener.onPullStreamError(errorCode);
mLiveStatusModel.setPlaying(state == ZegoPlayerState.PLAYING);
// 同步更新状态
for (ILivePullStateListener iLivePullStateListener : mLivePullStateListener) {
if (iLivePullStateListener != null) {
iLivePullStateListener.onPlayerStateUpdate(state.value());
}
}
Log.i(TAG, " 拉流状态变更回调 onPlayerStateUpdate streamId : " + streamID +
Log.i(TAG, "拉流状态变更回调 onPlayerStateUpdate streamId : " + streamID +
" , isPlaying : " + mLiveStatusModel.isPlaying() +
" , isPushing : " + mLiveStatusModel.isPushing() +
" , state : " + state.name() +
" , errorCode : " + errorCode +
" , extendData : " + extendedData.toString());
// 判断如果处于非播放和非推流状态则进行登出操作,并释放引擎
if (!mLiveStatusModel.isPlaying()
&& !mLiveStatusModel.isPushing()
&& mLiveStatusModel.getOnlineNumber() <= 1) {
logoutCurrentRoom();
// // 判断如果处于非播放和非推流状态则进行登出操作,并释放引擎
// if (!mLiveStatusModel.isPlaying()
// && !mLiveStatusModel.isPushing()
// && mLiveStatusModel.getOnlineNumber() <= 1) {
// logoutCurrentRoom();
// }
}
}
@Override
public void onPlayerMediaEvent(String streamID, ZegoPlayerMediaEvent zegoPlayerMediaEvent) {
super.onPlayerMediaEvent(streamID, zegoPlayerMediaEvent);
Log.i(TAG, "拉流媒体事件回调 onPlayerMediaEvent streamId : " + streamID +
" , isPlaying : " + mLiveStatusModel.isPlaying() +
" , isPushing : " + mLiveStatusModel.isPushing() +
" , zegoPlayerMediaEvent : " + zegoPlayerMediaEvent.name());
}
@Override
public void onPlayerStreamEvent(ZegoStreamEvent eventID, String streamID, String extraInfo) {
super.onPlayerStreamEvent(eventID, streamID, extraInfo);
Log.i(TAG, "拉流事件回调 onPlayerStreamEvent streamId : " + streamID +
" , isPlaying : " + mLiveStatusModel.isPlaying() +
" , isPushing : " + mLiveStatusModel.isPushing() +
" , extraInfo : " + extraInfo);
}
@Override
public void onPlayerQualityUpdate(String streamID, ZegoPlayStreamQuality quality) {
super.onPlayerQualityUpdate(streamID, quality);
Log.i(TAG, "拉流事件回调 onPlayerStreamEvent streamId : " + streamID +
" , isPlaying : " + mLiveStatusModel.isPlaying() +
" , isPushing : " + mLiveStatusModel.isPushing() +
" , quality.videoRecvFPS : " + quality.videoRecvFPS);
if (quality.videoRecvFPS <= 0) {
// 帧率为小于0即无数据展示loading
mLiveStatusModel.setPlaying(false);
// 同步更新状态
for (ILivePullStateListener iLivePullStateListener : mLivePullStateListener) {
if (iLivePullStateListener != null) {
iLivePullStateListener.onPlayerStateUpdate(1);
}
}
} else {
// 帧率为大于0即有数据进行播放
mLiveStatusModel.setPlaying(true);
// 同步更新状态
for (ILivePullStateListener iLivePullStateListener : mLivePullStateListener) {
if (iLivePullStateListener != null) {
iLivePullStateListener.onPlayerStateUpdate(2);
}
}
}
}
@@ -400,18 +474,10 @@ public class MoGoLiveManager {
public void onPlayerRecvVideoFirstFrame(String streamID) {
super.onPlayerRecvVideoFirstFrame(streamID);
Log.d(TAG, "onPlayerRecvVideoFirstFrame");
if (mMediaPlayerStateListener != null) {
mMediaPlayerStateListener.onVideoFirstFrame();
}
}
@Override
public void onRemoteCameraStateUpdate(String streamID, ZegoRemoteDeviceState state) {
super.onRemoteCameraStateUpdate(streamID, state);
if (state != OPEN) {
Log.e(TAG, "onRemoteCameraStateUpdate:" + state);
if (mMediaPlayerStateListener != null) {
mMediaPlayerStateListener.remoteDeviceError();
// 同步更新状态
for (ILivePullStateListener iLivePullStateListener : mLivePullStateListener) {
if (iLivePullStateListener != null) {
iLivePullStateListener.onVideoFirstFrame();
}
}
}
@@ -420,8 +486,11 @@ public class MoGoLiveManager {
public void onDeviceError(int errorCode, String deviceName) {
super.onDeviceError(errorCode, deviceName);
Log.e(TAG, "onDeviceError:" + errorCode);
if (mMediaPlayerStateListener != null && errorCode != 0) {
mMediaPlayerStateListener.onDeviceError(errorCode);
// 同步更新状态
for (ILivePullStateListener iLivePullStateListener : mLivePullStateListener) {
if (iLivePullStateListener != null) {
iLivePullStateListener.onDeviceError(errorCode);
}
}
}
};
@@ -472,14 +541,23 @@ public class MoGoLiveManager {
}
/**
* 直播状态回调
* 直播推送状态回调
*
* @param liveStatusListener 回调监听
*/
public static void setLiveStatusListener(ILiveStatusListener liveStatusListener) {
public static void addLivePushStatusListener(ILivePushStatusListener liveStatusListener) {
mLiveStatusListener.add(liveStatusListener);
}
/**
* 直播拉流播放状态回调
*
* @param livePullStateListener 回调监听
*/
public static void addLivePullStateListener(ILivePullStateListener livePullStateListener) {
mLivePullStateListener.add(livePullStateListener);
}
/**
* 初始化自定义采集
*/
@@ -698,10 +776,6 @@ public class MoGoLiveManager {
mExpressEngine.stopPublishingStream();
}
public void setMediaPlayerStateListener(IMediaPlayerStateListener mediaPlayerStateListener) {
mMediaPlayerStateListener = mediaPlayerStateListener;
}
/**
* 开始播放直播
*

View File

@@ -76,9 +76,7 @@ public class RequestLiveManager {
@Override
public void onNext(@NonNull BaseData baseData) {
if (requestLiveListener != null) {
requestLiveListener.onSuccess();
}
}
@Override
@@ -94,6 +92,10 @@ public class RequestLiveManager {
}
});
if (requestLiveListener != null) {
requestLiveListener.onSuccess();
}
}
/**

View File

@@ -36,24 +36,24 @@ PASSWORD=xintai2018
RELEASE=true
# AI CLOUD 云平台
# 工具类
MOGO_UTILS_VERSION=1.4.6.6
MOGO_UTILS_VERSION=1.4.6.7
# 网络请求
MOGO_NETWORK_VERSION=1.4.6.6
MOGO_NETWORK_VERSION=1.4.6.7
# 鉴权
MOGO_PASSPORT_VERSION=1.4.6.6
MOGO_PASSPORT_VERSION=1.4.6.7
# 常链接
MOGO_SOCKET_VERSION=1.4.6.6
MOGO_SOCKET_VERSION=1.4.6.7
# 数据采集
MOGO_REALTIME_VERSION=1.4.6.6
MOGO_REALTIME_VERSION=1.4.6.7
# 探路,道路事件发布,获取
MOGO_TANLU_VERSION=1.4.6.6
MOGO_TANLU_VERSION=1.4.6.7
# 直播推流
MOGO_LIVE_VERSION=1.4.6.6
MOGO_LIVE_VERSION=1.4.6.7
# 直播拉流
MOGO_TRAFFICLIVE_VERSION=1.4.6.6
MOGO_TRAFFICLIVE_VERSION=1.4.6.7
# 定位服务
MOGO_LOCATION_VERSION=1.4.6.6
MOGO_LOCATION_VERSION=1.4.6.7
# 远程通讯模块
MOGO_TELEMATIC_VERSION=1.4.6.6
MOGO_TELEMATIC_VERSION=1.4.6.7
# v2x
MOGO_V2X_VERSION=1.4.6.6
MOGO_V2X_VERSION=1.4.6.7

View File

@@ -19,6 +19,22 @@ public interface ITrafficCarLiveCallBack {
void onDisConnect();
/**
* 连接失败,播放失败,都走这里,可以展示播失败信息
*
* @param errorMsg
*/
void onError(String errorMsg);
/**
* 拉流成功且处于播放中
*/
void onPlaying();
/**
* 拉流重试中还没成功可以做Loading
*/
void onPlaRequesting();
}

View File

@@ -1,5 +1,9 @@
package com.mogo.cloud.trafficlive.core;
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;
import android.text.TextUtils;
import android.util.Log;
import android.view.SurfaceView;
@@ -7,7 +11,7 @@ import android.view.TextureView;
import com.mogo.cloud.live.listener.ILiveMultiRoomStatusListener;
import com.mogo.cloud.live.listener.ILiveProgressListener;
import com.mogo.cloud.live.listener.IMediaPlayerStateListener;
import com.mogo.cloud.live.listener.ILivePullStateListener;
import com.mogo.cloud.live.listener.IRequestLiveListener;
import com.mogo.cloud.live.manager.MoGoLiveManager;
import com.mogo.cloud.live.manager.MoGoLivePushConfig;
@@ -16,10 +20,6 @@ import com.mogo.cloud.passport.MoGoAiCloudClient;
import com.mogo.cloud.trafficlive.api.ITrafficCarLiveCallBack;
import com.mogo.cloud.trafficlive.api.ITrafficIntersectionLiveCallBack;
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 TrafficLiveCurrentManager
implements ILiveProgressListener, ILiveMultiRoomStatusListener {
@@ -142,7 +142,7 @@ public class TrafficLiveCurrentManager
mLivePushConfig.setDevicesId(sn);
// 登录要查看的SN房间
MoGoLiveManager.getInstance().loginMultiRoom(liveSn);
MoGoLiveManager.getInstance().setMediaPlayerStateListener(mediaPlayerStateListener);
MoGoLiveManager.getInstance().addLivePullStateListener(mediaPlayerStateListener);
// 直接 查看对应SN的直播
MoGoLiveManager.getInstance().startLive(surfaceView);
if (TrafficLiveCurrentManager.this.trafficLiveCallBack != null) {
@@ -165,7 +165,7 @@ public class TrafficLiveCurrentManager
mLivePushConfig.setDevicesId(sn);
// 登录要查看的SN房间
MoGoLiveManager.getInstance().loginMultiRoom(liveSn);
MoGoLiveManager.getInstance().setMediaPlayerStateListener(mediaPlayerStateListener);
MoGoLiveManager.getInstance().addLivePullStateListener(mediaPlayerStateListener);
// 直接 查看对应SN的直播
MoGoLiveManager.getInstance().startLive(textureView);
if (TrafficLiveCurrentManager.this.trafficLiveCallBack != null) {
@@ -271,7 +271,8 @@ public class TrafficLiveCurrentManager
trafficLiveCallBack.onDisConnect();
}
}
private IMediaPlayerStateListener mediaPlayerStateListener = new IMediaPlayerStateListener() {
private ILivePullStateListener mediaPlayerStateListener = new ILivePullStateListener() {
@Override
public void onVideoFirstFrame() {
if (trafficLiveCallBack != null) {
@@ -280,23 +281,30 @@ public class TrafficLiveCurrentManager
}
@Override
public void remoteDeviceError() {
public void onPlayerStateUpdate(int statusCode) {
if (trafficLiveCallBack != null) {
trafficLiveCallBack.onError("");
switch (statusCode) {
case 0: {
trafficLiveCallBack.onError("onPullStreamError");
break;
}
case 1: {
trafficLiveCallBack.onPlaRequesting();
break;
}
case 2: {
trafficLiveCallBack.onPlaying();
break;
}
}
}
}
@Override
public void onPullStreamError(int errorCode) {
if (trafficLiveCallBack != null) {
trafficLiveCallBack.onError("" + errorCode);
}
}
@Override
public void onDeviceError(int errorCode) {
if (trafficLiveCallBack != null) {
trafficLiveCallBack.onError("" + errorCode);
trafficLiveCallBack.onError("onDeviceError" + errorCode);
}
}
};