Skip to content

Commit

Permalink
Release 2.3.0 (#327)
Browse files Browse the repository at this point in the history
* Outside of browser environment

* Remove Buffer

* Remove unnecessary import

* Increase max package size

* Remove _

* Add options allowing for fine-grained control of sending and receiving certain ICE candidates

* Add description

* Add presets

* Fix wrong method name

* Remove debugging artifacts

* Remove extra newlines

* Extract to common method

* sample: Add manual JoinStorageSession button

* sample: Adjust labels

* master role

* sample: move the connected check to after the SDP answer is sent

* Add correlationId to sdp answer for joinStorageSession

* 100% code coverage in the unit tests

* Increase package size

* Remove testing artifact

* Update README for correlationId

* Fix boolean flag

* Adjust css

* Disable datachannel for WebRTC ingestion and remove remote-view in ingestion mode

* Adjust stop button color

* reset storage client on next run

* reset storage client on next run

* Adjust comment for correlationId

* Bump @babel/traverse from 7.21.4 to 7.23.2

Bumps [@babel/traverse](https://github.com/babel/babel/tree/HEAD/packages/babel-traverse) from 7.21.4 to 7.23.2.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.23.2/packages/babel-traverse)

---
updated-dependencies:
- dependency-name: "@babel/traverse"
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump react-devtools-core from 4.27.6 to 4.28.4

Bumps [react-devtools-core](https://github.com/facebook/react/tree/HEAD/packages/react-devtools-core) from 4.27.6 to 4.28.4.
- [Release notes](https://github.com/facebook/react/releases)
- [Changelog](https://github.com/facebook/react/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/react/commits/HEAD/packages/react-devtools-core)

---
updated-dependencies:
- dependency-name: react-devtools-core
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump version

* Bump package lock

* data channel benchmarking message

* additional logs

* granularity in time-to-first-frame

* master and viewer metrics timeline chart

* signaling metrics viewer + master breakdown

* color coded, dynamic height adjustment, dynamic dataTable row addition

* connectAsViewer, enable non-json messages, enable viewing them in message box

* set timelineChartTestLength to 20

* cleanup 1

* pr cleanup as per comments

* adding a comment

* readme update

* rename timestamp

* update the readme

* rename timestamps

* decouple from dqp

* rename

* DQP enhacement and bug fixes

* Rebase to include profiling chart

* Use metrics object data

* Bump follow-redirects from 1.15.2 to 1.15.5

Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.2 to 1.15.5.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](follow-redirects/follow-redirects@v1.15.2...v1.15.5)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump ip from 1.1.8 to 1.1.9

Bumps [ip](https://github.com/indutny/node-ip) from 1.1.8 to 1.1.9.
- [Commits](indutny/node-ip@v1.1.8...v1.1.9)

---
updated-dependencies:
- dependency-name: ip
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

* Dependabot - Bump multiple dependencies (#303)

* Bump express from 4.18.2 to 4.19.2

Bumps [express](https://github.com/expressjs/express) from 4.18.2 to 4.19.2.
- [Release notes](https://github.com/expressjs/express/releases)
- [Changelog](https://github.com/expressjs/express/blob/master/History.md)
- [Commits](expressjs/express@4.18.2...4.19.2)

---
updated-dependencies:
- dependency-name: express
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump webpack-dev-middleware from 5.3.3 to 5.3.4

Bumps [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware) from 5.3.3 to 5.3.4.
- [Release notes](https://github.com/webpack/webpack-dev-middleware/releases)
- [Changelog](https://github.com/webpack/webpack-dev-middleware/blob/v5.3.4/CHANGELOG.md)
- [Commits](webpack/webpack-dev-middleware@v5.3.3...v5.3.4)

---
updated-dependencies:
- dependency-name: webpack-dev-middleware
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump follow-redirects from 1.15.5 to 1.15.6

Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.5 to 1.15.6.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](follow-redirects/follow-redirects@v1.15.5...v1.15.6)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* CI for publishing develop application (#304)

* Separate connecting to signaling vs signing the request metric and print the values out (#305)

* Update README.md

* fix typo (#308)

* global.WebSocket -> WebSocket (#311)

* Bump tar from 6.1.13 to 6.2.1 (#312)

Bumps [tar](https://github.com/isaacs/node-tar) from 6.1.13 to 6.2.1.
- [Release notes](https://github.com/isaacs/node-tar/releases)
- [Changelog](https://github.com/isaacs/node-tar/blob/main/CHANGELOG.md)
- [Commits](isaacs/node-tar@v6.1.13...v6.2.1)

---
updated-dependencies:
- dependency-name: tar
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Sample: Master Cleanup (#313)

* Master p2p

* WebRTC storage portion

* Add comments, tidy up

* Additional cleanup

* Graceful exit

* DataChannel

* Always call describe

* Move endpoint field to the advanced section (#314)

* Bump ws from 8.14.2 to 8.17.1 (#319)

Bumps [ws](https://github.com/websockets/ws) from 8.14.2 to 8.17.1.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](websockets/ws@8.14.2...8.17.1)

---
updated-dependencies:
- dependency-name: ws
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump braces, react-native-codegen and fork-ts-checker-webpack-plugin (#318)

Bumps [braces](https://github.com/micromatch/braces) to 3.0.3 and updates ancestor dependencies [braces](https://github.com/micromatch/braces), [react-native-codegen](https://github.com/facebook/react-native/tree/HEAD/packages/react-native-codegen) and [fork-ts-checker-webpack-plugin](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin). These dependencies need to be updated together.


Updates `braces` from 3.0.2 to 3.0.3
- [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md)
- [Commits](micromatch/braces@3.0.2...3.0.3)

Updates `react-native-codegen` from 0.71.5 to 0.71.6
- [Release notes](https://github.com/facebook/react-native/releases)
- [Changelog](https://github.com/facebook/react-native/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/react-native/commits/v0.71.6/packages/react-native-codegen)

Updates `fork-ts-checker-webpack-plugin` from 4.1.6 to 9.0.2
- [Release notes](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/releases)
- [Changelog](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/blob/main/CHANGELOG.md)
- [Commits](TypeStrong/fork-ts-checker-webpack-plugin@v4.1.6...v9.0.2)

---
updated-dependencies:
- dependency-name: braces
  dependency-type: indirect
- dependency-name: react-native-codegen
  dependency-type: indirect
- dependency-name: fork-ts-checker-webpack-plugin
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump fast-xml-parser from 4.2.5 to 4.4.1 (#324)

Bumps [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) from 4.2.5 to 4.4.1.
- [Release notes](https://github.com/NaturalIntelligence/fast-xml-parser/releases)
- [Changelog](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/CHANGELOG.md)
- [Commits](NaturalIntelligence/fast-xml-parser@v4.2.5...v4.4.1)

---
updated-dependencies:
- dependency-name: fast-xml-parser
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Sample change: WebRTC ingestion with multi-viewer support (#326)

* Bump the version from 2.2.1 to 2.3.0 (#328)

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Niyati Maheshwari <[email protected]>
Co-authored-by: Divya Sampath Kumar <[email protected]>
Co-authored-by: Stefan Kieszkowski <[email protected]>
  • Loading branch information
5 people authored Aug 5, 2024
1 parent de20988 commit 590bded
Show file tree
Hide file tree
Showing 20 changed files with 2,191 additions and 19,493 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/develop-publish-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Deploy Action WebRTC JS SDK

on:
push:
branches:
- develop
jobs:
publish-ubuntu-build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@master
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: 16
- name: Install dependencies
run: npm install
- name: Run release
run: npm run release
- name: Deploy to Github pages
uses: JamesIves/[email protected]
with:
folder: dist
branch: gh-pages
target-folder: develop
clean: true
31 changes: 31 additions & 0 deletions .github/workflows/master-publish-gh-pages-and-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Deploy and Publish Action WebRTC JS SDK

on:
push:
branches:
- master
jobs:
publish-ubuntu-build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@master
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: 16
- name: Install dependencies
run: npm install
- name: Run release
run: npm run release
- name: Deploy to Github pages
uses: JamesIves/[email protected]
with:
folder: dist
branch: gh-pages
clean: true
clean-exclude: develop/
- name: Deploy to npm packages
uses: JS-DevTools/npm-publish@v1
with:
token: '${{ secrets.NPM_TOKEN }}'
31 changes: 0 additions & 31 deletions .github/workflows/publish.yml

This file was deleted.

78 changes: 42 additions & 36 deletions README.md

Large diffs are not rendered by default.

217 changes: 217 additions & 0 deletions examples/answerer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
class Answerer {
/**
* Represents a peer connection in the "answerer" or "callee" role.
* @constructor
* @param {RTCConfiguration} rtcPeerConnectionConfiguration - The configuration for the RTCPeerConnection.
* @param {MediaStream} localMediaStream - The local media stream to send to the remote client.
* @param {RTCSessionDescriptionInit} offer - The offer for the peer connection received from the remote client.
* @param {string} remoteClientId - The signaling ClientID of the remote client.
* @param {SignalingClient} signalingClient - Kinesis Video Streams WebRTC Signaling client.
* @param {boolean} trickleICE - Whether to use trickle ICE.
* @param {boolean} createDataChannel - Whether to create a data channel.
* @param {string} [loggingPrefix=''] - Prefix log messages will have.
* @param {function(RTCIceCandidate): boolean} [outboundIceCandidateFilterFn=candidate => true]
* Callback function invoked when an ICE candidate is generated by this peer.
* Return true if this candidate should be sent to the remote peer.
* If no function is provided, no candidates will be filtered and all generated candidates will be sent.
* @param {function(string): boolean} [inboundIceCandidateFilterFn=candidate => true]
* Callback function invoked when an ICE candidate is received through signaling
* from the remote peer. Return true if this candidate should be added to this peer connection.
* If no function is provided, no candidates will be filtered and all candidates received from remote will
* be added to this peer connection.
* @param {function(MediaStream[]): void} [mediaStreamsUpdated=mediaStreams => {}]
* Invoked when the remote peer adds a track to the peer connection.
* Nothing happens if no function is provided.
* @param {function(string): void} [dataChannelMessageReceived=dataChannelMessage => {}]
* Invoked when the remote peer sends a message over the data channel.
* Only will get invoked if createDataChannel is true.
* Nothing happens if no function is provided.
*/
constructor(
rtcPeerConnectionConfiguration,
localMediaStream,
offer,
remoteClientId,
signalingClient,
trickleICE,
createDataChannel,
loggingPrefix = '',
outboundIceCandidateFilterFn = candidate => true,
inboundIceCandidateFilterFn = candidate => true,
mediaStreamsUpdated = mediaStreams => {},
dataChannelMessageReceived = (dataChannelMessage) => {},
) {
this._configuration = rtcPeerConnectionConfiguration;
this._mediaStream = localMediaStream;
this._remoteClientId = remoteClientId;
this._offer = offer;
this._signalingClient = signalingClient;
this._trickleICE = trickleICE;
this._createDataChannel = createDataChannel;
this._loggingPrefix = loggingPrefix;
this._outboundIceCandidateFilterFn = outboundIceCandidateFilterFn;
this._inboundIceCandidateFilterFn = inboundIceCandidateFilterFn;
this._onMediaStreamsUpdated = mediaStreamsUpdated;
this._dataChannelMessageReceived = dataChannelMessageReceived;

this._dataChannel = null;
this._peerConnection = null;
}

// Must be called first.
// Create the PeerConnection and binds it to the Signaling client.
// It will send back an answer given the provided offer and media to send back.
// Optionally, if configured, the data channel will be opened.
init = async () => {
this._peerConnection = new RTCPeerConnection(this._configuration);

if (this._createDataChannel) {
this._peerConnection.ondatachannel = event => {
this._dataChannel = event.channel;
event.channel.onmessage = this._dataChannelMessageReceived;
};
}

this._addIceCandidate = async (candidate, remoteClientId) => {
if (remoteClientId !== this._remoteClientId) {
// All ICE candidates received over signaling will be received via this callback.
// Ignore ICE candidates not directed for this PeerConnection (when multiple
// viewer participants are connecting to the same signaling channel).
return;
}

console.log(this._loggingPrefix, `Received ICE candidate from ${remoteClientId || 'remote'}`);
console.debug(this._loggingPrefix, 'ICE candidate:', candidate);

if (this._inboundIceCandidateFilterFn(candidate)) {
// Add the ICE candidate received from the client to the peer connection
this._peerConnection.addIceCandidate(candidate);
} else {
console.log(this._loggingPrefix, `Candidate rejected through filter. Not adding candidate from ${remoteClientId || 'remote'}.`);
}
};

this._signalingClient.on('iceCandidate', this._addIceCandidate);

this._peerConnection.addEventListener('icecandidate', ({ candidate }) => {
// `candidate` will be the empty string if the event indicates that there are no further candidates
// to come in this generation, or null if all ICE gathering on all transports is complete.
// https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/icecandidate_event
if (candidate) {
console.log(this._loggingPrefix, 'Generated ICE candidate for', this._remoteClientId || 'remote');
console.debug(this._loggingPrefix, 'ICE candidate:', candidate);

// When trickle ICE is enabled, send the ICE candidates as they are generated.
if (this._trickleICE) {
if (this._outboundIceCandidateFilterFn(candidate)) {
console.log(this._loggingPrefix, 'Sending ICE candidate to', this._remoteClientId || 'remote');
this._signalingClient.sendIceCandidate(candidate, this._remoteClientId);
} else {
console.log(this._loggingPrefix, 'Not sending ICE candidate to', this._remoteClientId || 'remote');
}
}
} else {
console.log(this._loggingPrefix, 'All ICE candidates have been generated for', this._remoteClientId || 'remote');

// When trickle ICE is disabled, send the answer now that all the ICE candidates have been generated.
// NOTE: gathering all the ICE candidates can take a long time. It is recommended to use trickle ICE.
if (!this._trickleICE) {
console.log(this._loggingPrefix, 'Sending SDP answer to', this._remoteClientId || 'remote');
const correlationId = randomString();
console.debug('SDP answer:', this._peerConnection.localDescription, 'correlationId:', correlationId);
this._signalingClient.sendSdpAnswer(this._peerConnection.localDescription, this._remoteClientId, correlationId);
}
}
});

// We receive this event when the remote peer adds a new track to the PeerConnection
// https://webrtc.org/getting-started/remote-streams#adding_remote_tracks
this._peerConnection.addEventListener('track', event => {
console.log(this._loggingPrefix, 'Received track from', this._remoteClientId || 'remote', 'with track id:', event?.streams[0]?.id ?? '[Error retrieving track ID]');
this._onMediaStreamsUpdated(event.streams);
});

// If there's no video/audio, this._mediaStream will be null. So, we should skip adding the tracks from it.
if (this._mediaStream) {
this._mediaStream.getTracks().forEach(track => this._peerConnection.addTrack(track, this._mediaStream));
}

await this._peerConnection.setRemoteDescription(this._offer);

// Create an SDP answer to send back to the client
console.log(this._loggingPrefix, 'Creating SDP answer for', this._remoteClientId || 'remote');
await this._peerConnection.setLocalDescription(
await this._peerConnection.createAnswer({
offerToReceiveAudio: true,
offerToReceiveVideo: true,
}),
);

// When trickle ICE is enabled, send the answer now and then send ICE candidates as they are generated. Otherwise wait on the ICE candidates.
if (this._trickleICE) {
console.log(this._loggingPrefix, 'Sending SDP answer to', this._remoteClientId || 'remote');
const correlationId = randomString();
console.debug(this._loggingPrefix, 'SDP answer:', this._peerConnection.localDescription, 'correlationId:', correlationId);
this._signalingClient.sendSdpAnswer(this._peerConnection.localDescription, this._remoteClientId, correlationId);
}
console.log(this._loggingPrefix, 'Generating ICE candidates for', this._remoteClientId || 'remote');
};

// Returns true if the data channel was created and is currently open.
// Only available after init()
isDataChannelOpen = () => {
if (!this._peerConnection) {
throw 'Init must be called first!';
}
return this._createDataChannel && this._dataChannel.readyState === 'open';
};

// Sends a message over the data channel
// It will throw an error if the data channel is not currently open
// Only available after init()
sendDataChannelMessage = message => {
if (!this._peerConnection) {
throw 'Init must be called first!';
}
if (!this.isDataChannelOpen) {
throw 'The data channel is not open!';
}
this._dataChannel.send(message);
};

// Adds an ice candidate to the PeerConnection
// Only available after init()
addIceCandidate = candidate => {
if (!this._peerConnection) {
throw 'Init must be called first!';
}
this._peerConnection.addIceCandidate(candidate);
};

// Close the resources opened by this answerer.
// This will close the peer connection, unbind from the signaling client,
// and close the data channel (if any). This will not close the signaling
// client.
// Only available after init()
close = () => {
if (!this._peerConnection) {
throw 'Init must be called first!';
}
this._peerConnection.close();

this._signalingClient.removeListener('iceCandidate', this._addIceCandidate);

if (this._dataChannel) {
this._dataChannel.close();
}
};

// Return the peer connection this answerer is using
// Only available after init()
getPeerConnection = () => {
if (!this._peerConnection) {
throw 'Init must be called first!';
}
return this._peerConnection;
};
}
Loading

0 comments on commit 590bded

Please sign in to comment.