Coder Social home page Coder Social logo

roog / taresip Goto Github PK

View Code? Open in Web Editor NEW

This project forked from andrewvmail/taresip

0.0 0.0 0.0 24.97 MB

Cocoapod for baresip

License: BSD 2-Clause "Simplified" License

C 91.90% Objective-C 0.15% C++ 1.58% Ruby 0.74% Shell 1.12% Makefile 4.51%

taresip's Introduction

TareSIP

Platform: iOS 7+ Cocoapods compatible License: BSD Release version

Cocoapod for baresip.

Installation

With CocoaPods

Add the following line to your Podfile and run pod install command.

pod 'taresip', :git => 'https://github.com/andrewvmail/taresip.git'

Build manually

  1. Download project and run build.sh script.
  2. Drag generated libraries and headers files into your XCode project.
  3. Check your XCode project has the following frameworks: CFNetwork, AudioToolbox, AVFoundation, SystemConfiguration and CoreMedia.
  4. Check your XCode project has the follwing libraries: libstdc++.tbd and libresolv.9.tbd.

Usage

Please also refer to baresip docs.

Swift

Import headers on your -Bridging_Header.h.

#import <re.h>
#import <baresip.h>

Sample call flow

{
    var agent: OpaquePointer? = nil
    var client: SipClient? = nil
    do {
        client = try SipClient(agent: &agent)
    } catch {
        print("error: \(error)")
    }
}

enum SipError: Error {
    case libre
    case config
    case stack
    case modules
    case userAgent
    case call
}

final class SipClient {

    required init?(agent: inout OpaquePointer?) throws {
        guard libre_init() == 0 else { throw SipError.libre }

        // Initialize dynamic modules.
        mod_init()

        // Make configure file.
        if let path = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first {
            conf_path_set(path)
        }
        guard conf_configure() == 0 else { throw SipError.config }

        // Initialize the SIP stack.
        guard ua_init("SIP", 1, 1, 1, 0) == 0 else { throw SipError.stack }

        // Load modules.
        guard conf_modules() == 0 else { throw SipError.modules }

        let addr = "sip:user:[email protected]:port;transport=udp;answermode=auto"

        // Start user agent.
        guard ua_alloc(&agent, addr) == 0 else { throw SipError.userAgent }

        // Make an outgoing call.
        guard ua_connect(agent, nil, nil, "sip:[email protected]:port", nil, VIDMODE_OFF) == 0 else { throw SipError.call }

        // Start the main loop.
        re_main(nil)
    }

    func close(agent: OpaquePointer) {
        mem_deref(UnsafeMutablePointer(agent))
        ua_close()
        mod_close()

        // Close and check for memory leaks.
        libre_close()
        tmr_debug()
        mem_debug()
    }

}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.