Merge remote-tracking branch 'origin/live_sdk' into live_sdk
This commit is contained in:
@@ -4,7 +4,7 @@ import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.cloud.live.manager.CameraFrameManager;
|
||||
import com.mogo.cloud.live.manager.LiveStreamManager;
|
||||
import com.mogo.cloud.live.manager.ILiveStreamManager;
|
||||
import com.mogo.cloud.live.manager.LiveStreamManagerImpl;
|
||||
import com.mogo.cloud.live.server.PushService;
|
||||
import com.mogo.cloud.util.Devices;
|
||||
@@ -23,7 +23,7 @@ public class LivePushActivity extends BaseLiveActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// 初始化直播流管理
|
||||
LiveStreamManager liveStreamManager = LiveStreamManagerImpl.getInstance(this, Devices.getSn());
|
||||
ILiveStreamManager liveStreamManager = LiveStreamManagerImpl.getInstance(this, Devices.getSn());
|
||||
liveStreamManager.uploadCamStatus(1, 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.mogo.cloud.live.constant;
|
||||
|
||||
public class LiveConstant {
|
||||
|
||||
public static final String TAG = "MoGoAiCloud_Live";
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package com.mogo.cloud.live.manager;
|
||||
|
||||
import com.mogo.cloud.live.listener.ILiveStatusListener;
|
||||
|
||||
public interface LiveStreamManager {
|
||||
public interface ILiveStreamManager {
|
||||
/**
|
||||
* 开始直播
|
||||
*/
|
||||
@@ -13,16 +13,16 @@ import com.mogo.cloud.live.utils.LiveStreamUtils;
|
||||
*
|
||||
* @author donghongyu
|
||||
*/
|
||||
public class LiveStreamManagerImpl implements LiveStreamManager {
|
||||
public class LiveStreamManagerImpl implements ILiveStreamManager {
|
||||
private static final String TAG = "LiveStreamManagerImpl";
|
||||
|
||||
private static volatile LiveStreamManager sInstance;
|
||||
private static volatile ILiveStreamManager sInstance;
|
||||
public static volatile String mDevicesId;
|
||||
|
||||
private Context mContext;
|
||||
private LiveStreamUtils mLiveStreamUtils;
|
||||
private final Context mContext;
|
||||
private final LiveStreamUtils mLiveStreamUtils;
|
||||
|
||||
public static LiveStreamManager getInstance(Context context, String devicesId) {
|
||||
public static ILiveStreamManager getInstance(Context context, String devicesId) {
|
||||
if (sInstance == null) {
|
||||
synchronized (LiveStreamManagerImpl.class) {
|
||||
if (sInstance == null) {
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.mogo.cloud.live.manager;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.mogo.cloud.live.constant.LiveConstant;
|
||||
import com.mogo.cloud.live.listener.ILiveProgressListener;
|
||||
import com.mogo.cloud.live.model.BaseData;
|
||||
import com.mogo.cloud.live.model.LivePush;
|
||||
import com.mogo.cloud.live.network.LiveApiServer;
|
||||
import com.mogo.cloud.network.NetConstants;
|
||||
import com.mogo.cloud.network.RetrofitFactory;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import rx.Observer;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* 请求直播管理类
|
||||
*/
|
||||
public class RequestLiveManager {
|
||||
|
||||
private static volatile RequestLiveManager requestLiveManager;
|
||||
private final LiveApiServer liveApiServer;
|
||||
|
||||
private RequestLiveManager() {
|
||||
liveApiServer = RetrofitFactory.INSTANCE.getInstance(NetConstants.DEVA_HOST)
|
||||
.create(LiveApiServer.class);
|
||||
}
|
||||
|
||||
public static RequestLiveManager getInstance() {
|
||||
if (requestLiveManager == null) {
|
||||
synchronized (RequestLiveManager.class) {
|
||||
if (requestLiveManager == null) {
|
||||
requestLiveManager = new RequestLiveManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return requestLiveManager;
|
||||
}
|
||||
|
||||
public void requestVehicleHeadLive(Application application, String liveSn, ILiveProgressListener liveProgressListener) {
|
||||
Gson gson = new Gson();
|
||||
LivePush livePush = new LivePush(liveSn, "1", "C_1");
|
||||
String sn = MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getSn();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("sn", sn);
|
||||
map.put("type", gson.toJson(livePush));
|
||||
liveApiServer.getVehicleHeadLive(map)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseData>() {
|
||||
@Override
|
||||
public void onCompleted() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Logger.e(LiveConstant.TAG, "requestVehicleHeadLive exception : " + e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseData baseData) {
|
||||
MoGoLiveManager.getInstance().init(application, null);
|
||||
MoGoLiveManager.getInstance().loginRoom(sn, liveSn);
|
||||
MoGoLiveManager.getInstance().setLiveProgressListener(liveProgressListener);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.mogo.cloud.live.model;
|
||||
|
||||
/**
|
||||
* 请求直播
|
||||
*/
|
||||
public class LivePush {
|
||||
|
||||
private String sn;
|
||||
private String type;
|
||||
private String videoChannel; //C_1 前摄
|
||||
|
||||
public LivePush(String sn, String type, String videoChannel) {
|
||||
this.sn = sn;
|
||||
this.type = type;
|
||||
this.videoChannel = videoChannel;
|
||||
}
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
|
||||
public void setSn(String sn) {
|
||||
this.sn = sn;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getVideoChannel() {
|
||||
return videoChannel;
|
||||
}
|
||||
|
||||
public void setVideoChannel(String videoChannel) {
|
||||
this.videoChannel = videoChannel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LivePush{" +
|
||||
"sn='" + sn + '\'' +
|
||||
", type='" + type + '\'' +
|
||||
", videoChannel='" + videoChannel + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ public interface LiveApiServer {
|
||||
* @return {@link BaseData}
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("")
|
||||
@POST("/dataSave/integratedServices/app/push/no/livePushAndSwitch/v1")
|
||||
Observable<BaseData> getVehicleHeadLive(@FieldMap Map<String, String> vehicleHeadLiveMap);
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,8 +32,10 @@ dependencies {
|
||||
|
||||
if (Boolean.valueOf(RELEASE)) {
|
||||
implementation "com.mogo.cloud:network:${MOGO_NETWORK_VERSION}"
|
||||
implementation "com.mogo.cloud:network:${MOGO_LIVE_VERSION}"
|
||||
} else {
|
||||
implementation project(":foudations:mogo-network")
|
||||
implementation project(":foudations:mogo-live")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
package com.mogo.cloud.trafficlive.core;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import com.mogo.cloud.live.listener.ILiveProgressListener;
|
||||
import com.mogo.cloud.live.manager.RequestLiveManager;
|
||||
import com.mogo.cloud.trafficlive.api.ITrafficLiveCallBack;
|
||||
|
||||
public class TrafficLiveManager {
|
||||
public class TrafficLiveManager implements ILiveProgressListener {
|
||||
|
||||
private static volatile TrafficLiveManager mInstance;
|
||||
private RequestLiveManager requestLiveManager;
|
||||
private ITrafficLiveCallBack callBack;
|
||||
|
||||
private TrafficLiveManager() {
|
||||
}
|
||||
@@ -20,11 +26,49 @@ public class TrafficLiveManager {
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
public void getVehicleHeadLiveUrl(ITrafficLiveCallBack callBack){
|
||||
public void getVehicleHeadLiveUrl(Application application, String liveSn, ITrafficLiveCallBack callBack) {
|
||||
if (callBack == null) {
|
||||
this.callBack = callBack;
|
||||
}
|
||||
requestLiveManager.requestVehicleHeadLive(application, liveSn, this);
|
||||
}
|
||||
|
||||
public void getIntersectionLiveUrl(ITrafficLiveCallBack callBack) {
|
||||
|
||||
}
|
||||
|
||||
public void getIntersectionLiveUrl(ITrafficLiveCallBack callBack){
|
||||
@Override
|
||||
public void onStart() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnecting() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnected(String roomId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisConnect() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRoomStreamUpdate(String streamId, boolean isLive) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDebugError(int errorCode, String funcName, String errorInfo) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user