diff --git a/app/src/main/java/com/mogo/cloud/BaseLiveActivity.java b/app/src/main/java/com/mogo/cloud/BaseLiveActivity.java index de3620e..90fde31 100644 --- a/app/src/main/java/com/mogo/cloud/BaseLiveActivity.java +++ b/app/src/main/java/com/mogo/cloud/BaseLiveActivity.java @@ -139,10 +139,4 @@ public abstract class BaseLiveActivity extends AppCompatActivity { */ public abstract void toggleLive(boolean isLive); - /** - * 是否是静音模式 - * - * @param isMute true-静音,false-非静音 - */ - public abstract void toggleMute(boolean isMute); } \ No newline at end of file diff --git a/app/src/main/java/com/mogo/cloud/PushActivity.java b/app/src/main/java/com/mogo/cloud/PushActivity.java index 00f2946..5abd44d 100644 --- a/app/src/main/java/com/mogo/cloud/PushActivity.java +++ b/app/src/main/java/com/mogo/cloud/PushActivity.java @@ -1,14 +1,10 @@ package com.mogo.cloud; -import android.media.AudioFormat; import android.os.Bundle; -import android.os.SystemClock; import android.util.Log; -import com.mogo.cloud.live.listener.ILiveProgressListener; -import com.mogo.cloud.live.manager.MGLivePushConfig; -import com.mogo.cloud.live.manager.ZeGoLiveManager; -import com.mogo.cloud.live.utils.ByteUtils; +import com.mogo.cloud.live.manager.CameraFrameManager; +import com.mogo.cloud.live.server.PushService; import com.mogo.cloud.util.Devices; @@ -18,103 +14,37 @@ import com.mogo.cloud.util.Devices; public class PushActivity extends BaseLiveActivity { public static final String TAG = "PushActivity"; - private boolean isLoginSuccess = false; private boolean isLive = false; - private boolean isOnStart = false; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - MGLivePushConfig mLivePushConfig = new MGLivePushConfig(); - mLivePushConfig.setWidth(1280); - mLivePushConfig.setHeight(720); - mLivePushConfig.setVideoBitrate(1500); - mLivePushConfig.setVideoFPS(15); - mLivePushConfig.setAudioChannels(2); - mLivePushConfig.setAudioSampleRate(44100); - mLivePushConfig.setAudioFormat(AudioFormat.ENCODING_PCM_16BIT); - mLivePushConfig.setMute(true); - - ZeGoLiveManager.getInstance().init(this.getApplication(), mLivePushConfig); - ZeGoLiveManager.getInstance().setLiveProgressListener(new ILiveProgressListener() { - @Override - public void onStart() { - Log.i(TAG, "onStart"); - isOnStart = true; - } - - @Override - public void onStop() { - Log.i(TAG, "onStop"); - isOnStart = false; - } - - @Override - public void onConnecting() { - Log.i(TAG, "onConnecting"); - } - - @Override - public void onConnected(String roomId) { - Log.i(TAG, "onConnected"); - isLoginSuccess = true; - } - - @Override - public void onDisConnect() { - Log.i(TAG, "onDisConnect"); - isLoginSuccess = false; - } - - @Override - public void onDebugError(int errorCode, String funcName, String errorInfo) { - Log.i(TAG, "errorCode : " + errorCode + " , funcName : " + funcName + " , errorInfo : " + errorInfo); - } - }); } @Override public void onVideoFrame(byte[] bytes, int bytesLength) { - if (!isLoginSuccess) { -// Log.i(TAG, "还未进房成功"); - return; - } - if (!isOnStart) { -// Log.i(TAG, "还未执行onStart回调"); - return; - } if (!isLive) { return; } - Log.i(TAG, "onVideoFrame byte length: " + bytesLength); - ZeGoLiveManager.getInstance().startPublishingStream(ByteUtils.getBuffer(bytes, bytesLength), bytesLength, SystemClock.elapsedRealtime()); + //Log.i(TAG, "onVideoFrame byte length: " + bytesLength); + CameraFrameManager.getInstance().notifyYUVData(bytes, 1280, 720, 3); } @Override public void toggleLive(boolean isLive) { - this.isLive = isLive; - if (!isLoginSuccess) { - Log.i(TAG, "toggleLive isLive : " + isLive); - btnLive.setChecked(!isLive); - return; - } Log.i(TAG, "toggleLive : " + isLive); + this.isLive = isLive; if (isLive) { - ZeGoLiveManager.getInstance().startPush(Devices.getSn()); + PushService.startService(this, PushService.ACTION_START_RTMP_PUSH, Devices.getSn()); } else { - ZeGoLiveManager.getInstance().stopPublish(); + PushService.startService(this, PushService.ACTION_STOP_RTMP_PUSH, null); } } - @Override - public void toggleMute(boolean isMute) { - - } - @Override protected void onDestroy() { super.onDestroy(); - ZeGoLiveManager.getInstance().onDestroyPublish(); + PushService.startService(this, PushService.ACTION_STOP_RTMP_PUSH, null); } } \ No newline at end of file diff --git a/foudations/mogo-live/src/main/java/com/mogo/cloud/live/server/PushService.java b/foudations/mogo-live/src/main/java/com/mogo/cloud/live/server/PushService.java index 45d7642..24d688c 100644 --- a/foudations/mogo-live/src/main/java/com/mogo/cloud/live/server/PushService.java +++ b/foudations/mogo-live/src/main/java/com/mogo/cloud/live/server/PushService.java @@ -22,7 +22,6 @@ public class PushService extends Service implements IYUVDataListener { private static final String TAG = "PushService"; private static final String DEVICES_ID = "devices_id"; - private static final String CAM_ID = "cam_id"; private static final int WIDTH = 1280; private static final int HEIGHT = 720; @@ -42,14 +41,12 @@ public class PushService extends Service implements IYUVDataListener { * @param context 上下文 * @param action 动作标志 * @param devicesId 设备ID - * @param camId 摄像头 */ public static void startService(Context context, String action, - String devicesId, String camId) { + String devicesId) { Intent intent = new Intent(context, PushService.class); intent.setAction(action); intent.putExtra(DEVICES_ID, devicesId); - intent.putExtra(CAM_ID, camId); context.startService(intent); }