From b98f65f85e570449c4e4cddf38f98a282254b2b1 Mon Sep 17 00:00:00 2001 From: Redmer Loen Date: Mon, 22 Jan 2018 09:35:09 +0100 Subject: [PATCH 1/5] Podfile.lock updated --- Example/Podfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Example/Podfile.lock b/Example/Podfile.lock index f52cfef0..d90f8fe0 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -10,7 +10,7 @@ PODS: - SPLumberjackLogFormatter (0.0.1): - CocoaLumberjack - Vialer-pjsip-iOS (3.3.0) - - VialerSIPLib (2.8.0): + - VialerSIPLib (3.0.0): - CocoaLumberjack - Reachability - Vialer-pjsip-iOS @@ -40,7 +40,7 @@ SPEC CHECKSUMS: Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96 SPLumberjackLogFormatter: a2290c9b880f3166b2d1bace45dc1fc1302b28ab Vialer-pjsip-iOS: fe7317dd3702d54b08986d8d3e2a109cbb06ecae - VialerSIPLib: 6190a4a0a5f87724921cc9d1e1a5a4ccfa62c461 + VialerSIPLib: 3627633a13ba2a68edb4dd7ae0de0bad7b343887 PODFILE CHECKSUM: 64a9b7d822c5cdfb540de83747cdf7175cb1a64d From 11587c7f8a4cbfc1fbcc1af750b9faeaf07012f3 Mon Sep 17 00:00:00 2001 From: Redmer Loen Date: Mon, 22 Jan 2018 13:02:20 +0100 Subject: [PATCH 2/5] Release 3.0.0 --- Example/Podfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Example/Podfile.lock b/Example/Podfile.lock index d90f8fe0..91aa63c4 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -9,7 +9,7 @@ PODS: - Reachability (3.2) - SPLumberjackLogFormatter (0.0.1): - CocoaLumberjack - - Vialer-pjsip-iOS (3.3.0) + - Vialer-pjsip-iOS (3.3.1) - VialerSIPLib (3.0.0): - CocoaLumberjack - Reachability @@ -39,7 +39,7 @@ SPEC CHECKSUMS: OCMock: 2cd0716969bab32a2283ff3a46fd26a8c8b4c5e3 Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96 SPLumberjackLogFormatter: a2290c9b880f3166b2d1bace45dc1fc1302b28ab - Vialer-pjsip-iOS: fe7317dd3702d54b08986d8d3e2a109cbb06ecae + Vialer-pjsip-iOS: 682de71852150ed5d1827f064062755c1363f36e VialerSIPLib: 3627633a13ba2a68edb4dd7ae0de0bad7b343887 PODFILE CHECKSUM: 64a9b7d822c5cdfb540de83747cdf7175cb1a64d From bba46b5d289138464e0c704395a2618d57245129 Mon Sep 17 00:00:00 2001 From: Redmer Loen Date: Mon, 19 Feb 2018 08:37:44 +0100 Subject: [PATCH 3/5] Fixes for secure calling (#125) --- .../Configurations/VSLAccountConfiguration.h | 77 ++++++++++++----- .../Configurations/VSLAccountConfiguration.m | 5 +- .../Configurations/VSLEndpointConfiguration.h | 25 +++++- .../Configurations/VSLEndpointConfiguration.m | 35 +++++++- .../Configurations/VSLIpChangeConfiguration.h | 82 ++++++++++++++++++ .../Configurations/VSLIpChangeConfiguration.m | 20 +++++ .../Configurations/VSLStunConfiguration.h | 20 +++++ .../Configurations/VSLStunConfiguration.m | 21 +++++ Pod/Classes/VSLAccount.m | 53 +++++++----- Pod/Classes/VSLAudioController.m | 7 +- Pod/Classes/VSLCall.h | 4 + Pod/Classes/VSLCall.m | 41 +++++++-- Pod/Classes/VSLCallManager.h | 6 ++ Pod/Classes/VSLCallManager.m | 7 ++ Pod/Classes/VSLEndpoint.h | 3 +- Pod/Classes/VSLEndpoint.m | 84 +++++++++++++------ Pod/Classes/VSLNetworkMonitor.m | 4 +- Pod/Classes/VialerSIPLib.h | 67 ++++++++++++++- Pod/Classes/VialerSIPLib.m | 36 +++++++- 19 files changed, 503 insertions(+), 94 deletions(-) create mode 100644 Pod/Classes/Configurations/VSLIpChangeConfiguration.h create mode 100644 Pod/Classes/Configurations/VSLIpChangeConfiguration.m create mode 100644 Pod/Classes/Configurations/VSLStunConfiguration.h create mode 100644 Pod/Classes/Configurations/VSLStunConfiguration.m diff --git a/Pod/Classes/Configurations/VSLAccountConfiguration.h b/Pod/Classes/Configurations/VSLAccountConfiguration.h index 5b4c04fa..53a73a95 100644 --- a/Pod/Classes/Configurations/VSLAccountConfiguration.h +++ b/Pod/Classes/Configurations/VSLAccountConfiguration.h @@ -13,11 +13,11 @@ */ typedef NS_ENUM(NSUInteger, VSLStunUse) { /** - * Follow the default setting in the global \a pjsua_config. + * Follow the default setting in the global pjsua_config. */ VSLStunUseDefault = PJSUA_STUN_USE_DEFAULT, /** - * Disable STUN. If STUN is not enabled in the global \a pjsua_config, + * Disable STUN. If STUN is not enabled in the global pjsua_config, * this setting has no effect. */ VSLStunUseDisable = PJSUA_STUN_USE_DISABLED, @@ -31,18 +31,34 @@ typedef NS_ENUM(NSUInteger, VSLStunUse) { VSLStunUseRetryOnFailure = PJSUA_STUN_RETRY_ON_FAILURE }; +/** + * Enum which specifies the contact rewrite method + */ typedef NS_ENUM(NSUInteger, VSLContactRewriteMethod) { + /** + * The Contact update will be done by sending unregistration + * to the currently registered Contact, while simultaneously sending new + * registration (with different Call-ID) for the updated Contact. + */ VSLContactRewriteMethodUnregister = PJSUA_CONTACT_REWRITE_UNREGISTER, + /** + * The Contact update will be done in a single, current + * registration session, by removing the current binding (by setting its + * Contact's expires parameter to zero) and adding a new Contact binding, + * all done in a single request. + */ VSLContactRewriteMethodNoUnregister = PJSUA_CONTACT_REWRITE_NO_UNREG, + /** + * The Contact update will be done when receiving any registration final + * response. If this flag is not specified, contact update will only be + * done upon receiving 2xx response. This flag MUST be used with + * PJSUA_CONTACT_REWRITE_UNREGISTER or PJSUA_CONTACT_REWRITE_NO_UNREG + * above to specify how the Contact update should be performed when + * receiving 2xx response. + */ VSLContactRewriteMethodAlwaysUpdate = PJSUA_CONTACT_REWRITE_ALWAYS_UPDATE }; -typedef NS_ENUM(NSUInteger, VSLReinviteFlags) { - VSLReinviteFlagsReinitMedia = PJSUA_CALL_REINIT_MEDIA, - VSLReinviteFlagsUpdateContact = PJSUA_CALL_UPDATE_CONTACT, - VSLReinviteFlagsUpdateVia = PJSUA_CALL_UPDATE_VIA -}; - @interface VSLAccountConfiguration : NSObject /** @@ -98,6 +114,8 @@ typedef NS_ENUM(NSUInteger, VSLReinviteFlags) { /** * If YES all current calls will be hungup when a registation failure is detected. + * + * Default: NO */ @property (nonatomic) BOOL dropCallOnRegistrationFailure; @@ -111,30 +129,49 @@ typedef NS_ENUM(NSUInteger, VSLReinviteFlags) { */ @property (nonatomic) pjsua_stun_use mediaStunType; -@property (nonatomic) BOOL allowContactRewrite; +/** + * Control how Contact update will be done with the registration. + * + * Default: VSLContactRewriteMethodAlwaysUpdate + */ @property (nonatomic) VSLContactRewriteMethod contactRewriteMethod; -@property (nonatomic) BOOL contactUseSrcPort; -@property (nonatomic) BOOL allowViaRewrite; - /** - * Should the old transport be cleaned up. + * Specify if source TCP port should be used as the initial Contact + * address if TCP/TLS transport is used. Note that this feature will + * be automatically turned off when nameserver is configured because + * it may yield different destination address due to DNS SRV resolution. + * Also some platforms are unable to report the local address of the + * TCP socket when it is still connecting. In these cases, this + * feature will also be turned off. + * + * Default: YES */ -@property (nonatomic) BOOL ipAddressChangeShutdownTransport; +@property (nonatomic) BOOL contactUseSrcPort; /** - * Should all calls be ended when an ip address change has been detected. + * This option is used to update the transport address and the Contact + * header of REGISTER request. When this option is enabled, the library + * will keep track of the public IP address from the response of REGISTER + * request. Once it detects that the address has changed, it will + * unregister current Contact, update the Contact with transport address + * learned from Via header, and register a new Contact to the registrar. + * This will also update the public name of UDP transport if STUN is + * configured. * - * Default: NO + * Default: YES */ -@property (nonatomic) BOOL ipAddressChangeHangupAllCalls; +@property (nonatomic) BOOL allowContactRewrite; /** - * When ipAddressChangeHangupAllCalls is set to NO, this property should be set. + * This option is used to overwrite the "sent-by" field of the Via header + * for outgoing messages with the same interface address as the one in + * the REGISTER request, as long as the request uses the same transport + * instance as the previous REGISTER request. * - * Default: VSLReinviteFlagsReinitMedia | VSLReinviteFlagsUpdateVia | VSLReinviteFlagsUpdateContact + * Default: YES */ -@property (nonatomic) VSLReinviteFlags ipAddressChangeReinviteFlags; +@property (nonatomic) BOOL allowViaRewrite; @property (nonatomic) VSLTurnConfiguration * _Nullable turnConfiguration; diff --git a/Pod/Classes/Configurations/VSLAccountConfiguration.m b/Pod/Classes/Configurations/VSLAccountConfiguration.m index 463523d3..94cb96aa 100644 --- a/Pod/Classes/Configurations/VSLAccountConfiguration.m +++ b/Pod/Classes/Configurations/VSLAccountConfiguration.m @@ -12,12 +12,9 @@ - (instancetype)init { self.sipAuthRealm = @"*"; self.sipAuthScheme = @"digest"; self.dropCallOnRegistrationFailure = NO; - self.mediaStunType = VSLStunUseRetryOnFailure; + self.mediaStunType = VSLStunUseDefault; self.sipStunType = VSLStunUseDefault; self.contactRewriteMethod = VSLContactRewriteMethodAlwaysUpdate; - self.ipAddressChangeShutdownTransport = YES; - self.ipAddressChangeHangupAllCalls = NO; - self.ipAddressChangeReinviteFlags = VSLReinviteFlagsReinitMedia | VSLReinviteFlagsUpdateVia | VSLReinviteFlagsUpdateContact; self.contactUseSrcPort = YES; self.allowViaRewrite = YES; self.allowContactRewrite = YES; diff --git a/Pod/Classes/Configurations/VSLEndpointConfiguration.h b/Pod/Classes/Configurations/VSLEndpointConfiguration.h index 40c9c442..cbf9947e 100644 --- a/Pod/Classes/Configurations/VSLEndpointConfiguration.h +++ b/Pod/Classes/Configurations/VSLEndpointConfiguration.h @@ -4,6 +4,9 @@ // #import +#import "VSLIpChangeConfiguration.h" +#import "VSLStunConfiguration.h" + @interface VSLEndpointConfiguration : NSObject @@ -36,7 +39,7 @@ * * Default value: nil */ -@property (strong, nonatomic) NSString *logFilename; +@property (strong, nonatomic) NSString * _Nullable logFilename; /** * Additional flags to be given to pj_file_open() when opening the log file. @@ -69,16 +72,24 @@ /** * An array which will hold all the configured transports. */ -@property (strong, nonatomic) NSArray *transportConfigurations; +@property (strong, nonatomic) NSArray * _Nonnull transportConfigurations; /** * Coniguration property to not offer the video codec in the INVITE. + * + * Default: NO */ @property (nonatomic) BOOL disableVideoSupport; +@property (nonatomic) VSLStunConfiguration * _Nullable stunConfiguration; + +@property (nonatomic) VSLIpChangeConfiguration * _Nullable ipChangeConfiguration; + /** * Whether the account needs to be unregistered after a call has been made * + * Default: No + * * @return BOOL */ @property (nonatomic) BOOL unregisterAfterCall; @@ -97,9 +108,17 @@ */ -(BOOL)hasTLSConfiguration; +/** + * To check if the endpoint has an udp configuration. + * + * @return BOOL + */ +-(BOOL)hasUDPConfiguration; + /** * Optional user agent string (default empty). If it's empty, no * User-Agent header will be sent with outgoing requests. */ -@property (strong, nonatomic) NSString *userAgent; +@property (strong, nonatomic) NSString * _Nullable userAgent; + @end diff --git a/Pod/Classes/Configurations/VSLEndpointConfiguration.m b/Pod/Classes/Configurations/VSLEndpointConfiguration.m index a7228ff5..08593af7 100644 --- a/Pod/Classes/Configurations/VSLEndpointConfiguration.m +++ b/Pod/Classes/Configurations/VSLEndpointConfiguration.m @@ -20,16 +20,14 @@ @implementation VSLEndpointConfiguration - (instancetype)init { if (self = [super init]) { self.maxCalls = VSLEndpointConfigurationMaxCalls; - self.logLevel = VSLEndpointConfigurationLogLevel; self.logConsoleLevel = VSLEndpointConfigurationLogConsoleLevel; self.logFilename = VSLEndpointConfigurationLogFileName; self.logFileFlags = PJ_O_APPEND; - self.clockRate = VSLEndpointConfigurationClockRate; self.sndClockRate = VSLEndpointConfigurationSndClockRate; - self.disableVideoSupport = false; - self.unregisterAfterCall = false; + self.disableVideoSupport = NO; + self.unregisterAfterCall = NO; } return self; } @@ -41,6 +39,20 @@ - (NSArray *)transportConfigurations { return _transportConfigurations; } +- (VSLIpChangeConfiguration *)ipChangeConfiguration { + if (!_ipChangeConfiguration) { + _ipChangeConfiguration = [[VSLIpChangeConfiguration alloc] init]; + } + return _ipChangeConfiguration; +} + +- (VSLStunConfiguration *)stunConfiguration { + if (!_stunConfiguration) { + _stunConfiguration = [[VSLStunConfiguration alloc] init]; + } + return _stunConfiguration; +} + - (void)setLogLevel:(NSUInteger)logLevel { NSAssert(logLevel > 0, @"Log level needs to be set higher than 0"); _logLevel = logLevel; @@ -81,4 +93,19 @@ - (BOOL)hasTLSConfiguration { return YES; } +-(BOOL)hasUDPConfiguration { + NSUInteger index = [self.transportConfigurations indexOfObjectPassingTest:^BOOL(VSLTransportConfiguration *transportConfiguration, NSUInteger idx, BOOL *stop) { + if (transportConfiguration.transportType == VSLTransportTypeUDP || transportConfiguration.transportType == VSLTransportTypeUDP6) { + *stop = YES; + return YES; + } + return NO; + }]; + + if (index == NSNotFound) { + return NO; + } + return YES; +} + @end diff --git a/Pod/Classes/Configurations/VSLIpChangeConfiguration.h b/Pod/Classes/Configurations/VSLIpChangeConfiguration.h new file mode 100644 index 00000000..8fb7f529 --- /dev/null +++ b/Pod/Classes/Configurations/VSLIpChangeConfiguration.h @@ -0,0 +1,82 @@ +// +// VSLIpChangeConfiguration.h +// Copyright © 2018 Devhouse Spindle. All rights reserved. +// + +#import +#import + +typedef NS_ENUM(NSInteger, VSLIpChangeConfigurationIpChangeCalls) { + /** + * Use the ip change from pjsip. + */ + VSLIpChangeConfigurationIpChangeCallsDefault, + /** + * Do the reinvite of the calls self instead of pjsip. + */ + VSLIpChangeConfigurationIpChangeCallsReinvite, + /** + * Do an UPDATE sip message instead of a INVITE that is done by pjsip. + */ + VSLIpChangeConfigurationIpChangeCallsUpdate +}; +#define VSLEndpointIpChangeCallsString(VSLEndpointIpChangeCalls) [@[@"VSLIpChangeConfigurationIpChangeCallsDefault", @"VSLIpChangeConfigurationIpChangeCallsReinvite", @"VSLIpChangeConfigurationIpChangeCallsUpdate"] objectAtIndex:VSLEndpointIpChangeCalls] + +typedef NS_ENUM(NSUInteger, VSLReinviteFlags) { + /** + * Deinitialize and recreate media, including media transport. This flag + * is useful in IP address change situation, if the media transport + * address (or address family) changes, for example during IPv4/IPv6 + * network handover. + * This flag is only valid for #pjsua_call_reinvite()/reinvite2(), or + * #pjsua_call_update()/update2(). + * + * Warning: If the re-INVITE/UPDATE fails, the old media will not be + * reverted. + */ + VSLReinviteFlagsReinitMedia = PJSUA_CALL_REINIT_MEDIA, + /** + * Update the local invite session's contact with the contact URI from + * the account. This flag is only valid for #pjsua_call_set_hold2(), + * #pjsua_call_reinvite() and #pjsua_call_update(). This flag is useful + * in IP address change situation, after the local account's Contact has + * been updated (typically with re-registration) use this flag to update + * the invite session with the new Contact and to inform this new Contact + * to the remote peer with the outgoing re-INVITE or UPDATE. + */ + VSLReinviteFlagsUpdateContact = PJSUA_CALL_UPDATE_CONTACT, + /** + * Update the local invite session's Via with the via address from + * the account. This flag is only valid for #pjsua_call_set_hold2(), + * #pjsua_call_reinvite() and #pjsua_call_update(). Similar to + * the flag PJSUA_CALL_UPDATE_CONTACT above, this flag is useful + * in IP address change situation, after the local account's Via has + * been updated (typically with re-registration). + */ + VSLReinviteFlagsUpdateVia = PJSUA_CALL_UPDATE_VIA +}; +#define VSLReinviteFlagsString(VSLReinviteFlags) [@[@"VSLReinviteFlagsReinitMedia", @"VSLReinviteFlagsUpdateContact", @"VSLReinviteFlagsUpdateVia"] objectAtIndex:VSLReinviteFlags] + +@interface VSLIpChangeConfiguration : NSObject + +@property (nonatomic) VSLIpChangeConfigurationIpChangeCalls ipChangeCallsUpdate; + +/** + * Should the old transport be cleaned up. + */ +@property (nonatomic) BOOL ipAddressChangeShutdownTransport; + +/** + * Should all calls be ended when an ip address change has been detected. + * + * Default: NO + */ +@property (nonatomic) BOOL ipAddressChangeHangupAllCalls; + +/** + * When ipAddressChangeHangupAllCalls is set to NO, this property should be set. + * + * Default: VSLReinviteFlagsReinitMedia | VSLReinviteFlagsUpdateVia | VSLReinviteFlagsUpdateContact + */ +@property (nonatomic) VSLReinviteFlags ipAddressChangeReinviteFlags; +@end diff --git a/Pod/Classes/Configurations/VSLIpChangeConfiguration.m b/Pod/Classes/Configurations/VSLIpChangeConfiguration.m new file mode 100644 index 00000000..f5c7b5dc --- /dev/null +++ b/Pod/Classes/Configurations/VSLIpChangeConfiguration.m @@ -0,0 +1,20 @@ +// +// VSLIpChangeConfiguration.m +// Copyright © 2018 Devhouse Spindle. All rights reserved. +// + +#import "VSLIpChangeConfiguration.h" + +@implementation VSLIpChangeConfiguration + +- (instancetype)init { + if (self = [super init]) { + self.ipChangeCallsUpdate = VSLIpChangeConfigurationIpChangeCallsDefault; + self.ipAddressChangeShutdownTransport = YES; + self.ipAddressChangeHangupAllCalls = NO; + self.ipAddressChangeReinviteFlags = VSLReinviteFlagsReinitMedia | VSLReinviteFlagsUpdateVia | VSLReinviteFlagsUpdateContact; + } + return self; +} + +@end diff --git a/Pod/Classes/Configurations/VSLStunConfiguration.h b/Pod/Classes/Configurations/VSLStunConfiguration.h new file mode 100644 index 00000000..637e9a94 --- /dev/null +++ b/Pod/Classes/Configurations/VSLStunConfiguration.h @@ -0,0 +1,20 @@ +// +// VSLStunConfiguration.h +// Copyright © 2018 Devhouse Spindle. All rights reserved. +// + +#import + +@interface VSLStunConfiguration : NSObject + +/** + * Add the stun servers that are available to the NSArray. + */ +@property (strong, nonatomic) NSArray *stunServers; + +/** + * Property that will get the number of stun servers there are configured. + */ +@property (readonly, nonatomic) int numOfStunServers; + +@end diff --git a/Pod/Classes/Configurations/VSLStunConfiguration.m b/Pod/Classes/Configurations/VSLStunConfiguration.m new file mode 100644 index 00000000..9653e745 --- /dev/null +++ b/Pod/Classes/Configurations/VSLStunConfiguration.m @@ -0,0 +1,21 @@ +// +// VSLStunConfiguration.m +// Copyright © 2018 Devhouse Spindle. All rights reserved. +// + +#import "VSLStunConfiguration.h" + +@implementation VSLStunConfiguration + +- (NSArray *)stunServers { + if (!_stunServers) { + _stunServers = [NSArray array]; + } + return _stunServers; +} + +- (int)numOfStunServers { + return (int)self.stunServers.count; +} + +@end diff --git a/Pod/Classes/VSLAccount.m b/Pod/Classes/VSLAccount.m index 25b6e389..70881875 100644 --- a/Pod/Classes/VSLAccount.m +++ b/Pod/Classes/VSLAccount.m @@ -123,51 +123,58 @@ - (BOOL)configureWithAccountConfiguration:(VSLAccountConfiguration * _Nonnull)ac acc_cfg.cred_info[0].data_type = PJSIP_CRED_DATA_PLAIN_PASSWD; acc_cfg.cred_info[0].data = accountConfiguration.sipPassword.pjString; acc_cfg.proxy_cnt = 0; - acc_cfg.media_stun_use = accountConfiguration.mediaStunType; + + // If a proxy server is present on the account configuration add this to pjsua account configuration. + if (accountConfiguration.sipProxyServer) { + acc_cfg.proxy_cnt = 1; + acc_cfg.proxy[0] = [[accountConfiguration.sipProxyServer stringByAppendingString:transportString] prependSipUri].pjString; + } + acc_cfg.sip_stun_use = accountConfiguration.sipStunType; + acc_cfg.media_stun_use = accountConfiguration.mediaStunType; + acc_cfg.allow_via_rewrite = accountConfiguration.allowViaRewrite ? PJ_TRUE : PJ_FALSE; acc_cfg.allow_contact_rewrite = accountConfiguration.allowContactRewrite ? PJ_TRUE : PJ_FALSE; - acc_cfg.contact_rewrite_method = accountConfiguration.contactRewriteMethod; - // Shutdown the old transport is no longer connected because of an ip address change. - acc_cfg.ip_change_cfg.shutdown_tp = accountConfiguration.ipAddressChangeShutdownTransport ? PJ_TRUE : PJ_FALSE; + // Only set the contact rewrite method when allow contact rewrite is set to TRUE. + if (accountConfiguration.allowContactRewrite) { + acc_cfg.contact_rewrite_method = accountConfiguration.contactRewriteMethod; + } - // Don't hangup calls when the ip address changes. - acc_cfg.ip_change_cfg.hangup_calls = accountConfiguration.ipAddressChangeHangupAllCalls ? PJ_TRUE : PJ_FALSE; + if ([[VSLEndpoint sharedEndpoint].endpointConfiguration hasTCPConfiguration] || [[VSLEndpoint sharedEndpoint].endpointConfiguration hasTLSConfiguration]) { + VSLIpChangeConfiguration *ipChangeConfiguration = [VSLEndpoint sharedEndpoint].endpointConfiguration.ipChangeConfiguration; + if (ipChangeConfiguration) { + // Shutdown the old transport is no longer connected because of an ip address change. + acc_cfg.ip_change_cfg.shutdown_tp = ipChangeConfiguration.ipAddressChangeShutdownTransport ? PJ_TRUE : PJ_FALSE; - // When a call is reinvited use the specified header. - if (!accountConfiguration.ipAddressChangeHangupAllCalls) { - acc_cfg.ip_change_cfg.reinvite_flags = (unsigned int)accountConfiguration.ipAddressChangeReinviteFlags; - } + // Don't hangup calls when the ip address changes. + acc_cfg.ip_change_cfg.hangup_calls = ipChangeConfiguration.ipAddressChangeHangupAllCalls ? PJ_TRUE : PJ_FALSE; - acc_cfg.contact_use_src_port = accountConfiguration.contactUseSrcPort ? PJ_TRUE : PJ_FALSE; - acc_cfg.allow_via_rewrite = accountConfiguration.allowViaRewrite ? PJ_TRUE : PJ_FALSE; + // When a call is reinvited use the specified header. + if (!ipChangeConfiguration.ipAddressChangeHangupAllCalls) { + acc_cfg.ip_change_cfg.reinvite_flags = (unsigned int)ipChangeConfiguration.ipAddressChangeReinviteFlags; + } + + } + acc_cfg.contact_use_src_port = accountConfiguration.contactUseSrcPort ? PJ_TRUE : PJ_FALSE; + } if ([[VSLEndpoint sharedEndpoint].endpointConfiguration hasTLSConfiguration]) { acc_cfg.srtp_secure_signaling = 1; acc_cfg.use_srtp = PJMEDIA_SRTP_MANDATORY; } - - // If a proxy server is present on the account configuration add this to pjsua account configuration. - if (accountConfiguration.sipProxyServer) { - acc_cfg.proxy_cnt = 1; - acc_cfg.proxy[0] = [[accountConfiguration.sipProxyServer stringByAppendingString:transportString] prependSipUri].pjString; - } - - acc_cfg.contact_use_src_port = accountConfiguration.contactUseSrcPort; - acc_cfg.allow_via_rewrite = accountConfiguration.allowViaRewrite; if (accountConfiguration.turnConfiguration) { acc_cfg.turn_cfg_use = PJSUA_TURN_CONFIG_USE_CUSTOM; acc_cfg.turn_cfg.enable_turn = accountConfiguration.turnConfiguration.enableTurn; acc_cfg.turn_cfg.turn_server = accountConfiguration.turnConfiguration.server.pjString; acc_cfg.turn_cfg.turn_auth_cred.data.static_cred.username = accountConfiguration.turnConfiguration.username.pjString; - acc_cfg.turn_cfg.turn_auth_cred.data.static_cred.data_type = accountConfiguration.turnConfiguration.passwordType; + acc_cfg.turn_cfg.turn_auth_cred.data.static_cred.data_type = (pj_stun_passwd_type) accountConfiguration.turnConfiguration.passwordType; acc_cfg.turn_cfg.turn_auth_cred.data.static_cred.data = accountConfiguration.turnConfiguration.password.pjString; } if (accountConfiguration.iceConfiguration) { - acc_cfg.ice_cfg_use = PJSUA_ICE_CONFIG_USE_CUSTOM; + acc_cfg.ice_cfg_use = PJSUA_ICE_CONFIG_USE_DEFAULT; acc_cfg.ice_cfg.enable_ice = accountConfiguration.iceConfiguration.enableIce; } diff --git a/Pod/Classes/VSLAudioController.m b/Pod/Classes/VSLAudioController.m index e195545d..4a64ff4a 100644 --- a/Pod/Classes/VSLAudioController.m +++ b/Pod/Classes/VSLAudioController.m @@ -90,8 +90,11 @@ - (void)activateAudioSession { VSLLogDebug(@"Activating audiosession"); [self checkCurrentThreadIsRegisteredWithPJSUA]; pjsua_set_no_snd_dev(); - pj_status_t status; - status = pjsua_set_snd_dev(PJMEDIA_AUD_DEFAULT_CAPTURE_DEV, PJMEDIA_AUD_DEFAULT_PLAYBACK_DEV); + + pjsua_snd_dev_param snd_dev_param; + pjsua_snd_dev_param_default(&snd_dev_param); + pj_status_t status = pjsua_set_snd_dev2(&snd_dev_param); + if (status != PJ_SUCCESS) { VSLLogWarning(@"Failure in enabling sound device"); } diff --git a/Pod/Classes/VSLCall.h b/Pod/Classes/VSLCall.h index d037a697..f57448ec 100644 --- a/Pod/Classes/VSLCall.h +++ b/Pod/Classes/VSLCall.h @@ -439,4 +439,8 @@ typedef NS_ENUM(NSInteger, VSLCallTerminateReason) { */ - (void)reinvite; +/** + * Will sent the UPDATE message to the call. + */ +- (void)update; @end diff --git a/Pod/Classes/VSLCall.m b/Pod/Classes/VSLCall.m index 83ffd38f..4e16ff9c 100644 --- a/Pod/Classes/VSLCall.m +++ b/Pod/Classes/VSLCall.m @@ -50,6 +50,7 @@ @interface VSLCall() @property (readwrite, nonatomic) NSTimeInterval lastSeenConnectDuration; @property (strong, nonatomic) NSString *numberToCall; @property (weak, nonatomic) VSLAccount *account; +@property (nonatomic) BOOL reinviteCall; /** * Stats */ @@ -288,20 +289,50 @@ - (void)callTransferStatusChangedWithStatusCode:(NSInteger)statusCode statusText - (void)reinvite { if (self.callState > VSLCallStateNull && self.callState < VSLCallStateDisconnected) { - pjsua_call_setting options; - pjsua_call_setting_default(&options); + pjsua_call_setting callSetting; + pjsua_call_setting_default(&callSetting); - options.flag = self.account.accountConfiguration.ipAddressChangeReinviteFlags; + VSLIpChangeConfiguration *ipChangeConfiguration = [VSLEndpoint sharedEndpoint].endpointConfiguration.ipChangeConfiguration; + if (ipChangeConfiguration) { + callSetting.flag = ipChangeConfiguration.ipAddressChangeReinviteFlags; + } if ([VSLEndpoint sharedEndpoint].endpointConfiguration.disableVideoSupport) { - options.vid_cnt = 0; + callSetting.vid_cnt = 0; } - pj_status_t status = pjsua_call_reinvite2((pjsua_call_id)self.callId, &options, NULL); + pj_status_t status = pjsua_call_reinvite2((pjsua_call_id)self.callId, &callSetting, NULL); if (status != PJ_SUCCESS) { VSLLogError(@"Cannot reinvite for call id: %ld!", (long)self.callId); } else { VSLLogDebug(@"Reinvite sent for call id: %ld", (long)self.callId); + self.reinviteCall = YES; + } + } +} + +- (void)update { + if (self.callState > VSLCallStateNull && self.callState < VSLCallStateDisconnected) { + pjsua_call_setting callSetting; + pjsua_call_setting_default(&callSetting); + + VSLIpChangeConfiguration *ipChangeConfiguration = [VSLEndpoint sharedEndpoint].endpointConfiguration.ipChangeConfiguration; + if (ipChangeConfiguration) { + callSetting.flag = ipChangeConfiguration.ipAddressChangeReinviteFlags; } + + if ([VSLEndpoint sharedEndpoint].endpointConfiguration.disableVideoSupport) { + callSetting.vid_cnt = 0; + } + + pj_status_t status = pjsua_call_update2((pjsua_call_id)self.callId, &callSetting, NULL); + if (status != PJ_SUCCESS) { + VSLLogError(@"Cannot sent UPDATE for call id: %ld!", (long)self.callId); + } else { + VSLLogDebug(@"UPDATE sent for call id: %ld", (long)self.callId); + self.reinviteCall = YES; + } + } else { + VSLLogDebug(@"Can not send call update because the call is not yet setup or already disconnected"); } } diff --git a/Pod/Classes/VSLCallManager.h b/Pod/Classes/VSLCallManager.h index 7a3214eb..bde41362 100644 --- a/Pod/Classes/VSLCallManager.h +++ b/Pod/Classes/VSLCallManager.h @@ -151,4 +151,10 @@ */ - (void)reinviteActiveCallsForAccount:(VSLAccount * _Nonnull)account; +/** + * Sent a SIP UPDATE message to all active calls for the given account. + * + * @param account The VSLAccount instance for which to sent the UPDATE. + */ +- (void)updateActiveCallsForAccount:(VSLAccount * _Nonnull)account; @end diff --git a/Pod/Classes/VSLCallManager.m b/Pod/Classes/VSLCallManager.m index 43df3840..af5cd5fb 100644 --- a/Pod/Classes/VSLCallManager.m +++ b/Pod/Classes/VSLCallManager.m @@ -327,6 +327,13 @@ - (void)reinviteActiveCallsForAccount:(VSLAccount *)account { } } +- (void)updateActiveCallsForAccount:(VSLAccount *)account { + VSLLogDebug(@"Sent UPDATE for calls"); + for (VSLCall *call in [self activeCallsForAccount:account]) { + [call update]; + } +} + - (void)callStateChanged:(NSNotification *)notification { VSLCall *call = [[notification userInfo] objectForKey:VSLNotificationUserInfoCallKey]; if (call.callState == VSLCallStateDisconnected) { diff --git a/Pod/Classes/VSLEndpoint.h b/Pod/Classes/VSLEndpoint.h index 64d8a5a1..932698b2 100644 --- a/Pod/Classes/VSLEndpoint.h +++ b/Pod/Classes/VSLEndpoint.h @@ -58,7 +58,6 @@ typedef NS_ENUM(NSInteger, VSLEndpointState) { }; #define VSLEndpointStateString(VSLEndpointState) [@[@"VSLEndpointStopped", @"VSLEndpointStarting", @"VSLEndpointStarted"] objectAtIndex:VSLEndpointState] - @interface VSLEndpoint : NSObject /** @@ -71,6 +70,8 @@ typedef NS_ENUM(NSInteger, VSLEndpointState) { */ @property (readonly) pj_pool_t * _Nullable pjPool; +@property (readwrite) BOOL ipChangeInProgress; + /** * The incomingCallBlock will be called when an incoming call is received by pjsip. */ diff --git a/Pod/Classes/VSLEndpoint.m b/Pod/Classes/VSLEndpoint.m index 760aff9e..9d4913d0 100644 --- a/Pod/Classes/VSLEndpoint.m +++ b/Pod/Classes/VSLEndpoint.m @@ -13,6 +13,7 @@ #import "VSLCallManager.h" #import "VSLLogging.h" #import "VSLNetworkMonitor.h" +#import "VSLIpChangeConfiguration.h" #import "VSLTransportConfiguration.h" static NSString * const VSLEndpointErrorDomain = @"VialerSIPLib.VSLEndpoint.error"; @@ -74,11 +75,11 @@ - (void)setState:(VSLEndpointState)state { } - @try { - [[NSNotificationCenter defaultCenter] removeObserver:self name:VSLCallDeallocNotification object: nil]; - } @catch(NSException *exceptiom) { - - } +// @try { +// [[NSNotificationCenter defaultCenter] removeObserver:self name:VSLCallDeallocNotification object: nil]; +// } @catch(NSException *exceptiom) { +// +// } break; } case VSLEndpointStarting: { @@ -86,7 +87,7 @@ - (void)setState:(VSLEndpointState)state { } case VSLEndpointStarted: { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkNetworkMonitoring:) name:VSLCallStateChangedNotification object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callDealloc:) name:VSLCallDeallocNotification object:nil]; +// [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callDealloc:) name:VSLCallDeallocNotification object:nil]; break; } } @@ -181,11 +182,22 @@ - (BOOL)startEndpointWithEndpointConfiguration:(VSLEndpointConfiguration * _Non endpointConfig.max_calls = (unsigned int)endpointConfiguration.maxCalls; endpointConfig.user_agent = endpointConfiguration.userAgent.pjString; + if (endpointConfiguration.stunConfiguration) { + endpointConfig.stun_srv_cnt = endpointConfiguration.stunConfiguration.numOfStunServers; + int i = 0; + for (NSString* stunServer in endpointConfiguration.stunConfiguration.stunServers){ + endpointConfig.stun_srv[i] = [stunServer pjString]; + i++; + } + } + // Configure the media information for the endpoint. pjsua_media_config mediaConfig; pjsua_media_config_default(&mediaConfig); mediaConfig.clock_rate = (unsigned int)endpointConfiguration.clockRate == 0 ? PJSUA_DEFAULT_CLOCK_RATE : (unsigned int)endpointConfiguration.clockRate; mediaConfig.snd_clock_rate = (unsigned int)endpointConfiguration.sndClockRate; + mediaConfig.has_ioqueue = PJ_TRUE; + mediaConfig.thread_cnt = 1; // Initialize Endpoint. status = pjsua_init(&endpointConfig, &logConfig, &mediaConfig); @@ -333,7 +345,6 @@ - (VSLAccount *)lookupAccount:(NSInteger)accountId { } - (VSLCall *)lookupCall:(NSInteger)callId { - for (VSLAccount *account in self.accounts) { VSLCall *call = [account lookupCall:callId]; if (call) { @@ -510,6 +521,30 @@ static void onRegState2(pjsua_acc_id acc_id, pjsua_reg_info *info) { if (account) { [account accountStateChanged]; } + + if ([VSLEndpoint sharedEndpoint].ipChangeInProgress) { + // When disableVideoSupport is on reinivite the calls again. And in the reinivite + // disable the video stream. Otherwise the response is an 488 Not Acceptatble here. + if ([VSLEndpoint sharedEndpoint].endpointConfiguration.disableVideoSupport) { + VSLIpChangeConfiguration *ipChangeConfiguration = [VSLEndpoint sharedEndpoint].endpointConfiguration.ipChangeConfiguration; + VSLAccount *account = [[VSLEndpoint sharedEndpoint] lookupAccount:acc_id]; + if (ipChangeConfiguration) { + switch (ipChangeConfiguration.ipChangeCallsUpdate) { + case VSLIpChangeConfigurationIpChangeCallsReinvite: + VSLLogInfo(@"Do a reinvite for all calls of account: %d", acc_id); + [[[VSLEndpoint sharedEndpoint] callManager] reinviteActiveCallsForAccount:account]; + break; + case VSLIpChangeConfigurationIpChangeCallsUpdate: + VSLLogInfo(@"Do a update for all calls of account: %d", acc_id); + [[[VSLEndpoint sharedEndpoint] callManager] updateActiveCallsForAccount:account]; + break; + case VSLIpChangeConfigurationIpChangeCallsDefault: + // Do nothing. + break; + } + } + } + } } /* Callback on media events. Adjust renderer window size to original video size */ @@ -574,8 +609,9 @@ static void onCallTransferStatus(pjsua_call_id callId, int statusCode, const pj_ } } -- (void)callDealloc:(NSNotification *)notification { - if (![self.endpointConfiguration unregisterAfterCall]) { +//- (void)callDealloc:(NSNotification *)notification { +- (void)callDealloc { + if (!self.endpointConfiguration.unregisterAfterCall) { return; } @@ -627,7 +663,7 @@ - (void)checkNetworkMonitoring:(NSNotification *)notification { [self stopNetworkMonitoring]; break; } - default: { + case VSLCallStateConfirmed: { if (!self.monitoringCalls) { for (VSLAccount *account in self.accounts) { if ([account firstActiveCall]) { @@ -640,6 +676,14 @@ - (void)checkNetworkMonitoring:(NSNotification *)notification { } } } + case VSLCallStateNull: + case VSLCallStateCalling: + case VSLCallStateIncoming: + case VSLCallStateEarly: + case VSLCallStateConnecting: { + // Do nothing. + break; + } } } @@ -668,6 +712,7 @@ - (void)stopNetworkMonitoring { [self.networkMonitor stopMonitoring]; self.networkMonitor = nil; self.monitoringCalls = NO; + [self callDealloc]; } } @@ -680,10 +725,9 @@ - (void)stopNetworkMonitoring { * @param notification The notification which lead to this function being invoked over GCD. */ - (void)ipAddressChanged:(NSNotification *)notification { - pjsua_ip_change_param param; pjsua_ip_change_param_default(¶m); - param.restart_lis_delay = 10; + param.restart_lis_delay = 100; param.restart_listener = PJ_TRUE; pjsua_handle_ip_change(¶m); @@ -692,6 +736,8 @@ - (void)ipAddressChanged:(NSNotification *)notification { static void onIpChangeProgress(pjsua_ip_change_op op, pj_status_t status, const pjsua_ip_change_op_info *info) { VSLLogInfo(@"onIpChangeProgress:"); + [VSLEndpoint sharedEndpoint].ipChangeInProgress = TRUE; + switch (op) { case PJSUA_IP_CHANGE_OP_RESTART_LIS: { VSLLogInfo(@"Restart Listener: %u", status); @@ -703,18 +749,6 @@ static void onIpChangeProgress(pjsua_ip_change_op op, pj_status_t status, const } case PJSUA_IP_CHANGE_OP_ACC_UPDATE_CONTACT: { VSLLogInfo(@"Account update contact: %u", status); - // When disableVideoSupport is on reinivite the calls again. And in the reinivite - // disable the video stream. Otherwise the response is an 488 Not Acceptatble here. - if ([VSLEndpoint sharedEndpoint].endpointConfiguration.disableVideoSupport) { - pjsua_call_id callId = info->acc_reinvite_calls.call_id; - pjsua_acc_id accountId = info->acc_reinvite_calls.acc_id; - - VSLLogError(@"Do a reinvite for account: %d and the call: %d", accountId, callId); - - VSLAccount *account = [[VSLEndpoint sharedEndpoint] lookupAccount:accountId]; - VSLCall *call = [account lookupCall:callId]; - [call reinvite]; - } break; } case PJSUA_IP_CHANGE_OP_ACC_HANGUP_CALLS: { @@ -723,7 +757,7 @@ static void onIpChangeProgress(pjsua_ip_change_op op, pj_status_t status, const } case PJSUA_IP_CHANGE_OP_ACC_REINVITE_CALLS: { VSLLogInfo(@"Account reinvite calls: %u", status); - + [VSLEndpoint sharedEndpoint].ipChangeInProgress = FALSE; break; } default: diff --git a/Pod/Classes/VSLNetworkMonitor.m b/Pod/Classes/VSLNetworkMonitor.m index 451260b4..40597288 100644 --- a/Pod/Classes/VSLNetworkMonitor.m +++ b/Pod/Classes/VSLNetworkMonitor.m @@ -10,7 +10,7 @@ #import "VSLLogging.h" -static double const VSLNetworkMonitorDelayTimeForNotification = 0.5; +static double const VSLNetworkMonitorDelayTimeForNotification = 1; NSString * const VSLNetworkMonitorChangedNotification = @"VSLNetworkMonitorChangedNotification"; @@ -72,7 +72,7 @@ - (void)internetConnectionChanged:(NSNotification *)notification { __weak VSLNetworkMonitor *weakSelf = self; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(VSLNetworkMonitorDelayTimeForNotification * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - VSLLogDebug(@"Posting notification that internet connection has changed."); + VSLLogInfo(@"Posting notification that internet connection has changed."); weakSelf.isChangingNetwork = NO; [[NSNotificationCenter defaultCenter] postNotificationName:VSLNetworkMonitorChangedNotification object:nil]; }); diff --git a/Pod/Classes/VialerSIPLib.h b/Pod/Classes/VialerSIPLib.h index 9ee89414..118be566 100644 --- a/Pod/Classes/VialerSIPLib.h +++ b/Pod/Classes/VialerSIPLib.h @@ -9,6 +9,8 @@ #import "VSLCallManager.h" #import "VSLCall.h" #import "VSLEndpointConfiguration.h" +#import "VSLIceConfiguration.h" +#import "VSLStunConfiguration.h" #import "VSLTransportConfiguration.h" #import "CallKitProviderDelegate.h" @@ -50,18 +52,21 @@ typedef NS_ENUM(NSUInteger, VialerSIPLibErrors) { * The protocol which needs to be implemented in order to use the library. */ @protocol SIPEnabledUser + /** * The sip account that should be used when authenticate on remote PBX. * * @return NSString with the password. */ @property (readonly, nonatomic) NSString * _Nonnull sipAccount; + /** * The password that should be used when authenticate on remote PBX. * * @return NSString with the password. */ @property (readonly, nonatomic) NSString * _Nonnull sipPassword; + /** * The domain where the PBX can be found. * @@ -69,6 +74,7 @@ typedef NS_ENUM(NSUInteger, VialerSIPLibErrors) { */ @property (readonly, nonatomic) NSString * _Nonnull sipDomain; @optional + /** * When set to YES, the account will be registered on configuration. * @@ -77,6 +83,16 @@ typedef NS_ENUM(NSUInteger, VialerSIPLibErrors) { * @return BOOL is registration should happen. */ @property (readonly, nonatomic) BOOL sipRegisterOnAdd; + +/** + * When set to YES, calls will be dropped after registration fails. + * + * Default is NO. + * + * @return BOOL if call should be dropped if registration fails. + */ +@property (readonly, nonatomic) BOOL dropCallOnRegistrationFailure; + /** * The proxy address where to connect to. * @@ -100,7 +116,56 @@ typedef NS_ENUM(NSUInteger, VialerSIPLibErrors) { */ @property (nonatomic) VSLStunUse mediaStunType; -@end +/** + * The ICE Configuration that should be used. + */ +@property (readonly, nonatomic) VSLIceConfiguration * _Nullable iceConfiguration; + +/** + * Specify if source TCP port should be used as the initial Contact + * address if TCP/TLS transport is used. Note that this feature will + * be automatically turned off when nameserver is configured because + * it may yield different destination address due to DNS SRV resolution. + * Also some platforms are unable to report the local address of the + * TCP socket when it is still connecting. In these cases, this + * feature will also be turned off. + * + * Default: YES + */ +@property (readonly, nonatomic) BOOL contactUseSrcPort; + +/** + * This option is used to overwrite the "sent-by" field of the Via header + * for outgoing messages with the same interface address as the one in + * the REGISTER request, as long as the request uses the same transport + * instance as the previous REGISTER request. + * + * Default: YES + */ +@property (readonly, nonatomic) BOOL allowViaRewrite; + +/** + * This option is used to update the transport address and the Contact + * header of REGISTER request. When this option is enabled, the library + * will keep track of the public IP address from the response of REGISTER + * request. Once it detects that the address has changed, it will + * unregister current Contact, update the Contact with transport address + * learned from Via header, and register a new Contact to the registrar. + * This will also update the public name of UDP transport if STUN is + * configured. + * + * Default: YES + */ +@property (readonly, nonatomic) BOOL allowContactRewrite; + +/** + * Control how Contact update will be done with the registration. + * + * Default: VSLContactRewriteMethodAlwaysUpdate + */ +@property (readonly, nonatomic) VSLContactRewriteMethod contactRewriteMethod; + +@end // End of the SIPEnabledUser protocol @interface VialerSIPLib : NSObject diff --git a/Pod/Classes/VialerSIPLib.m b/Pod/Classes/VialerSIPLib.m index 5b011dab..db2e579b 100644 --- a/Pod/Classes/VialerSIPLib.m +++ b/Pod/Classes/VialerSIPLib.m @@ -98,17 +98,45 @@ - (VSLAccount *)createAccountWithSipUser:(id _Nonnull __autorel accountConfiguration.sipAccount = sipUser.sipAccount; accountConfiguration.sipPassword = sipUser.sipPassword; accountConfiguration.sipDomain = sipUser.sipDomain; + if ([sipUser respondsToSelector:@selector(sipProxy)]) { accountConfiguration.sipProxyServer = sipUser.sipProxy; } - accountConfiguration.sipRegisterOnAdd = sipUser.sipRegisterOnAdd; - accountConfiguration.dropCallOnRegistrationFailure = YES; + + if ([sipUser respondsToSelector:@selector(sipRegisterOnAdd)]) { + accountConfiguration.sipRegisterOnAdd = sipUser.sipRegisterOnAdd; + } + + if ([sipUser respondsToSelector:@selector(dropCallOnRegistrationFailure)]) { + accountConfiguration.dropCallOnRegistrationFailure = sipUser.dropCallOnRegistrationFailure; + } if ([sipUser respondsToSelector:@selector(mediaStunType)]) { - accountConfiguration.mediaStunType = sipUser.mediaStunType; + accountConfiguration.mediaStunType = (pjsua_stun_use) sipUser.mediaStunType; } + if ([sipUser respondsToSelector:@selector(sipStunType)]) { - accountConfiguration.sipStunType = sipUser.sipStunType; + accountConfiguration.sipStunType = (pjsua_stun_use) sipUser.sipStunType; + } + + if ([sipUser respondsToSelector:@selector(contactRewriteMethod)]) { + accountConfiguration.contactRewriteMethod = sipUser.contactRewriteMethod; + } + + if ([sipUser respondsToSelector:@selector(iceConfiguration)]) { + accountConfiguration.iceConfiguration = sipUser.iceConfiguration; + } + + if ([sipUser respondsToSelector:@selector(contactUseSrcPort)]) { + accountConfiguration.contactUseSrcPort = sipUser.contactUseSrcPort; + } + + if ([sipUser respondsToSelector:@selector(allowViaRewrite)]) { + accountConfiguration.allowViaRewrite = sipUser.allowViaRewrite; + } + + if ([sipUser respondsToSelector:@selector(allowContactRewrite)]) { + accountConfiguration.allowContactRewrite = sipUser.allowContactRewrite; } account = [[VSLAccount alloc] initWithCallManager:self.callManager]; From cfd9cd4f61b8e020da84f941da3f9831241dfa0a Mon Sep 17 00:00:00 2001 From: Redmer Loen Date: Mon, 19 Feb 2018 08:56:54 +0100 Subject: [PATCH 4/5] Remoed comments from code that is still needed --- Pod/Classes/VSLEndpoint.m | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Pod/Classes/VSLEndpoint.m b/Pod/Classes/VSLEndpoint.m index 9d4913d0..8624a79c 100644 --- a/Pod/Classes/VSLEndpoint.m +++ b/Pod/Classes/VSLEndpoint.m @@ -75,11 +75,11 @@ - (void)setState:(VSLEndpointState)state { } -// @try { -// [[NSNotificationCenter defaultCenter] removeObserver:self name:VSLCallDeallocNotification object: nil]; -// } @catch(NSException *exceptiom) { -// -// } + @try { + [[NSNotificationCenter defaultCenter] removeObserver:self name:VSLCallDeallocNotification object: nil]; + } @catch(NSException *exceptiom) { + + } break; } case VSLEndpointStarting: { @@ -87,7 +87,7 @@ - (void)setState:(VSLEndpointState)state { } case VSLEndpointStarted: { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkNetworkMonitoring:) name:VSLCallStateChangedNotification object:nil]; -// [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callDealloc:) name:VSLCallDeallocNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callDealloc:) name:VSLCallDeallocNotification object:nil]; break; } } @@ -609,8 +609,7 @@ static void onCallTransferStatus(pjsua_call_id callId, int statusCode, const pj_ } } -//- (void)callDealloc:(NSNotification *)notification { -- (void)callDealloc { +- (void)callDealloc:(NSNotification *)notification { if (!self.endpointConfiguration.unregisterAfterCall) { return; } @@ -712,7 +711,7 @@ - (void)stopNetworkMonitoring { [self.networkMonitor stopMonitoring]; self.networkMonitor = nil; self.monitoringCalls = NO; - [self callDealloc]; + [self callDealloc: nil]; } } From 7dd3996d464937199cc7df8722c8ca93ed13a4e0 Mon Sep 17 00:00:00 2001 From: Redmer Loen Date: Mon, 19 Feb 2018 08:59:04 +0100 Subject: [PATCH 5/5] Release 3.1.0 --- VialerSIPLib.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VialerSIPLib.podspec b/VialerSIPLib.podspec index a3384c22..00ede673 100644 --- a/VialerSIPLib.podspec +++ b/VialerSIPLib.podspec @@ -9,7 +9,7 @@ Pod::Spec.new do |s| s.name = "VialerSIPLib" - s.version = "3.0.0" + s.version = "3.1.0" s.summary = "Vialer SIP Library for iOS" s.description = "Objective-C wrapper around PJSIP." s.homepage = "https://github.com/VoIPGRID/VialerSIPLib"