add user notif when video is disabled because of low bw

This commit is contained in:
Jehan Monnier 2012-10-03 16:10:49 +02:00
parent ab2d6d8897
commit 22a50d41aa
5 changed files with 52 additions and 15 deletions

View file

@ -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;
}

View file

@ -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;

View file

@ -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);
}

View file

@ -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);

@ -1 +1 @@
Subproject commit 5f348a03c29f71c9d536a7dd3baf257259de8f39
Subproject commit 8af1e4767c3629aff8c14773a020dcd84b495bbc