All Projects → open-voip-alliance → WebphoneLib

open-voip-alliance / WebphoneLib

Licence: MIT license
Easier web calling by providing a layer of abstraction around SIP.js

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
Dockerfile
14818 projects

Labels

Projects that are alternatives of or similar to WebphoneLib

Siprtcproxy
网关服务:Sip与Rtc互通,实现Web,Android,iOS,小程序,SIP座机,PSTN电话,手机互通。
Stars: ✭ 217 (+317.31%)
Mutual labels:  sip
sems-yeti
YETI application for SEMS core
Stars: ✭ 15 (-71.15%)
Mutual labels:  sip
HA-SIP
A SIP client inside home assistant!
Stars: ✭ 81 (+55.77%)
Mutual labels:  sip
Restcomm Connect
The Open Source Cloud Communications Platform
Stars: ✭ 232 (+346.15%)
Mutual labels:  sip
drachtio-siprec-recording-server
SIPREC recording server based on drachtio and rtpengine
Stars: ✭ 58 (+11.54%)
Mutual labels:  sip
dsip
通过netty网络框架,编解码sip消息。 以及国标gb28181的部分功能, 不依赖spring,方便集成
Stars: ✭ 19 (-63.46%)
Mutual labels:  sip
Sipp Scenarios
SIPp scenarios I use for testing SIP stuff
Stars: ✭ 190 (+265.38%)
Mutual labels:  sip
freepbx
FreePBX container (Asterisk 16; OpenPBX 15 with Backup and IVR modules installed)
Stars: ✭ 36 (-30.77%)
Mutual labels:  sip
blueberry
监控设备管理平台,支持GB28181国标设备接入、支持海康、大华等品牌监控设备接入
Stars: ✭ 26 (-50%)
Mutual labels:  sip
SipCaller
React SIP user agent
Stars: ✭ 42 (-19.23%)
Mutual labels:  sip
sippet
C++ SIP stack based on Chromium source code
Stars: ✭ 23 (-55.77%)
Mutual labels:  sip
opentok-rtc
OpenTok demo application
Stars: ✭ 97 (+86.54%)
Mutual labels:  sip
exosip
some library source code about sip
Stars: ✭ 18 (-65.38%)
Mutual labels:  sip
React Native Pjsip
A PJSIP module for React Native.
Stars: ✭ 229 (+340.38%)
Mutual labels:  sip
awesome-rtc
📡 A curated list of awesome Real Time Communications resources
Stars: ✭ 196 (+276.92%)
Mutual labels:  sip
Linphone Desktop
Linphone is a free VoIP and video softphone based on the SIP protocol. Mirror of git://git.linphone.org/linphone-desktop.git
Stars: ✭ 212 (+307.69%)
Mutual labels:  sip
npm-civic-sip-api
Node.js client library for the Civic Secure Identity Platform (SIP).
Stars: ✭ 25 (-51.92%)
Mutual labels:  sip
libjuice
JUICE is a UDP Interactive Connectivity Establishment library
Stars: ✭ 197 (+278.85%)
Mutual labels:  sip
sipsak
SIP swiss army knife
Stars: ✭ 96 (+84.62%)
Mutual labels:  sip
jami-overlay
Jami (formerly Ring (formerly SFLphone)) is a SIP compatible softphone for GNU/Linux.
Stars: ✭ 22 (-57.69%)
Mutual labels:  sip

Open VoIP Alliance Webphone Lib

npm

Makes calling easier by providing a layer of abstraction around SIP.js. To figure out why we made this, read our blog post.

Documentation

Check out the documentation here.

Cool stuff

  • Allows you to switch audio devices mid-call.
  • Automatically recovers calls on connectivity loss.
  • Offers an easy-to-use modern javascript api.

Join us!

We would love more input for this project. Create an issue, create a pull request for an issue, or if you're not really sure, ask us. We're often hanging around on discourse. We would also love to hear your thoughts and feedback on our project and answer any questions you might have!

Getting started

