소스 검색

修正视频通话缩放问题

heavyrain2012 4 년 전
부모
커밋
9d5a1e95f3

+ 6 - 4
wfuikit/WFChatUIKit/AVEngine/WFAVEngineKit.framework/Headers/WFAVEngineKit.h

@@ -46,14 +46,16 @@ typedef NS_ENUM(NSInteger, WFAVEngineState) {
 /**
  缩放模式
 
- - kWFAVVideoScalingTypeAspectFit: 自适应
- - kWFAVVideoScalingTypeAspectFill: 拉伸
- - kWFAVVideoScalingTypeAspectBalanced: 平衡
+ - kWFAVVideoScalingTypeAspectFit: 填满屏幕,裁去多余部分。如果视图和视频的方向不一致,则缩放模式自动采用kWFAVVideoScalingTypeAspectFill模式,因为如果要是裁边会裁去过多内容。
+ - kWFAVVideoScalingTypeAspectFill: 显示所有内容,背景会留黑边
+ - kWFAVVideoScalingTypeAspectBalanced: 平衡,Fit和Fill折中
+ - kWFAVVideoScalingTypeScaleFill: 拉伸填满
  */
 typedef NS_ENUM(NSInteger, WFAVVideoScalingType) {
     kWFAVVideoScalingTypeAspectFit,
     kWFAVVideoScalingTypeAspectFill,
-    kWFAVVideoScalingTypeAspectBalanced
+    kWFAVVideoScalingTypeAspectBalanced,
+    kWFAVVideoScalingTypeScaleFill
 };
 
 /**

BIN
wfuikit/WFChatUIKit/AVEngine/WFAVEngineKit.framework/Info.plist


BIN
wfuikit/WFChatUIKit/AVEngine/WFAVEngineKit.framework/WFAVEngineKit


+ 4 - 19
wfuikit/WFChatUIKit/AVEngine/WFAVEngineKit.framework/_CodeSignature/CodeResources

@@ -4,17 +4,13 @@
 <dict>
 	<key>files</key>
 	<dict>
-		<key>Headers/WFAVCallSession.h</key>
-		<data>
-		L4CiTQ97f7JJqOcW68TeH96XTHs=
-		</data>
 		<key>Headers/WFAVEngineKit.h</key>
 		<data>
-		F1qlsrGqp13oNK45kwn3ckVKTrE=
+		VGTYHr0n5s+4sAOqdfMX2mKqZXY=
 		</data>
 		<key>Info.plist</key>
 		<data>
-		BU1eAFoXklvHmDFnv1BZ+cM37sw=
+		VKUtR5bsfOsADnpec6LNS3ZA/N8=
 		</data>
 		<key>LICENSE.md</key>
 		<data>
@@ -23,26 +19,15 @@
 	</dict>
 	<key>files2</key>
 	<dict>
-		<key>Headers/WFAVCallSession.h</key>
-		<dict>
-			<key>hash</key>
-			<data>
-			L4CiTQ97f7JJqOcW68TeH96XTHs=
-			</data>
-			<key>hash2</key>
-			<data>
-			gz6tOGsfIzpt98g7lfQpjIDyDpdIKO2Eea4xuUhG2u0=
-			</data>
-		</dict>
 		<key>Headers/WFAVEngineKit.h</key>
 		<dict>
 			<key>hash</key>
 			<data>
-			F1qlsrGqp13oNK45kwn3ckVKTrE=
+			VGTYHr0n5s+4sAOqdfMX2mKqZXY=
 			</data>
 			<key>hash2</key>
 			<data>
-			XRsrPBGOw+5tAk/SBeTuk4nA74YsJrz1UbjMnZuV2ZU=
+			mlOuwYEssxsjtuK4Cqa1MAxVKzhryVAR0q3JfMyYofk=
 			</data>
 		</dict>
 		<key>LICENSE.md</key>

+ 3 - 3
wfuikit/WFChatUIKit/Voip/WFCUFloatingWindow.m

@@ -176,14 +176,14 @@ static NSString *kFloatingWindowPosY = @"kFloatingWindowPosY";
         } else if (self.callSession.state == kWFAVEngineStateOutgoing) {
             self.videoView.hidden = NO;
             [self.floatingButton setTitle:@"" forState:UIControlStateNormal];
-            [self.callSession setupLocalVideoView:self.videoView scalingType:kWFAVVideoScalingTypeAspectBalanced];
+            [self.callSession setupLocalVideoView:self.videoView scalingType:kWFAVVideoScalingTypeAspectFit];
         } else if (self.callSession.state == kWFAVEngineStateConnected) {
             self.videoView.hidden = NO;
             [self.floatingButton setTitle:@"" forState:UIControlStateNormal];
             if ([self.focusUserId isEqualToString:[WFCCNetworkService sharedInstance].userId]) {
-                [self.callSession setupLocalVideoView:self.videoView scalingType:kWFAVVideoScalingTypeAspectBalanced];
+                [self.callSession setupLocalVideoView:self.videoView scalingType:kWFAVVideoScalingTypeAspectFit];
             } else {
-                [self.callSession setupRemoteVideoView:self.videoView scalingType:kWFAVVideoScalingTypeAspectBalanced forUser:self.focusUserId];
+                [self.callSession setupRemoteVideoView:self.videoView scalingType:kWFAVVideoScalingTypeAspectFit forUser:self.focusUserId];
             }
         } else if (self.callSession.state == kWFAVEngineStateIdle) {
             UILabel *videoStopTips =

+ 27 - 10
wfuikit/WFChatUIKit/Voip/WFCUMultiVideoViewController.m

@@ -135,8 +135,8 @@
     [super viewDidLoad];
     [self.view setBackgroundColor:[UIColor blackColor]];
     
-    self.smallScalingType = kWFAVVideoScalingTypeAspectFill;
-    self.bigScalingType = kWFAVVideoScalingTypeAspectBalanced;
+    self.smallScalingType = kWFAVVideoScalingTypeAspectFit;
+    self.bigScalingType = kWFAVVideoScalingTypeAspectFit;
     self.bigVideoView = [[UIView alloc] initWithFrame:self.view.bounds];
     UITapGestureRecognizer *tapBigVideo = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClickedBigVideoView:)];
     [self.bigVideoView addGestureRecognizer:tapBigVideo];
@@ -519,40 +519,57 @@
 }
 
 - (BOOL)onDeviceOrientationDidChange{
+    if (self.currentSession.state == kWFAVEngineStateIdle) {
+        return YES;
+    }
     //获取当前设备Device
     UIDevice *device = [UIDevice currentDevice] ;
-
+    NSString *lastUser = nil;
     switch (device.orientation) {
         case UIDeviceOrientationFaceUp:
-            NSLog(@"屏幕幕朝上平躺");
             break;
 
         case UIDeviceOrientationFaceDown:
-            NSLog(@"屏幕朝下平躺");
             break;
 
         case UIDeviceOrientationUnknown:
             //系统当前无法识别设备朝向,可能是倾斜
-            NSLog(@"未知方向");
             break;
 
         case UIDeviceOrientationLandscapeLeft:
             self.bigVideoView.transform = CGAffineTransformMakeRotation(M_PI_2);
-            NSLog(@"屏幕向左橫置");
+            self.bigVideoView.frame = self.view.bounds;
+            lastUser = [self.participants lastObject];
+            if ([lastUser isEqualToString:[WFCCNetworkService sharedInstance].userId]) {
+                [self.currentSession setupLocalVideoView:self.bigVideoView scalingType:self.bigScalingType];
+            } else {
+                [self.currentSession setupRemoteVideoView:self.bigVideoView scalingType:self.bigScalingType forUser:lastUser];
+            }
             break;
 
         case UIDeviceOrientationLandscapeRight:
             self.bigVideoView.transform = CGAffineTransformMakeRotation(-M_PI_2);
-            NSLog(@"屏幕向右橫置");
+            self.bigVideoView.frame = self.view.bounds;
+            lastUser = [self.participants lastObject];
+            if ([lastUser isEqualToString:[WFCCNetworkService sharedInstance].userId]) {
+                [self.currentSession setupLocalVideoView:self.bigVideoView scalingType:self.bigScalingType];
+            } else {
+                [self.currentSession setupRemoteVideoView:self.bigVideoView scalingType:self.bigScalingType forUser:lastUser];
+            }
             break;
 
         case UIDeviceOrientationPortrait:
             self.bigVideoView.transform = CGAffineTransformMakeRotation(0);
-            NSLog(@"屏幕直立");
+            self.bigVideoView.frame = self.view.bounds;
+            lastUser = [self.participants lastObject];
+            if ([lastUser isEqualToString:[WFCCNetworkService sharedInstance].userId]) {
+                [self.currentSession setupLocalVideoView:self.bigVideoView scalingType:self.bigScalingType];
+            } else {
+                [self.currentSession setupRemoteVideoView:self.bigVideoView scalingType:self.bigScalingType forUser:lastUser];
+            }
             break;
 
         case UIDeviceOrientationPortraitUpsideDown:
-            NSLog(@"屏幕直立,上下顛倒");
             break;
 
         default:

+ 18 - 9
wfuikit/WFChatUIKit/Voip/WFCUVideoViewController.m

@@ -105,7 +105,7 @@
     [super viewDidLoad];
     [self.view setBackgroundColor:[UIColor blackColor]];
     
-    self.scalingType = kWFAVVideoScalingTypeAspectBalanced;
+    self.scalingType = kWFAVVideoScalingTypeAspectFit;
     self.bigVideoView = [[UIView alloc] initWithFrame:self.view.bounds];
     UITapGestureRecognizer *tapBigVideo = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClickedBigVideoView:)];
     [self.bigVideoView addGestureRecognizer:tapBigVideo];
@@ -289,6 +289,9 @@
 }
 - (void)setSwapVideoView:(BOOL)swapVideoView {
     _swapVideoView = swapVideoView;
+    if (self.currentSession.state == kWFAVEngineStateIdle) {
+        return;
+    }
     if (swapVideoView) {
         [self.currentSession setupLocalVideoView:self.bigVideoView scalingType:self.scalingType];
         [self.currentSession setupRemoteVideoView:self.smallVideoView scalingType:self.scalingType forUser:self.currentSession.participantIds[0]];
@@ -797,6 +800,10 @@
 }
 
 - (BOOL)onDeviceOrientationDidChange{
+    if (self.currentSession.state == kWFAVEngineStateIdle) {
+        return YES;
+    }
+    
     //获取当前设备Device
     UIDevice *device = [UIDevice currentDevice] ;
     //识别当前设备的旋转方向
@@ -805,48 +812,50 @@
     CGFloat height = self.view.bounds.size.height;
     switch (device.orientation) {
         case UIDeviceOrientationFaceUp:
-            NSLog(@"屏幕幕朝上平躺");
             break;
 
         case UIDeviceOrientationFaceDown:
-            NSLog(@"屏幕朝下平躺");
             break;
 
         case UIDeviceOrientationUnknown:
             //系统当前无法识别设备朝向,可能是倾斜
-            NSLog(@"未知方向");
             break;
 
         case UIDeviceOrientationLandscapeLeft:
             self.smallVideoView.transform = CGAffineTransformMakeRotation(M_PI_2);
             self.bigVideoView.transform = CGAffineTransformMakeRotation(M_PI_2);
+            self.bigVideoView.frame = self.view.bounds;
             smallVideoFrame = CGRectMake(width - SmallVideoView - 8, height - 8 - kStatusBarAndNavigationBarHeight + 64 - SmallVideoView - SmallVideoView/3 - kTabbarSafeBottomMargin, SmallVideoView * 4 /3, SmallVideoView);
-            NSLog(@"屏幕向左橫置");
+            self.smallVideoView.frame = smallVideoFrame;
+            self.swapVideoView = _swapVideoView;
             break;
 
         case UIDeviceOrientationLandscapeRight:
             self.smallVideoView.transform = CGAffineTransformMakeRotation(-M_PI_2);
             self.bigVideoView.transform = CGAffineTransformMakeRotation(-M_PI_2);
+            self.bigVideoView.frame = self.view.bounds;
             smallVideoFrame = CGRectMake(8-SmallVideoView/3, 8 + kStatusBarAndNavigationBarHeight - 64+SmallVideoView/3, SmallVideoView * 4 /3, SmallVideoView);
-            NSLog(@"屏幕向右橫置");
+            self.smallVideoView.frame = smallVideoFrame;
+            self.swapVideoView = _swapVideoView;
             break;
 
         case UIDeviceOrientationPortrait:
             self.smallVideoView.transform = CGAffineTransformMakeRotation(0);
             self.bigVideoView.transform = CGAffineTransformMakeRotation(0);
+            self.bigVideoView.frame = self.view.bounds;
             smallVideoFrame = CGRectMake(self.view.frame.size.width - SmallVideoView, kStatusBarAndNavigationBarHeight, SmallVideoView, SmallVideoView * 4 /3);
-            NSLog(@"屏幕直立");
+            self.smallVideoView.frame = smallVideoFrame;
+            self.swapVideoView = _swapVideoView;
             break;
 
         case UIDeviceOrientationPortraitUpsideDown:
-            NSLog(@"屏幕直立,上下顛倒");
             break;
 
         default:
             NSLog(@"無法识别");
             break;
     }
-    self.smallVideoView.frame = smallVideoFrame;
+    
     return YES;
 }
 #endif