55 lines
1.6 KiB
Java
55 lines
1.6 KiB
Java
package com.mogo.cloud;
|
|
|
|
import android.os.Bundle;
|
|
import android.util.Log;
|
|
|
|
import com.mogo.cloud.live.manager.CameraFrameManager;
|
|
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;
|
|
|
|
|
|
/**
|
|
* 推流页面
|
|
*/
|
|
public class LivePushActivity extends BaseLiveActivity {
|
|
public static final String TAG = "PushActivity";
|
|
|
|
private boolean isLive = false;
|
|
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
|
|
// 初始化直播流管理
|
|
ILiveStreamManager liveStreamManager = LiveStreamManagerImpl.getInstance(this, Devices.getSn());
|
|
liveStreamManager.uploadCamStatus(1, 1);
|
|
}
|
|
|
|
@Override
|
|
public void onVideoFrame(byte[] bytes, int bytesLength) {
|
|
if (!isLive) {
|
|
return;
|
|
}
|
|
//Log.i(TAG, "onVideoFrame byte length: " + bytesLength);
|
|
CameraFrameManager.getInstance().notifyYUVData(bytes, 1280, 720, 3);
|
|
}
|
|
|
|
@Override
|
|
public void toggleLive(boolean isLive) {
|
|
Log.i(TAG, "toggleLive : " + isLive);
|
|
this.isLive = isLive;
|
|
if (isLive) {
|
|
PushService.startService(this, PushService.ACTION_START_RTMP_PUSH, Devices.getSn());
|
|
} else {
|
|
PushService.startService(this, PushService.ACTION_STOP_RTMP_PUSH, null);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected void onDestroy() {
|
|
super.onDestroy();
|
|
PushService.startService(this, PushService.ACTION_STOP_RTMP_PUSH, null);
|
|
}
|
|
} |