From ef0b1edba135de416726f2cf7d874d9517848b61 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Tue, 17 Apr 2012 11:16:07 +0200 Subject: [PATCH] Add zoom support (using double tap/pinch/pan gestures) Conflicts: submodules/linphone --- Classes/IncallViewController.h | 1 + Classes/IncallViewController.m | 78 ++++++++++++++++++++++++++++++ linphone.xcodeproj/project.pbxproj | 2 +- submodules/externals/exosip | 2 +- submodules/linphone | 2 +- submodules/mssilk | 2 +- 6 files changed, 83 insertions(+), 4 deletions(-) diff --git a/Classes/IncallViewController.h b/Classes/IncallViewController.h index e1bd40cdb..117a9f648 100644 --- a/Classes/IncallViewController.h +++ b/Classes/IncallViewController.h @@ -91,6 +91,7 @@ UIActionSheet* visibleActionSheet; NSTimer* hideControlsTimer; + float zoomLevel, cx, cy; } -(void)displayStatus:(NSString*) message; diff --git a/Classes/IncallViewController.m b/Classes/IncallViewController.m index c6e6bcad9..0d1e28ee4 100644 --- a/Classes/IncallViewController.m +++ b/Classes/IncallViewController.m @@ -243,6 +243,9 @@ void addAnimationFadeTransition(UIView* view, float duration) { -(void) enableVideoDisplay { [self orientationChanged:nil]; + zoomLevel = 1; + cx = cy = 0.5; + [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:1.0]; [videoGroup setAlpha:1.0]; @@ -368,6 +371,66 @@ void addAnimationFadeTransition(UIView* view, float duration) { } } +-(void) zoomInOut:(UITapGestureRecognizer*) reco { + if (zoomLevel != 1) + zoomLevel = 1; + else + zoomLevel = 2; + + if (zoomLevel != 1) { + CGPoint point = [reco locationInView:videoGroup]; + cx = point.x / videoGroup.frame.size.width; + cy = 1 - point.y / videoGroup.frame.size.height; + } else { + cx = cy = 0.5; + } + linphone_call_zoom_video(linphone_core_get_current_call([LinphoneManager getLc]), zoomLevel, cx, cy); +} + +-(void) videoPan:(UIPanGestureRecognizer*) reco { + if (zoomLevel <= 1.0) + return; + + float x,y; + CGPoint translation = [reco translationInView:videoGroup]; + if ([reco state] == UIGestureRecognizerStateEnded) { + cx -= translation.x / videoGroup.frame.size.width; + cy += translation.y / videoGroup.frame.size.height; + x = cx; + y = cy; + } else if ([reco state] == UIGestureRecognizerStateChanged) { + x = cx - translation.x / videoGroup.frame.size.width; + y = cy + translation.y / videoGroup.frame.size.height; + } else { + return; + } + + linphone_call_zoom_video(linphone_core_get_current_call([LinphoneManager getLc]), zoomLevel, x, y); +} + +-(void) pinch:(UIPinchGestureRecognizer*) reco { + float s = zoomLevel; + CGPoint point = [reco locationInView:videoGroup]; + // float ccx = cx + (point.x / videoGroup.frame.size.width - 0.5) / s; + // float ccy = cy - (point.y / videoGroup.frame.size.height - 0.5) / s; + if ([reco state] == UIGestureRecognizerStateEnded) { + zoomLevel = MAX(MIN(zoomLevel * reco.scale, 3.0), 1.0); + s = zoomLevel; + // cx = ccx; + // cy = ccy; + } else if ([reco state] == UIGestureRecognizerStateChanged) { + s = zoomLevel * reco.scale; + s = MAX(MIN(s, 3.0), 1.0); + } else if ([reco state] == UIGestureRecognizerStateBegan) { + + } else { + return; + } + + + linphone_call_zoom_video(linphone_core_get_current_call([LinphoneManager getLc]), s, cx, cy); +} + // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; @@ -413,10 +476,25 @@ void addAnimationFadeTransition(UIView* view, float duration) { } UITapGestureRecognizer* singleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showControls:)]; + [singleFingerTap setNumberOfTapsRequired:1]; [videoGroup addGestureRecognizer:singleFingerTap]; + + UITapGestureRecognizer* doubleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(zoomInOut:)]; + [doubleFingerTap setNumberOfTapsRequired:2]; + [doubleFingerTap setNumberOfTouchesRequired:1]; + [videoGroup addGestureRecognizer:doubleFingerTap]; + + UIPanGestureRecognizer* pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(videoPan:)]; + [videoGroup addGestureRecognizer:pan]; + UIPinchGestureRecognizer* pinchReco = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinch:)]; + [videoGroup addGestureRecognizer:pinchReco]; videoGroup.alpha = 0; [singleFingerTap release]; + [doubleFingerTap release]; + [pan release]; + [pinchReco release]; + cx = cy = 0.5; mVideoShown=FALSE; mIncallViewIsReady=FALSE; diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index 0d902225b..7b0afb044 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -1623,7 +1623,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 3.1; LIBRARY_SEARCH_PATHS = ""; LINK_WITH_STANDARD_LIBRARIES = YES; - PROVISIONING_PROFILE = "7EBE410C-11B9-4346-9977-2C3BEE43ED16"; + PROVISIONING_PROFILE = "32E63D15-36ED-474A-8157-8DD0770DF063"; SDKROOT = iphoneos; }; name = DistributionAdhoc; diff --git a/submodules/externals/exosip b/submodules/externals/exosip index 014f5a021..8483ca292 160000 --- a/submodules/externals/exosip +++ b/submodules/externals/exosip @@ -1 +1 @@ -Subproject commit 014f5a021ad4a0c024088edbb721f144a6f96699 +Subproject commit 8483ca292c10e4bca3331040dd9babf8431d0393 diff --git a/submodules/linphone b/submodules/linphone index 2111e92a3..02369158f 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 2111e92a393cd0cbf3934ea1de406904f0d34bca +Subproject commit 02369158f50408f4d805fe0284a37aa8fe953105 diff --git a/submodules/mssilk b/submodules/mssilk index 391b6d6b0..498a7c526 160000 --- a/submodules/mssilk +++ b/submodules/mssilk @@ -1 +1 @@ -Subproject commit 391b6d6b0fdf6854e5a25f287c4d8461730a1d40 +Subproject commit 498a7c526192392e402e72b7e9f2c6c381bdb7fd