[Add]增加了是否开启自定义采集配置isExpressEngine
This commit is contained in:
@@ -37,7 +37,7 @@ public class LivePlayActivity extends AppCompatActivity implements ITrafficCarLi
|
||||
tvWifiState = findViewById(R.id.tvWifiState);
|
||||
|
||||
LiveStreamManagerImpl.getInstance(this.getApplication(),
|
||||
MoGoAiCloudClientConfig.getInstance().getSn());
|
||||
MoGoAiCloudClientConfig.getInstance().getSn(),false);
|
||||
liveToggleBtn.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
Toast.makeText(getApplicationContext(), buttonView.getText(), Toast.LENGTH_SHORT).show();
|
||||
if (isChecked) {
|
||||
|
||||
@@ -32,7 +32,7 @@ public class LivePlayAndPushActivity extends BaseLiveActivity
|
||||
|
||||
// 初始化直播流管理
|
||||
liveStreamManager = LiveStreamManagerImpl.getInstance(this.getApplication(),
|
||||
MoGoAiCloudClientConfig.getInstance().getSn());
|
||||
MoGoAiCloudClientConfig.getInstance().getSn(),true);
|
||||
|
||||
// 设置状态回调
|
||||
liveStreamManager.setLiveStatusChangeCallback(new ILiveStatusListener() {
|
||||
@@ -100,9 +100,9 @@ public class LivePlayAndPushActivity extends BaseLiveActivity
|
||||
public void toggleLoginMultiRoom(boolean isLogin) {
|
||||
if (isLogin) {
|
||||
liveSn = etLookRoomId.getText().toString().trim();
|
||||
liveStreamManager.getLivePusher().loginMultiRoom(liveSn);
|
||||
liveStreamManager.getMoGoLiveManager().loginMultiRoom(liveSn);
|
||||
} else {
|
||||
liveStreamManager.getLivePusher().logoutMultiRoom();
|
||||
liveStreamManager.getMoGoLiveManager().logoutMultiRoom();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public class LivePushActivity extends BaseLiveActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
// 初始化直播流管理
|
||||
liveStreamManager = LiveStreamManagerImpl.getInstance(this.getApplication(),
|
||||
MoGoAiCloudClientConfig.getInstance().getSn());
|
||||
MoGoAiCloudClientConfig.getInstance().getSn(), true);
|
||||
|
||||
// 设置状态回调
|
||||
liveStreamManager.setLiveStatusChangeCallback(new ILiveStatusListener() {
|
||||
|
||||
@@ -41,15 +41,14 @@ public class LiveStreamManagerImpl implements ILiveStreamManager {
|
||||
private Handler mHandlerPushCameraStatus; // 循环上报摄像头状态
|
||||
private Handler mHandlerCheckOnlineNum; // 检测在线观看人数
|
||||
private final SocketMsgUtils mSocketMsgUtils; // Socket 长链接
|
||||
private MoGoLiveManager mLivePusher; // 自研直播SDK
|
||||
|
||||
private MoGoLiveManager mMoGoLiveManager; // 自研直播SDK
|
||||
private CameraStatusManager cameraStatusManager;
|
||||
|
||||
public static LiveStreamManagerImpl getInstance(Application application, String devicesId) {
|
||||
public static LiveStreamManagerImpl getInstance(Application application, String devicesId, boolean isExpressEngine) {
|
||||
if (sInstance == null) {
|
||||
synchronized (LiveStreamManagerImpl.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new LiveStreamManagerImpl(application, devicesId);
|
||||
sInstance = new LiveStreamManagerImpl(application, devicesId, isExpressEngine);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,13 +57,13 @@ public class LiveStreamManagerImpl implements ILiveStreamManager {
|
||||
}
|
||||
|
||||
|
||||
private LiveStreamManagerImpl(Application application, String devicesId) {
|
||||
private LiveStreamManagerImpl(Application application, String devicesId, boolean isExpressEngine) {
|
||||
mApplication = application;
|
||||
mHandlerPushCameraStatus = new Handler();
|
||||
mHandlerCheckOnlineNum = new Handler();
|
||||
cameraStatusManager = CameraStatusManager.getInstance();
|
||||
// 初始化直播推流
|
||||
initLivePush(devicesId);
|
||||
initMoGoLiveManager(devicesId, isExpressEngine);
|
||||
// 初始化Socket长连接通道
|
||||
mSocketMsgUtils = SocketMsgUtils.getInstance(mApplication,
|
||||
new IMogoCloudSocketOnMessageListener<CommandModel>() {
|
||||
@@ -84,15 +83,15 @@ public class LiveStreamManagerImpl implements ILiveStreamManager {
|
||||
restartCamStatusLoop();
|
||||
// 开启房间人数检测
|
||||
restartCheckOnlineNumLoop();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化直播推流
|
||||
* 初始化直播引擎
|
||||
*
|
||||
* @param devicesId 设备ID
|
||||
* @param devicesId 设备ID
|
||||
* @param isExpressEngine 是否自定义采集
|
||||
*/
|
||||
private void initLivePush(String devicesId) {
|
||||
private void initMoGoLiveManager(String devicesId, boolean isExpressEngine) {
|
||||
// 初始化配置文件
|
||||
MoGoLivePushConfig mLivePushConfig = MoGoLivePushConfig.getInstance();
|
||||
mLivePushConfig.setWidth(1280);
|
||||
@@ -105,11 +104,11 @@ public class LiveStreamManagerImpl implements ILiveStreamManager {
|
||||
mLivePushConfig.setMute(true);
|
||||
mLivePushConfig.setDevicesId(devicesId);
|
||||
// 初始化直播
|
||||
mLivePusher = MoGoLiveManager.getInstance().init(mApplication, mLivePushConfig);
|
||||
mMoGoLiveManager = MoGoLiveManager.getInstance().init(mApplication, mLivePushConfig);
|
||||
}
|
||||
|
||||
public MoGoLiveManager getLivePusher() {
|
||||
return mLivePusher;
|
||||
public MoGoLiveManager getMoGoLiveManager() {
|
||||
return mMoGoLiveManager;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,8 +152,8 @@ public class LiveStreamManagerImpl implements ILiveStreamManager {
|
||||
|
||||
@Override
|
||||
public void setLiveStatusChangeCallback(ILiveStatusListener liveStatusListener) {
|
||||
if (mLivePusher != null) {
|
||||
mLivePusher.setLiveStatusListener(liveStatusListener);
|
||||
if (mMoGoLiveManager != null) {
|
||||
mMoGoLiveManager.setLiveStatusListener(liveStatusListener);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,11 +208,11 @@ public class LiveStreamManagerImpl implements ILiveStreamManager {
|
||||
*/
|
||||
private final Runnable mOnlineNumRun = () -> {
|
||||
// 判断当前观众的个数,如果没人观看了的情况则停止直播
|
||||
Logger.i(TAG, "直播状态为:" + mLivePusher.getLiveStatusModel().isPushing() +
|
||||
" 观众人数:" + mLivePusher.getLiveStatusModel().getOnlineNumber());
|
||||
Logger.i(TAG, "直播状态为:" + mMoGoLiveManager.getLiveStatusModel().isPushing() +
|
||||
" 观众人数:" + mMoGoLiveManager.getLiveStatusModel().getOnlineNumber());
|
||||
|
||||
if (mLivePusher.getLiveStatusModel().isPushing() &&
|
||||
mLivePusher.getLiveStatusModel().getOnlineNumber() <= 1) {
|
||||
if (mMoGoLiveManager.getLiveStatusModel().isPushing() &&
|
||||
mMoGoLiveManager.getLiveStatusModel().getOnlineNumber() <= 1) {
|
||||
livePushHandler(PUSH_STOP, C1);
|
||||
} else {
|
||||
livePushHandler(PUSH_START, C1);
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package com.mogo.cloud.live.manager;
|
||||
|
||||
import static com.mogo.cloud.httpdns.MogoHttpDnsConfig.HTTP_DNS_ENV_DEMO;
|
||||
import static com.mogo.cloud.httpdns.MogoHttpDnsConfig.HTTP_DNS_ENV_DEV;
|
||||
import static com.mogo.cloud.httpdns.MogoHttpDnsConfig.HTTP_DNS_ENV_QA;
|
||||
import static com.mogo.cloud.httpdns.MogoHttpDnsConfig.HTTP_DNS_ENV_RELEASE;
|
||||
import static im.zego.zegoexpress.constants.ZegoRemoteDeviceState.OPEN;
|
||||
|
||||
import android.app.Application;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@@ -26,7 +32,6 @@ import im.zego.zegoexpress.callback.IZegoCustomVideoCaptureHandler;
|
||||
import im.zego.zegoexpress.callback.IZegoEventHandler;
|
||||
import im.zego.zegoexpress.constants.ZegoEngineState;
|
||||
import im.zego.zegoexpress.constants.ZegoLanguage;
|
||||
import im.zego.zegoexpress.constants.ZegoPlayerMediaEvent;
|
||||
import im.zego.zegoexpress.constants.ZegoPlayerState;
|
||||
import im.zego.zegoexpress.constants.ZegoPublishChannel;
|
||||
import im.zego.zegoexpress.constants.ZegoPublisherState;
|
||||
@@ -46,12 +51,6 @@ import im.zego.zegoexpress.entity.ZegoUser;
|
||||
import im.zego.zegoexpress.entity.ZegoVideoConfig;
|
||||
import im.zego.zegoexpress.entity.ZegoVideoFrameParam;
|
||||
|
||||
import static com.mogo.cloud.httpdns.MogoHttpDnsConfig.HTTP_DNS_ENV_DEMO;
|
||||
import static com.mogo.cloud.httpdns.MogoHttpDnsConfig.HTTP_DNS_ENV_DEV;
|
||||
import static com.mogo.cloud.httpdns.MogoHttpDnsConfig.HTTP_DNS_ENV_QA;
|
||||
import static com.mogo.cloud.httpdns.MogoHttpDnsConfig.HTTP_DNS_ENV_RELEASE;
|
||||
import static im.zego.zegoexpress.constants.ZegoRemoteDeviceState.OPEN;
|
||||
|
||||
/**
|
||||
* 即构直播管理
|
||||
*/
|
||||
@@ -165,7 +164,9 @@ public class MoGoLiveManager {
|
||||
public MoGoLiveManager init(Application application, MoGoLivePushConfig livePushConfig) {
|
||||
mApplication = application;
|
||||
mLivePushConfig = livePushConfig;
|
||||
initExpressEngine();
|
||||
if (mLivePushConfig.isExpressEngine()) {
|
||||
initExpressEngine();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -446,7 +447,7 @@ public class MoGoLiveManager {
|
||||
/**
|
||||
* 初始化自定义采集
|
||||
*/
|
||||
private void initExpressEngine() {
|
||||
public void initExpressEngine() {
|
||||
Log.i(TAG, "initCustomVideoCapture 初始化引擎");
|
||||
mLiveStatusModel.setExpressEngineCanUse(true);
|
||||
// 创建 enging 对象, appID, appSign 为开发者在 ZEGO 管理控制台申请的凭证信息,
|
||||
|
||||
@@ -13,6 +13,7 @@ public class MoGoLivePushConfig {
|
||||
private int mAudioFormat = 2;
|
||||
private boolean isMute = true;
|
||||
private String devicesId;
|
||||
private boolean isExpressEngine;
|
||||
|
||||
private static MoGoLivePushConfig mMoGoLivePushConfig;
|
||||
|
||||
@@ -101,5 +102,13 @@ public class MoGoLivePushConfig {
|
||||
public void setMute(boolean mute) {
|
||||
this.isMute = mute;
|
||||
}
|
||||
|
||||
public boolean isExpressEngine() {
|
||||
return isExpressEngine;
|
||||
}
|
||||
|
||||
public void setExpressEngine(boolean expressEngine) {
|
||||
isExpressEngine = expressEngine;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -111,6 +111,7 @@ public class TrafficLiveCurrentManager
|
||||
String sn = MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getSn();
|
||||
// 初始化配置文件
|
||||
MoGoLivePushConfig mLivePushConfig = MoGoLivePushConfig.getInstance();
|
||||
// 自己对sn
|
||||
mLivePushConfig.setDevicesId(sn);
|
||||
// 登录要查看的SN房间
|
||||
MoGoLiveManager.getInstance().loginMultiRoom(liveSn);
|
||||
|
||||
Reference in New Issue
Block a user