|
@@ -6,9 +6,12 @@ import android.util.Log;
|
|
|
import com.cooleshow.base.data.net.BaseResponse;
|
|
|
import com.cooleshow.base.presenter.BasePresenter;
|
|
|
import com.cooleshow.base.rx.BaseObserver;
|
|
|
+import com.cooleshow.base.utils.LogUtils;
|
|
|
import com.cooleshow.base.utils.RequestBodyUtil;
|
|
|
import com.cooleshow.student.api.APIService;
|
|
|
import com.cooleshow.student.bean.FriendInfoBean;
|
|
|
+import com.daya.live_teaching.common.ErrorCode;
|
|
|
+import com.daya.live_teaching.common.ResultCallback;
|
|
|
import com.rong.io.live.bean.ImUserState;
|
|
|
import com.cooleshow.student.bean.LiveRoomInfoBean;
|
|
|
import com.cooleshow.student.contract.LiveRoomContract;
|
|
@@ -86,8 +89,22 @@ public class LiveRoomPresenter extends BasePresenter<LiveRoomContract.view> impl
|
|
|
@Override
|
|
|
public void onRemoteUserPublishResource(RCRTCRemoteUser rcrtcRemoteUser, List<RCRTCInputStream> list) {
|
|
|
Log.i("pq", "onRemoteUserPublishResource:");
|
|
|
- if (getView() != null) {
|
|
|
- getView().onRemoteUserPublishResource(rcrtcRemoteUser.getUserId());
|
|
|
+ if (currentRoomInfo != null && TextUtils.equals(currentRoomInfo.speakerId, rcrtcRemoteUser.getUserId())) {
|
|
|
+ subscribeAVStream();
|
|
|
+ } else {
|
|
|
+ subscribeTargetStream(rcrtcRemoteUser.getUserId(), list, new ResultCallback<String>() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(String s) {
|
|
|
+ if (getView() != null) {
|
|
|
+ getView().onRemoteUserPublishResource(rcrtcRemoteUser.getUserId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int errorCode, String errorStr) {
|
|
|
+ LogUtils.i("pq","subscribeTargetStream fail:errorCode:"+errorCode+"errorStr:"+errorStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -175,7 +192,7 @@ public class LiveRoomPresenter extends BasePresenter<LiveRoomContract.view> impl
|
|
|
if (currentConnectionStatus == RongIMClient.ConnectionStatusListener.ConnectionStatus.CONNECTED) {
|
|
|
Log.i("pq", "LiveRoomActivity init getRoomInfo");
|
|
|
getRoomInfo(roomId);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
connectIM();
|
|
|
}
|
|
|
|
|
@@ -453,10 +470,10 @@ public class LiveRoomPresenter extends BasePresenter<LiveRoomContract.view> impl
|
|
|
private void joinRoom(String roomId, boolean isCreate) {
|
|
|
//如果是观众就直接加入房间
|
|
|
Log.i("pq", "joinRoom");
|
|
|
- LiveEventHelper.getInstance().joinRoom(roomId,RCRTCLiveRole.AUDIENCE,new ClickCallback<Boolean>() {
|
|
|
+ LiveEventHelper.getInstance().joinRoom(roomId, RCRTCLiveRole.AUDIENCE, new ClickCallback<Boolean>() {
|
|
|
@Override
|
|
|
public void onResult(Boolean result, String msg) {
|
|
|
- Log.i("pq", "joinRoom onResult:" + result+"->"+msg);
|
|
|
+ Log.i("pq", "joinRoom onResult:" + result + "->" + msg);
|
|
|
if (result) {
|
|
|
setCurrentRoom(currentRoomInfo, isCreate);
|
|
|
refreshMusicView(true);
|
|
@@ -982,6 +999,38 @@ public class LiveRoomPresenter extends BasePresenter<LiveRoomContract.view> impl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 订阅指定的流
|
|
|
+ *
|
|
|
+ * @param userId
|
|
|
+ * @param list
|
|
|
+ * @param callback
|
|
|
+ */
|
|
|
+ public void subscribeTargetStream(final String userId, List<RCRTCInputStream> list, final ResultCallback<String> callback) {
|
|
|
+ RCRTCRoom rcrtcRoom = LiveEventHelper.getInstance().getRtcRoom();
|
|
|
+ if (rcrtcRoom == null) {
|
|
|
+ Log.i("pq", "unSubscribeStream failed , rcrtcRoom is null");
|
|
|
+ if (callback != null) {
|
|
|
+ callback.onFail(ErrorCode.RTC_ERROR.getCode(), null);
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ rcrtcRoom.getLocalUser().subscribeStreams(list, new IRCRTCResultCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess() {
|
|
|
+ if (callback != null) {
|
|
|
+ callback.onSuccess("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFailed(RTCErrorCode errorCode) {
|
|
|
+ if (callback != null) {
|
|
|
+ callback.onFail(errorCode.getValue(), errorCode.getReason());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 主动订阅远端用户发布的流
|