Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@signalwire/js

Package Overview
Dependencies
Maintainers
1
Versions
366
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@signalwire/js - npm Package Compare versions

Comparing version 1.3.0-alpha.9.3 to 1.3.0-alpha.9.4

5

dist/esm/common/src/util/logger.js

@@ -8,3 +8,6 @@ import log from 'loglevel';

return function () {
const messages = [datetime(), '-'];
const messages = [];
if (typeof window === 'undefined') {
messages.push(datetime() + ' -');
}
for (let i = 0; i < arguments.length; i++) {

@@ -11,0 +14,0 @@ messages.push(arguments[i]);

@@ -11,2 +11,5 @@ import { CallOptions, IVertoCanvasInfo, ICanvasInfo } from './interfaces';

declare const sdpMediaOrderHack: (answer: string, localOffer: string) => string;
declare const sdpAudioVideoOrderHack: (offerLines: string) => string;
declare const sdpAudioRemoveRTPExtensions: (sdp: string, extensionsToFilter: string[]) => string;
declare const sdpAudioRemoveRidMidExtHack: (sdp: string) => string;
declare type DestructuredResult = {

@@ -31,2 +34,2 @@ subscribed: string[];

}) => boolean;
export { getUserMedia, getDevices, scanResolutions, getMediaConstraints, assureDeviceId, removeUnsupportedConstraints, checkDeviceIdConstraints, sdpStereoHack, sdpMediaOrderHack, sdpBitrateHack, destructSubscribeResponse, enableAudioTracks, disableAudioTracks, toggleAudioTracks, enableVideoTracks, disableVideoTracks, toggleVideoTracks, mutateCanvasInfoData, checkIsDirectCall, };
export { getUserMedia, getDevices, scanResolutions, getMediaConstraints, assureDeviceId, removeUnsupportedConstraints, checkDeviceIdConstraints, sdpStereoHack, sdpMediaOrderHack, sdpBitrateHack, destructSubscribeResponse, enableAudioTracks, disableAudioTracks, toggleAudioTracks, enableVideoTracks, disableVideoTracks, toggleVideoTracks, mutateCanvasInfoData, checkIsDirectCall, sdpAudioVideoOrderHack, sdpAudioRemoveRTPExtensions, sdpAudioRemoveRidMidExtHack };

47

dist/esm/common/src/webrtc/helpers.js

@@ -186,2 +186,47 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

};
const sdpAudioVideoOrderHack = (offerLines) => {
const endOfLine = '\r\n';
const sdp = offerLines.split(endOfLine);
const offerAudioIndex = sdp.findIndex(_isAudioLine);
const offerVideoIndex = sdp.findIndex(_isVideoLine);
if (offerAudioIndex < offerVideoIndex) {
return offerLines;
}
const newLines = offerLines.split(endOfLine);
const beginLines = newLines.slice(0, offerVideoIndex);
const videoLines = newLines.slice(offerVideoIndex, offerAudioIndex);
const audioLines = newLines.slice(offerAudioIndex, (newLines.length - 1));
return [...beginLines, ...audioLines, ...videoLines, ''].join(endOfLine);
};
const sdpAudioRemoveRTPExtensions = (sdp, extensionsToFilter) => {
const endOfLine = '\r\n';
let beginLines = [];
let audioLines = [];
let videoLines = [];
const newLines = sdp.split(endOfLine);
const offerAudioIndex = newLines.findIndex(_isAudioLine);
const offerVideoIndex = newLines.findIndex(_isVideoLine);
if (offerAudioIndex < offerVideoIndex) {
beginLines = newLines.slice(0, offerAudioIndex);
audioLines = newLines.slice(offerAudioIndex, offerVideoIndex);
videoLines = newLines.slice(offerVideoIndex, (newLines.length - 1));
}
else {
beginLines = newLines.slice(0, offerVideoIndex);
audioLines = newLines.slice(offerAudioIndex, (newLines.length - 1));
videoLines = newLines.slice(offerVideoIndex, offerAudioIndex);
}
const newAudioLines = audioLines.filter((line) => {
return !(line.includes(extensionsToFilter[0]) || line.includes(extensionsToFilter[1]) || line.includes(extensionsToFilter[2]));
});
return [...beginLines, ...newAudioLines, ...videoLines, ''].join(endOfLine);
};
const sdpAudioRemoveRidMidExtHack = (sdp) => {
const extensionsToFilter = [
'urn:ietf:params:rtp-hdrext:sdes:mid',
'urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id',
'urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id',
];
return sdpAudioRemoveRTPExtensions(sdp, extensionsToFilter);
};
const destructSubscribeResponse = (response) => {

@@ -276,2 +321,2 @@ const tmp = {

};
export { getUserMedia, getDevices, scanResolutions, getMediaConstraints, assureDeviceId, removeUnsupportedConstraints, checkDeviceIdConstraints, sdpStereoHack, sdpMediaOrderHack, sdpBitrateHack, destructSubscribeResponse, enableAudioTracks, disableAudioTracks, toggleAudioTracks, enableVideoTracks, disableVideoTracks, toggleVideoTracks, mutateCanvasInfoData, checkIsDirectCall, };
export { getUserMedia, getDevices, scanResolutions, getMediaConstraints, assureDeviceId, removeUnsupportedConstraints, checkDeviceIdConstraints, sdpStereoHack, sdpMediaOrderHack, sdpBitrateHack, destructSubscribeResponse, enableAudioTracks, disableAudioTracks, toggleAudioTracks, enableVideoTracks, disableVideoTracks, toggleVideoTracks, mutateCanvasInfoData, checkIsDirectCall, sdpAudioVideoOrderHack, sdpAudioRemoveRTPExtensions, sdpAudioRemoveRidMidExtHack };

@@ -35,2 +35,5 @@ export interface CallOptions {

negotiateVideo?: boolean;
sfu?: boolean;
simulcast?: boolean;
msStreamsNumber?: number;
}

@@ -37,0 +40,0 @@ export interface ICantinaUser {

@@ -10,5 +10,8 @@ import { PeerType } from './constants';

private _iceTimeout;
private _negotiating;
constructor(call: WebRTCCall, type: PeerType, options: CallOptions);
get isOffer(): boolean;
get isAnswer(): boolean;
get isSimulcast(): boolean;
get isSfu(): boolean;
get config(): RTCConfiguration;

@@ -24,2 +27,3 @@ stopTrackSender(kind: string): void;

onRemoteSdp(sdp: string): Promise<void>;
private _logTransceivers;
private _init;

@@ -26,0 +30,0 @@ private _checkMediaToNegotiate;

@@ -23,2 +23,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

this._iceTimeout = null;
this._negotiating = false;
logger.info('New Peer with type:', this.type, 'Options:', this.options);

@@ -34,2 +35,8 @@ this._onIce = this._onIce.bind(this);

}
get isSimulcast() {
return this.options.simulcast === true;
}
get isSfu() {
return this.options.sfu === true;
}
get config() {

@@ -138,2 +145,6 @@ const { iceServers = [] } = this.options;

return __awaiter(this, void 0, void 0, function* () {
if (this._negotiating) {
return logger.warn('Skip twice onnegotiationneeded!');
}
this._negotiating = true;
try {

@@ -155,2 +166,3 @@ if (this.options.secondSource === true) {

yield this._setRemoteDescription({ sdp: this.options.remoteSdp, type: PeerType.Offer });
this._logTransceivers();
const answer = yield this.instance.createAnswer({ voiceActivityDetection: false });

@@ -171,3 +183,4 @@ yield this._setLocalDescription(answer);

try {
yield this._setRemoteDescription({ sdp, type: PeerType.Answer });
const type = this.isOffer ? PeerType.Answer : PeerType.Offer;
yield this._setRemoteDescription({ sdp, type });
}

@@ -180,2 +193,9 @@ catch (error) {

}
_logTransceivers() {
logger.info('Number of transceivers:', this.instance.getTransceivers().length);
this.instance.getTransceivers().forEach((tr, index) => {
logger.info(`>> Transceiver [${index}]:`, tr.mid, tr.direction, tr.stopped);
logger.info(`>> Sender Params [${index}]:`, JSON.stringify(tr.sender.getParameters(), null, 2));
});
}
_init() {

@@ -186,2 +206,12 @@ return __awaiter(this, void 0, void 0, function* () {

logger.info('signalingState:', this.instance.signalingState);
switch (this.instance.signalingState) {
case 'stable':
this._negotiating = false;
break;
case 'closed':
this.instance = null;
break;
default:
this._negotiating = true;
}
};

@@ -193,2 +223,4 @@ this.instance.onnegotiationneeded = event => {

this.instance.addEventListener('track', (event) => {
const notification = { type: 'trackAdd', event };
this.call._dispatchNotification(notification);
this.options.remoteStream = event.streams[0];

@@ -209,12 +241,51 @@ const { remoteElement, remoteStream, screenShare } = this.options;

if (streamIsValid(localStream)) {
if (typeof this.instance.addTrack === 'function') {
localStream.getAudioTracks().forEach(t => {
this.options.userVariables.microphoneLabel = t.label;
this.instance.addTrack(t, localStream);
const audioTracks = localStream.getAudioTracks();
logger.info('Local audio tracks: ', audioTracks);
const videoTracks = localStream.getVideoTracks();
logger.info('Local video tracks: ', videoTracks);
if (typeof this.instance.addTransceiver === 'function') {
audioTracks.forEach(track => {
this.options.userVariables.microphoneLabel = track.label;
this.instance.addTransceiver(track, {
direction: 'sendrecv',
streams: [localStream],
});
});
localStream.getVideoTracks().forEach(t => {
this.options.userVariables.cameraLabel = t.label;
this.instance.addTrack(t, localStream);
const transceiverParams = {
direction: 'sendrecv',
streams: [localStream],
};
if (this.isSimulcast) {
const rids = ['0', '1', '2'];
transceiverParams.sendEncodings = rids.map(rid => ({
active: true,
rid: rid,
scaleResolutionDownBy: (Number(rid) * 6 || 1.0),
}));
}
console.debug('Applying video transceiverParams', transceiverParams);
videoTracks.forEach(track => {
this.options.userVariables.cameraLabel = track.label;
this.instance.addTransceiver(track, transceiverParams);
});
if (this.isSfu) {
const { msStreamsNumber = 5 } = this.options;
console.debug('Add ', msStreamsNumber, 'recvonly MS Streams');
transceiverParams.direction = 'recvonly';
for (let i = 0; i < Number(msStreamsNumber); i++) {
this.instance.addTransceiver('video', transceiverParams);
}
}
this._logTransceivers();
}
else if (typeof this.instance.addTrack === 'function') {
audioTracks.forEach(track => {
this.options.userVariables.microphoneLabel = track.label;
this.instance.addTrack(track, localStream);
});
videoTracks.forEach(track => {
this.options.userVariables.cameraLabel = track.label;
this.instance.addTrack(track, localStream);
});
}
else {

@@ -315,7 +386,6 @@ this.instance.addStream(localStream);

}
logger.info('>>>> _setLocalDescription', localDescription);
logger.info('LOCAL SDP \n', `Type: ${localDescription.type}`, '\n\n', localDescription.sdp);
return this.instance.setLocalDescription(localDescription);
}
_setRemoteDescription(remoteDescription) {
logger.info('REMOTE SDP \n', `Type: ${remoteDescription.type}`, '\n\n', remoteDescription.sdp);
if (this.options.useStereo) {

@@ -325,3 +395,3 @@ remoteDescription.sdp = sdpStereoHack(remoteDescription.sdp);

const sessionDescr = sdpToJsonHack(remoteDescription);
logger.info('>>>> _setRemoteDescription', remoteDescription);
logger.info('REMOTE SDP \n', `Type: ${remoteDescription.type}`, '\n\n', remoteDescription.sdp);
return this.instance.setRemoteDescription(sessionDescr);

@@ -328,0 +398,0 @@ }

@@ -96,2 +96,5 @@ import BrowserSession from '../BrowserSession';

negotiateVideo?: boolean;
sfu?: boolean;
simulcast?: boolean;
msStreamsNumber?: number;
};

@@ -130,2 +133,5 @@ };

toggleDeaf(participantId?: string): void;
sfuLowResolution(streamId: string, trackId: string): Promise<any>;
sfuHighResolution(streamId: string, trackId: string): Promise<any>;
sfuDefaultResolution(streamId: string, trackId: string): Promise<any>;
stopOutboundAudio(): void;

@@ -132,0 +138,0 @@ restoreOutboundAudio(): void;

@@ -266,2 +266,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

}
sfuLowResolution(streamId, trackId) {
console.debug('Set video res to low');
const msg = new Modify(Object.assign(Object.assign({}, this.messagePayload), { action: 'set-sfu-low-res', streamId, trackId }));
return this._execute(msg);
}
sfuHighResolution(streamId, trackId) {
console.debug('Set video res to high');
const msg = new Modify(Object.assign(Object.assign({}, this.messagePayload), { action: 'set-sfu-high-res', streamId, trackId }));
return this._execute(msg);
}
sfuDefaultResolution(streamId, trackId) {
console.debug('Set video res to default');
const msg = new Modify(Object.assign(Object.assign({}, this.messagePayload), { action: 'set-sfu-default-res', streamId, trackId }));
return this._execute(msg);
}
stopOutboundAudio() {

@@ -353,6 +368,6 @@ if (this.peer) {

_onParticipantData(params) {
const { display_name: displayName, display_number: displayNumber, display_direction } = params;
const { display_name: displayName, display_number: displayNumber, display_direction } = params, rest = __rest(params, ["display_name", "display_number", "display_direction"]);
this.extension = displayNumber;
const displayDirection = display_direction === Direction.Inbound ? Direction.Outbound : Direction.Inbound;
this._dispatchNotification({ type: Notification.ParticipantData, displayName, displayNumber, displayDirection });
this._dispatchNotification(Object.assign({ type: Notification.ParticipantData, displayName, displayNumber, displayDirection }, rest));
}

@@ -414,2 +429,5 @@ _onVertoAnswer(params) {

return __awaiter(this, void 0, void 0, function* () {
if (this.options.simulcast === true) {
console.debug('Handle verto.attach for a simulcast call?', params);
}
switch (this._state) {

@@ -416,0 +434,0 @@ case State.New:

import Relay from './src/SignalWire';
import Verto from './src/Verto';
import CantinaAuth from '../common/src/webrtc/CantinaAuth';
export declare const VERSION = "1.3.0-alpha.9.3";
export declare const VERSION = "1.3.0-alpha.9.4";
export { Relay, Verto, CantinaAuth };
export * from '../common/src/util/interfaces';
export * from '../common/src/webrtc/interfaces';

@@ -5,4 +5,4 @@ import Relay from './src/SignalWire';

import CantinaAuth from '../common/src/webrtc/CantinaAuth';
export const VERSION = '1.3.0-alpha.9.3';
export const VERSION = '1.3.0-alpha.9.4';
setAgentName(`JavaScript SDK/${VERSION}`);
export { Relay, Verto, CantinaAuth };
{
"name": "@signalwire/js",
"version": "1.3.0-alpha.9.3",
"version": "1.3.0-alpha.9.4",
"description": "Relay SDK for JavaScript to connect to SignalWire.",

@@ -5,0 +5,0 @@ "author": "SignalWire Team <open.source@signalwire.com>",

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc