From 22a50d41aa54fb5f483d382c92e267104e7fd5b0 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Wed, 3 Oct 2012 16:10:49 +0200 Subject: [PATCH] add user notif when video is disabled because of low bw --- Classes/InCallViewController.m | 17 ++++++++++++++- Classes/LinphoneManager.h | 9 +++++--- Classes/LinphoneManager.m | 35 ++++++++++++++++++++++-------- Classes/LinphoneUI/UIVideoButton.m | 4 +++- submodules/linphone | 2 +- 5 files changed, 52 insertions(+), 15 deletions(-) diff --git a/Classes/InCallViewController.m b/Classes/InCallViewController.m index dacc7a6d2..41eb4ab11 100644 --- a/Classes/InCallViewController.m +++ b/Classes/InCallViewController.m @@ -250,7 +250,22 @@ static UICompositeViewDescription *compositeDescription = nil; if (linphone_call_params_video_enabled(linphone_call_get_current_params(call))) { [self displayVideoCall:animated]; } else { - [self displayTableCall:animated]; + [self displayTableCall:animated]; + const LinphoneCallParams* param = linphone_call_get_current_params(call); + const LinphoneCallAppData* callAppData = linphone_call_get_user_pointer(call); + if(state == LinphoneCallStreamsRunning + && callAppData->videoRequested + && linphone_call_params_low_bandwidth_enabled(param)) { + //too bad video was not enabled because low bandwidth + UIAlertView* alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Low bandwidth", nil) + message:NSLocalizedString(@"Video cannot be activated because of low bandwidth condition, only audio is available", nil) + delegate:nil + cancelButtonTitle:NSLocalizedString(@"Continue", nil) + otherButtonTitles:nil]; + [alert show]; + [alert release]; + callAppData->videoRequested=FALSE; /*reset field*/ + } } break; } diff --git a/Classes/LinphoneManager.h b/Classes/LinphoneManager.h index 0c03037fb..96825e4dc 100644 --- a/Classes/LinphoneManager.h +++ b/Classes/LinphoneManager.h @@ -64,11 +64,14 @@ struct NetworkReachabilityContext { void (*networkStateChanged) (Connectivity newConnectivity); }; -typedef struct _LinphoneCallAppData { - bool_t batteryWarningShown; +@interface LinphoneCallAppData :NSObject { + @public + bool_t batteryWarningShown; UILocalNotification *notification; NSMutableDictionary *userInfos; -} LinphoneCallAppData; + bool_t videoRequested; /*set when user has requested for video*/ +}; +@end typedef struct _LinphoneManagerSounds { SystemSoundID call; diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 8686fd83c..b8737183d 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -77,7 +77,22 @@ extern void libmssilk_init(); #if HAVE_G729 extern void libmsbcg729_init(); #endif +@implementation LinphoneCallAppData +- (id)init { + if ((self = [super init])) { + self->batteryWarningShown = FALSE; + self->notification = nil; + self->videoRequested=FALSE; + self->userInfos = [[NSMutableDictionary alloc] init]; + } + return self; +} +- (void)dealloc { + [self->userInfos release]; + [super dealloc]; +} +@end @implementation LinphoneManager @synthesize connectivity; @@ -376,16 +391,12 @@ static void linphone_iphone_display_status(struct _LinphoneCore * lc, const char if(state == LinphoneCallReleased) { LinphoneCallAppData* data = linphone_call_get_user_pointer(call); if(data != NULL) { - [data->userInfos release]; - free (linphone_call_get_user_pointer(call)); + [data release]; linphone_call_set_user_pointer(call, NULL); } } if (!linphone_call_get_user_pointer(call)) { - LinphoneCallAppData* data = (LinphoneCallAppData*) malloc(sizeof(LinphoneCallAppData)); - data->batteryWarningShown = FALSE; - data->notification = nil; - data->userInfos = [[NSMutableDictionary alloc] init]; + LinphoneCallAppData* data = [[LinphoneCallAppData alloc] init]; linphone_call_set_user_pointer(call, data); } @@ -982,7 +993,8 @@ static void audioRouteChangeListenerCallback ( //get default proxy linphone_core_get_default_proxy([LinphoneManager getLc],&proxyCfg); LinphoneCallParams* lcallParams = linphone_core_create_default_call_parameters([LinphoneManager getLc]); - + LinphoneCall* call=NULL; + if ([address length] == 0) return; //just return if ([address hasPrefix:@"sip:"]) { LinphoneAddress* linphoneAddress = linphone_address_new([address cStringUsingEncoding:[NSString defaultCStringEncoding]]); @@ -992,7 +1004,7 @@ static void audioRouteChangeListenerCallback ( if(transfer) { linphone_core_transfer_call([LinphoneManager getLc], linphone_core_get_current_call([LinphoneManager getLc]), [address cStringUsingEncoding:[NSString defaultCStringEncoding]]); } else { - linphone_core_invite_address_with_params([LinphoneManager getLc], linphoneAddress, lcallParams); + call=linphone_core_invite_address_with_params([LinphoneManager getLc], linphoneAddress, lcallParams); } linphone_address_destroy(linphoneAddress); } else if (proxyCfg==nil){ @@ -1014,10 +1026,15 @@ static void audioRouteChangeListenerCallback ( if(transfer) { linphone_core_transfer_call([LinphoneManager getLc], linphone_core_get_current_call([LinphoneManager getLc]), normalizedUserName); } else { - linphone_core_invite_address_with_params([LinphoneManager getLc], linphoneAddress, lcallParams); + call=linphone_core_invite_address_with_params([LinphoneManager getLc], linphoneAddress, lcallParams); } linphone_address_destroy(linphoneAddress); } + if (call) { + LinphoneCallAppData* data = [[LinphoneCallAppData alloc] init]; + data->videoRequested = linphone_call_params_video_enabled(lcallParams); /* will be used later to notify user if video was not activated because of the linphone core*/ + linphone_call_set_user_pointer(call, data); + } linphone_call_params_destroy(lcallParams); } diff --git a/Classes/LinphoneUI/UIVideoButton.m b/Classes/LinphoneUI/UIVideoButton.m index c8ed0a549..9514e3f23 100644 --- a/Classes/LinphoneUI/UIVideoButton.m +++ b/Classes/LinphoneUI/UIVideoButton.m @@ -66,7 +66,9 @@ [waitView startAnimating]; LinphoneCall* call = linphone_core_get_current_call([LinphoneManager getLc]); - if (call) { + if (call) { + LinphoneCallAppData* callAppData = (LinphoneCallAppData*)linphone_call_get_user_pointer(call); + callAppData->videoRequested=TRUE; /* will be used later to notify user if video was not activated because of the linphone core*/ LinphoneCallParams* call_params = linphone_call_params_copy(linphone_call_get_current_params(call)); linphone_call_params_enable_video(call_params, TRUE); linphone_core_update_call(lc, call, call_params); diff --git a/submodules/linphone b/submodules/linphone index 5f348a03c..8af1e4767 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 5f348a03c29f71c9d536a7dd3baf257259de8f39 +Subproject commit 8af1e4767c3629aff8c14773a020dcd84b495bbc