Skip to content

Commit

Permalink
VIALI-3437: Added the option for users to set the audio quality (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
Redmer Loen authored and c0deaddict committed Nov 6, 2018
1 parent 4972cad commit c5774f8
Show file tree
Hide file tree
Showing 33 changed files with 658 additions and 161 deletions.
12 changes: 6 additions & 6 deletions Gemfile.lock
Expand Up @@ -36,7 +36,7 @@ GEM
fuzzy_match (~> 2.0.4)
nap (~> 1.0)
cocoapods-deintegrate (1.0.2)
cocoapods-downloader (1.2.1)
cocoapods-downloader (1.2.2)
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.0)
Expand Down Expand Up @@ -66,7 +66,7 @@ GEM
faraday_middleware (0.12.2)
faraday (>= 0.7.4, < 1.0)
fastimage (2.1.4)
fastlane (2.105.1)
fastlane (2.107.0)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.3, < 3.0.0)
babosa (>= 1.0.2, < 2.0.0)
Expand Down Expand Up @@ -151,10 +151,10 @@ GEM
uber (< 0.2.0)
retriable (3.1.2)
rouge (2.0.7)
ruby-macho (1.2.0)
ruby-macho (1.3.1)
rubyzip (1.2.2)
security (0.1.3)
signet (0.9.2)
signet (0.11.0)
addressable (~> 2.3)
faraday (~> 0.9)
jwt (>= 1.5, < 3.0)
Expand All @@ -179,7 +179,7 @@ GEM
unf_ext (0.0.7.5)
unicode-display_width (1.4.0)
word_wrap (1.0.0)
xcodeproj (1.6.0)
xcodeproj (1.7.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
Expand All @@ -198,4 +198,4 @@ DEPENDENCIES
fastlane

BUNDLED WITH
1.16.4
1.16.6
12 changes: 6 additions & 6 deletions Podfile.lock
Expand Up @@ -53,12 +53,12 @@ PODS:
- PBWebViewController (0.5.0)
- Reachability (3.2)
- SAMKeychain (1.5.3)
- SimulatorStatusMagic (2.2)
- SimulatorStatusMagic (2.3)
- SPLumberjackLogFormatter (0.0.1):
- CocoaLumberjack
- SVProgressHUD (2.2.5)
- Vialer-pjsip-iOS (3.3.7)
- VialerSIPLib (3.3.4):
- Vialer-pjsip-iOS (3.4.1)
- VialerSIPLib (3.4.0):
- CocoaLumberjack
- Reachability
- Vialer-pjsip-iOS
Expand Down Expand Up @@ -130,11 +130,11 @@ SPEC CHECKSUMS:
PBWebViewController: 6537990155ca850fb8d0563efbc12becebc953ef
Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96
SAMKeychain: 483e1c9f32984d50ca961e26818a534283b4cd5c
SimulatorStatusMagic: 0389a805fa8bd001e2977c4046730bdbd6642861
SimulatorStatusMagic: 631fe6e4195a8a8d587ad8744af9015126526cc2
SPLumberjackLogFormatter: a2290c9b880f3166b2d1bace45dc1fc1302b28ab
SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6
Vialer-pjsip-iOS: 3b8bac1bf7e6831379cd0b4763dce1842db0abb4
VialerSIPLib: 93ffe714270208cb1c5595eb8febca71feb8ff84
Vialer-pjsip-iOS: 9b8fc1226e9a51150642b9cc81a8c62c9e9c530b
VialerSIPLib: d62821042b97fd6264fd44da07661648dd00fb3f

PODFILE CHECKSUM: 8e7a2fdf72deeac99781236e5c990c0e454b5552

Expand Down
94 changes: 59 additions & 35 deletions Vialer.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0940"
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Vialer.xcodeproj/xcshareddata/xcschemes/ANNAbel.xcscheme
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0940"
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0940"
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Vialer.xcodeproj/xcshareddata/xcschemes/Verbonden.xcscheme
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0940"
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0940"
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0940"
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Vialer.xcodeproj/xcshareddata/xcschemes/Vialer.xcscheme
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0940"
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0940"
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0940"
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Vialer.xcodeproj/xcshareddata/xcschemes/Voys.xcscheme
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0940"
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
8 changes: 8 additions & 0 deletions Vialer/Api/VoIPGRIDRequestOperationManager.h
Expand Up @@ -171,6 +171,14 @@ extern NSString * const VoIPGRIDRequestOperationManagerUnAuthorizedNotification;
*/
- (void)pushUseEncryptionWithCompletion:(void(^)(BOOL success, NSError *error))completion;

/**
* This method will try to enable or disable the use of the opus codec.
*
* @param enable Wheter to enable the opus codec.
* @param completion A block that will be called after the push attempt. It will return the response data if any or an error if any.
*/
- (void)pushUseOpus:(BOOL)enable withCompletion:(void(^)(BOOL success, NSError *error))completion;

/**
* This method will try to fetch the mobile profile of the currently authenticated user.
*
Expand Down
15 changes: 15 additions & 0 deletions Vialer/Api/VoIPGRIDRequestOperationManager.m
Expand Up @@ -21,6 +21,7 @@

static NSString * const VoIPGRIDRequestOperationManagerApiKeyMobileNumber = @"mobile_nr";
static NSString * const VoIPGRIDRequestOperationManagerApiKeyAppAccountUseEncryption = @"appaccount_use_encryption";
static NSString * const VoIPGRIDRequestOperationManagerApiKeyAppAccountUseOpus = @"appaccount_use_opus";

static int const VoIPGRIDRequestOperationManagerTimoutInterval = 15;

Expand Down Expand Up @@ -275,6 +276,20 @@ - (void)pushUseEncryptionWithCompletion:(void (^)(BOOL, NSError *))completion {
}];
}

- (void)pushUseOpus:(BOOL)enable withCompletion:(void (^)(BOOL, NSError *))completion {
NSDictionary *parameters = @{VoIPGRIDRequestOperationManagerApiKeyAppAccountUseOpus: enable ? @YES : @NO};

[self PUT:VoIPGRIDRequestOperationManagerURLMobileProfile parameters:parameters withCompletion:^(AFHTTPRequestOperation *operation, NSDictionary *responseData, NSError *error) {
if (completion) {
if (error) {
completion(NO, error);
} else {
completion(YES, nil);
}
}
}];
}

#pragma mark - Miscellaneous

- (void)autoLoginTokenWithCompletion:(void (^)(AFHTTPRequestOperation *operation, NSDictionary *responseData, NSError *error))completion {
Expand Down
41 changes: 39 additions & 2 deletions Vialer/AppDelegate.swift
Expand Up @@ -3,6 +3,7 @@
// Copyright © 2017 VoIPGRID. All rights reserved.
//

import AVFoundation
import CoreData
import UIKit

Expand Down Expand Up @@ -160,8 +161,11 @@ extension AppDelegate {
/// Hook up the observers that AppDelegate should listen to
fileprivate func setupObservers() {
NotificationCenter.default.addObserver(self, selector: #selector(updatedSIPCredentials), name: NSNotification.Name.SystemUserSIPCredentialsChanged, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(updateSIPEndpoint(_:)), name: NSNotification.Name.SystemUserEncryptionUsageChanged, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(updateSIPEndpoint(_:)), name: NSNotification.Name.SystemUserStunUsageChanged, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(sipDisabledNotification), name: NSNotification.Name.SystemUserSIPDisabled, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(sipDisabledNotification), name: NSNotification.Name.SystemUserLogout, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(registerForPushNotification), name: NSNotification.Name.SystemUserLogin, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(callStateChanged(_:)), name: NSNotification.Name.VSLCallStateChanged, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(callKitCallWasHandled(_:)), name: NSNotification.Name.CallKitProviderDelegateInboundCallAccepted, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(callKitCallWasHandled(_:)), name: NSNotification.Name.CallKitProviderDelegateInboundCallRejected, object: nil)
Expand All @@ -176,7 +180,10 @@ extension AppDelegate {
/// Remove the observers that the AppDelegate is listening to
fileprivate func removeObservers() {
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.SystemUserSIPCredentialsChanged, object: nil)
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.SystemUserEncryptionUsageChanged, object: nil)
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.SystemUserStunUsageChanged, object: nil)
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.SystemUserSIPDisabled, object: nil)
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.SystemUserLogin, object: nil)
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.SystemUserLogout, object: nil)
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.VSLCallStateChanged, object: nil)
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.MiddlewareAccountRegistrationIsDone, object: nil)
Expand Down Expand Up @@ -344,8 +351,14 @@ extension AppDelegate {
/// Setup the endpoint if user has SIP enabled
@objc fileprivate func updatedSIPCredentials() {
VialerLogInfo("SIP Credentials have changed")
if !user.sipEnabled { return }
if !user.loggedIn { return }
if !user.loggedIn {
VialerLogWarning("User is not logged in")
return
}
if !user.sipEnabled {
VialerLogWarning("SIP not enabled")
return
}

DispatchQueue.main.async {
SIPUtils.setupSIPEndpoint()
Expand All @@ -356,6 +369,30 @@ extension AppDelegate {
}
}

@objc fileprivate func updateSIPEndpoint(_ notification: NSNotification) {
VialerLogInfo("\(notification.name) fired to update SIP endpoint")
if !user.loggedIn {
VialerLogWarning("User is not logged in")
return
}
if !user.sipEnabled {
VialerLogWarning("SIP not enabled")
return
}

DispatchQueue.main.async {
SIPUtils.setupSIPEndpoint()
}
}

@objc fileprivate func registerForPushNotification() {
VialerLogInfo("User has been logged in register for push notifications")

DispatchQueue.main.async {
APNSHandler.shared()?.registerForVoIPNotifications()
}
}

/// SIP was disabled, remove the endpoint
@objc fileprivate func sipDisabledNotification() {
VialerLogInfo("SIP has been disabled")
Expand Down
77 changes: 72 additions & 5 deletions Vialer/Base.lproj/SettingsStoryboard.storyboard
@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Wbd-46-JZE">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Wbd-46-JZE">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand Down Expand Up @@ -128,6 +127,7 @@
<connections>
<segue destination="zEE-Ao-KU6" kind="show" identifier="ShowEditNumberSegue" id="x7r-DJ-ID7"/>
<segue destination="YfQ-oy-Qzc" kind="show" identifier="ShowActivateSIPAccount" id="RKt-er-1hs"/>
<segue destination="zk1-1z-hLN" kind="show" identifier="ShowAudioQualitySegue" id="b5T-6q-Qgg"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="IaI-um-zII" userLabel="First Responder" sceneMemberID="firstResponder"/>
Expand Down Expand Up @@ -298,7 +298,74 @@ At this moment there is no VoIP account linked to your user.</string>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="fVo-uT-7Db" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2460" y="625"/>
<point key="canvasLocation" x="1346" y="1143"/>
</scene>
<!--Audio Quality-->
<scene sceneID="xwv-9x-WAZ">
<objects>
<viewController id="zk1-1z-hLN" customClass="AudioQualityViewController" customModule="ANNAbel" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="8wp-nH-HWY"/>
<viewControllerLayoutGuide type="bottom" id="Isg-tr-PTy"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="gR9-Xe-EIQ">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="01J-sa-L18">
<rect key="frame" x="0.0" y="64" width="375" height="603"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="AudioQualityCell" textLabel="3sE-tJ-A80" detailTextLabel="y4G-Cq-OBg" style="IBUITableViewCellStyleSubtitle" id="Dtg-wN-EjP">
<rect key="frame" x="0.0" y="28" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Dtg-wN-EjP" id="Y6A-iV-ogI">
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="3sE-tJ-A80">
<rect key="frame" x="15" y="5" width="33.5" height="20.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Subtitle" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="y4G-Cq-OBg">
<rect key="frame" x="15" y="25.5" width="44" height="14.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
</tableView>
</subviews>
<color key="backgroundColor" red="0.93725490199999995" green="0.93725490199999995" blue="0.95686274510000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="01J-sa-L18" secondAttribute="trailing" id="5FB-Eb-iY4"/>
<constraint firstItem="01J-sa-L18" firstAttribute="top" secondItem="8wp-nH-HWY" secondAttribute="bottom" id="IdM-i7-G69"/>
<constraint firstItem="01J-sa-L18" firstAttribute="bottom" secondItem="Isg-tr-PTy" secondAttribute="top" id="gxO-x9-81R"/>
<constraint firstItem="01J-sa-L18" firstAttribute="leading" secondItem="gR9-Xe-EIQ" secondAttribute="leading" id="oCR-2H-sUg"/>
</constraints>
</view>
<navigationItem key="navigationItem" title="Audio Quality" id="Ayx-zo-TME">
<barButtonItem key="leftBarButtonItem" title="Back" id="nqE-VI-Hnq">
<connections>
<action selector="backButtonPressed:" destination="zk1-1z-hLN" id="ZfG-2R-i4H"/>
</connections>
</barButtonItem>
</navigationItem>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
<connections>
<outlet property="tableView" destination="01J-sa-L18" id="uUJ-8O-TdR"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="svf-4n-0Oj" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2047" y="1143"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="OxG-fz-0Qy">
Expand All @@ -316,7 +383,7 @@ At this moment there is no VoIP account linked to your user.</string>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="swc-W8-Hfn" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="631" y="374"/>
<point key="canvasLocation" x="753" y="324"/>
</scene>
</scenes>
<resources>
Expand Down
Expand Up @@ -4,6 +4,7 @@
//

import UIKit
import AVFoundation

class DialerViewController: UIViewController, SegueHandler {

Expand Down

0 comments on commit c5774f8

Please sign in to comment.