diff --git a/Classes/LinphoneManager.h b/Classes/LinphoneManager.h index da64fca6c..3a3fe4657 100644 --- a/Classes/LinphoneManager.h +++ b/Classes/LinphoneManager.h @@ -112,6 +112,7 @@ typedef struct _LinphoneManagerSounds { + (BOOL)runningOnIpad; + (BOOL)isNotIphone3G; + (NSString *)getPreferenceForCodec: (const char*) name withRate: (int) rate; ++ (BOOL)isCodecSupported: (const char*)codecName; + (NSSet *)unsupportedCodecs; + (NSString *)getUserAgent; diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 1390b4240..ce05c20d9 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -149,14 +149,30 @@ struct codec_name_pref_table codec_pref_table[]={ + (NSSet *)unsupportedCodecs { NSMutableSet *set = [NSMutableSet set]; for(int i=0;codec_pref_table[i].name!=NULL;++i) { - if(linphone_core_find_payload_type(theLinphoneCore,codec_pref_table[i].name - , codec_pref_table[i].rate,LINPHONE_FIND_PAYLOAD_IGNORE_CHANNELS) == NULL) { + PayloadType* available = linphone_core_find_payload_type(theLinphoneCore, + codec_pref_table[i].name, + codec_pref_table[i].rate, + LINPHONE_FIND_PAYLOAD_IGNORE_CHANNELS); + + if( (available == NULL) + // these two codecs should not be hidden, even if not supported + && [codec_pref_table[i].prefname isEqualToString:@"h264_preference"] + && [codec_pref_table[i].prefname isEqualToString:@"mp4v-es_preference"] + ) + { [set addObject:codec_pref_table[i].prefname]; } } return set; } ++ (BOOL)isCodecSupported: (const char *)codecName { + return (codecName != NULL) && + (NULL != linphone_core_find_payload_type(theLinphoneCore, codecName, + LINPHONE_FIND_PAYLOAD_IGNORE_RATE, + LINPHONE_FIND_PAYLOAD_IGNORE_CHANNELS)); +} + + (BOOL)runningOnIpad { #ifdef UI_USER_INTERFACE_IDIOM return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad); diff --git a/Classes/SettingsViewController.m b/Classes/SettingsViewController.m index 8469cda3f..8aa2fc7d1 100644 --- a/Classes/SettingsViewController.m +++ b/Classes/SettingsViewController.m @@ -27,6 +27,7 @@ #import "IASKSpecifierValuesViewController.h" #import "IASKPSTextFieldSpecifierViewCell.h" +#import "IASKPSTitleValueSpecifierViewCell.h" #import "IASKSpecifier.h" #import "IASKTextField.h" #include "lpconfig.h" @@ -256,8 +257,12 @@ UITextField *field = ((IASKPSTextFieldSpecifierViewCell*)cell).textField; [field setTextColor:LINPHONE_MAIN_COLOR]; } - - cell.detailTextLabel.textColor = LINPHONE_MAIN_COLOR; + + if([cell isKindOfClass:[IASKPSTitleValueSpecifierViewCell class]]) { + cell.detailTextLabel.textColor = [UIColor grayColor]; + } else { + cell.detailTextLabel.textColor = LINPHONE_MAIN_COLOR; + } // Background View UACellBackgroundView *selectedBackgroundView = [[[UACellBackgroundView alloc] initWithFrame:CGRectZero] autorelease]; @@ -540,6 +545,23 @@ static UICompositeViewDescription *compositeDescription = nil; #pragma mark - ++ (IASKSpecifier*)disableCodecSpecifier:(IASKSpecifier *)specifier { + NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:[specifier specifierDict]]; + + NSMutableString *type = [NSMutableString stringWithString:[dict objectForKey:kIASKType]]; + [type setString:kIASKPSTitleValueSpecifier]; + [dict setObject:type forKey:kIASKType]; + + NSMutableArray *values = [NSMutableArray arrayWithObjects:[NSNumber numberWithInt:0], [NSNumber numberWithInt:1], nil ]; + [dict setObject:values forKey:kIASKValues]; + + NSString* title = NSLocalizedString(@"Disabled, build from sources to enable", nil); + NSMutableArray *titles = [NSMutableArray arrayWithObjects:title, title, nil]; + [dict setObject:titles forKey:kIASKTitles]; + + return [[[IASKSpecifier alloc] initWithSpecifier:dict] autorelease]; +} + + (IASKSpecifier*)filterSpecifier:(IASKSpecifier *)specifier { #ifndef HAVE_SSL if ([[specifier key] isEqualToString:@"transport_preference"]) { @@ -576,6 +598,15 @@ static UICompositeViewDescription *compositeDescription = nil; } } #endif //HAVE_SSL + + // Add "build from source" if MPEG4 or H264 disabled + if ([[specifier key] isEqualToString:@"h264_preference"] && ![LinphoneManager isCodecSupported:"h264"]) { + return [SettingsViewController disableCodecSpecifier:specifier]; + } + if ([[specifier key] isEqualToString:@"mp4v-es_preference"] && ![LinphoneManager isCodecSupported:"mp4v-es"]) { + return [SettingsViewController disableCodecSpecifier:specifier]; + } + return specifier; }