$ git clone [email protected]:open-voip-alliance/WebphoneLib.git
$ cd WebphoneLib
$ touch demo/config.mjs

Add the following to demo/config.mjs

export const authorizationUserId = <your-voip-account-id>;
export const password = '<your-voip-password>';
export const realm = '<realm>';
export const websocketUrl = '<websocketUrl>';

Run the demo-server:

$ npm i && npm run demo

And then play around at http://localhost:1235/demo/.

Examples

Connecting and registering

import { Client } from 'webphone-lib';

const account = {
  user: 'accountId',
  password: 'password',
  uri: 'sip:accountId@<realm>',
  name: 'test'
};

const transport = {
  wsServers: '<websocket-url>', // or replace with your
  iceServers: [] // depending on if your provider needs STUN/TURN.
};

const media = {
  input: {
    id: undefined, // default audio device
    audioProcessing: true,
    volume: 1.0,
    muted: false
  },
  output: {
    id: undefined, // default audio device
    volume: 1.0,
    muted: false
  }
};

const client = new Client({ account, transport, media });

await client.register();

Incoming call

// incoming call below
client.on('invite', (session) => {
  try {
    ringer();

    let { accepted, rejectCause } = await session.accepted(); // wait until the call is picked up
    if (!accepted) {
      return;
    }

    showCallScreen();

    await session.terminated();
  } catch (e) {
    showErrorMessage(e)
  } finally {
    closeCallScreen();
  }
});

Outgoing call

const session = client.invite('sip:518@<realm>');

try {
  showOutgoingCallInProgress();

  let { accepted, rejectCause } = await session.accepted(); // wait until the call is picked up
  if (!accepted) {
    showRejectedScreen();
    return;
  }

  showCallScreen();

  await session.terminated();
} catch (e) {
} finally {
  closeCallScreen();
}

Attended transfer of a call

if (await sessionA.accepted()) {
  await sessionA.hold();

  const sessionB = client.invite('sip:519@<realm>');
  if (await sessionB.accepted()) {
    // immediately transfer after the other party picked up :p
    await client.attendedTransfer(sessionA, sessionB);

    await sessionB.terminated();
  }
}

Audio device selection

Set a primary input & output device:

const client = new Client({
  account,
  transport,
  media: {
    input: {
      id: undefined, // default input device
      audioProcessing: true,
      volume: 1.0,
      muted: false
    },
    output: {
      id: undefined, // default output device
      volume: 1.0,
      muted: false
    }
  }
});

Change the primary I/O devices:

client.defaultMedia.output.id = '230988012091820398213';

Change the media of a session:

const session = await client.invite('123');
session.media.input.volume = 50;
session.media.input.audioProcessing = false;
session.media.input.muted = true;
session.media.output.muted = false;
session.media.setInput({
  id: '120398120398123',
  audioProcessing: true,
  volume: 0.5,
  muted: true
});

Commands

Command Help
npm run docs Generate the docs
npm run test Run the tests
npm run test -- --verbose Show output of console.log during tests
npm run test-watch Watch the tests as you make changes
npm run build Build the projects
npm run prepare Prepare the project for publish, this is automatically run before npm publish
npm run lint Run tslint over the source files
npm run typecheck Verifies type constraints are met

Generate documentation

Typedoc is used to generate the documentation from the jsdoc comments in the source code. See this link for more information on which jsdoc tags are supported.

Run puppeteer tests

Using docker

Add a .env file with the following:

USER_A = <user-a>
USER_B = <user-b>
PASSWORD_A = <password-user-a>
PASSWORD_B = <password-user-b>
NUMBER_A = <number-user-a>
NUMBER_B = <number-user-b>
WEBSOCKET_URL = <your-websocket-url>
REALM = <realm>

Then call docker-compose up to run the tests.

Note: Don't forget to call npm ci in the puppeteer folder. :)

Without docker

If you don't want to use docker, you will need to run the demo with the npm run demo command (and keep it running) and run the tests with npm run test:e2e. For this you will need the .env file with your settings.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].