From af92b0a7e02aa72c28254811b0817d69c24a0165 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Mon, 12 Mar 2012 11:27:45 +0100 Subject: [PATCH] VideoViewController not used anymore --- Classes/IncallViewController.h | 10 ++ Classes/IncallViewController.m | 137 ++++++++++++++++++++++- Classes/IncallViewController.xib | 186 ++++++++++++++++++++----------- Classes/LinphoneAppDelegate.m | 5 +- 4 files changed, 269 insertions(+), 69 deletions(-) diff --git a/Classes/IncallViewController.h b/Classes/IncallViewController.h index a17617aa6..ac1081718 100644 --- a/Classes/IncallViewController.h +++ b/Classes/IncallViewController.h @@ -58,6 +58,10 @@ UIDigitButton* hash; UIButton* close; + UIView* videoGroup; + UIView* videoView; + UIView* videoPreview; + bool dismissed; NSTimer *durationRefreasher; @@ -79,6 +83,8 @@ UIImage* verified, *unverified; UIImage* stat_sys_signal_0, *stat_sys_signal_1, *stat_sys_signal_2, *stat_sys_signal_3, *stat_sys_signal_4; UIActionSheet* zrtpVerificationSheet; + + NSTimer* hideControlsTimer; } + (UIImage*) stat_sys_signal_0; @@ -124,4 +130,8 @@ @property (nonatomic, retain) IBOutlet UIButton* hash; @property (nonatomic, retain) IBOutlet UIButton* close; @property (nonatomic, retain) IBOutlet VideoViewController* videoViewController; + +@property (nonatomic, retain) IBOutlet UIView* videoGroup; +@property (nonatomic, retain) IBOutlet UIView* videoView; +@property (nonatomic, retain) IBOutlet UIView* videoPreview; @end diff --git a/Classes/IncallViewController.m b/Classes/IncallViewController.m index b0bdf7cf7..1c3dd590b 100644 --- a/Classes/IncallViewController.m +++ b/Classes/IncallViewController.m @@ -24,6 +24,10 @@ #include "LinphoneManager.h" #include "private.h" #import "ContactPickerDelegate.h" +#import +#import +#import +#import #define STRINGIFY(x) #x #define TOSTRING(x) STRINGIFY(x) @@ -63,6 +67,10 @@ const NSInteger SECURE_BUTTON_TAG=5; @synthesize hash; @synthesize videoViewController; +@synthesize videoGroup; +@synthesize videoView; +@synthesize videoPreview; + @synthesize addVideo; @@ -105,6 +113,76 @@ int callCount(LinphoneCore* lc) { return count; } + + +void addAnimationFadeTransition(UIView* view, float duration) { + CATransition* animation = [CATransition animation]; + animation.type = kCATransitionFromBottom; // kCATransitionFade; + animation.duration = duration; + [view.layer addAnimation:animation forKey:nil]; +} + +-(void) showControls:(id)sender { + if (hideControlsTimer) { + [hideControlsTimer invalidate]; + hideControlsTimer = nil; + } + // show controls + addAnimationFadeTransition(controlSubView, 0.2); + controlSubView.hidden = FALSE; + + addAnimationFadeTransition(hangUpView, 0.2); + hangUpView.hidden = FALSE; + + // hide controls in 5 sec + hideControlsTimer = [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(hideControls:) userInfo:nil repeats:NO]; +} + +-(void) hideControls:(id)sender { + addAnimationFadeTransition(controlSubView, 0.4); + controlSubView.hidden = TRUE; + addAnimationFadeTransition(hangUpView, 0.4); + hangUpView.hidden = TRUE; + + hideControlsTimer = nil; +} + +-(void) enableVideoDisplay { + [videoGroup setHidden:FALSE]; + [controlSubView setHidden:TRUE]; + [hangUpView setHidden:TRUE]; + [callTableView setHidden:TRUE]; + + linphone_core_set_native_video_window_id([LinphoneManager getLc],(unsigned long)videoView); + linphone_core_set_native_preview_window_id([LinphoneManager getLc],(unsigned long)videoPreview); + linphone_core_set_device_rotation([LinphoneManager getLc], 0); + + [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide]; + + static bool done = false; + if (!done) { + NSLog(@"old center: %f %f", videoView.center.x, videoView.center.y); + videoView.center = CGPointMake(videoView.center.x, videoView.center.y + (self.view.frame.size.height - videoView.window.frame.size.height)); + NSLog(@"new center: %f %f", videoView.center.x, videoView.center.y); + done = true; + } + +} + +-(void) disableVideoDisplay { + [videoGroup setHidden:TRUE]; + [controlSubView setHidden:FALSE]; + [hangUpView setHidden:FALSE]; + [callTableView setHidden:FALSE]; + + if (hideControlsTimer != nil) { + [hideControlsTimer invalidate]; + hideControlsTimer = nil; + } + + [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone]; +} + -(void) updateUIFromLinphoneState:(UIViewController *)viewCtrl { activeCallCell = nil; [mute reset]; @@ -201,6 +279,10 @@ int callCount(LinphoneCore* lc) { } + UITapGestureRecognizer* singleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showControls:)]; + [videoGroup addGestureRecognizer:singleFingerTap]; + [singleFingerTap release]; + mVideoShown=FALSE; mIncallViewIsReady=FALSE; mVideoIsPending=FALSE; @@ -208,6 +290,10 @@ int callCount(LinphoneCore* lc) { callTableView.rowHeight = 80; + [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil]; + + } -(void) addCallPressed { @@ -231,6 +317,9 @@ int callCount(LinphoneCore* lc) { if (linphone_call_get_state(currentCall) == LinphoneCallStreamsRunning) { [pause setSelected:NO]; linphone_core_pause_call(lc, currentCall); + + // hide video view + [self disableVideoDisplay]; } } else { if (linphone_core_get_calls_nb(lc) == 1) { @@ -238,6 +327,11 @@ int callCount(LinphoneCore* lc) { if (linphone_call_get_state(c) == LinphoneCallPaused) { linphone_core_resume_call(lc, c); [pause setSelected:YES]; + + const LinphoneCallParams* p = linphone_call_get_current_params(c); + if (linphone_call_params_video_enabled(p)) { + [self enableVideoDisplay]; + } } } } @@ -248,7 +342,32 @@ int callCount(LinphoneCore* lc) { [self updateUIFromLinphoneState: nil]; } --(void) viewWillAppear:(BOOL)animated {} +-(void) orientationChanged: (NSNotification*) notif { + int oldLinphoneOrientation = linphone_core_get_device_rotation([LinphoneManager getLc]); + UIDeviceOrientation orientation = [UIDevice currentDevice].orientation; + switch (orientation) { + case UIInterfaceOrientationPortrait: + linphone_core_set_device_rotation([LinphoneManager getLc], 0); + break; + case UIInterfaceOrientationLandscapeRight: + linphone_core_set_device_rotation([LinphoneManager getLc], 270); + break; + case UIInterfaceOrientationLandscapeLeft: + linphone_core_set_device_rotation([LinphoneManager getLc], 90); + break; + } + if ((oldLinphoneOrientation != linphone_core_get_device_rotation([LinphoneManager getLc])) + && linphone_core_get_current_call([LinphoneManager getLc])) { + linphone_core_set_native_video_window_id([LinphoneManager getLc],(unsigned long)videoView); + //Orientation has change, must call update call + linphone_core_update_call([LinphoneManager getLc], linphone_core_get_current_call([LinphoneManager getLc]), NULL); + } +} + +-(void) awakeFromNib +{ + +} -(void)viewDidAppear:(BOOL)animated { [[UIApplication sharedApplication] setIdleTimerDisabled:YES]; @@ -319,13 +438,14 @@ int callCount(LinphoneCore* lc) { } -(void) displayPad:(bool) enable { - [LinphoneManager set:callTableView hidden:enable withName:"CALL_TABLE view" andReason:AT]; + if (videoView.hidden) + [LinphoneManager set:callTableView hidden:enable withName:"CALL_TABLE view" andReason:AT]; [LinphoneManager set:hangUpView hidden:enable withName:"HANG_UP view" andReason:AT]; [LinphoneManager set:controlSubView hidden:enable withName:"CONTROL view" andReason:AT]; [LinphoneManager set:padSubView hidden:!enable withName:"PAD view" andReason:AT]; } -(void) displayCall:(LinphoneCall*) call InProgressFromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName { - //restaure view + //restore view [self displayPad:false]; dismissed = false; UIDevice *device = [UIDevice currentDevice]; @@ -352,11 +472,14 @@ int callCount(LinphoneCore* lc) { if ([speaker isOn]) [speaker toggle]; } [self updateUIFromLinphoneState: nil]; - if (self.presentedViewController == (UIViewController*)mVideoViewController) { + + [self disableVideoDisplay]; + /*if (self.presentedViewController == (UIViewController*)mVideoViewController) { [self dismissVideoView]; - } + }*/ } -(void) displayDialerFromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName { + [self disableVideoDisplay]; UIViewController* modalVC = self.modalViewController; UIDevice *device = [UIDevice currentDevice]; device.proximityMonitoringEnabled = NO; @@ -377,6 +500,10 @@ int callCount(LinphoneCore* lc) { [self updateUIFromLinphoneState: nil]; } -(void) displayVideoCall:(LinphoneCall*) call FromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName { + + [self enableVideoDisplay]; + return; + if (mIncallViewIsReady) { [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone]; mVideoShown=TRUE; diff --git a/Classes/IncallViewController.xib b/Classes/IncallViewController.xib index 9a8d85d63..ee1eac9e3 100644 --- a/Classes/IncallViewController.xib +++ b/Classes/IncallViewController.xib @@ -42,6 +42,51 @@ 274 YES + + + 292 + + YES + + + 292 + {320, 480} + + + + _NS:196 + + 3 + MCAwAA + + IBCocoaTouchFramework + + + + 292 + {{240, 354}, {80, 106}} + + + + + 3 + MQA + + 2 + + + IBCocoaTouchFramework + + + {320, 460} + + + + _NS:196 + + NO + IBCocoaTouchFramework + 274 @@ -50,10 +95,7 @@ _NS:418 - - 3 - MCAwAA - + YES IBCocoaTouchFramework YES @@ -707,7 +749,7 @@ {{0, 20}, {320, 460}} - + NO IBCocoaTouchFramework @@ -940,6 +982,30 @@ 125 + + + videoGroup + + + + 129 + + + + videoPreview + + + + 130 + + + + videoView + + + + 133 + doAction: @@ -1024,6 +1090,7 @@ + @@ -1035,6 +1102,7 @@ + hangupview 18 @@ -1212,6 +1280,29 @@ video + + 126 + + + YES + + + + + video + + + 127 + + + preview + + + 132 + + + display + @@ -1232,9 +1323,12 @@ 120.IBPluginDependency 123.CustomClassName 123.IBPluginDependency + 126.IBPluginDependency + 127.IBPluginDependency 13.CustomClassName 13.IBPluginDependency 13.IBUIButtonInspectorSelectedStateConfigurationMetadataKey + 132.IBPluginDependency 15.IBPluginDependency 16.CustomClassName 16.IBPluginDependency @@ -1289,10 +1383,13 @@ com.apple.InterfaceBuilder.IBCocoaTouchPlugin UIAddVideoButton com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin UISpeakerButton com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin UIMuteButton com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -1343,7 +1440,7 @@ - 125 + 133 @@ -1367,9 +1464,7 @@ YES addCall - addToConf addVideo - callControlSubView callTableView close conferenceDetail @@ -1394,6 +1489,9 @@ star three two + videoGroup + videoPreview + videoView videoViewController zero @@ -1401,8 +1499,6 @@ YES UIButton UIButton - UIButton - UIView UITableView UIButton UIViewController @@ -1427,6 +1523,9 @@ UIButton UIButton UIButton + UIView + UIView + UIView VideoViewController UIButton @@ -1436,9 +1535,7 @@ YES addCall - addToConf addVideo - callControlSubView callTableView close conferenceDetail @@ -1463,6 +1560,9 @@ star three two + videoGroup + videoPreview + videoView videoViewController zero @@ -1472,18 +1572,10 @@ addCall UIButton - - addToConf - UIButton - addVideo UIButton - - callControlSubView - UIView - callTableView UITableView @@ -1580,6 +1672,18 @@ two UIButton + + videoGroup + UIView + + + videoPreview + UIView + + + videoView + UIView + videoViewController VideoViewController @@ -1673,27 +1777,21 @@ mCallQualityLandLeft mCallQualityLandRight mCamSwitch - mCamSwitchLand mCamSwitchLandLeft mCamSwitchLandRight mDisplay - mDisplayLand mDisplayLandLeft mDisplayLandRight mHangUp - mHangUpLand mHangUpLandLeft mHangUpLandRight - mLandscape mLandscapeLeft mLandscapeRight mMute - mMuteLand mMuteLandLeft mMuteLandRight mPortrait mPreview - mPreviewLand mPreviewLandLeft mPreviewLandRight @@ -1705,23 +1803,17 @@ UICamSwitch UICamSwitch UICamSwitch - UICamSwitch - UIView UIView UIView UIView UIHangUpButton UIHangUpButton UIHangUpButton - UIHangUpButton - UIView UIView UIView UIMuteButton UIMuteButton UIMuteButton - UIMuteButton - UIView UIView UIView UIView @@ -1736,27 +1828,21 @@ mCallQualityLandLeft mCallQualityLandRight mCamSwitch - mCamSwitchLand mCamSwitchLandLeft mCamSwitchLandRight mDisplay - mDisplayLand mDisplayLandLeft mDisplayLandRight mHangUp - mHangUpLand mHangUpLandLeft mHangUpLandRight - mLandscape mLandscapeLeft mLandscapeRight mMute - mMuteLand mMuteLandLeft mMuteLandRight mPortrait mPreview - mPreviewLand mPreviewLandLeft mPreviewLandRight @@ -1778,10 +1864,6 @@ mCamSwitch UICamSwitch - - mCamSwitchLand - UICamSwitch - mCamSwitchLandLeft UICamSwitch @@ -1794,10 +1876,6 @@ mDisplay UIView - - mDisplayLand - UIView - mDisplayLandLeft UIView @@ -1810,10 +1888,6 @@ mHangUp UIHangUpButton - - mHangUpLand - UIHangUpButton - mHangUpLandLeft UIHangUpButton @@ -1822,10 +1896,6 @@ mHangUpLandRight UIHangUpButton - - mLandscape - UIView - mLandscapeLeft UIView @@ -1838,10 +1908,6 @@ mMute UIMuteButton - - mMuteLand - UIMuteButton - mMuteLandLeft UIMuteButton @@ -1858,10 +1924,6 @@ mPreview UIView - - mPreviewLand - UIView - mPreviewLandLeft UIView diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index d84fa8dd9..3f9ebdc61 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -29,7 +29,7 @@ #include "LinphoneManager.h" #include "linphonecore.h" -#if __clang__ && TARGET_OS_IPHONE +#if __clang__ && __arm__ extern int __divsi3(int a, int b); int __aeabi_idiv(int a, int b) { return __divsi3(a,b); @@ -116,7 +116,8 @@ int __aeabi_idiv(int a, int b) { #endif #ifdef HAVE_G729 @"YES",@"g729_preference", // enable amr by default if compiled with -#endif @"NO",@"debugenable_preference", +#endif + @"NO",@"debugenable_preference", //@"+33",@"countrycode_preference", nil];