Browse Source

Removed top codec from MGMSIP and changed to a codec priority setup. Added ability to choose where recorded calls are stored. Added codec priority management to advanced preferences. Added more codec options to PJSIP build script and created fat version of libpjmedia-videodev (don't know if we'll ever implement Video support, why it's not linked to MGMSIP).

master
GRMrGecko 11 years ago
parent
commit
00e5c28922
  1. 4
      Classes/VoiceBase/SIP/MGMSIP.h
  2. 38
      Classes/VoiceBase/SIP/MGMSIP.m
  3. 1
      Classes/VoiceMac/MGMController.h
  4. 3
      Classes/VoiceMac/MGMController.m
  5. 11
      Classes/VoiceMac/Preferences/MGMSIPPane.h
  6. 89
      Classes/VoiceMac/Preferences/MGMSIPPane.m
  7. 2
      Classes/VoiceMac/SIP/MGMSIPCallWindow.m
  8. 6
      Resources/VoiceMac/Info.plist
  9. 1611
      Resources/VoiceMac/Preferences/English.lproj/SIPPane.xib
  10. 7
      SIP/install

4
Classes/VoiceBase/SIP/MGMSIP.h

@ -40,7 +40,7 @@ extern NSString * const MGMSIPEchoCacnellationEnabled;
extern NSString * const MGMSIPPort;
extern NSString * const MGMSIPPublicAddress;
extern NSString * const MGMSIPUserAgent;
extern NSString * const MGMSIPCodec;
extern NSString * const MGMSIPCodecs;
extern NSString * const MGMNetworkConnectedNotification;
extern NSString * const MGMNetworkDisconnectedNotification;
@ -113,7 +113,6 @@ typedef enum {
BOOL shouldRestart;
NSTimer *restartTimer;
unsigned int codecOriginalPriority;
NSMutableDictionary *codecsInfo;
NSMutableArray *accounts;
@ -165,7 +164,6 @@ typedef enum {
- (void)registerThread:(pj_thread_desc *)thePJThreadDesc;
- (void)setTopCodec:(NSString *)theCodec;
- (void)setPriority:(unsigned int)thePriority forCodec:(NSString *)theCodec;
- (NSDictionary *)codecs;

38
Classes/VoiceBase/SIP/MGMSIP.m

@ -51,6 +51,7 @@ NSString * const MGMSIPPort = @"MGMSIPPort";
NSString * const MGMSIPPublicAddress = @"MGMSIPPublicAddress";
NSString * const MGMSIPUserAgent = @"MGMSIPUserAgent";
NSString * const MGMSIPCodec = @"MGMSIPCodec";
NSString * const MGMSIPCodecs = @"MGMSIPCodecs";
NSString * const MGMNetworkConnectedNotification = @"MGMNetworkConnectedNotification";
NSString * const MGMNetworkDisconnectedNotification = @"MGMNetworkDisconnectedNotification";
@ -342,7 +343,12 @@ static OSStatus MGMAudioDevicesChanged(AudioHardwarePropertyID propertyID, void
[defaults setObject:[NSNumber numberWithBool:NO] forKey:MGMSIPNameServersEnabled];
[defaults setObject:[NSNumber numberWithBool:YES] forKey:MGMSIPEchoCacnellationEnabled];
[defaults setObject:[NSNumber numberWithInt:0] forKey:MGMSIPPort];
[defaults setObject:@"speex/16000" forKey:MGMSIPCodec];
if ([[NSUserDefaults standardUserDefaults] objectForKey:MGMSIPCodec]!=nil) {
[defaults setObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:PJMEDIA_CODEC_PRIO_NEXT_HIGHER], [[NSUserDefaults standardUserDefaults] objectForKey:MGMSIPCodec], nil] forKey:MGMSIPCodecs];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:MGMSIPCodec];
} else {
[defaults setObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:PJMEDIA_CODEC_PRIO_NEXT_HIGHER], @"speex/16000", nil] forKey:MGMSIPCodecs];
}
[defaults setObject:[NSNumber numberWithFloat:1.0] forKey:MGMSIPVolume];
[defaults setObject:[NSNumber numberWithFloat:1.0] forKey:MGMSIPMicVolume];
[defaults setObject:MGMSIPASystemDefault forKey:MGMSIPACurrentInputDevice];
@ -582,11 +588,21 @@ static OSStatus MGMAudioDevicesChanged(AudioHardwarePropertyID propertyID, void
if (status==PJ_SUCCESS) {
for (int i=0; i<count; i++) {
[codecsInfo setObject:[NSNumber numberWithUnsignedInt:prio[i]] forKey:[NSString stringWithFormat:@"%@/%u", [NSString stringWithPJString:codecs[i].encoding_name], codecs[i].clock_rate]];
NSString *codecName = [NSString stringWithFormat:@"%@/%u", [NSString stringWithPJString:codecs[i].encoding_name], codecs[i].clock_rate];
NSNumber *codecPriority = [NSNumber numberWithUnsignedInt:prio[i]];
[codecsInfo setObject:codecPriority forKey:codecName];
}
}
NSDictionary *currentPriorities = [[defaults objectForKey:MGMSIPCodecs] copy];
NSArray *codecKeys = [currentPriorities allKeys];
for (int i=0; i<[codecKeys count]; i++) {
NSString *codecName = [codecKeys objectAtIndex:i];
if ([codecsInfo objectForKey:codecName]==nil) {
continue;
}
[self setPriority:[[currentPriorities objectForKey:codecName] unsignedIntValue] forCodec:codecName];
}
codecOriginalPriority = [[codecsInfo objectForKey:[defaults objectForKey:MGMSIPCodec]] unsignedIntValue];
[self setPriority:PJMEDIA_CODEC_PRIO_NEXT_HIGHER forCodec:[defaults objectForKey:MGMSIPCodec]];
[currentPriorities release];
} else {
NSLog(@"pjsua_var.med_endpt was NULL");
}
@ -735,18 +751,18 @@ static OSStatus MGMAudioDevicesChanged(AudioHardwarePropertyID propertyID, void
}
}
- (void)setTopCodec:(NSString *)theCodec {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[self setPriority:codecOriginalPriority forCodec:[defaults objectForKey:MGMSIPCodec]];
[defaults setObject:theCodec forKey:MGMSIPCodec];
codecOriginalPriority = [[codecsInfo objectForKey:theCodec] unsignedIntValue];
[self setPriority:PJMEDIA_CODEC_PRIO_NEXT_HIGHER forCodec:theCodec];
}
- (void)setPriority:(unsigned int)thePriority forCodec:(NSString *)theCodec {
if ([codecsInfo objectForKey:theCodec]!=nil) {
pj_thread_desc PJThreadDesc;
[self registerThread:&PJThreadDesc];
if (thePriority>PJMEDIA_CODEC_PRIO_HIGHEST)
thePriority = PJMEDIA_CODEC_PRIO_HIGHEST;
pj_str_t codec = [theCodec PJString];
pj_status_t status = pjmedia_codec_mgr_set_codec_priority(pjmedia_endpt_get_codec_mgr(pjsua_var.med_endpt), &codec, thePriority);
[codecsInfo setObject:[NSNumber numberWithUnsignedInt:thePriority] forKey:theCodec];
[[NSUserDefaults standardUserDefaults] setObject:codecsInfo forKey:MGMSIPCodecs];
if (status!=PJ_SUCCESS)
NSLog(@"Error changing priority of codec %@ to %u: %d", theCodec, thePriority, status);
}

1
Classes/VoiceMac/MGMController.h

@ -22,6 +22,7 @@
@class MGMContactsController, MGMPreferences, MGMAbout, MGMTaskManager, MGMURLConnectionManager, MGMThemeManager, MGMSMSManager, MGMBadge, MGMMultiSMS, MGMInstance, WebView;
extern NSString * const MGMContactsControllersChangedNotification;
extern NSString * const MGMSIPRecordFolder;
@interface MGMController : NSObject {
NSMutableArray *contactsControllers;

3
Classes/VoiceMac/MGMController.m

@ -40,6 +40,8 @@ NSString * const MGMLaunchCount = @"MGMLaunchCount";
NSString * const MGMMakeDefault = @"MGMMakeDefault";
NSString * const MGMSIPRecordFolder = @"MGMSIPRecordFolder";
NSString * const MGMContactsControllersChangedNotification = @"MGMContactsControllersChangedNotification";
NSString * const MGMLoading = @"Loading...";
@ -54,6 +56,7 @@ NSString * const MGMLoading = @"Loading...";
[GrowlApplicationBridge setGrowlDelegate:nil];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults registerDefaults:[NSMutableDictionary dictionaryWithObjectsAndKeys:@"~/Desktop/", MGMSIPRecordFolder, nil]];
if ([defaults boolForKey:MGMMakeDefault]) {
NSString *bundleID = [[NSBundle mainBundle] bundleIdentifier];
LSSetDefaultHandlerForURLScheme(CFSTR("tel"), (CFStringRef)bundleID);

11
Classes/VoiceMac/Preferences/MGMSIPPane.h

@ -48,8 +48,12 @@
IBOutlet NSTextField *logFileLevelField;
IBOutlet NSTextField *consoleLogLevelField;
IBOutlet NSTextField *publicAddressField;
IBOutlet NSTextField *recordedCallsField;
IBOutlet NSTextField *userAgentField;
IBOutlet NSPopUpButton *codecPopUp;
NSMutableArray *codecs;
IBOutlet NSWindow *codecWindow;
IBOutlet NSTableView *codecView;
}
- (id)initWithPreferences:(MGMPreferences *)thePreferences;
+ (void)setUpToolbarItem:(NSToolbarItem *)theItem;
@ -80,6 +84,9 @@
- (IBAction)consoleLogLevel:(id)sender;
- (IBAction)publicAddress:(id)sender;
- (IBAction)userAgent:(id)sender;
- (IBAction)codec:(id)sender;
- (IBAction)recordedCallsFolder:(id)sender;
- (IBAction)chooseRecordedCallsFolder:(id)sender;
- (IBAction)showCodecs:(id)sender;
- (IBAction)hideCodecs:(id)sender;
@end
#endif

89
Classes/VoiceMac/Preferences/MGMSIPPane.m

@ -19,8 +19,12 @@
#if MGMSIPENABLED
#import "MGMSIPPane.h"
#import "MGMController.h"
#import <VoiceBase/VoiceBase.h>
NSString * const MGMCodecName = @"name";
NSString * const MGMCodecPriority = @"priority";
@implementation MGMSIPPane
- (id)initWithPreferences:(MGMPreferences *)thePreferences {
if ((self = [super initWithPreferences:thePreferences])) {
@ -62,15 +66,10 @@
[publicAddressField setStringValue:[defaults objectForKey:MGMSIPPublicAddress]];
if ([defaults objectForKey:MGMSIPUserAgent]!=nil)
[userAgentField setStringValue:[defaults objectForKey:MGMSIPUserAgent]];
NSArray *codecs = [[[MGMSIP sharedSIP] codecs] allKeys];
codecs = [codecs sortedArrayUsingSelector:@selector(compare:)];
int currentCodecIndex = 0;
for (int i=0; i<[codecs count]; i++) {
if ([[codecs objectAtIndex:i] isEqual:[defaults objectForKey:MGMSIPCodec]])
currentCodecIndex = i;
[codecPopUp addItemWithTitle:[codecs objectAtIndex:i]];
if ([defaults objectForKey:MGMSIPRecordFolder]==nil || [[defaults objectForKey:MGMSIPRecordFolder] isEqual:@""]) {
[defaults setObject:@"~/Desktop/" forKey:MGMSIPRecordFolder];
}
[codecPopUp selectItemAtIndex:currentCodecIndex];
[recordedCallsField setStringValue:[defaults objectForKey:MGMSIPRecordFolder]];
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter addObserver:self selector:@selector(volumeChanged:) name:MGMSIPVolumeChangedNotification object:nil];
@ -99,6 +98,8 @@
//[[MGMSIP sharedSIP] restart];
}
[mainView release];
[codecs release];
[codecWindow release];
[super dealloc];
}
+ (void)setUpToolbarItem:(NSToolbarItem *)theItem {
@ -253,8 +254,76 @@
[[NSUserDefaults standardUserDefaults] setObject:[userAgentField stringValue] forKey:MGMSIPUserAgent];
shouldRestart = YES;
}
- (IBAction)codec:(id)sender {
[[MGMSIP sharedSIP] setTopCodec:[[codecPopUp selectedItem] title]];
- (IBAction)recordedCallsFolder:(id)sender {
[[NSUserDefaults standardUserDefaults] setObject:[logFileField stringValue] forKey:MGMSIPRecordFolder];
}
- (IBAction)chooseRecordedCallsFolder:(id)sender {
NSOpenPanel *panel = [NSOpenPanel openPanel];
[panel setCanChooseDirectories:YES];
[panel setCanChooseFiles:NO];
int returnCode;
returnCode = [panel runModal];
if (returnCode==NSOKButton) {
NSString *path = [[panel URL] path];
[recordedCallsField setStringValue:path];
[[NSUserDefaults standardUserDefaults] setObject:path forKey:MGMSIPRecordFolder];
}
}
- (void)reloadCodecs {
NSDictionary *allCodecs = [[MGMSIP sharedSIP] codecs];
NSArray *codecKeys = [allCodecs allKeys];
[codecs release];
codecs = [NSMutableArray new];
for (int i=0; i<[codecKeys count]; i++) {
[codecs addObject:[NSDictionary dictionaryWithObjectsAndKeys:[codecKeys objectAtIndex:i], MGMCodecName, [allCodecs objectForKey:[codecKeys objectAtIndex:i]], MGMCodecPriority, nil]];
}
if ([[codecView sortDescriptors] count]==0) {
[codecView setSortDescriptors:[NSArray arrayWithObject:[[[NSSortDescriptor alloc] initWithKey:MGMCodecName ascending:YES] autorelease]]];
}
[codecs sortUsingDescriptors:[codecView sortDescriptors]];
[codecView reloadData];
}
- (IBAction)showCodecs:(id)sender {
[self reloadCodecs];
[[NSApplication sharedApplication] beginSheet:codecWindow modalForWindow:[preferences preferencesWindow] modalDelegate:nil didEndSelector:nil contextInfo:nil];
}
- (IBAction)hideCodecs:(id)sender {
[[NSApplication sharedApplication] endSheet:codecWindow returnCode:NSCancelButton];
[codecWindow orderOut:sender];
}
- (NSInteger)numberOfRowsInTableView:(NSTableView *)theTableView {
return [codecs count];
}
- (id)tableView:(NSTableView *)theTableView objectValueForTableColumn:(NSTableColumn *)theColumn row:(NSInteger)rowIndex {
if ([[theColumn identifier] isEqualToString:MGMCodecName]) {
return [[codecs objectAtIndex:rowIndex] objectForKey:MGMCodecName];
} else if ([[theColumn identifier] isEqualToString:MGMCodecPriority]) {
return [[codecs objectAtIndex:rowIndex] objectForKey:MGMCodecPriority];
}
return @"";
}
- (BOOL)tableView:(NSTableView *)theTableView shouldEditTableColumn:(NSTableColumn *)theColumn row:(NSInteger)rowIndex {
if ([[theColumn identifier] isEqualToString:MGMCodecPriority])
return YES;
return NO;
}
- (void)tableView:(NSTableView *)theTableView setObjectValue:(id)theValue forTableColumn:(NSTableColumn *)theColumn row:(NSInteger)rowIndex {
NSString *codecName = [[codecs objectAtIndex:rowIndex] objectForKey:MGMCodecName];
unsigned int priority = [theValue unsignedIntValue];
if (priority>255)
priority = 255;
[codecs replaceObjectAtIndex:rowIndex withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:priority], MGMCodecPriority, codecName, MGMCodecName, nil]];
[[MGMSIP sharedSIP] setPriority:priority forCodec:codecName];
[codecs sortUsingDescriptors:[theTableView sortDescriptors]];
[theTableView reloadData];
}
- (BOOL)tableView:(NSTableView *)aTableView shouldSelectTableColumn:(NSTableColumn *)aTableColumn {
return NO;
}
- (void)tableView:(NSTableView *)theTableView sortDescriptorsDidChange:(NSArray *)oldDescriptors {
[codecs sortUsingDescriptors:[theTableView sortDescriptors]];
[theTableView reloadData];
}
@end
#endif

2
Classes/VoiceMac/SIP/MGMSIPCallWindow.m

@ -289,7 +289,7 @@ NSString * const MGMSCTitleNoNameFormat = @"Call With %@";
[call stopRecording];
} else {
NSFileManager *manager = [NSFileManager defaultManager];
NSString *baseName = [[NSString stringWithFormat:@"~/Desktop/Call With %@ - ", phoneNumber] stringByExpandingTildeInPath];
NSString *baseName = [[[[NSUserDefaults standardUserDefaults] objectForKey:MGMSIPRecordFolder] stringByExpandingTildeInPath] stringByAppendingPathComponent:[NSString stringWithFormat:@"Call With %@ - ", phoneNumber]];
NSString *name = nil;
for (int i=1; i<50; i++) { // Not like someone will have 50 recordings with one person on their desktop...
name = [[baseName stringByAppendingFormat:@"%02d", i] stringByAppendingPathExtension:MGMWavExt];

6
Resources/VoiceMac/Info.plist

@ -68,7 +68,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.3</string>
<string>0.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
@ -105,7 +105,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>0.3</string>
<string>0.4</string>
<key>MGMGRBugsEmail</key>
<string>bugs@mrgeckosmedia.com</string>
<key>MGMGRContactEmail</key>
@ -131,7 +131,7 @@
<key>SUEnableSystemProfiling</key>
<true/>
<key>SUFeedURL</key>
<string>http://mrgeckosmedia.com/applications/appcast/VoiceMac</string>
<string>https://mrgeckosmedia.com/applications/appcast/VoiceMac</string>
<key>SUPublicDSAKeyFile</key>
<string>dsa_pub.pem</string>
<key>SUScheduledCheckInterval</key>

1611
Resources/VoiceMac/Preferences/English.lproj/SIPPane.xib
File diff suppressed because it is too large
View File

7
SIP/install

@ -1,6 +1,6 @@
#!/bin/bash
PPCFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.4 -arch ppc -ggdb"
PPCFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.4 -arch ppc -ggdb -DPJMEDIA_HAS_G7221_CODEC=1 -DPJMEDIA_HAS_G711_CODEC=1"
PPCCC="/Applications/Xcode.app/Contents/Developer/usr/bin/gcc-4.2"
PPCCXX="/Applications/Xcode.app/Contents/Developer/usr/bin/g++-4.2"
PPCAR="/Applications/Xcode.app/Contents/Developer/usr/bin/ar rv"
@ -9,14 +9,14 @@ PPCHOST="ppc-apple-darwin10"
PPCPATH="${PWD}/opt-ppc"
PPCLDFLAGS="-arch ppc -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.5.sdk"
I386FLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.4 -arch i386 -ggdb"
I386FLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.4 -arch i386 -ggdb -DPJMEDIA_HAS_G7221_CODEC=1 -DPJMEDIA_HAS_G711_CODEC=1"
I386CC="/Applications/Xcode.app/Contents/Developer/usr/bin/gcc-4.2"
I386CXX="/Applications/Xcode.app/Contents/Developer/usr/bin/g++-4.2"
I386HOST="i386-apple-darwin10"
I386PATH="${PWD}/opt-i386"
I386LDFLAGS="-arch i386"
X86_64FLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -arch x86_64 -ggdb"
X86_64FLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -arch x86_64 -ggdb -DPJMEDIA_HAS_G7221_CODEC=1 -DPJMEDIA_HAS_G711_CODEC=1"
X86_64CC="/Applications/Xcode.app/Contents/Developer/usr/bin/gcc-4.2"
X86_64CXX="/Applications/Xcode.app/Contents/Developer/usr/bin/g++-4.2"
X86_64HOST="x86_64-apple-darwin10"
@ -204,6 +204,7 @@ if [ "$1" = "" ]; then
lipo -create "${PPCPATH}/lib/libpjlib-util-powerpc-apple-darwin10.a" "${I386PATH}/lib/libpjlib-util-i386-apple-darwin10.a" "${X86_64PATH}/lib/libpjlib-util-x86_64-apple-darwin10.a" -output "${FINALPATH}/lib/libpjlib-util.a"
lipo -create "${PPCPATH}/lib/libpjmedia-audiodev-powerpc-apple-darwin10.a" "${I386PATH}/lib/libpjmedia-audiodev-i386-apple-darwin10.a" "${X86_64PATH}/lib/libpjmedia-audiodev-x86_64-apple-darwin10.a" -output "${FINALPATH}/lib/libpjmedia-audiodev.a"
lipo -create "${PPCPATH}/lib/libpjmedia-codec-powerpc-apple-darwin10.a" "${I386PATH}/lib/libpjmedia-codec-i386-apple-darwin10.a" "${X86_64PATH}/lib/libpjmedia-codec-x86_64-apple-darwin10.a" -output "${FINALPATH}/lib/libpjmedia-codec.a"
lipo -create "${PPCPATH}/lib/libpjmedia-videodev-powerpc-apple-darwin10.a" "${I386PATH}/lib/libpjmedia-videodev-i386-apple-darwin10.a" "${X86_64PATH}/lib/libpjmedia-videodev-x86_64-apple-darwin10.a" -output "${FINALPATH}/lib/libpjmedia-videodev.a"
lipo -create "${PPCPATH}/lib/libpjmedia-powerpc-apple-darwin10.a" "${I386PATH}/lib/libpjmedia-i386-apple-darwin10.a" "${X86_64PATH}/lib/libpjmedia-x86_64-apple-darwin10.a" -output "${FINALPATH}/lib/libpjmedia.a"
lipo -create "${PPCPATH}/lib/libpjnath-powerpc-apple-darwin10.a" "${I386PATH}/lib/libpjnath-i386-apple-darwin10.a" "${X86_64PATH}/lib/libpjnath-x86_64-apple-darwin10.a" -output "${FINALPATH}/lib/libpjnath.a"
lipo -create "${PPCPATH}/lib/libpjsip-powerpc-apple-darwin10.a" "${I386PATH}/lib/libpjsip-i386-apple-darwin10.a" "${X86_64PATH}/lib/libpjsip-simple-x86_64-apple-darwin10.a" -output "${FINALPATH}/lib/libpjsip-simple.a"

Loading…
Cancel
Save