Steven 2 年之前
父節點
當前提交
3a40a2b796

二進制
KulexiuForStudent/KulexiuForStudent.xcworkspace/xcuserdata/wangzhi.xcuserdatad/UserInterfaceState.xcuserstate


+ 50 - 2
KulexiuForStudent/KulexiuForStudent.xcworkspace/xcuserdata/wangzhi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -126,8 +126,8 @@
             filePath = "KulexiuForStudent/Module/Live/Controller/LiveVideoRoomViewController.m"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "687"
-            endingLineNumber = "687"
+            startingLineNumber = "728"
+            endingLineNumber = "728"
             landmarkName = "-updateVideoViewContainer"
             landmarkType = "7">
          </BreakpointContent>
@@ -500,5 +500,53 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "84DE9E35-E62D-4C6B-AB45-37F619865FD1"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "KulexiuForStudent/Module/Live/Controller/LiveVideoRoomViewController.m"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "754"
+            endingLineNumber = "754"
+            landmarkName = "-updateVideoViewContainer"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "A8FC4392-7631-409C-A01A-EB2D3FF3209E"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "KulexiuForStudent/Module/Live/Controller/LiveVideoRoomViewController.m"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "842"
+            endingLineNumber = "842"
+            landmarkName = "LiveVideoRoomViewController"
+            landmarkType = "3">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "BC893046-7BBE-47D7-9C82-A0579FCE0066"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "KulexiuForStudent/Module/Live/Controller/LiveVideoRoomViewController.m"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "650"
+            endingLineNumber = "650"
+            landmarkName = "-connectHostWithStatus:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
    </Breakpoints>
 </Bucket>

+ 1 - 0
KulexiuForStudent/KulexiuForStudent/Common/Base/RCConnectionManager.m

@@ -60,6 +60,7 @@
     if (status == ConnectionStatus_Connected) { // RTC会自动断线重连 此处多余
         self.isConnected = YES;
         NSLog(@"connect im success");
+        [[NSNotificationCenter defaultCenter] postNotificationName:@"RongIMConnected" object:nil];
     }
     else if (status == ConnectionStatus_KICKED_OFFLINE_BY_OTHER_CLIENT) { // 账号被挤掉
         

+ 50 - 17
KulexiuForStudent/KulexiuForStudent/Module/Live/Controller/LiveVideoRoomViewController.m

@@ -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];
                         }