|
@@ -236,7 +236,13 @@ static int clickPraiseBtnTimes = 0;
|
|
|
}
|
|
|
|
|
|
- (void)joinRTCRoom {
|
|
|
- [self setRoleType];
|
|
|
+ if (self.room && self.liveRoleType == RCRTCLiveRoleTypeBroadcaster) {
|
|
|
+ [self connectHostWithStatus:NO];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [self setRoleType];
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- (void)judgeAutoClose {
|
|
@@ -573,7 +579,7 @@ static int clickPraiseBtnTimes = 0;
|
|
|
[strongSelf subscribeRemoteResource:streamArray];
|
|
|
}
|
|
|
else {
|
|
|
-
|
|
|
+ [strongSelf updateVideoViewContainer];
|
|
|
}
|
|
|
|
|
|
strongSelf.micStatus = MICSTATUS_CONNECTING;
|
|
@@ -585,9 +591,20 @@ static int clickPraiseBtnTimes = 0;
|
|
|
NSLog(@"------- up error code %ld", code);
|
|
|
weakSelf.isTransferRole = NO;
|
|
|
dispatch_main_async_safe(^{
|
|
|
- // 失败
|
|
|
- [weakSelf MBPShow:@"上麦失败"];
|
|
|
- weakSelf.micStatus = MICSTATUS_NOMAL;
|
|
|
+ if (code == RCRTCCodeSwitchRoleSameRoleError) {
|
|
|
+ weakSelf.liveRoleType = RCRTCLiveRoleTypeBroadcaster;
|
|
|
+ // 失败
|
|
|
+ weakSelf.micStatus = MICSTATUS_CONNECTING;
|
|
|
+ // 刷新麦位状态
|
|
|
+ [weakSelf renderSeatView];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // 失败
|
|
|
+ [weakSelf MBPShow:@"上麦失败"];
|
|
|
+ weakSelf.micStatus = MICSTATUS_NOMAL;
|
|
|
+ [weakSelf renderSeatView];
|
|
|
+ }
|
|
|
+
|
|
|
});
|
|
|
|
|
|
} onKicked:^{
|
|
@@ -607,8 +624,9 @@ static int clickPraiseBtnTimes = 0;
|
|
|
__strong typeof(weakSelf) strongSelf = weakSelf;
|
|
|
strongSelf.liveRoleType = RCRTCLiveRoleTypeAudience;
|
|
|
[strongSelf.engine.defaultAudioStream setMicrophoneDisable:YES];
|
|
|
+
|
|
|
+ NSMutableArray *streamArray = [NSMutableArray array];
|
|
|
if (strongSelf.room.remoteUsers.count) {
|
|
|
- NSMutableArray *streamArray = [NSMutableArray array];
|
|
|
NSArray *remoteUserArray = [strongSelf.room.remoteUsers mutableCopy];
|
|
|
for (RCRTCRemoteUser *user in remoteUserArray) {
|
|
|
if (user.remoteStreams.count) {
|
|
@@ -617,9 +635,10 @@ static int clickPraiseBtnTimes = 0;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else {
|
|
|
-
|
|
|
+ if (streamArray.count == 0) {
|
|
|
+ [strongSelf updateVideoViewContainer];
|
|
|
}
|
|
|
+
|
|
|
strongSelf.micStatus = MICSTATUS_NOMAL;
|
|
|
// 刷新麦位状态
|
|
|
[strongSelf renderSeatView];
|
|
@@ -631,9 +650,19 @@ static int clickPraiseBtnTimes = 0;
|
|
|
weakSelf.isTransferRole = NO;
|
|
|
NSLog(@"------- down error code %ld", code);
|
|
|
dispatch_main_async_safe(^{
|
|
|
- // 失败
|
|
|
- [weakSelf MBPShow:@"下麦失败"];
|
|
|
- weakSelf.micStatus = MICSTATUS_CONNECTING;
|
|
|
+ if (code == RCRTCCodeSwitchRoleSameRoleError) {
|
|
|
+ weakSelf.liveRoleType = RCRTCLiveRoleTypeAudience;
|
|
|
+ weakSelf.micStatus = MICSTATUS_NOMAL;
|
|
|
+ [weakSelf renderSeatView];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // 失败
|
|
|
+ [weakSelf MBPShow:@"下麦失败"];
|
|
|
+ weakSelf.micStatus = MICSTATUS_CONNECTING;
|
|
|
+ }
|
|
|
+ // 刷新麦位状态
|
|
|
+ [weakSelf renderSeatView];
|
|
|
+
|
|
|
});
|
|
|
|
|
|
} onKicked:^{
|
|
@@ -683,11 +712,11 @@ static int clickPraiseBtnTimes = 0;
|
|
|
|
|
|
// 更新视图
|
|
|
- (void)updateVideoViewContainer {
|
|
|
-
|
|
|
+ NSMutableArray *steamArray = [self.streamVideos mutableCopy];
|
|
|
if (self.streamVideos.count > 0) {
|
|
|
// 渲染主播的流 优先显示主播的共享流
|
|
|
KSLiveStreamVideo *mainVideo = nil;
|
|
|
- for (KSLiveStreamVideo *videoSource in self.streamVideos) {
|
|
|
+ for (KSLiveStreamVideo *videoSource in steamArray) {
|
|
|
if ([videoSource.userId isEqualToString:self.createrId]) { // 主屏只渲染主讲人
|
|
|
if ([videoSource.streamTag isEqualToString:@"screenshare"]) { // 如果是共享流
|
|
|
if (![self.videoView.streamId isEqualToString:videoSource.streamId]) { // 主屏渲染不同 则重新渲染
|
|
@@ -849,7 +878,8 @@ static int clickPraiseBtnTimes = 0;
|
|
|
|
|
|
// 根据 streamId 确认唯一的音视频流
|
|
|
- (KSLiveStreamVideo *)fetchStreamVideoWithStreamId:(NSString *)streamId {
|
|
|
- for (KSLiveStreamVideo *sVideo in self.streamVideos) {
|
|
|
+ NSMutableArray *streamArray = [self.streamVideos mutableCopy];
|
|
|
+ for (KSLiveStreamVideo *sVideo in streamArray) {
|
|
|
if ([streamId isEqualToString:sVideo.streamId]) {
|
|
|
return sVideo;
|
|
|
}
|
|
@@ -946,8 +976,10 @@ static int clickPraiseBtnTimes = 0;
|
|
|
if (self.micStatus == MICSTATUS_CONNECTING) {
|
|
|
[self connectHostWithStatus:NO];
|
|
|
}
|
|
|
+ else {
|
|
|
+ [self removeSeatContainer];
|
|
|
+ }
|
|
|
self.micStatus = MICSTATUS_NOMAL;
|
|
|
- [self removeSeatContainer];
|
|
|
}
|
|
|
|
|
|
- (void)resetMicWaitToNomal {
|
|
@@ -1318,6 +1350,7 @@ static int clickPraiseBtnTimes = 0;
|
|
|
RCChatroomSeatsControl *seatControlMessage = (RCChatroomSeatsControl *)rcMessage.content;
|
|
|
if (seatControlMessage.seatBan) { // 禁止连麦
|
|
|
__blockSelf.enableSeat = NO;
|
|
|
+ __blockSelf.micStatus = MICSTATUS_NOMAL;
|
|
|
}
|
|
|
else { // 开启连麦
|
|
|
__blockSelf.enableSeat = YES;
|
|
@@ -1336,8 +1369,8 @@ static int clickPraiseBtnTimes = 0;
|
|
|
NSString *titles = [NSString stringWithFormat:@"%@邀请您连麦",[NSString returnNoNullStringWithString:seatApplyMessage.teacherName]];
|
|
|
[__blockSelf showInviteAlertMessage:titles];
|
|
|
}
|
|
|
- else if (seatApplyMessage.type == SEATHANDLE_DISINVITE) { // 主讲人撤回申请
|
|
|
- [__blockSelf MBPShow:@"主讲人撤回了连麦申请"];
|
|
|
+ else if (seatApplyMessage.type == SEATHANDLE_DISINVITE) { // 主讲人撤回邀请
|
|
|
+ [__blockSelf MBPShow:@"主讲人撤回了连麦邀请"];
|
|
|
if (__blockSelf.alertView && __blockSelf.alertView.isShow) {
|
|
|
[__blockSelf.alertView dismissAlertView];
|
|
|
}
|