Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/draft_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name-template: '$NEXT_MINOR_VERSION'
tag-template: '$NEXT_MINOR_VERSION'
categories:
- title: 'Features'
labels:
- 'feature'
- 'enhancement'
- title: 'Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'
- title: 'Maintenance'
label: 'chore'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
exclude-labels:
- 'skip-changelog'
template: |
## Changes
$CHANGES
19 changes: 19 additions & 0 deletions .github/workflows/draft_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Draft Release

on:
push:
branches:
- main
- master

jobs:
draft-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
# Drafts your next Release notes as Pull Requests are merged
- uses: release-drafter/release-drafter@v5
with:
config-name: draft_release.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33 changes: 33 additions & 0 deletions .github/workflows/release_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Publish Release

on:
release:
types:
- published

jobs:
publish-npm:
# Only run if release is a prod release
if: ${{ !github.event.release.prerelease }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: '24'
- name: npm install
run: npm install
- name: npm version and publish
run: |
npm version ${{ github.event.release.tag_name }} --no-git-tag-version
npm publish --access public
- name: Upload Standalone Bundle Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./dist/BandwidthRtc.bundle.js
asset_name: BandwidthRtc.bundle.js
asset_content_type: application/javascript
22 changes: 22 additions & 0 deletions .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Unit Tests

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Install Node.js
uses: actions/setup-node@v5
with:
node-version: '24'
check-latest: true
- name: npm install
run: npm install
- name: npm test
run: npm test
- name: npm build
run: npm run build
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
node_modules/
dist
coverage
.DS_Store
.vscode
src/**.js
*.swp
*.iml
*.iws
*.ipr
.idea/
5 changes: 5 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.github/
coverage/
BandwidthRtc.bundle.js
*.iml
.idea/
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://registry.npmjs.org/
9 changes: 9 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.github
.vscode
coverage
dist
node_modules
webpack.common.js
webpack.dev.js
webpack.prod.js
.bandwidth
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"printWidth": 160,
"endOfLine": "auto"
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Bandwidth, Inc

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
124 changes: 124 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# BandwidthRTC Node SDK Documentation

## Initialize the BandwidthRTC Node SDK

```javascript
import BandwidthRtc from "bandwidth-rtc";

const bandwidthRtc = new BandwidthRtc();
```

## API Methods

### connect

- Params:
- authParams: the device token to connect with
- options: optional SDK settings (can be omitted)
- websocketUrl: override the default Bandwidth RTC connection url (this should not generally be needed)
- Description: connect device to the Bandwidth RTC platform

```javascript
await bandwidthRtc.connect({
deviceToken: deviceToken,
});
```

### publish

- Params:
- input: the input to publish; this can be an instance of:
- mediaStream: An already existing media stream such as a screen share
- Type: MediaStream
- Return:
- rtcStream: a media stream with the supplied media stream constraints
- Type: RtcStream
- Description: publish media

#### Publish with default settings:

```javascript
let rtcStream: RtcStream = await bandwidthRtc.publish();
```

#### Publish audio only

#### Publish with customized constraints

```javascript
const mediaConstraints: MediaStreamConstraints = {
audio: {
autoGainControl: true,
channelCount: 1,
deviceId: "default",
echoCancellation: true,
latency: 0.01,
noiseSuppression: true,
sampleRate: 48000,
sampleSize: 16,
}
};
let microphoneStream = await navigator.mediaDevices.getUserMedia(mediaConstraints);
let sourceNode = audioContext.createMediaStreamSource(microphoneStream);
let rtcStream: RtcStream = await bandwidthRtc.publish(mediaConstraints);
```

#### Publish with existing media stream

```javascript
let screenShare = await navigator.mediaDevices.getDisplayMedia({
video: true,
});
let rtcStream: RtcStream = await bandwidthRtc.publish(screenShare);
```

Please see the following resources for more information on MediaStreamConstraints and MediaTrackConstraints that can be specified here:

- https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamConstraints
- https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints

### disconnect

- Description: disconnect device from the Bandwidth RTC platform

### DTMF

- Description: send a set of VoIP-network-friendly DTMF tones. The tone amplitude and duration can not be controlled
- Params:
- tone: the digits to send, as a string, chosen from the set of valid DTMF characters [0-9,*,#,\,]
- streamId (optional): the stream to 'play' the tone on

```javascript
bandwidthRtc.sendDtmf("3");
bandwidthRtc.sendDtmf("313,3211*#");
```

## Event Listeners

### onStreamAvailable

- Description: called when a media stream is available to attach to the UI. This will be called for every independent stream presented to the Participant, meaning that if a new remote Participant is added to a subscribed Session a new stream will be made available to the browser, and will need to be presented to the UI for consumption by the user.

```javascript
bandwidthRtc.onStreamAvailable((event) => {
console.log(
`A stream is available with streamId=${event.mediaStream.id}, its media types are ${event.mediaTypes} and the stream itself is ${event.mediaStream}`,
);
});
```

### onStreamUnavailable

- Description: called when a media stream is now unavailable and should be removed from the UI

```javascript
bandwidthRtc.onStreamUnavailable((event) => {
console.log(
`The stream with streamId=${event.mediaStream.id} is now unavailable and should be removed from the UI because the media is likely to freeze imminently.`,
);
});
```

### Notes

- Pinning `rpc-websockets` library to version `7.10.0` so that the transpiling and compilation of the RPC Client works.
4 changes: 4 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
presets: [["@babel/preset-env", { targets: { node: "current" } }], "@babel/preset-typescript"],
plugins: ["@babel/plugin-proposal-class-properties"],
};
Loading