-
-
Save jasjisdo/dbfac9530026760b6738 to your computer and use it in GitHub Desktop.
Try to create a simpler Goosip example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// GSEMySipViewController.h | |
// Gossip | |
// | |
// Created by Jaschar domann on 13.10.14. | |
// | |
// | |
#import <UIKit/UIKit.h> | |
#import "Gossip.h" | |
@interface GSEMySipViewController : UIViewController | |
@property (nonatomic, strong) GSAccountConfiguration *accountConfig; | |
@property (nonatomic, strong) GSConfiguration *configuration; | |
@property (nonatomic, strong) GSUserAgent *userAgent; | |
@property (nonatomic, strong) GSAccount *account; | |
@property (nonatomic, strong) GSCall *call; | |
@property (strong, nonatomic) IBOutlet UILabel *statusLabel; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.m | |
// MySIPApp | |
// | |
// Created by Jaschar domann on 09.10.14. | |
// Copyright (c) 2014 dailab. All rights reserved. | |
// | |
#import "GSEMySipViewController.h" | |
@interface GSEMySipViewController () <GSAccountDelegate> | |
{ | |
NSString *voipNumber; | |
} | |
@end | |
@implementation GSEMySipViewController | |
@synthesize statusLabel = _statusLabel; | |
@synthesize accountConfig = _accountConfig; | |
@synthesize configuration = _configuration; | |
@synthesize userAgent = _userAgent; | |
@synthesize account = _account; | |
@synthesize call = _call; | |
-(void)viewDidLoad { | |
[super viewDidLoad]; | |
// Do any additional setup after loading the view, typically from a nib. | |
NSLog(@"view Load"); | |
[_statusLabel setText:@"inactive"]; | |
[self registerAccount]; | |
NSLog(@"init done..."); | |
} | |
-(void)account:(GSAccount *)account didReceiveIncomingCall:(GSCall *)call | |
{ | |
[_statusLabel setText:@"Incoming call..."]; | |
const double delayInSeconds = 1.0; | |
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC); | |
__block GSCall *call_ = call; | |
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ | |
BOOL isBegin = [call_ begin]; | |
NSLog(@"isBegin: %@",isBegin ? @"YES" : @"NO"); | |
}); | |
} | |
-(IBAction)call:(id)sender { | |
[self startCall]; | |
} | |
-(void)startCall | |
{ | |
voipNumber = @"chakrit@sip2sip.info"; | |
NSLog(@"Account status: %u",[_account status]); | |
_call = [GSCall outgoingCallToUri:voipNumber fromAccount:_account]; | |
NSLog(@"call prepared..."); | |
[_call begin]; | |
} | |
-(void)registerAccount | |
{ | |
// Account Configuration | |
_accountConfig = [GSAccountConfiguration defaultConfiguration]; | |
_accountConfig.address = @"223281800@sip2sip.info"; | |
_accountConfig.username = @"223281800"; | |
_accountConfig.password = @"iCdw5twjDsCixkVwFZJV"; | |
_accountConfig.domain = @"sip2sip.info"; | |
_accountConfig.proxyServer = @"sip2sip.info"; | |
NSLog(@"ringfile: %@",_accountConfig.ringbackFilename); | |
// Configuration | |
_configuration = [GSConfiguration defaultConfiguration]; | |
_configuration.account = _accountConfig; | |
_configuration.logLevel = 5; | |
_configuration.consoleLogLevel = 5; | |
// User agent | |
_userAgent = [GSUserAgent sharedAgent]; | |
[_userAgent configure:_configuration]; | |
[_userAgent start]; | |
NSLog(@"User agent started..."); | |
NSLog(@"Codecs:"); | |
NSArray *codecs = [_userAgent arrayOfAvailableCodecs]; | |
for (GSCodecInfo *codec in codecs) { | |
NSLog(@"codecid: %@, priority: %i",codec.codecId,codec.priority); | |
} | |
// Account | |
_account = _userAgent.account; | |
_account.delegate = self; | |
[_account connect]; | |
NSLog(@"Account connected..."); | |
NSLog(@"Account Status: %u",[_account status]); | |
} | |
-(void)didReceiveMemoryWarning { | |
[super didReceiveMemoryWarning]; | |
// Dispose of any resources that can be recreated. | |
} | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6245" systemVersion="13F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES"> | |
<dependencies> | |
<deployment defaultVersion="1552" identifier="iOS"/> | |
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6238"/> | |
</dependencies> | |
<objects> | |
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="GSEMySipViewController"> | |
<connections> | |
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/> | |
</connections> | |
</placeholder> | |
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> | |
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT"> | |
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/> | |
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | |
<subviews> | |
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="9vW-qX-yYU"> | |
<rect key="frame" x="8" y="269" width="304" height="30"/> | |
<state key="normal" title="Call"> | |
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/> | |
</state> | |
<connections> | |
<action selector="call:" destination="-1" eventType="touchUpInside" id="JDA-5w-mFJ"/> | |
</connections> | |
</button> | |
</subviews> | |
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> | |
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/> | |
</view> | |
</objects> | |
</document> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment