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

@signalwire/webrtc

Package Overview
Dependencies
Maintainers
0
Versions
189
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@signalwire/webrtc - npm Package Compare versions

Comparing version 3.12.2-dev.202410111319.91dfb3a.0 to 3.12.2-dev.202410161307.fca4c09.0

1

dist/cjs/core/src/memberPosition/workers.d.ts

@@ -6,3 +6,2 @@ import { SagaIterator, SDKWorker, SDKWorkerParams, VideoMemberUpdatedEventParams } from '..';

}): Generator<SagaIterator<any>, void, unknown>;
export declare const MEMBER_POSITION_COMPOUND_EVENTS: Map<any, any>;
export declare const memberPositionWorker: SDKWorker<any>;

@@ -9,0 +8,0 @@ declare type MemberEventParamsList = Map<string, VideoMemberUpdatedEventParams>;

20

dist/cjs/core/src/memberPosition/workers.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.memberPositionWorker = exports.MEMBER_POSITION_COMPOUND_EVENTS = exports.memberUpdatedWorker = void 0;
exports.memberPositionWorker = exports.memberUpdatedWorker = void 0;
const effects_1 = require("@redux-saga/core/effects");

@@ -84,14 +84,2 @@ const __1 = require("..");

exports.memberUpdatedWorker = memberUpdatedWorker;
exports.MEMBER_POSITION_COMPOUND_EVENTS = new Map([
[
'video.member.updated',
[
'video.layout.changed',
// `member.joined` and `member.left` are needed to
// keep the member list up to date
'video.member.joined',
'video.member.left',
],
],
]);
const memberPositionWorker = function* memberPositionWorker({ instance, channels, initialState, getSession, instanceMap, dispatcher = defaultDispatcher, }) {

@@ -174,5 +162,7 @@ if (!initialState) {

members.forEach((member) => {
memberList.set(member.id, {
const memberId = member.id || member.member_id;
const roomSessionId = payload.room_session.id || payload.room_session.room_session_id;
memberList.set(memberId, {
room_id: payload.room_session.room_id,
room_session_id: payload.room_session.id,
room_session_id: roomSessionId,
// At this point we don't have `member.updated`

@@ -179,0 +169,0 @@ // @ts-expect-error

@@ -14,11 +14,8 @@ "use strict";

var _a;
//@ts-ignore
return (_a = this._payload.member.id) !== null && _a !== void 0 ? _a : this._payload.member.member_id;
}
get callId() {
//@ts-ignore
return this._payload.member.call_id;
}
get nodeId() {
//@ts-ignore
return this._payload.member.node_id;

@@ -25,0 +22,0 @@ }

@@ -181,3 +181,3 @@ /// <reference types="node" />

*/
export declare type CallFabricMethod = 'call.mute' | 'call.unmute' | 'call.deaf' | 'call.undeaf' | 'call.layout.list' | 'call.member.list' | 'call.member.remove' | 'call.layout.set' | 'call.microphone.volume.set' | 'call.microphone.sensitivity.set' | 'call.lock' | 'call.unlock' | 'call.raisehand' | 'call.lowerhand';
export declare type CallFabricMethod = 'call.mute' | 'call.unmute' | 'call.deaf' | 'call.undeaf' | 'call.layout.list' | 'call.member.list' | 'call.member.remove' | 'call.member.position.set' | 'call.layout.set' | 'call.microphone.volume.set' | 'call.microphone.sensitivity.set' | 'call.lock' | 'call.unlock' | 'call.raisehand' | 'call.lowerhand';
export interface WebSocketClient {

@@ -184,0 +184,0 @@ addEventListener: WebSocket['addEventListener'];

@@ -70,3 +70,3 @@ import { EventEmitter } from '@signalwire/core';

private _setupRTCPeerConnection;
start(): Promise<unknown>;
start(offering?: boolean): Promise<unknown>;
detachAndStop(): void;

@@ -73,0 +73,0 @@ stop(): void;

@@ -414,4 +414,8 @@ "use strict";

}
start() {
start(offering = false) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
if (offering) { // allow callee to send renegotiation offers
this.options.remoteSdp = undefined;
this.type = 'offer';
}
return new Promise((resolve, reject) => tslib_1.__awaiter(this, void 0, void 0, function* () {

@@ -678,3 +682,2 @@ this._resolveStartMethod = resolve;

_retrieveLocalStream() {
var _a;
return tslib_1.__awaiter(this, void 0, void 0, function* () {

@@ -684,4 +687,3 @@ if ((0, utils_1.streamIsValid)(this.options.localStream)) {

}
const remoteSDP = (_a = this.remoteSdp) !== null && _a !== void 0 ? _a : this.options.remoteSdp;
const constraints = yield (0, helpers_1.getMediaConstraints)(this.options, remoteSDP);
const constraints = yield (0, helpers_1.getMediaConstraints)(this.options);
return (0, helpers_1.getUserMedia)(constraints);

@@ -688,0 +690,0 @@ });

import { ConnectionOptions } from './interfaces';
export declare const getUserMedia: (constraints: MediaStreamConstraints) => Promise<MediaStream> | undefined;
export declare const getMediaConstraints: (options: ConnectionOptions, remoteSDP?: string) => Promise<MediaStreamConstraints>;
export declare const getMediaConstraints: (options: ConnectionOptions) => Promise<MediaStreamConstraints>;
interface FilterIceServersOptions {

@@ -5,0 +5,0 @@ disableUdpIceServers?: boolean;

@@ -19,8 +19,27 @@ "use strict";

exports.getUserMedia = getUserMedia;
const getMediaConstraints = (options, remoteSDP) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const { audio: optionsAudio, micId } = options;
const { micLabel = '' } = options;
let audio = (remoteSDP && (0, sdpHelpers_1.hasMediaSection)(remoteSDP, 'audio')) || !remoteSDP
? optionsAudio !== null && optionsAudio !== void 0 ? optionsAudio : true
: false; //should not request audio when the remote SDP don't accept audio
const _shouldNegotiateVideo = (options) => {
var _a;
return (((_a = options.negotiateVideo) !== null && _a !== void 0 ? _a : true) &&
(!options.remoteSdp ||
(0, sdpHelpers_1.hasMediaSection)(options.remoteSdp, 'video')));
};
const _shouldNegotiateAudio = (options) => {
var _a;
return (((_a = options.negotiateAudio) !== null && _a !== void 0 ? _a : true) &&
(!options.remoteSdp ||
(0, sdpHelpers_1.hasMediaSection)(options.remoteSdp, 'audio')));
};
const _getVideoConstraints = (options) => {
var _a;
return _shouldNegotiateVideo(options) ? (_a = options.video) !== null && _a !== void 0 ? _a : !!options.camId
: false;
};
const _getAudioConstraints = (options) => {
var _a;
return _shouldNegotiateAudio(options) ? (_a = options.audio) !== null && _a !== void 0 ? _a : true
: false;
};
const getMediaConstraints = (options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
let audio = _getAudioConstraints(options);
const { micLabel = '', micId } = options;
if (micId && audio) {

@@ -35,7 +54,4 @@ const newMicId = yield (0, deviceHelpers_1.assureDeviceId)(micId, micLabel, 'microphone').catch((_error) => null);

}
let { video: optionsVideo, camId } = options;
const { camLabel = '' } = options;
let video = (remoteSDP && (0, sdpHelpers_1.hasMediaSection)(remoteSDP, 'video')) || !remoteSDP
? optionsVideo !== null && optionsVideo !== void 0 ? optionsVideo : !!camId
: false; //should not request video when the remote SDP don't accept video
let video = _getVideoConstraints(options);
const { camLabel = '', camId } = options;
if (camId && video) {

@@ -42,0 +58,0 @@ const newCamId = yield (0, deviceHelpers_1.assureDeviceId)(camId, camLabel, 'camera').catch((_error) => null);

@@ -6,3 +6,2 @@ import { SagaIterator, SDKWorker, SDKWorkerParams, VideoMemberUpdatedEventParams } from '..';

}): Generator<SagaIterator<any>, void, unknown>;
export declare const MEMBER_POSITION_COMPOUND_EVENTS: Map<any, any>;
export declare const memberPositionWorker: SDKWorker<any>;

@@ -9,0 +8,0 @@ declare type MemberEventParamsList = Map<string, VideoMemberUpdatedEventParams>;

@@ -80,14 +80,2 @@ import { fork } from '@redux-saga/core/effects';

}
export const MEMBER_POSITION_COMPOUND_EVENTS = new Map([
[
'video.member.updated',
[
'video.layout.changed',
// `member.joined` and `member.left` are needed to
// keep the member list up to date
'video.member.joined',
'video.member.left',
],
],
]);
export const memberPositionWorker = function* memberPositionWorker({ instance, channels, initialState, getSession, instanceMap, dispatcher = defaultDispatcher, }) {

@@ -169,5 +157,7 @@ if (!initialState) {

members.forEach((member) => {
memberList.set(member.id, {
const memberId = member.id || member.member_id;
const roomSessionId = payload.room_session.id || payload.room_session.room_session_id;
memberList.set(memberId, {
room_id: payload.room_session.room_id,
room_session_id: payload.room_session.id,
room_session_id: roomSessionId,
// At this point we don't have `member.updated`

@@ -174,0 +164,0 @@ // @ts-expect-error

@@ -11,11 +11,8 @@ import { BaseComponent } from '../BaseComponent';

var _a;
//@ts-ignore
return (_a = this._payload.member.id) !== null && _a !== void 0 ? _a : this._payload.member.member_id;
}
get callId() {
//@ts-ignore
return this._payload.member.call_id;
}
get nodeId() {
//@ts-ignore
return this._payload.member.node_id;

@@ -22,0 +19,0 @@ }

@@ -181,3 +181,3 @@ /// <reference types="node" />

*/
export declare type CallFabricMethod = 'call.mute' | 'call.unmute' | 'call.deaf' | 'call.undeaf' | 'call.layout.list' | 'call.member.list' | 'call.member.remove' | 'call.layout.set' | 'call.microphone.volume.set' | 'call.microphone.sensitivity.set' | 'call.lock' | 'call.unlock' | 'call.raisehand' | 'call.lowerhand';
export declare type CallFabricMethod = 'call.mute' | 'call.unmute' | 'call.deaf' | 'call.undeaf' | 'call.layout.list' | 'call.member.list' | 'call.member.remove' | 'call.member.position.set' | 'call.layout.set' | 'call.microphone.volume.set' | 'call.microphone.sensitivity.set' | 'call.lock' | 'call.unlock' | 'call.raisehand' | 'call.lowerhand';
export interface WebSocketClient {

@@ -184,0 +184,0 @@ addEventListener: WebSocket['addEventListener'];

@@ -70,3 +70,3 @@ import { EventEmitter } from '@signalwire/core';

private _setupRTCPeerConnection;
start(): Promise<unknown>;
start(offering?: boolean): Promise<unknown>;
detachAndStop(): void;

@@ -73,0 +73,0 @@ stop(): void;

@@ -403,3 +403,7 @@ import { getLogger, uuid } from '@signalwire/core';

}
async start() {
async start(offering = false) {
if (offering) { // allow callee to send renegotiation offers
this.options.remoteSdp = undefined;
this.type = 'offer';
}
return new Promise(async (resolve, reject) => {

@@ -663,8 +667,6 @@ this._resolveStartMethod = resolve;

async _retrieveLocalStream() {
var _a;
if (streamIsValid(this.options.localStream)) {
return this.options.localStream;
}
const remoteSDP = (_a = this.remoteSdp) !== null && _a !== void 0 ? _a : this.options.remoteSdp;
const constraints = await getMediaConstraints(this.options, remoteSDP);
const constraints = await getMediaConstraints(this.options);
return getUserMedia(constraints);

@@ -671,0 +673,0 @@ }

import { ConnectionOptions } from './interfaces';
export declare const getUserMedia: (constraints: MediaStreamConstraints) => Promise<MediaStream> | undefined;
export declare const getMediaConstraints: (options: ConnectionOptions, remoteSDP?: string) => Promise<MediaStreamConstraints>;
export declare const getMediaConstraints: (options: ConnectionOptions) => Promise<MediaStreamConstraints>;
interface FilterIceServersOptions {

@@ -5,0 +5,0 @@ disableUdpIceServers?: boolean;

@@ -14,8 +14,27 @@ import { getLogger } from '@signalwire/core';

};
export const getMediaConstraints = async (options, remoteSDP) => {
const { audio: optionsAudio, micId } = options;
const { micLabel = '' } = options;
let audio = (remoteSDP && hasMediaSection(remoteSDP, 'audio')) || !remoteSDP
? optionsAudio !== null && optionsAudio !== void 0 ? optionsAudio : true
: false; //should not request audio when the remote SDP don't accept audio
const _shouldNegotiateVideo = (options) => {
var _a;
return (((_a = options.negotiateVideo) !== null && _a !== void 0 ? _a : true) &&
(!options.remoteSdp ||
hasMediaSection(options.remoteSdp, 'video')));
};
const _shouldNegotiateAudio = (options) => {
var _a;
return (((_a = options.negotiateAudio) !== null && _a !== void 0 ? _a : true) &&
(!options.remoteSdp ||
hasMediaSection(options.remoteSdp, 'audio')));
};
const _getVideoConstraints = (options) => {
var _a;
return _shouldNegotiateVideo(options) ? (_a = options.video) !== null && _a !== void 0 ? _a : !!options.camId
: false;
};
const _getAudioConstraints = (options) => {
var _a;
return _shouldNegotiateAudio(options) ? (_a = options.audio) !== null && _a !== void 0 ? _a : true
: false;
};
export const getMediaConstraints = async (options) => {
let audio = _getAudioConstraints(options);
const { micLabel = '', micId } = options;
if (micId && audio) {

@@ -30,7 +49,4 @@ const newMicId = await assureDeviceId(micId, micLabel, 'microphone').catch((_error) => null);

}
let { video: optionsVideo, camId } = options;
const { camLabel = '' } = options;
let video = (remoteSDP && hasMediaSection(remoteSDP, 'video')) || !remoteSDP
? optionsVideo !== null && optionsVideo !== void 0 ? optionsVideo : !!camId
: false; //should not request video when the remote SDP don't accept video
let video = _getVideoConstraints(options);
const { camLabel = '', camId } = options;
if (camId && video) {

@@ -37,0 +53,0 @@ const newCamId = await assureDeviceId(camId, camLabel, 'camera').catch((_error) => null);

@@ -6,3 +6,3 @@ {

"license": "MIT",
"version": "3.12.2-dev.202410111319.91dfb3a.0",
"version": "3.12.2-dev.202410161307.fca4c09.0",
"main": "dist/cjs/webrtc/src/index.js",

@@ -41,3 +41,3 @@ "module": "dist/mjs/webrtc/src/index.js",

"dependencies": {
"@signalwire/core": "4.2.0-dev.202410111319.91dfb3a.0",
"@signalwire/core": "4.2.0-dev.202410161307.fca4c09.0",
"sdp": "^3.2.0"

@@ -44,0 +44,0 @@ },

@@ -510,3 +510,7 @@ import { EventEmitter, getLogger, uuid } from '@signalwire/core'

async start() {
async start(offering=false) {
if(offering) { // allow callee to send renegotiation offers
this.options.remoteSdp = undefined
this.type = 'offer'
}
return new Promise(async (resolve, reject) => {

@@ -831,4 +835,3 @@ this._resolveStartMethod = resolve

}
const remoteSDP = this.remoteSdp ?? this.options.remoteSdp
const constraints = await getMediaConstraints(this.options, remoteSDP)
const constraints = await getMediaConstraints(this.options)
return getUserMedia(constraints)

@@ -835,0 +838,0 @@ }

@@ -49,3 +49,3 @@ import { getMediaConstraints } from '../utils/helpers'

it('should return audio === true', async () => {
const mediaConstraints = await getMediaConstraints({}, SDP)
const mediaConstraints = await getMediaConstraints({remoteSdp: SDP})
expect(mediaConstraints.audio).toStrictEqual(true)

@@ -55,3 +55,3 @@ })

it('should return audio === {}', async () => {
const mediaConstraints = await getMediaConstraints({audio: {}}, SDP)
const mediaConstraints = await getMediaConstraints({audio: {}, remoteSdp: SDP})
expect(mediaConstraints.audio).toEqual({})

@@ -61,3 +61,3 @@ })

it('should return audio === {deviceId: { exact: "abcd" }}', async () => {
const mediaConstraints = await getMediaConstraints({micId: 'abcd'}, SDP)
const mediaConstraints = await getMediaConstraints({micId: 'abcd', remoteSdp: SDP})
expect(mediaConstraints.audio).toEqual({deviceId: { exact: "abcd" }})

@@ -72,3 +72,3 @@ })

it('should return audio === true', async () => {
const mediaConstraints = await getMediaConstraints({}, SDP)
const mediaConstraints = await getMediaConstraints({remoteSdp: SDP})
expect(mediaConstraints.audio).toStrictEqual(false)

@@ -78,3 +78,3 @@ })

it('should return audio === {}', async () => {
const mediaConstraints = await getMediaConstraints({audio: {}}, SDP)
const mediaConstraints = await getMediaConstraints({audio: {}, remoteSdp: SDP})
expect(mediaConstraints.audio).toStrictEqual(false)

@@ -84,3 +84,3 @@ })

it('should return audio === {deviceId: { exact: "abcd" }}', async () => {
const mediaConstraints = await getMediaConstraints({micId: 'abcd'}, SDP)
const mediaConstraints = await getMediaConstraints({micId: 'abcd', remoteSdp: SDP})
expect(mediaConstraints.audio).toStrictEqual(false)

@@ -95,3 +95,3 @@ })

it('should return video === false, case 1', async () => {
const mediaConstraints = await getMediaConstraints({}, SDP)
const mediaConstraints = await getMediaConstraints({remoteSdp: SDP})
expect(mediaConstraints.video).toStrictEqual(false)

@@ -101,3 +101,3 @@ })

it('should return video === false , case 2', async () => {
const mediaConstraints = await getMediaConstraints({audio: {}}, SDP)
const mediaConstraints = await getMediaConstraints({audio: {}, remoteSdp: SDP})
expect(mediaConstraints.video).toStrictEqual(false)

@@ -107,3 +107,3 @@ })

it('should return audio === video === false , case 3', async () => {
const mediaConstraints = await getMediaConstraints({camId: 'abcd'}, SDP)
const mediaConstraints = await getMediaConstraints({camId: 'abcd', remoteSdp: SDP})
expect(mediaConstraints.video).toStrictEqual(false)

@@ -118,3 +118,3 @@ })

it('should return audio === true & video === false', async () => {
const mediaConstraints = await getMediaConstraints({}, SDP)
const mediaConstraints = await getMediaConstraints({remoteSdp: SDP})
expect(mediaConstraints.audio).toStrictEqual(true)

@@ -125,3 +125,3 @@ expect(mediaConstraints.video).toStrictEqual(false)

it('should return audio === true & video === true', async () => {
const mediaConstraints = await getMediaConstraints({video: true}, SDP)
const mediaConstraints = await getMediaConstraints({video: true, remoteSdp: SDP})
expect(mediaConstraints.audio).toStrictEqual(true)

@@ -132,3 +132,3 @@ expect(mediaConstraints.video).toStrictEqual(true)

it('should return audio === {} & video === {}', async () => {
const mediaConstraints = await getMediaConstraints({audio: {}, video: {}}, SDP)
const mediaConstraints = await getMediaConstraints({audio: {}, video: {}, remoteSdp: SDP})
expect(mediaConstraints.audio).toEqual({})

@@ -139,3 +139,3 @@ expect(mediaConstraints.video).toEqual({})

it('should return audio === {deviceId: { exact: "abcd" }} & video === {deviceId: { exact: "abcd" }}' , async () => {
const mediaConstraints = await getMediaConstraints({micId: 'abcd', camId: 'abcd'}, SDP)
const mediaConstraints = await getMediaConstraints({micId: 'abcd', camId: 'abcd', remoteSdp: SDP})
expect(mediaConstraints.audio).toEqual({deviceId: { exact: "abcd" }})

@@ -142,0 +142,0 @@ expect(mediaConstraints.video).toEqual({deviceId: { exact: "abcd" }})

@@ -18,13 +18,34 @@ import { getLogger } from '@signalwire/core'

const _shouldNegotiateVideo = (options: ConnectionOptions) => {
return (
(options.negotiateVideo ?? true) &&
(!options.remoteSdp ||
hasMediaSection(options.remoteSdp, 'video'))
)
}
const _shouldNegotiateAudio = (options: ConnectionOptions) => {
return (
(options.negotiateAudio ?? true) &&
(!options.remoteSdp ||
hasMediaSection(options.remoteSdp, 'audio'))
)
}
const _getVideoConstraints = (options: ConnectionOptions) => {
return _shouldNegotiateVideo(options) ? options.video ?? !!options.camId
: false
}
const _getAudioConstraints = (options: ConnectionOptions) => {
return _shouldNegotiateAudio(options) ? options.audio ?? true
: false
}
export const getMediaConstraints = async (
options: ConnectionOptions,
remoteSDP?: string
options: ConnectionOptions
): Promise<MediaStreamConstraints> => {
const { audio: optionsAudio, micId } = options
const { micLabel = '' } = options
let audio: boolean | MediaTrackConstraints =
(remoteSDP && hasMediaSection(remoteSDP, 'audio')) || !remoteSDP
? optionsAudio ?? true
: false //should not request audio when the remote SDP don't accept audio
let audio = _getAudioConstraints(options)
const { micLabel = '', micId } = options
if (micId && audio) {

@@ -42,9 +63,5 @@ const newMicId = await assureDeviceId(micId, micLabel, 'microphone').catch(

let { video: optionsVideo, camId } = options
const { camLabel = '' } = options
let video: boolean | MediaTrackConstraints =
(remoteSDP && hasMediaSection(remoteSDP, 'video')) || !remoteSDP
? optionsVideo ?? !!camId
: false //should not request video when the remote SDP don't accept video
let video = _getVideoConstraints(options)
const { camLabel = '', camId } = options
if (camId && video) {

@@ -51,0 +68,0 @@ const newCamId = await assureDeviceId(camId, camLabel, 'camera').catch(

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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