@signalwire/js 1.3.0-dev.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/dist/esm/common/src/BaseSession.d.ts +8 -13
- package/dist/esm/common/src/BaseSession.js +33 -46
- package/dist/esm/common/src/BrowserSession.d.ts +20 -57
- package/dist/esm/common/src/BrowserSession.js +91 -359
- package/dist/esm/common/src/messages/Verto.d.ts +1 -10
- package/dist/esm/common/src/messages/Verto.js +1 -16
- package/dist/esm/common/src/messages/verto/Login.d.ts +1 -13
- package/dist/esm/common/src/messages/verto/Login.js +2 -5
- package/dist/esm/common/src/services/BroadcastHandler.js +3 -2
- package/dist/esm/common/src/services/Handler.d.ts +8 -9
- package/dist/esm/common/src/services/Handler.js +38 -41
- package/dist/esm/common/src/util/constants/index.d.ts +0 -1
- package/dist/esm/common/src/util/constants/index.js +0 -1
- package/dist/esm/common/src/util/helpers.d.ts +9 -2
- package/dist/esm/common/src/util/helpers.js +11 -6
- package/dist/esm/common/src/util/interfaces.d.ts +55 -20
- package/dist/esm/common/src/util/logger.js +1 -4
- package/dist/esm/common/src/util/webrtc/index.d.ts +1 -6
- package/dist/esm/common/src/util/webrtc/index.js +2 -63
- package/dist/esm/common/src/webrtc/BaseCall.d.ts +76 -0
- package/dist/esm/common/src/webrtc/BaseCall.js +701 -0
- package/dist/esm/common/src/webrtc/Call.d.ts +5 -5
- package/dist/esm/common/src/webrtc/Call.js +15 -34
- package/dist/esm/common/src/webrtc/CantinaAuth.d.ts +13 -8
- package/dist/esm/common/src/webrtc/CantinaAuth.js +18 -24
- package/dist/esm/common/src/webrtc/LayoutHandler.d.ts +3 -0
- package/dist/esm/common/src/webrtc/LayoutHandler.js +36 -0
- package/dist/esm/common/src/webrtc/Peer.d.ts +21 -0
- package/dist/esm/common/src/webrtc/Peer.js +145 -0
- package/dist/esm/common/src/webrtc/VertoHandler.d.ts +11 -2
- package/dist/esm/common/src/webrtc/VertoHandler.js +187 -147
- package/dist/esm/common/src/webrtc/constants.d.ts +12 -28
- package/dist/esm/common/src/webrtc/constants.js +11 -34
- package/dist/esm/common/src/webrtc/helpers.d.ts +20 -18
- package/dist/esm/common/src/webrtc/helpers.js +177 -162
- package/dist/esm/common/src/webrtc/interfaces.d.ts +51 -209
- package/dist/esm/js/index.d.ts +1 -3
- package/dist/esm/js/index.js +1 -2
- package/dist/esm/js/src/SignalWire.d.ts +2 -0
- package/dist/esm/js/src/SignalWire.js +13 -0
- package/dist/esm/js/src/Verto.d.ts +2 -8
- package/dist/esm/js/src/Verto.js +14 -50
- package/dist/index.min.js +2 -2
- package/package.json +13 -14
- package/dist/esm/common/src/webrtc/ChatChannelHandler.d.ts +0 -5
- package/dist/esm/common/src/webrtc/ChatChannelHandler.js +0 -22
- package/dist/esm/common/src/webrtc/Conference.d.ts +0 -15
- package/dist/esm/common/src/webrtc/Conference.js +0 -68
- package/dist/esm/common/src/webrtc/ConferenceListChannelHandler.d.ts +0 -5
- package/dist/esm/common/src/webrtc/ConferenceListChannelHandler.js +0 -77
- package/dist/esm/common/src/webrtc/InfoChannelHandler.d.ts +0 -7
- package/dist/esm/common/src/webrtc/InfoChannelHandler.js +0 -85
- package/dist/esm/common/src/webrtc/LaChannelHandler.d.ts +0 -5
- package/dist/esm/common/src/webrtc/LaChannelHandler.js +0 -58
- package/dist/esm/common/src/webrtc/ModChannelHandler.d.ts +0 -71
- package/dist/esm/common/src/webrtc/ModChannelHandler.js +0 -267
- package/dist/esm/common/src/webrtc/RTCPeer.d.ts +0 -51
- package/dist/esm/common/src/webrtc/RTCPeer.js +0 -556
- package/dist/esm/common/src/webrtc/WebRTCCall.d.ts +0 -182
- package/dist/esm/common/src/webrtc/WebRTCCall.js +0 -784
- package/dist/esm/common/src/webrtc/deviceHelpers.d.ts +0 -18
- package/dist/esm/common/src/webrtc/deviceHelpers.js +0 -113
- package/dist/esm/common/src/webrtc/sdpHelpers.d.ts +0 -3
- package/dist/esm/common/src/webrtc/sdpHelpers.js +0 -56
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export declare const checkPermissions: (kind?: string) => Promise<boolean>;
|
|
2
|
-
export declare const checkVideoPermissions: () => Promise<boolean>;
|
|
3
|
-
export declare const checkAudioPermissions: () => Promise<boolean>;
|
|
4
|
-
export declare const getDevicesWithPermissions: (kind?: string, fullList?: boolean) => Promise<MediaDeviceInfo[]>;
|
|
5
|
-
export declare const getVideoDevicesWithPermissions: () => Promise<MediaDeviceInfo[]>;
|
|
6
|
-
export declare const getAudioInDevicesWithPermissions: () => Promise<MediaDeviceInfo[]>;
|
|
7
|
-
export declare const getAudioOutDevicesWithPermissions: () => Promise<MediaDeviceInfo[]>;
|
|
8
|
-
export declare const getDevices: (kind?: string, fullList?: boolean) => Promise<MediaDeviceInfo[]>;
|
|
9
|
-
export declare const getVideoDevices: () => Promise<MediaDeviceInfo[]>;
|
|
10
|
-
export declare const getAudioInDevices: () => Promise<MediaDeviceInfo[]>;
|
|
11
|
-
export declare const getAudioOutDevices: () => Promise<MediaDeviceInfo[]>;
|
|
12
|
-
export declare const scanResolutions: (deviceId: string) => Promise<any[]>;
|
|
13
|
-
export declare const assureDeviceId: (id: string, label: string, kind: MediaDeviceKind) => Promise<string>;
|
|
14
|
-
export declare const validateVideoDevice: (id: string, label: string) => Promise<string>;
|
|
15
|
-
export declare const validateAudioInDevice: (id: string, label: string) => Promise<string>;
|
|
16
|
-
export declare const validateAudioOutDevice: (id: string, label: string) => Promise<string>;
|
|
17
|
-
export declare const checkDeviceIdConstraints: (id: string, label: string, kind: MediaDeviceKind, constraints: MediaTrackConstraints) => Promise<MediaTrackConstraints>;
|
|
18
|
-
export declare const requestPermissions: (constraints: MediaStreamConstraints) => Promise<void>;
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import logger from '../util/logger';
|
|
11
|
-
import * as WebRTC from '../util/webrtc';
|
|
12
|
-
import { DeviceType } from './constants';
|
|
13
|
-
export const checkPermissions = (kind = null) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
-
const devices = yield WebRTC.enumerateDevicesByKind(kind);
|
|
15
|
-
if (!devices.length) {
|
|
16
|
-
logger.warn(`No ${kind} devices to check for permissions!`);
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
return devices.every(({ deviceId, label }) => Boolean(deviceId && label));
|
|
20
|
-
});
|
|
21
|
-
export const checkVideoPermissions = () => checkPermissions(DeviceType.Video);
|
|
22
|
-
export const checkAudioPermissions = () => checkPermissions(DeviceType.AudioIn);
|
|
23
|
-
const _constraintsByKind = (kind = null) => {
|
|
24
|
-
return {
|
|
25
|
-
audio: !kind || kind === DeviceType.AudioIn || kind === DeviceType.AudioOut,
|
|
26
|
-
video: !kind || kind === DeviceType.Video,
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
export const getDevicesWithPermissions = (kind = null, fullList = false) => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
-
const hasPerms = yield checkPermissions(kind);
|
|
31
|
-
if (hasPerms === false) {
|
|
32
|
-
const constraints = _constraintsByKind(kind);
|
|
33
|
-
const stream = yield WebRTC.getUserMedia(constraints);
|
|
34
|
-
WebRTC.stopStream(stream);
|
|
35
|
-
}
|
|
36
|
-
return getDevices(kind, fullList);
|
|
37
|
-
});
|
|
38
|
-
export const getVideoDevicesWithPermissions = () => getDevicesWithPermissions(DeviceType.Video);
|
|
39
|
-
export const getAudioInDevicesWithPermissions = () => getDevicesWithPermissions(DeviceType.AudioIn);
|
|
40
|
-
export const getAudioOutDevicesWithPermissions = () => getDevicesWithPermissions(DeviceType.AudioOut);
|
|
41
|
-
export const getDevices = (kind = null, fullList = false) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
-
const devices = yield WebRTC.enumerateDevicesByKind(kind);
|
|
43
|
-
if (fullList === true) {
|
|
44
|
-
return devices;
|
|
45
|
-
}
|
|
46
|
-
const found = [];
|
|
47
|
-
return devices.filter(({ deviceId, label, kind, groupId }) => {
|
|
48
|
-
if (!deviceId || !label) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
if (!groupId) {
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
const key = `${kind}-${groupId}`;
|
|
55
|
-
if (!found.includes(key)) {
|
|
56
|
-
found.push(key);
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
return false;
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
export const getVideoDevices = () => getDevices(DeviceType.Video);
|
|
63
|
-
export const getAudioInDevices = () => getDevices(DeviceType.AudioIn);
|
|
64
|
-
export const getAudioOutDevices = () => getDevices(DeviceType.AudioOut);
|
|
65
|
-
const resolutionList = [[320, 240], [640, 360], [640, 480], [1280, 720], [1920, 1080]];
|
|
66
|
-
export const scanResolutions = (deviceId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
67
|
-
const supported = [];
|
|
68
|
-
const stream = yield WebRTC.getUserMedia({ video: { deviceId: { exact: deviceId } } });
|
|
69
|
-
const videoTrack = stream.getVideoTracks()[0];
|
|
70
|
-
for (let i = 0; i < resolutionList.length; i++) {
|
|
71
|
-
const [width, height] = resolutionList[i];
|
|
72
|
-
const success = yield videoTrack.applyConstraints({ width: { exact: width }, height: { exact: height } })
|
|
73
|
-
.then(() => true)
|
|
74
|
-
.catch(() => false);
|
|
75
|
-
if (success) {
|
|
76
|
-
supported.push({ resolution: `${width}x${height}`, width, height });
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
WebRTC.stopStream(stream);
|
|
80
|
-
return supported;
|
|
81
|
-
});
|
|
82
|
-
export const assureDeviceId = (id, label, kind) => __awaiter(void 0, void 0, void 0, function* () {
|
|
83
|
-
const devices = yield getDevices(kind, true);
|
|
84
|
-
for (let i = 0; i < devices.length; i++) {
|
|
85
|
-
const { deviceId, label: deviceLabel } = devices[i];
|
|
86
|
-
if (id === deviceId || label === deviceLabel) {
|
|
87
|
-
return deviceId;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return null;
|
|
91
|
-
});
|
|
92
|
-
export const validateVideoDevice = (id, label) => assureDeviceId(id, label, DeviceType.Video);
|
|
93
|
-
export const validateAudioInDevice = (id, label) => assureDeviceId(id, label, DeviceType.AudioIn);
|
|
94
|
-
export const validateAudioOutDevice = (id, label) => assureDeviceId(id, label, DeviceType.AudioOut);
|
|
95
|
-
export const checkDeviceIdConstraints = (id, label, kind, constraints) => __awaiter(void 0, void 0, void 0, function* () {
|
|
96
|
-
const { deviceId = null } = constraints;
|
|
97
|
-
if (deviceId === null && (id || label)) {
|
|
98
|
-
const deviceId = yield assureDeviceId(id, label, kind).catch(error => null);
|
|
99
|
-
if (deviceId) {
|
|
100
|
-
constraints.deviceId = { exact: deviceId };
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return constraints;
|
|
104
|
-
});
|
|
105
|
-
export const requestPermissions = (constraints) => __awaiter(void 0, void 0, void 0, function* () {
|
|
106
|
-
try {
|
|
107
|
-
const stream = yield WebRTC.getUserMedia(constraints);
|
|
108
|
-
WebRTC.stopStream(stream);
|
|
109
|
-
}
|
|
110
|
-
catch (error) {
|
|
111
|
-
throw error;
|
|
112
|
-
}
|
|
113
|
-
});
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
const _isAudioLine = (line) => /^m=audio/.test(line);
|
|
2
|
-
const _isVideoLine = (line) => /^m=video/.test(line);
|
|
3
|
-
const _getCodecPayloadType = (line) => {
|
|
4
|
-
const pattern = new RegExp('a=rtpmap:(\\d+) \\w+\\/\\d+');
|
|
5
|
-
const result = line.match(pattern);
|
|
6
|
-
return result && result.length == 2 ? result[1] : null;
|
|
7
|
-
};
|
|
8
|
-
export const sdpStereoHack = (sdp) => {
|
|
9
|
-
const endOfLine = '\r\n';
|
|
10
|
-
const sdpLines = sdp.split(endOfLine);
|
|
11
|
-
const opusIndex = sdpLines.findIndex(s => /^a=rtpmap/.test(s) && /opus\/48000/.test(s));
|
|
12
|
-
if (opusIndex < 0) {
|
|
13
|
-
return sdp;
|
|
14
|
-
}
|
|
15
|
-
const opusPayload = _getCodecPayloadType(sdpLines[opusIndex]);
|
|
16
|
-
const pattern = new RegExp(`a=fmtp:${opusPayload}`);
|
|
17
|
-
const fmtpLineIndex = sdpLines.findIndex(s => pattern.test(s));
|
|
18
|
-
if (fmtpLineIndex >= 0) {
|
|
19
|
-
if (!/stereo=1;/.test(sdpLines[fmtpLineIndex])) {
|
|
20
|
-
sdpLines[fmtpLineIndex] += '; stereo=1; sprop-stereo=1';
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
sdpLines[opusIndex] += `${endOfLine}a=fmtp:${opusPayload} stereo=1; sprop-stereo=1`;
|
|
25
|
-
}
|
|
26
|
-
return sdpLines.join(endOfLine);
|
|
27
|
-
};
|
|
28
|
-
export const sdpMediaOrderHack = (answer, localOffer) => {
|
|
29
|
-
const endOfLine = '\r\n';
|
|
30
|
-
const offerLines = localOffer.split(endOfLine);
|
|
31
|
-
const offerAudioIndex = offerLines.findIndex(_isAudioLine);
|
|
32
|
-
const offerVideoIndex = offerLines.findIndex(_isVideoLine);
|
|
33
|
-
if (offerAudioIndex < offerVideoIndex) {
|
|
34
|
-
return answer;
|
|
35
|
-
}
|
|
36
|
-
const answerLines = answer.split(endOfLine);
|
|
37
|
-
const answerAudioIndex = answerLines.findIndex(_isAudioLine);
|
|
38
|
-
const answerVideoIndex = answerLines.findIndex(_isVideoLine);
|
|
39
|
-
const audioLines = answerLines.slice(answerAudioIndex, answerVideoIndex);
|
|
40
|
-
const videoLines = answerLines.slice(answerVideoIndex, (answerLines.length - 1));
|
|
41
|
-
const beginLines = answerLines.slice(0, answerAudioIndex);
|
|
42
|
-
return [...beginLines, ...videoLines, ...audioLines, ''].join(endOfLine);
|
|
43
|
-
};
|
|
44
|
-
export const sdpBitrateHack = (sdp, max, min, start) => {
|
|
45
|
-
const endOfLine = '\r\n';
|
|
46
|
-
const lines = sdp.split(endOfLine);
|
|
47
|
-
lines.forEach((line, i) => {
|
|
48
|
-
if (/^a=fmtp:\d*/.test(line)) {
|
|
49
|
-
lines[i] += `;x-google-max-bitrate=${max};x-google-min-bitrate=${min};x-google-start-bitrate=${start}`;
|
|
50
|
-
}
|
|
51
|
-
else if (/^a=mid:(1|video)/.test(line)) {
|
|
52
|
-
lines[i] += `\r\nb=AS:${max}`;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
return lines.join(endOfLine);
|
|
56
|
-
};
|