GithubHelp home page GithubHelp logo

arthur-kamau / sip_native Goto Github PK

View Code? Open in Web Editor NEW

This project forked from iampato/sip_native

0.0 1.0 0.0 128 KB

A native SIP flutter plugin

License: Other

Java 65.18% Swift 2.12% Objective-C 1.60% Dart 29.10% Ruby 1.99%

sip_native's Introduction

sip_native

A native SIP flutter plugin

Motivation

Currently our team is working on solution that requires and uses sip but available sip packages only support websocket as a connection protocol and after struggles using it we were disappointed, so we decided to build one from scratch using link here

Disclaimer

  1. Android Supported Only

Currently only android is supported even though flutter is fully cross platform

  1. Support

Even though the specs states the SIP API is available for Android devices from 2.3, it is not. The Android SIP API is not supported on all devices. Interestingly, it is supported on my old 2.3 LG P970 and not my 4.4 Moto G. (By the way, you have to test on real device and not the Android emulator). Now there are alternatives: With the Android SIP API out, what are the alternatives? Well, there are a couple of open source SIP stacks for Android. The popular ones people talk about are:

  • JAIN
  • MjSIP
  • PjSIP
  • Doubango

more on this link: https://obem.be/2014/06/04/sip-on-android.html

Getting Started

  1. Install this plugin

Currently the plugin is not available in (https://pub.dev)[pub.dev] In your pubspec.yaml add the following

  sip_native:
      git:
        url: https://github.com/iampato/sip_native.git

  1. SipNative plugin supported

    Check if the plugin is supported by the device
    void main() {
      WidgetsFlutterBinding.ensureInitialized();
      SipNative.initPlugin().then((SipNativeSupport value) {
        Fluttertoast.showToast(
          msg: "Voip supported: ${value.isVoipSupported}\n" +
              "SipManager supported: ${value.isSipManagerSupported}",
          backgroundColor: value.isVoipSupported ? Colors.green : Colors.red,
          toastLength: Toast.LENGTH_LONG,
        );
      });
      runApp(MyApp());
    }
   
  1. Sip connect

You can further specify other parameters i.e

  1. Protocol -> support protocols are UDP,TLS,TCP
  2. Port -> By default the port is 5060
  bool response = await SipNative.initSipConnection(
    username: "test_username",
    password: "test_password",
    domain: "sip.linphone.org",
  );
  1. Sip connection status listener

The stream emits Strings, and the following are events emited

  1. UNKNOWN -> we do not know anything (it's the initial)
  2. ONREGISTERING -> attempting to connect
  3. ONREGISTRATIONDONE -> connected all is well
  4. ONREGISTRATIONFAILED -> an error occurred and you should wrap this function in a try catch to catch the exception plus the reason for the failure
  try {
    SipNative.registrationStateStream().listen((event) {
      setState(() {
        _registrationState = event.toString();
      });
    });
  } catch (e) {
    print(e.toString());  
  }
  1. Sip init audio call

A future that returns void and takes two parameters

  1. Username

since in the background the plugin generates a profile uri: example username: test_user and domain: test_domain will be test_user@test_domain the domain will be gotten from sip manager

 await SipNative.initCall("test_user");
  1. Sip call state status listener

The stream emits Strings, and the following are events emited
  1. `UNKNOWN` -> we do not know anything (it's the initial)
  2. ONCALLING,
  3. ONRINGING,
  4. ONRINGINGBACK,
  5. ONREADYTOCALL,
  6. ONCALLESTABLISHED,
  7. ONCALLENDED,
  8. ONCALLBUSY,
  9. ONERROR,
  1. Sip hold call

await SipNative.holdCall();
  1. Sip mute call

await SipNative.muteCall();
  1. Sip speaker mode

await SipNative.changeSpeakerMode();
  1. Sip end call

await SipNative.endCall();
  1. Sip disconnect

await SipNative.disconnectSip();

This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Advice

Always call SipNative.disconnectSip() while closing the app to clear any sip session created

Special Thanks to:

  1. Arther Kamau link
  2. BenBera Kemboi link

sip_native's People

Contributors

iampato avatar

Watchers

James Cloos avatar

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.