From 2bc0cd8c84be1b828b58bde2d70e891b11423d12 Mon Sep 17 00:00:00 2001 From: Guillaume BIENKOWSKI Date: Mon, 14 Oct 2013 16:59:26 +0200 Subject: [PATCH 1/3] Display a "disabled, compile from source" if the codec is not installed. --- Classes/LinphoneManager.h | 1 + Classes/LinphoneManager.m | 20 ++++++++++++++++-- Classes/SettingsViewController.m | 35 ++++++++++++++++++++++++++++++-- 3 files changed, 52 insertions(+), 4 deletions(-) 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; } From 40bce46996336db231512e9460017bf94ad3d381 Mon Sep 17 00:00:00 2001 From: Guillaume BIENKOWSKI Date: Mon, 14 Oct 2013 17:06:08 +0200 Subject: [PATCH 2/3] Disable some image processing in release mode, since it looks like it messes up the iPad display. Also moved the script out of Xcode's project file to a physical file on disk. This allows for easier editing. --- ImageOptim.sh | 53 ++++++++++++++++++++++++++++++ linphone.xcodeproj/project.pbxproj | 10 ++++-- 2 files changed, 61 insertions(+), 2 deletions(-) create mode 100755 ImageOptim.sh diff --git a/ImageOptim.sh b/ImageOptim.sh new file mode 100755 index 000000000..d67f4030b --- /dev/null +++ b/ImageOptim.sh @@ -0,0 +1,53 @@ +#!/bin/sh + +# ImageOptim.sh +# linphone +# +# Created by guillaume on 14/10/13. +# + +if [ "$CONFIGURATION" == "Debug" ]; then + exit 0 +fi + +CONVERT=/opt/local/bin/convert +CONVERTFILTER="-sharpen 1x0.0 -filter Catrom" +OPTIPNG=/opt/local/bin/optipng +CMDS="${CONVERT} ${OPTIPNG}" +for i in $CMDS; do + command -v $i > /dev/null && continue || { echo "$i command not found"; exit 1; } +done + +exit 0 + +DIR=${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH} +PNGS=$(find $DIR -type f -name *.png) + +echo "Running PNG optimization in $DIR" + +for PNG in $PNGS; do + + BASENAME=$(basename $PNG ".png") + PROCESS=false # put true here when the resizing is fixed + + if [ -f $DIR/$BASENAME"@2x.png" ]; then + echo "Don't process $BASENAME"; + PROCESS=false + fi + + case $BASENAME in *@2x) + echo "Skip $BASENAME"; + continue + esac + + if $PROCESS ; then + echo -n "Processing ${BASENAME} (${CONVERTFILTER})..." + mv $DIR/$BASENAME".png" $DIR/$BASENAME"@2x.png" + $CONVERT $DIR/$BASENAME"@2x.png" $CONVERTFILTER -resize "50%" $DIR/$BASENAME".png" > /dev/null + fi + + echo "Optimizing ${BASENAME} and ${BASENAME}@2x ..." + $OPTIPNG -quiet $DIR/$BASENAME"@2x.png" > /dev/null + $OPTIPNG -quiet $DIR/$BASENAME".png" > /dev/null + +done \ No newline at end of file diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index c17931c1c..646919bca 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -1340,6 +1340,8 @@ D3F9A9DB15AEEB940045320F /* history_notification.png in Resources */ = {isa = PBXBuildFile; fileRef = D3F9A9DA15AEEB940045320F /* history_notification.png */; }; D3F9A9EE15AF277E0045320F /* UACellBackgroundView.m in Sources */ = {isa = PBXBuildFile; fileRef = D3F9A9ED15AF277D0045320F /* UACellBackgroundView.m */; }; D3F9A9EF15AF277E0045320F /* UACellBackgroundView.m in Sources */ = {isa = PBXBuildFile; fileRef = D3F9A9ED15AF277D0045320F /* UACellBackgroundView.m */; }; + F04892FF180C3296002FED35 /* ImageOptim.sh in Resources */ = {isa = PBXBuildFile; fileRef = F04892FE180C3296002FED35 /* ImageOptim.sh */; }; + F0489300180C3296002FED35 /* ImageOptim.sh in Resources */ = {isa = PBXBuildFile; fileRef = F04892FE180C3296002FED35 /* ImageOptim.sh */; }; F04F1E9D1806A41800D080F2 /* libpolarssl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 57B0E35F173C010400A476B8 /* libpolarssl.a */; }; F066515517F9A02E0064280C /* UITransparentTVCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F066515417F9A02E0064280C /* UITransparentTVCell.m */; }; F066515617F9A02E0064280C /* UITransparentTVCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F066515417F9A02E0064280C /* UITransparentTVCell.m */; }; @@ -2491,6 +2493,7 @@ D3F9A9DA15AEEB940045320F /* history_notification.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = history_notification.png; path = Resources/history_notification.png; sourceTree = ""; }; D3F9A9EC15AF277D0045320F /* UACellBackgroundView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UACellBackgroundView.h; path = Utils/UACellBackgroundView/UACellBackgroundView.h; sourceTree = ""; }; D3F9A9ED15AF277D0045320F /* UACellBackgroundView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = UACellBackgroundView.m; path = Utils/UACellBackgroundView/UACellBackgroundView.m; sourceTree = ""; }; + F04892FE180C3296002FED35 /* ImageOptim.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = ImageOptim.sh; sourceTree = ""; }; F066515317F9A02E0064280C /* UITransparentTVCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UITransparentTVCell.h; sourceTree = ""; }; F066515417F9A02E0064280C /* UITransparentTVCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UITransparentTVCell.m; sourceTree = ""; }; F0818E7B17FC5160005A3330 /* linphone_icon_120.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = linphone_icon_120.png; path = Resources/linphone_icon_120.png; sourceTree = ""; }; @@ -3284,6 +3287,7 @@ 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { isa = PBXGroup; children = ( + F04892FE180C3296002FED35 /* ImageOptim.sh */, 154227D017BA81CE005E686A /* libzrtpcppcore.a */, 15017E6F1773578400784ACB /* libxml2.a */, 57B0E35F173C010400A476B8 /* libpolarssl.a */, @@ -4594,6 +4598,7 @@ 2234C8E915EE2F7F00E18E83 /* chat_message_delivered.png in Resources */, 2234C8EB15EE2F7F00E18E83 /* chat_message_not_delivered.png in Resources */, 2234C8EE15EE744200E18E83 /* chat_message_inprogress.png in Resources */, + F04892FF180C3296002FED35 /* ImageOptim.sh in Resources */, D37EE10D16035793003608A6 /* ImageViewController.xib in Resources */, D381881115FE3F0B00C3EDCA /* UICallCell.xib in Resources */, D381881915FE3FCA00C3EDCA /* InCallViewController.xib in Resources */, @@ -5132,6 +5137,7 @@ 2234C8EA15EE2F7F00E18E83 /* chat_message_delivered.png in Resources */, 2234C8EC15EE2F7F00E18E83 /* chat_message_not_delivered.png in Resources */, 2234C8EF15EE744200E18E83 /* chat_message_inprogress.png in Resources */, + F0489300180C3296002FED35 /* ImageOptim.sh in Resources */, D37EE10E16035793003608A6 /* ImageViewController.xib in Resources */, D381881215FE3F0B00C3EDCA /* UICallCell.xib in Resources */, D381881A15FE3FCA00C3EDCA /* InCallViewController.xib in Resources */, @@ -5250,7 +5256,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if [ \"$CONFIGURATION\" == \"Debug\" ]; then\n exit 0\nfi\n\nCONVERT=/opt/local/bin/convert\nCONVERTFILTER=\"-sharpen 1x0.0 -filter Catrom\"\nOPTIPNG=/opt/local/bin/optipng\nCMDS=\"${CONVERT} ${OPTIPNG}\"\nfor i in $CMDS; do\ncommand -v $i > /dev/null && continue || { echo \"$i command not found\"; exit 1; }\ndone\n\nDIR=${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}\nPNGS=$(find $DIR -type f -name *.png)\nfor PNG in $PNGS; do\n BASENAME=$(basename $PNG \".png\")\n PROCESS=true\n if [ -f $DIR/$BASENAME\"@2x.png\" ]; then\n echo \"Ignoring $BASENAME\";\n PROCESS=false\n fi\n case $BASENAME in *@2x)\n echo \"Ignoring $BASENAME\";\n continue\n esac\n\n if $PROCESS ; then\n echo \"Processing ${BASENAME} (${CONVERTFILTER})...\"\n mv $DIR/$BASENAME\".png\" $DIR/$BASENAME\"@2x.png\"\n $CONVERT $DIR/$BASENAME\"@2x.png\" $CONVERTFILTER -resize \"50%\" $DIR/$BASENAME\".png\" > /dev/null\n fi\n\n echo \"Optimizing ${BASENAME} and ${BASENAME}@2x ...\"\n $OPTIPNG -quiet $DIR/$BASENAME\"@2x.png\" > /dev/null\n $OPTIPNG -quiet $DIR/$BASENAME\".png\" > /dev/null\n\ndone"; + shellScript = $SRCROOT/ImageOptim.sh; }; D33CF35115D3AC9800CD4B85 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; @@ -5263,7 +5269,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if [ \"$CONFIGURATION\" == \"Debug\" ]; then\n exit 0\nfi\n\nCONVERT=/opt/local/bin/convert\nCONVERTFILTER=\"-sharpen 1x0.0 -filter Catrom\"\nOPTIPNG=/opt/local/bin/optipng\nCMDS=\"${CONVERT} ${OPTIPNG}\"\nfor i in $CMDS; do\n command -v $i > /dev/null && continue || { echo \"$i command not found\"; exit 1; }\ndone\n\nDIR=${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}\nPNGS=$(find $DIR -type f -name *.png)\nfor PNG in $PNGS; do\n BASENAME=$(basename $PNG \".png\")\n PROCESS=true\n if [ -f $DIR/$BASENAME\"@2x.png\" ]; then\n echo \"Ignoring $BASENAME\";\n PROCESS=false\n fi\n case $BASENAME in *@2x)\n echo \"Ignoring $BASENAME\";\n continue\n esac\n\n if $PROCESS ; then\n echo \"Processing ${BASENAME} (${CONVERTFILTER})...\"\n mv $DIR/$BASENAME\".png\" $DIR/$BASENAME\"@2x.png\"\n $CONVERT $DIR/$BASENAME\"@2x.png\" $CONVERTFILTER -resize \"50%\" $DIR/$BASENAME\".png\" > /dev/null\n fi\n\n echo \"Optimizing ${BASENAME} and ${BASENAME}@2x ...\"\n $OPTIPNG -quiet $DIR/$BASENAME\"@2x.png\" > /dev/null\n $OPTIPNG -quiet $DIR/$BASENAME\".png\" > /dev/null\n\ndone"; + shellScript = $SRCROOT/ImageOptim.sh; }; /* End PBXShellScriptBuildPhase section */ From 779a0909d8162d1d1d6027c7f5746db353833ace Mon Sep 17 00:00:00 2001 From: Guillaume BIENKOWSKI Date: Mon, 14 Oct 2013 17:06:54 +0200 Subject: [PATCH 3/3] Optimized the build system for something shorter. --- submodules/build/builder-iphone-os.mk | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/submodules/build/builder-iphone-os.mk b/submodules/build/builder-iphone-os.mk index 8933c20a8..e66fd9218 100644 --- a/submodules/build/builder-iphone-os.mk +++ b/submodules/build/builder-iphone-os.mk @@ -92,18 +92,11 @@ SWITCHES := $(addprefix $(LINPHONE_BUILD_DIR)/,$(SWITCHES)) mode_switch_check: $(SWITCHES) - -$(LINPHONE_BUILD_DIR)/disable_%: +$(LINPHONE_BUILD_DIR)/enable_% $(LINPHONE_BUILD_DIR)/disable_%: mkdir -p $(LINPHONE_BUILD_DIR) - touch $(LINPHONE_BUILD_DIR)/disable_$* - rm -f $(LINPHONE_BUILD_DIR)/enable_$* - cd $(LINPHONE_BUILD_DIR) && rm -f Makefile && rm -f oRTP/Makefile && rm -f mediastreamer2/Makefile - -$(LINPHONE_BUILD_DIR)/enable_%: - mkdir -p $(LINPHONE_BUILD_DIR) - touch $(LINPHONE_BUILD_DIR)/enable_$* - rm -f $(LINPHONE_BUILD_DIR)/disable_$* - cd $(LINPHONE_BUILD_DIR) && rm -f Makefile && rm -f oRTP/Makefile && rm -f mediastreamer2/Makefile + cd $(LINPHONE_BUILD_DIR) && rm -f *able_$* + touch $@ + cd $(LINPHONE_BUILD_DIR) && rm -f Makefile && rm -f oRTP/Makefile && rm -f mediastreamer2/Makefile # end of switches parsing