修复了在线状态的bug
This commit is contained in:
@@ -29,6 +29,8 @@ public abstract class BaseLiveActivity extends AppCompatActivity {
|
||||
protected ToggleButton btnLive;
|
||||
// 保存文件到本地
|
||||
private ToggleButton btnSaveFile;
|
||||
// 设置摄像头与状态
|
||||
private ToggleButton btnChangeCameraState;
|
||||
|
||||
// 相机数据预览
|
||||
protected SurfaceView surfaceView;
|
||||
@@ -56,6 +58,12 @@ public abstract class BaseLiveActivity extends AppCompatActivity {
|
||||
}
|
||||
});
|
||||
|
||||
btnChangeCameraState = findViewById(R.id.btnChangeCameraState);
|
||||
btnChangeCameraState.setOnCheckedChangeListener((btnSaveFile, isChecked) -> {
|
||||
Toast.makeText(getApplicationContext(), btnSaveFile.getText(), Toast.LENGTH_SHORT).show();
|
||||
toggleCameraState(isChecked);
|
||||
});
|
||||
|
||||
initCamer();
|
||||
}
|
||||
|
||||
@@ -139,4 +147,11 @@ public abstract class BaseLiveActivity extends AppCompatActivity {
|
||||
*/
|
||||
public abstract void toggleLive(boolean isLive);
|
||||
|
||||
/**
|
||||
* 摄像头状态
|
||||
*
|
||||
* @param isLive true-可以直播,false-不可以直播
|
||||
*/
|
||||
public abstract void toggleCameraState(boolean isLive);
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.cloud;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.cloud.live.manager.ILiveStreamManager;
|
||||
import com.mogo.cloud.live.manager.LiveStreamManagerImpl;
|
||||
@@ -20,7 +21,6 @@ public class LivePushActivity extends BaseLiveActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
// 初始化直播流管理
|
||||
liveStreamManager = LiveStreamManagerImpl.getInstance(this, MoGoAiCloudClientConfig.getInstance().getSn());
|
||||
liveStreamManager.uploadCamStatus(1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -37,6 +37,16 @@ public class LivePushActivity extends BaseLiveActivity {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toggleCameraState(boolean isLive) {
|
||||
Log.i(TAG, "toggleCameraState isLive: " + isLive);
|
||||
if (isLive) {
|
||||
liveStreamManager.uploadCamStatus(1, 1);
|
||||
} else {
|
||||
liveStreamManager.uploadCamStatus(2, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
@@ -8,19 +8,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<!-- <com.baidu.rtc.RTCVideoView-->
|
||||
<!-- android:id="@+id/rtcView"-->
|
||||
<!-- android:layout_width="860px"-->
|
||||
<!-- android:layout_height="540px"-->
|
||||
<!-- android:layout_below="@+id/surfaceView" />-->
|
||||
|
||||
<!-- <com.baidu.rtc.RTCVideoView-->
|
||||
<!-- android:id="@+id/rtcRemoteView"-->
|
||||
<!-- android:layout_width="900px"-->
|
||||
<!-- android:layout_height="540px"-->
|
||||
<!-- android:layout_alignParentRight="true"-->
|
||||
<!-- android:layout_below="@+id/surfaceView" />-->
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/flTestPanel"
|
||||
@@ -37,6 +24,14 @@
|
||||
android:textOff="@string/start"
|
||||
android:textOn="@string/stop" />
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/btnChangeCameraState"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:textOff="设置不可直播"
|
||||
android:textOn="设置可直播" />
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/btnSaveFile"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -7,6 +7,8 @@ import com.mogo.cloud.socket.IMogoCloudSocketMsgAckListener;
|
||||
import com.mogo.cloud.socket.IMogoCloudSocketOnMessageListener;
|
||||
import com.mogo.cloud.socket.MsgBody;
|
||||
import com.mogo.cloud.socket.SocketManager;
|
||||
import com.zhidao.ptech.connsvr.commom.protocol.MogoCommon;
|
||||
import com.zhidao.socket.SocketClient;
|
||||
|
||||
/**
|
||||
* Socket常链接工具类
|
||||
@@ -64,7 +66,10 @@ public class SocketMsgUtils implements IMogoCloudSocketMsgAckListener {
|
||||
* @param body 数据包
|
||||
*/
|
||||
public void uploadCamInfo(MsgBody body) {
|
||||
mSocketManager.sendMsg(appId, headerType, body, this);
|
||||
SocketClient.getInstance().sendData(appId,
|
||||
MogoCommon.Product.mogoBussiness.getNumber(),
|
||||
(byte[]) body.getContent(), headerType, true, body.getMsgId());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.mogo.cloud.live.socket;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.zhidao.ptech.connsvr.protocol.MogoConnsvr;
|
||||
import com.zhidao.ptech.shadow.server.protocol.DeviceInfo;
|
||||
import com.zhidao.utils.common.TelephoneUtil;
|
||||
|
||||
public class SocketRequestUtils {
|
||||
public static DeviceInfo.DeviceInfoData buildDeviceData(int c1, int c2) {
|
||||
public static byte[] buildDeviceData(int c1, int c2) {
|
||||
DeviceInfo.CameraStatus c1Status = DeviceInfo.CameraStatus.forNumber(c1);
|
||||
DeviceInfo.CameraStatus c2Status = DeviceInfo.CameraStatus.forNumber(c2);
|
||||
DeviceInfo.CameraInfo cameraInfo = DeviceInfo.CameraInfo.newBuilder()
|
||||
@@ -15,8 +17,14 @@ public class SocketRequestUtils {
|
||||
.setCameraInfo(cameraInfo)
|
||||
.setSn(TelephoneUtil.getSerialNumber())
|
||||
.setTimestamp(System.currentTimeMillis()).build();
|
||||
return data;
|
||||
return buildSocketPayload(data.toByteArray(), 196614);
|
||||
}
|
||||
|
||||
private static byte[] buildSocketPayload(byte[] payload, int payloadType) {
|
||||
MogoConnsvr.Payload payloadData = MogoConnsvr.Payload.newBuilder()
|
||||
.setMsgType(payloadType)
|
||||
.setPayload(ByteString.copyFrom(payload)).build();
|
||||
return payloadData.toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -84,7 +84,8 @@ public class SocketManager implements IMogoCloudSocketManager, Callback {
|
||||
.setClient(Platform.getClient(Platform.car))
|
||||
.setChannelId(SocketServicesConstants.SOCKET_CHANNEL_ID)
|
||||
.setOpenAnalytics(true)
|
||||
.setSn(cloudClientConfig.getSn())
|
||||
// TODO 这里先用设备ID,原因是因为后台分配的SN与蘑菇自研车机SN不符合导致在线及推送有问题
|
||||
.setSn(cloudClientConfig.getThirdPartyDeviceId())
|
||||
.setToken(cloudClientConfig.getToken())
|
||||
.setAuthPubKey(cloudClientConfig.getAuthPubKey())
|
||||
.setDebug(cloudClientConfig.isShowDebugLog());
|
||||
|
||||
Reference in New Issue
Block a user