From e9189df8863d1ca049dc677c10eec316ee3cd54d Mon Sep 17 00:00:00 2001 From: Yann Diorcet Date: Fri, 20 Jul 2012 09:21:36 +0200 Subject: [PATCH] Fix strange animation Enable speaker on video call --- Classes/InCallViewController.m | 26 +++++++++---------- Classes/LinphoneManager.m | 12 +++++++++ .../LinphoneUI/UICompositeViewController.m | 16 +++++++++--- 3 files changed, 37 insertions(+), 17 deletions(-) diff --git a/Classes/InCallViewController.m b/Classes/InCallViewController.m index 13cb6895a..e83afaf97 100644 --- a/Classes/InCallViewController.m +++ b/Classes/InCallViewController.m @@ -142,7 +142,7 @@ static UICompositeViewDescription *compositeDescription = nil; // Update on show LinphoneCall* call = linphone_core_get_current_call([LinphoneManager getLc]); LinphoneCallState state = (call != NULL)?linphone_call_get_state(call): 0; - [self callUpdate:call state:state]; + [self callUpdate:call state:state animated:FALSE]; if ([[UIDevice currentDevice].systemVersion doubleValue] < 5.0) { [callTableController viewDidAppear:animated]; @@ -184,7 +184,7 @@ static UICompositeViewDescription *compositeDescription = nil; #pragma mark - -- (void)callUpdate:(LinphoneCall *)call state:(LinphoneCallState) state { +- (void)callUpdate:(LinphoneCall *)call state:(LinphoneCallState)state animated:(BOOL)animated { // Update table [callTableView reloadData]; @@ -214,9 +214,9 @@ static UICompositeViewDescription *compositeDescription = nil; { //check video if (linphone_call_params_video_enabled(linphone_call_get_current_params(call))) { - [self displayVideoCall]; + [self displayVideoCall:animated]; } else { - [self displayTableCall]; + [self displayTableCall:animated]; } break; } @@ -232,7 +232,7 @@ static UICompositeViewDescription *compositeDescription = nil; linphone_core_defer_call_update([LinphoneManager getLc], call); [self displayAskToEnableVideoCall:call]; } else if (linphone_call_params_video_enabled(current) && !linphone_call_params_video_enabled(remote)) { - [self displayTableCall]; + [self displayTableCall:animated]; } break; } @@ -240,13 +240,13 @@ static UICompositeViewDescription *compositeDescription = nil; case LinphoneCallPaused: case LinphoneCallPausedByRemote: { - [self displayTableCall]; + [self displayTableCall:animated]; break; } case LinphoneCallEnd: case LinphoneCallError: { - if(linphone_core_get_calls_nb([LinphoneManager getLc]) <= 1) { + if(linphone_core_get_calls_nb([LinphoneManager getLc]) <= 2) { [callTableController maximizeAll]; } break; @@ -329,7 +329,7 @@ static UICompositeViewDescription *compositeDescription = nil; [videoView setAlpha: 1.0]; [videoView setHidden: FALSE]; - if ([LinphoneManager instance].frontCamId !=nil ) { + if ([LinphoneManager instance].frontCamId !=nil) { // only show camera switch button if we have more than 1 camera [videoCameraSwitch setHidden:FALSE]; } @@ -379,12 +379,12 @@ static UICompositeViewDescription *compositeDescription = nil; [[PhoneMainView instance] fullScreen:false]; } -- (void)displayVideoCall { - [self enableVideoDisplay: TRUE]; +- (void)displayVideoCall:(BOOL)animated { + [self enableVideoDisplay:animated]; } -- (void)displayTableCall { - [self disableVideoDisplay: TRUE]; +- (void)displayTableCall:(BOOL)animated { + [self disableVideoDisplay:animated]; } @@ -405,7 +405,7 @@ static void hideSpinner(LinphoneCall* call, void* user_data) { - (void)callUpdateEvent: (NSNotification*) notif { LinphoneCall *call = [[notif.userInfo objectForKey: @"call"] pointerValue]; LinphoneCallState state = [[notif.userInfo objectForKey: @"state"] intValue]; - [self callUpdate:call state:state]; + [self callUpdate:call state:state animated:TRUE]; } diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 9292eb920..e190be907 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -269,11 +269,23 @@ static void linphone_iphone_display_status(struct _LinphoneCore * lc, const char linphone_call_set_user_pointer(call, data); } + // Disable speaker when no more call if ((state == LinphoneCallEnd || state == LinphoneCallError)) { if(linphone_core_get_calls_nb([LinphoneManager getLc]) == 0) [self enableSpeaker:FALSE]; } + // Enable speaker when video + if(state == LinphoneCallIncomingReceived || + state == LinphoneCallOutgoingInit || + state == LinphoneCallConnected || + state == LinphoneCallStreamsRunning || + state == LinphoneCallUpdated) { + if (linphone_call_params_video_enabled(linphone_call_get_current_params(call))) { + [self enableSpeaker:TRUE]; + } + } + // Post event NSDictionary* dict = [[[NSDictionary alloc] initWithObjectsAndKeys: [NSValue valueWithPointer:call], @"call", diff --git a/Classes/LinphoneUI/UICompositeViewController.m b/Classes/LinphoneUI/UICompositeViewController.m index c7e3b4030..990d30c22 100644 --- a/Classes/LinphoneUI/UICompositeViewController.m +++ b/Classes/LinphoneUI/UICompositeViewController.m @@ -197,7 +197,7 @@ UICompositeViewDescription *oldViewDescription = (currentViewDescription != nil)? [currentViewDescription copy]: nil; if(description != nil) { - currentViewDescription = description; + currentViewDescription = [description copy]; // Animate only with a previous screen if(oldViewDescription != nil && viewTransition != nil) { @@ -229,12 +229,20 @@ } if(tabBar != nil) { - currentViewDescription.tabBarEnabled = [tabBar boolValue]; + if(currentViewDescription.tabBarEnabled != [tabBar boolValue]) { + currentViewDescription.tabBarEnabled = [tabBar boolValue]; + } else { + tabBar = nil; // No change = No Update + } } if(fullscreen != nil) { - currentViewDescription.fullscreen = [fullscreen boolValue]; - [[UIApplication sharedApplication] setStatusBarHidden:currentViewDescription.fullscreen withAnimation:UIStatusBarAnimationSlide ]; + if(currentViewDescription.fullscreen != [fullscreen boolValue]) { + currentViewDescription.fullscreen = [fullscreen boolValue]; + [[UIApplication sharedApplication] setStatusBarHidden:currentViewDescription.fullscreen withAnimation:UIStatusBarAnimationSlide]; + } else { + fullscreen = nil; // No change = No Update + } } else { [[UIApplication sharedApplication] setStatusBarHidden:currentViewDescription.fullscreen withAnimation:UIStatusBarAnimationNone]; }