Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release/3.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Redmer Loen committed Feb 19, 2018
2 parents 057962e + 7dd3996 commit 56edf2d
Show file tree
Hide file tree
Showing 21 changed files with 500 additions and 92 deletions.
8 changes: 4 additions & 4 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ PODS:
- Reachability (3.2)
- SPLumberjackLogFormatter (0.0.1):
- CocoaLumberjack
- Vialer-pjsip-iOS (3.3.0)
- VialerSIPLib (2.8.0):
- Vialer-pjsip-iOS (3.3.1)
- VialerSIPLib (3.0.0):
- CocoaLumberjack
- Reachability
- Vialer-pjsip-iOS
Expand Down Expand Up @@ -39,8 +39,8 @@ SPEC CHECKSUMS:
OCMock: 2cd0716969bab32a2283ff3a46fd26a8c8b4c5e3
Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96
SPLumberjackLogFormatter: a2290c9b880f3166b2d1bace45dc1fc1302b28ab
Vialer-pjsip-iOS: fe7317dd3702d54b08986d8d3e2a109cbb06ecae
VialerSIPLib: 6190a4a0a5f87724921cc9d1e1a5a4ccfa62c461
Vialer-pjsip-iOS: 682de71852150ed5d1827f064062755c1363f36e
VialerSIPLib: 3627633a13ba2a68edb4dd7ae0de0bad7b343887

PODFILE CHECKSUM: 64a9b7d822c5cdfb540de83747cdf7175cb1a64d

Expand Down
77 changes: 57 additions & 20 deletions Pod/Classes/Configurations/VSLAccountConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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

/**
Expand Down Expand Up @@ -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;

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

Expand Down
5 changes: 1 addition & 4 deletions Pod/Classes/Configurations/VSLAccountConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
25 changes: 22 additions & 3 deletions Pod/Classes/Configurations/VSLEndpointConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
//

#import <Foundation/Foundation.h>
#import "VSLIpChangeConfiguration.h"
#import "VSLStunConfiguration.h"


@interface VSLEndpointConfiguration : NSObject

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand All @@ -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
35 changes: 31 additions & 4 deletions Pod/Classes/Configurations/VSLEndpointConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down Expand Up @@ -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
82 changes: 82 additions & 0 deletions Pod/Classes/Configurations/VSLIpChangeConfiguration.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//
// VSLIpChangeConfiguration.h
// Copyright © 2018 Devhouse Spindle. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <VialerPJSIP/pjsua.h>

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
20 changes: 20 additions & 0 deletions Pod/Classes/Configurations/VSLIpChangeConfiguration.m
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit 56edf2d

Please sign in to comment.