完成了直播播放的拉流demo

This commit is contained in:
董宏宇
2021-02-03 17:46:47 +08:00
parent 533f4df3b9
commit f325f43171
8 changed files with 160 additions and 9 deletions

View File

@@ -0,0 +1,50 @@
package com.mogo.cloud;
import android.os.Bundle;
import android.util.Log;
import com.mogo.cloud.live.manager.CameraFrameManager;
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);
}
@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);
}
}