Steven 1 anno fa
parent
commit
e34887a09e

+ 1 - 1
KulexiuForTeacher/KulexiuForTeacher.xcodeproj/xcshareddata/xcschemes/KulexiuForTeacher.xcscheme

@@ -52,7 +52,7 @@
       </Testables>
    </TestAction>
    <LaunchAction
-      buildConfiguration = "TEST"
+      buildConfiguration = "Debug"
       selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
       launchStyle = "0"

+ 1 - 1
KulexiuForTeacher/KulexiuForTeacher/Module/Course/Controller/CourseViewController.m

@@ -553,7 +553,7 @@
     [KSNetworkingManager courseAdjustRequst:KS_POST courseId:model.courseId classDate:classDate startTime:chooseTime endTime:endTime success:^(NSDictionary * _Nonnull dic) {
         [LOADING_MANAGER removeHUD];
         if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
-            [LOADING_MANAGER KSShowMsg:@"下架成功" promptCompletion:^{
+            [LOADING_MANAGER KSShowMsg:@"调整成功" promptCompletion:^{
                 [self loadMonthCourse:self.chooseMonth];
                 if (![NSString isEmptyString:self.chooseDay]) {
                     [self getCourseByDate:self.chooseDay];

+ 12 - 1
KulexiuForTeacher/KulexiuForTeacher/Module/TXClassRoom/Controller/TXClassroomViewController.m

@@ -161,6 +161,16 @@
 @end
 
 @implementation TXClassroomViewController
+
+- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
+    [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
+    [coordinator animateAlongsideTransition:nil completion:^(id<UIViewControllerTransitionCoordinatorContext>  _Nonnull context) {
+        if (size.width > size.height) {
+            [TRTC_MANAGER refreshGSMode];
+        }
+    }];
+}
+
 -(BOOL)prefersHomeIndicatorAutoHidden {
     return YES;
 }
@@ -177,7 +187,7 @@
         [UIDevice switchNewOrientation:UIInterfaceOrientationLandscapeRight inController:self];
     }
     else {
-        // 切换到
+        // 切换到
         AppDelegate* delegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
         delegate.allowAutoRotate = NO;
         dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
@@ -1971,6 +1981,7 @@
 
 
 - (void)dealloc {
+    NSLog(@"----- class room dealloc----");
     [[NSNotificationCenter defaultCenter] removeObserver:self];
 }
 

+ 3 - 0
KulexiuForTeacher/KulexiuForTeacher/Module/TXClassRoom/Service/TRTC/TXRTCService.h

@@ -36,6 +36,9 @@ NS_ASSUME_NONNULL_BEGIN
 
 + (instancetype)shareInstance;
 
+// 刷新publish重力感应模式
+- (void)refreshGSMode;
+
 - (void)setting3AParmWithANS:(NSInteger)ANS AEC:(NSInteger)AEC AGC:(NSInteger)AGC;
 
 - (void)config3AWithANS:(NSInteger)ANS AEC:(NSInteger)AEC AGC:(NSInteger)AGC;

+ 31 - 39
KulexiuForTeacher/KulexiuForTeacher/Module/TXClassRoom/Service/TRTC/TXRTCService.m

@@ -27,8 +27,6 @@
 
 @property (nonatomic, copy) KSRTCCallback error;
 
-@property (nonatomic, strong) TRTCCloud *engine;
-
 @end
 
 @implementation TXRTCService
@@ -43,6 +41,9 @@
     return service;
 }
 
+- (void)refreshGSMode {
+    [[TRTCCloud sharedInstance] setGravitySensorAdaptiveMode:TRTCGravitySensorAdaptiveMode_Disable];
+}
 - (void)defaultAudioSetting {
     self.ANS = 0;
     self.AEC = 100;
@@ -70,8 +71,8 @@
     if (error) {
         self.error = error;
     }
-    [self.engine enterRoom:[self getTRTCRoomConfig:roomId] appScene:TRTCAppSceneVideoCall];
-    self.engine.delegate = self;
+    [[TRTCCloud sharedInstance] enterRoom:[self getTRTCRoomConfig:roomId] appScene:TRTCAppSceneVideoCall];
+    [[TRTCCloud sharedInstance] addDelegate:self];
     [self configDefaultHardwareStatus];
 }
 
@@ -92,9 +93,9 @@
     if (callback) {
         self.success = callback;
     }
-    [self.engine exitRoom];
-    _engine = nil;
-    [TRTCCloud destroySharedIntance];
+    [[TRTCCloud sharedInstance] exitRoom];
+    [[TRTCCloud sharedInstance] removeDelegate:self]; // 移除代理
+    [TRTCCloud destroySharedInstance];
     if (callback) {
         callback(1);
     }
@@ -104,18 +105,16 @@
 - (void)publishStream {
     NSString *currentUserID = [ClassroomService sharedService].currentRoom.currentMemberId;
     NSString *streamId = [NSString stringWithFormat:@"%@_%@", self.roomID, currentUserID];
-    [self.engine startPublishing:streamId type:TRTCVideoStreamTypeBig];
+    [[TRTCCloud sharedInstance] startPublishing:streamId type:TRTCVideoStreamTypeBig];
 }
 
 - (void)configVideoAndAudioSetting {
-    [self.engine startLocalAudio:TRTCAudioQualityMusic];
+    [[TRTCCloud sharedInstance] startLocalAudio:TRTCAudioQualityMusic];
     TRTCVideoEncParam *videoEncParams = [[TRTCVideoEncParam alloc] init];
     videoEncParams.videoFps = 15.0f;
     videoEncParams.resMode = TRTCVideoResolutionModeLandscape;
     videoEncParams.videoResolution =  TRTCVideoResolution_640_480;
-    [self.engine setVideoEncoderParam:videoEncParams];
-    [self.engine setGSensorMode:TRTCGSensorMode_UIFixLayout];
-//    [self.engine setVideoMuteImage:[self generalCloseImage] fps:5];
+    [[TRTCCloud sharedInstance] setVideoEncoderParam:videoEncParams];
     [self config3AWithANS:self.ANS AEC:self.AEC AGC:self.AGC];
 }
 
@@ -154,26 +153,26 @@
 
 - (void)renderLocalUserInView:(UIView *)displayView isCameraEnable:(BOOL)cameraEnable {
     if (cameraEnable) {
-        [self.engine setLocalRenderParams:[self getRenderParms:YES]];
-        [self.engine startLocalPreview:[self isFrontCamera] view:displayView];
+        [[TRTCCloud sharedInstance] setLocalRenderParams:[self getRenderParms:YES]];
+        [[TRTCCloud sharedInstance] startLocalPreview:[self isFrontCamera] view:displayView];
     }
     else {
         [self stopLocalPreview];
     }
 }
 - (void)stopLocalPreview {
-    [self.engine stopLocalPreview];
+    [[TRTCCloud sharedInstance] stopLocalPreview];
 }
 - (void)renderRemoteUser:(NSString *)userId inView:(UIView *)displayView {
     [self cancleRenderUserVideo:userId];
-    [self.engine setRemoteRenderParams:userId streamType:TRTCVideoStreamTypeBig params:[self getRenderParms:NO]];
-    [self.engine startRemoteView:userId streamType:TRTCVideoStreamTypeBig view:displayView];
+    [[TRTCCloud sharedInstance] setRemoteRenderParams:userId streamType:TRTCVideoStreamTypeBig params:[self getRenderParms:NO]];
+    [[TRTCCloud sharedInstance] startRemoteView:userId streamType:TRTCVideoStreamTypeBig view:displayView];
 }
 
 - (void)cancleRenderUserVideo:(NSString *)userId {
     NSString *currentUserID = [ClassroomService sharedService].currentRoom.currentMemberId;
     if (![userId isEqualToString:currentUserID]) {
-        [self.engine stopRemoteView:userId streamType:TRTCVideoStreamTypeBig];
+        [[TRTCCloud sharedInstance] stopRemoteView:userId streamType:TRTCVideoStreamTypeBig];
     }
     else {
         
@@ -213,7 +212,7 @@
     [dic setValue:subDic forKey:@"params"];
     NSData *data = [NSJSONSerialization dataWithJSONObject:dic options:kNilOptions error:nil];
     NSString *jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
-    [self.engine callExperimentalAPI:jsonString];
+    [[TRTCCloud sharedInstance] callExperimentalAPI:jsonString];
 }
 
 // 回声消除
@@ -232,7 +231,7 @@
     [dic setValue:subDic forKey:@"params"];
     NSData *data = [NSJSONSerialization dataWithJSONObject:dic options:kNilOptions error:nil];
     NSString *jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
-    [self.engine callExperimentalAPI:jsonString];
+    [[TRTCCloud sharedInstance] callExperimentalAPI:jsonString];
 }
 
 // 自动增益
@@ -251,7 +250,7 @@
     [dic setValue:subDic forKey:@"params"];
     NSData *data = [NSJSONSerialization dataWithJSONObject:dic options:kNilOptions error:nil];
     NSString *jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
-    [self.engine callExperimentalAPI:jsonString];
+    [[TRTCCloud sharedInstance] callExperimentalAPI:jsonString];
 }
 
 #pragma mark --- TRTCCloudDelegate
@@ -263,9 +262,8 @@
     }
     else {
         if (self.error) {
-            [self.engine exitRoom];
-            _engine = nil;
-            [TRTCCloud destroySharedIntance];
+            [[TRTCCloud sharedInstance] exitRoom];
+            [TRTCCloud destroySharedInstance];
             self.error(result);
         }
     }
@@ -324,10 +322,10 @@
     for (RoomMember *member in memberList) {
         if (member.role == RoleStudent) {
             if ([member.userId isEqualToString:studentId]) {
-                [self.engine setRemoteAudioVolume:member.userId volume:100];
+                [[TRTCCloud sharedInstance] setRemoteAudioVolume:member.userId volume:100];
             }
             else {
-                [self.engine setRemoteAudioVolume:member.userId volume:0];
+                [[TRTCCloud sharedInstance] setRemoteAudioVolume:member.userId volume:0];
             }
         }
     }
@@ -337,7 +335,7 @@
     NSMutableArray *memberList = [[ClassroomService sharedService].currentRoom.memberList mutableCopy];
     for (RoomMember *member in memberList) {
         if (member.role == RoleStudent) {
-            [self.engine setRemoteAudioVolume:member.userId volume:100];
+            [[TRTCCloud sharedInstance] setRemoteAudioVolume:member.userId volume:100];
         }
     }
 }
@@ -355,11 +353,11 @@
  */
 - (void)setMicrophoneDisable:(BOOL)disable {
     if (disable) {
-        [self.engine setAudioCaptureVolume:0];
+        [[TRTCCloud sharedInstance] setAudioCaptureVolume:0];
         
     }
     else {
-        [self.engine setAudioCaptureVolume:100];
+        [[TRTCCloud sharedInstance] setAudioCaptureVolume:100];
     }
 }
 
@@ -369,21 +367,21 @@
  @param disable YES 关闭,否则打开
  */
 - (void)setCameraDisable:(BOOL)disable {
-    [self.engine muteLocalVideo:TRTCVideoStreamTypeBig mute:disable];
+    [[TRTCCloud sharedInstance] muteLocalVideo:TRTCVideoStreamTypeBig mute:disable];
 }
 
 /**
  切换前后摄像头
  */
 - (void)switchCamera {
-    TXDeviceManager *deviceManager = [self.engine getDeviceManager];
+    TXDeviceManager *deviceManager = [[TRTCCloud sharedInstance] getDeviceManager];
     BOOL isFrontCamera = [deviceManager isFrontCamera];
     [deviceManager switchCamera:!isFrontCamera];
 }
 
 
 - (BOOL)isFrontCamera {
-    TXDeviceManager *deviceManager = [self.engine getDeviceManager];
+    TXDeviceManager *deviceManager = [[TRTCCloud sharedInstance] getDeviceManager];
     BOOL isFrontCamera = [deviceManager isFrontCamera];
     return isFrontCamera;
 }
@@ -392,7 +390,7 @@
  切换使用外放/听筒
  */
 - (void)useSpeaker:(BOOL)useSpeaker {
-    TXDeviceManager *deviceManager = [self.engine getDeviceManager];
+    TXDeviceManager *deviceManager = [[TRTCCloud sharedInstance] getDeviceManager];
     TXAudioRoute route = useSpeaker ? TXAudioRouteSpeakerphone :TXAudioRouteEarpiece;
     [deviceManager setAudioRoute:route];
 }
@@ -404,10 +402,4 @@
     return parms;
 }
 
-- (TRTCCloud *)engine {
-    if (!_engine) {
-        _engine = [TRTCCloud sharedInstance];
-    }
-    return _engine;
-}
 @end

+ 5 - 4
KulexiuForTeacher/KulexiuForTeacher/Module/TXLiveModule/Controller/TXLiveRoomViewController.m

@@ -363,7 +363,7 @@ typedef NS_ENUM(NSInteger, LIVEPAGE) {
     parms.role = TRTCRoleAnchor;
     parms.strRoomId = self.roomId;
     parms.userId = UserDefault(IM_USERID);
-    self.trtcCloud.delegate = self;
+    [self.trtcCloud addDelegate:self];
     [self config3AParams];
     [self.trtcCloud startLocalPreview:YES view:self.liveVideoView];
     [self.trtcCloud enterRoom:parms appScene:TRTCAppSceneLIVE];
@@ -371,6 +371,7 @@ typedef NS_ENUM(NSInteger, LIVEPAGE) {
     [self configVideoAndAudioSetting];
     NSString *streamId = [NSString stringWithFormat:@"%@_%@", self.roomId, UserDefault(IM_USERID)];
     [self.trtcCloud startPublishing:streamId type:TRTCVideoStreamTypeBig];
+    [self.trtcCloud setGravitySensorAdaptiveMode:TRTCGravitySensorAdaptiveMode_Disable];// 重力感应 disable
     [self sendOpenLiveMessage];
 }
 
@@ -2203,12 +2204,12 @@ typedef NS_ENUM(NSInteger, LIVEPAGE) {
         [self.trtcCloud stopLocalPreview];
         [self.trtcCloud stopPublishing];
         [self.trtcCloud exitRoom];
+        [self.trtcCloud removeDelegate:self];
         _trtcCloud = nil;
-        [TRTCCloud destroySharedIntance];
+        [TRTCCloud destroySharedInstance];
     }
 }
 
-
 - (dispatch_source_t)SEITimer {
     if (!_SEITimer) {
         _SEITimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0,dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0));
@@ -2391,7 +2392,7 @@ typedef NS_ENUM(NSInteger, LIVEPAGE) {
 - (TRTCCloud *)trtcCloud {
     if (!_trtcCloud) {
         _trtcCloud = [TRTCCloud sharedInstance];
-        _trtcCloud.delegate = self;
+        [_trtcCloud addDelegate:self];
     }
     return _trtcCloud;
 }