Display a "disabled, compile from source" if the codec

is not installed.
This commit is contained in:
Guillaume BIENKOWSKI 2013-10-14 16:59:26 +02:00
parent e1e35b6bc9
commit 2bc0cd8c84
3 changed files with 52 additions and 4 deletions

View file

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

View file

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

View file

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