@signalwire/webrtc
Advanced tools
Comparing version 3.0.0 to 3.1.0
@@ -138,2 +138,18 @@ "use strict"; | ||
return session.disconnect(); | ||
case 'verto.mediaParams': { | ||
const { callID, mediaParams = {} } = params; | ||
if (!callID) { | ||
utils_1.logger.debug(`Invalid mediaParams event`, params); | ||
break; | ||
} | ||
const component = { id: callID }; | ||
if (mediaParams === null || mediaParams === void 0 ? void 0 : mediaParams.video) { | ||
component.videoConstraints = mediaParams.video; | ||
} | ||
if (mediaParams === null || mediaParams === void 0 ? void 0 : mediaParams.audio) { | ||
component.audioConstraints = mediaParams.audio; | ||
} | ||
yield effects_1.put(__1.componentActions.upsert(component)); | ||
break; | ||
} | ||
// case 'verto.invite': | ||
@@ -140,0 +156,0 @@ // break |
@@ -645,2 +645,97 @@ "use strict"; | ||
}); | ||
describe('verto.mediaParams', () => { | ||
it('should handle verto.mediaParams event with audio', () => { | ||
const jsonrpc = JSON.parse('{"jsonrpc":"2.0","id":"ac079c2a-8ed0-4713-b217-c1d70d90ffd9","method":"signalwire.event","params":{"event_type":"webrtc.message","event_channel":"signalwire_437fb1b7c9eee487988f50bedd42abbb132c96015a5f9d2b29834a6ed36ef4be_abeab57c-4629-49ae-848d-a12f8bd2fc58_78429ef1-283b-4fa9-8ebc-16b59f95bb1f","timestamp":1628684202.690967,"project_id":"78429ef1-283b-4fa9-8ebc-16b59f95bb1f","node_id":"2ecd18d4-81f6-4206-817d-0f0884ec9dd3@","params":{"jsonrpc":"2.0","id":4,"method":"verto.mediaParams","params":{"callID":"05274260-163b-43b7-805e-b4b14f92baaf","mediaParams":{"audio":{"autoGainControl":false,"echoCancellation":false,"noiseSuppression":false}}}}}}'); | ||
let runSaga = true; | ||
const session = { | ||
// relayProtocol: jsonrpc.params.protocol, | ||
}; | ||
const pubSubChannel = testUtils_1.createPubSubChannel(); | ||
const sessionChannel = redux_saga_1.eventChannel(() => () => { }); | ||
const dispatchedActions = []; | ||
return redux_saga_test_plan_1.expectSaga(sessionSaga_1.sessionChannelWatcher, { | ||
session, | ||
pubSubChannel, | ||
sessionChannel, | ||
}) | ||
.provide([ | ||
{ | ||
take({ channel }, next) { | ||
if (runSaga && channel === sessionChannel) { | ||
runSaga = false; | ||
return actions_1.socketMessageAction(jsonrpc); | ||
} | ||
sessionChannel.close(); | ||
pubSubChannel.close(); | ||
return next(); | ||
}, | ||
put(action, next) { | ||
dispatchedActions.push(action); | ||
return next(); | ||
}, | ||
}, | ||
]) | ||
.put(__1.componentActions.upsert({ | ||
id: '05274260-163b-43b7-805e-b4b14f92baaf', | ||
audioConstraints: { | ||
autoGainControl: false, | ||
echoCancellation: false, | ||
noiseSuppression: false, | ||
}, | ||
})) | ||
.run() | ||
.finally(() => { | ||
expect(dispatchedActions).toHaveLength(1); | ||
}); | ||
}); | ||
it('should handle verto.mediaParams event with video', () => { | ||
const jsonrpc = JSON.parse('{"jsonrpc":"2.0","id":"502cbb29-a3d7-4aaf-9e5d-cb9879ea8320","method":"signalwire.event","params":{"event_type":"webrtc.message","event_channel":"signalwire_437fb1b7c9eee487988f50bedd42abbb132c96015a5f9d2b29834a6ed36ef4be_abeab57c-4629-49ae-848d-a12f8bd2fc58_78429ef1-283b-4fa9-8ebc-16b59f95bb1f","timestamp":1628684206.549961,"project_id":"78429ef1-283b-4fa9-8ebc-16b59f95bb1f","node_id":"2ecd18d4-81f6-4206-817d-0f0884ec9dd3@","params":{"jsonrpc":"2.0","id":7,"method":"verto.mediaParams","params":{"callID":"05274260-163b-43b7-805e-b4b14f92baaf","mediaParams":{"video":{"frameRate":{"ideal":20},"aspectRatio":{"exact":1.7777777910232544},"width":644,"height":362}}}}}}'); | ||
let runSaga = true; | ||
const session = { | ||
// relayProtocol: jsonrpc.params.protocol, | ||
}; | ||
const pubSubChannel = testUtils_1.createPubSubChannel(); | ||
const sessionChannel = redux_saga_1.eventChannel(() => () => { }); | ||
const dispatchedActions = []; | ||
return redux_saga_test_plan_1.expectSaga(sessionSaga_1.sessionChannelWatcher, { | ||
session, | ||
pubSubChannel, | ||
sessionChannel, | ||
}) | ||
.provide([ | ||
{ | ||
take({ channel }, next) { | ||
if (runSaga && channel === sessionChannel) { | ||
runSaga = false; | ||
return actions_1.socketMessageAction(jsonrpc); | ||
} | ||
sessionChannel.close(); | ||
pubSubChannel.close(); | ||
return next(); | ||
}, | ||
put(action, next) { | ||
dispatchedActions.push(action); | ||
return next(); | ||
}, | ||
}, | ||
]) | ||
.put(__1.componentActions.upsert({ | ||
id: '05274260-163b-43b7-805e-b4b14f92baaf', | ||
videoConstraints: { | ||
frameRate: { | ||
ideal: 20, | ||
}, | ||
aspectRatio: { | ||
exact: 1.7777777910232544, | ||
}, | ||
width: 644, | ||
height: 362, | ||
}, | ||
})) | ||
.run() | ||
.finally(() => { | ||
expect(dispatchedActions).toHaveLength(1); | ||
}); | ||
}); | ||
}); | ||
}); | ||
@@ -647,0 +742,0 @@ }); |
@@ -23,2 +23,4 @@ import { PayloadAction } from '@reduxjs/toolkit'; | ||
redirectDestination?: string; | ||
audioConstraints?: MediaTrackConstraints; | ||
videoConstraints?: MediaTrackConstraints; | ||
} | ||
@@ -25,0 +27,0 @@ export interface Message extends SWComponent { |
@@ -73,2 +73,6 @@ import { BaseComponent, BaseComponentOptions, BaseConnectionState, Rooms, JSONRPCRequest } from '@signalwire/core'; | ||
onRoomSubscribed(component: any): void; | ||
/** @internal */ | ||
onVideoConstraints(component: any): void; | ||
/** @internal */ | ||
onAudioConstraints(component: any): void; | ||
updateCamera(constraints: MediaTrackConstraints): Promise<void>; | ||
@@ -75,0 +79,0 @@ updateMicrophone(constraints: MediaTrackConstraints): Promise<void>; |
@@ -211,2 +211,16 @@ "use strict"; | ||
} | ||
/** @internal */ | ||
onVideoConstraints(component) { | ||
core_1.logger.debug('onVideoConstraints', component); | ||
if (component === null || component === void 0 ? void 0 : component.videoConstraints) { | ||
this.peer.applyMediaConstraints('video', component.videoConstraints); | ||
} | ||
} | ||
/** @internal */ | ||
onAudioConstraints(component) { | ||
core_1.logger.debug('onAudioConstraints', component); | ||
if (component === null || component === void 0 ? void 0 : component.audioConstraints) { | ||
this.peer.applyMediaConstraints('audio', component.audioConstraints); | ||
} | ||
} | ||
updateCamera(constraints) { | ||
@@ -213,0 +227,0 @@ return this.updateConstraints({ |
export { getDevices, getCameraDevices, getMicrophoneDevices, getSpeakerDevices, getDevicesWithPermissions, getCameraDevicesWithPermissions, getMicrophoneDevicesWithPermissions, getSpeakerDevicesWithPermissions, checkPermissions, checkCameraPermissions, checkMicrophonePermissions, checkSpeakerPermissions, assureDeviceId, assureVideoDevice, assureAudioInDevice, assureAudioOutDevice, requestPermissions, createDeviceWatcher, createMicrophoneDeviceWatcher, createSpeakerDeviceWatcher, createCameraDeviceWatcher, } from './utils/deviceHelpers'; | ||
export { supportsMediaDevices, getUserMedia, getDisplayMedia, enumerateDevices, enumerateDevicesByKind, getSupportedConstraints, streamIsValid, supportsMediaOutput, setMediaElementSinkId, stopStream, stopTrack, } from './utils/webrtcHelpers'; | ||
export { supportsMediaDevices, supportsGetUserMedia, supportsGetDisplayMedia, getUserMedia, getDisplayMedia, enumerateDevices, enumerateDevicesByKind, getSupportedConstraints, streamIsValid, supportsMediaOutput, setMediaElementSinkId, stopStream, stopTrack, } from './utils/webrtcHelpers'; | ||
export * from './utils/interfaces'; | ||
export { BaseConnection, BaseConnectionOptions } from './BaseConnection'; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BaseConnection = exports.stopTrack = exports.stopStream = exports.setMediaElementSinkId = exports.supportsMediaOutput = exports.streamIsValid = exports.getSupportedConstraints = exports.enumerateDevicesByKind = exports.enumerateDevices = exports.getDisplayMedia = exports.getUserMedia = exports.supportsMediaDevices = exports.createCameraDeviceWatcher = exports.createSpeakerDeviceWatcher = exports.createMicrophoneDeviceWatcher = exports.createDeviceWatcher = exports.requestPermissions = exports.assureAudioOutDevice = exports.assureAudioInDevice = exports.assureVideoDevice = exports.assureDeviceId = exports.checkSpeakerPermissions = exports.checkMicrophonePermissions = exports.checkCameraPermissions = exports.checkPermissions = exports.getSpeakerDevicesWithPermissions = exports.getMicrophoneDevicesWithPermissions = exports.getCameraDevicesWithPermissions = exports.getDevicesWithPermissions = exports.getSpeakerDevices = exports.getMicrophoneDevices = exports.getCameraDevices = exports.getDevices = void 0; | ||
exports.BaseConnection = exports.stopTrack = exports.stopStream = exports.setMediaElementSinkId = exports.supportsMediaOutput = exports.streamIsValid = exports.getSupportedConstraints = exports.enumerateDevicesByKind = exports.enumerateDevices = exports.getDisplayMedia = exports.getUserMedia = exports.supportsGetDisplayMedia = exports.supportsGetUserMedia = exports.supportsMediaDevices = exports.createCameraDeviceWatcher = exports.createSpeakerDeviceWatcher = exports.createMicrophoneDeviceWatcher = exports.createDeviceWatcher = exports.requestPermissions = exports.assureAudioOutDevice = exports.assureAudioInDevice = exports.assureVideoDevice = exports.assureDeviceId = exports.checkSpeakerPermissions = exports.checkMicrophonePermissions = exports.checkCameraPermissions = exports.checkPermissions = exports.getSpeakerDevicesWithPermissions = exports.getMicrophoneDevicesWithPermissions = exports.getCameraDevicesWithPermissions = exports.getDevicesWithPermissions = exports.getSpeakerDevices = exports.getMicrophoneDevices = exports.getCameraDevices = exports.getDevices = void 0; | ||
const tslib_1 = require("tslib"); | ||
@@ -29,2 +29,4 @@ var deviceHelpers_1 = require("./utils/deviceHelpers"); | ||
Object.defineProperty(exports, "supportsMediaDevices", { enumerable: true, get: function () { return webrtcHelpers_1.supportsMediaDevices; } }); | ||
Object.defineProperty(exports, "supportsGetUserMedia", { enumerable: true, get: function () { return webrtcHelpers_1.supportsGetUserMedia; } }); | ||
Object.defineProperty(exports, "supportsGetDisplayMedia", { enumerable: true, get: function () { return webrtcHelpers_1.supportsGetDisplayMedia; } }); | ||
Object.defineProperty(exports, "getUserMedia", { enumerable: true, get: function () { return webrtcHelpers_1.getUserMedia; } }); | ||
@@ -31,0 +33,0 @@ Object.defineProperty(exports, "getDisplayMedia", { enumerable: true, get: function () { return webrtcHelpers_1.getDisplayMedia; } }); |
@@ -169,4 +169,9 @@ "use strict"; | ||
if (sender.track.readyState === 'live') { | ||
core_1.logger.info(`Apply ${kind} constraints`, this.call.id, constraints); | ||
yield sender.track.applyConstraints(constraints); | ||
const newConstraints = Object.assign(Object.assign({}, sender.track.getConstraints()), constraints); | ||
const deviceId = this.getDeviceId(kind); | ||
if (deviceId && !this.options.screenShare) { | ||
newConstraints.deviceId = { exact: deviceId }; | ||
} | ||
core_1.logger.info(`Apply ${kind} constraints`, this.call.id, newConstraints); | ||
yield sender.track.applyConstraints(newConstraints); | ||
} | ||
@@ -173,0 +178,0 @@ } |
@@ -35,3 +35,2 @@ export interface ConnectionOptions { | ||
camLabel?: string; | ||
/** @internal */ | ||
speakerId?: string; | ||
@@ -38,0 +37,0 @@ /** @internal */ |
export declare const RTCPeerConnection: (config: RTCConfiguration) => RTCPeerConnection; | ||
export declare const supportsMediaDevices: () => boolean; | ||
export declare const supportsGetUserMedia: () => boolean; | ||
export declare const supportsGetDisplayMedia: () => boolean; | ||
export declare const getMediaDevicesApi: () => MediaDevices; | ||
@@ -4,0 +6,0 @@ export declare const getUserMedia: (constraints?: MediaStreamConstraints) => Promise<MediaStream>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.stopTrack = exports.stopStream = exports.sdpToJsonHack = exports.setMediaElementSinkId = exports.supportsMediaOutput = exports.streamIsValid = exports.getSupportedConstraints = exports.enumerateDevicesByKind = exports.enumerateDevices = exports.getDisplayMedia = exports.getUserMedia = exports.getMediaDevicesApi = exports.supportsMediaDevices = exports.RTCPeerConnection = void 0; | ||
exports.stopTrack = exports.stopStream = exports.sdpToJsonHack = exports.setMediaElementSinkId = exports.supportsMediaOutput = exports.streamIsValid = exports.getSupportedConstraints = exports.enumerateDevicesByKind = exports.enumerateDevices = exports.getDisplayMedia = exports.getUserMedia = exports.getMediaDevicesApi = exports.supportsGetDisplayMedia = exports.supportsGetUserMedia = exports.supportsMediaDevices = exports.RTCPeerConnection = void 0; | ||
const tslib_1 = require("tslib"); | ||
@@ -14,2 +14,13 @@ const core_1 = require("@signalwire/core"); | ||
exports.supportsMediaDevices = supportsMediaDevices; | ||
const supportsGetUserMedia = () => { | ||
var _a; | ||
return typeof ((_a = navigator === null || navigator === void 0 ? void 0 : navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia) === 'function'; | ||
}; | ||
exports.supportsGetUserMedia = supportsGetUserMedia; | ||
const supportsGetDisplayMedia = () => { | ||
var _a; | ||
// @ts-expect-error | ||
return typeof ((_a = navigator === null || navigator === void 0 ? void 0 : navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getDisplayMedia) === 'function'; | ||
}; | ||
exports.supportsGetDisplayMedia = supportsGetDisplayMedia; | ||
const getMediaDevicesApi = () => { | ||
@@ -68,3 +79,3 @@ if (!exports.supportsMediaDevices()) { | ||
const getDisplayMedia = (constraints) => { | ||
// @ts-ignore | ||
// @ts-expect-error | ||
return exports.getMediaDevicesApi().getDisplayMedia(constraints); | ||
@@ -71,0 +82,0 @@ }; |
export declare const RTCPeerConnection: (config: RTCConfiguration) => any; | ||
export declare const getUserMedia: (constraints: MediaStreamConstraints) => any; | ||
export declare const getDisplayMedia: (constraints: MediaStreamConstraints) => any; | ||
export declare const supportsGetUserMedia: () => boolean; | ||
export declare const supportsGetDisplayMedia: () => boolean; | ||
export declare const enumerateDevices: () => any; | ||
@@ -5,0 +7,0 @@ export declare const enumerateDevicesByKind: (filterByKind: string) => Promise<MediaDeviceInfo[]>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.stopTrack = exports.stopStream = exports.sdpToJsonHack = exports.setMediaElementSinkId = exports.getSupportedConstraints = exports.streamIsValid = exports.enumerateDevicesByKind = exports.enumerateDevices = exports.getDisplayMedia = exports.getUserMedia = exports.RTCPeerConnection = void 0; | ||
exports.stopTrack = exports.stopStream = exports.sdpToJsonHack = exports.setMediaElementSinkId = exports.getSupportedConstraints = exports.streamIsValid = exports.enumerateDevicesByKind = exports.enumerateDevices = exports.supportsGetDisplayMedia = exports.supportsGetUserMedia = exports.getDisplayMedia = exports.getUserMedia = exports.RTCPeerConnection = void 0; | ||
const tslib_1 = require("tslib"); | ||
@@ -20,2 +20,10 @@ const react_native_webrtc_1 = require("react-native-webrtc"); | ||
exports.getDisplayMedia = getDisplayMedia; | ||
const supportsGetUserMedia = () => { | ||
return typeof (react_native_webrtc_1.mediaDevices === null || react_native_webrtc_1.mediaDevices === void 0 ? void 0 : react_native_webrtc_1.mediaDevices.getUserMedia) === 'function'; | ||
}; | ||
exports.supportsGetUserMedia = supportsGetUserMedia; | ||
const supportsGetDisplayMedia = () => { | ||
return typeof (react_native_webrtc_1.mediaDevices === null || react_native_webrtc_1.mediaDevices === void 0 ? void 0 : react_native_webrtc_1.mediaDevices.getDisplayMedia) === 'function'; | ||
}; | ||
exports.supportsGetDisplayMedia = supportsGetDisplayMedia; | ||
const enumerateDevices = () => react_native_webrtc_1.mediaDevices.enumerateDevices(); | ||
@@ -22,0 +30,0 @@ exports.enumerateDevices = enumerateDevices; |
@@ -134,2 +134,18 @@ import { eventChannel } from 'redux-saga'; | ||
return session.disconnect(); | ||
case 'verto.mediaParams': { | ||
const { callID, mediaParams = {} } = params; | ||
if (!callID) { | ||
logger.debug(`Invalid mediaParams event`, params); | ||
break; | ||
} | ||
const component = { id: callID }; | ||
if (mediaParams === null || mediaParams === void 0 ? void 0 : mediaParams.video) { | ||
component.videoConstraints = mediaParams.video; | ||
} | ||
if (mediaParams === null || mediaParams === void 0 ? void 0 : mediaParams.audio) { | ||
component.audioConstraints = mediaParams.audio; | ||
} | ||
yield put(componentActions.upsert(component)); | ||
break; | ||
} | ||
// case 'verto.invite': | ||
@@ -136,0 +152,0 @@ // break |
@@ -642,2 +642,97 @@ import { eventChannel } from 'redux-saga'; | ||
}); | ||
describe('verto.mediaParams', () => { | ||
it('should handle verto.mediaParams event with audio', () => { | ||
const jsonrpc = JSON.parse('{"jsonrpc":"2.0","id":"ac079c2a-8ed0-4713-b217-c1d70d90ffd9","method":"signalwire.event","params":{"event_type":"webrtc.message","event_channel":"signalwire_437fb1b7c9eee487988f50bedd42abbb132c96015a5f9d2b29834a6ed36ef4be_abeab57c-4629-49ae-848d-a12f8bd2fc58_78429ef1-283b-4fa9-8ebc-16b59f95bb1f","timestamp":1628684202.690967,"project_id":"78429ef1-283b-4fa9-8ebc-16b59f95bb1f","node_id":"2ecd18d4-81f6-4206-817d-0f0884ec9dd3@","params":{"jsonrpc":"2.0","id":4,"method":"verto.mediaParams","params":{"callID":"05274260-163b-43b7-805e-b4b14f92baaf","mediaParams":{"audio":{"autoGainControl":false,"echoCancellation":false,"noiseSuppression":false}}}}}}'); | ||
let runSaga = true; | ||
const session = { | ||
// relayProtocol: jsonrpc.params.protocol, | ||
}; | ||
const pubSubChannel = createPubSubChannel(); | ||
const sessionChannel = eventChannel(() => () => { }); | ||
const dispatchedActions = []; | ||
return expectSaga(sessionChannelWatcher, { | ||
session, | ||
pubSubChannel, | ||
sessionChannel, | ||
}) | ||
.provide([ | ||
{ | ||
take({ channel }, next) { | ||
if (runSaga && channel === sessionChannel) { | ||
runSaga = false; | ||
return socketMessageAction(jsonrpc); | ||
} | ||
sessionChannel.close(); | ||
pubSubChannel.close(); | ||
return next(); | ||
}, | ||
put(action, next) { | ||
dispatchedActions.push(action); | ||
return next(); | ||
}, | ||
}, | ||
]) | ||
.put(componentActions.upsert({ | ||
id: '05274260-163b-43b7-805e-b4b14f92baaf', | ||
audioConstraints: { | ||
autoGainControl: false, | ||
echoCancellation: false, | ||
noiseSuppression: false, | ||
}, | ||
})) | ||
.run() | ||
.finally(() => { | ||
expect(dispatchedActions).toHaveLength(1); | ||
}); | ||
}); | ||
it('should handle verto.mediaParams event with video', () => { | ||
const jsonrpc = JSON.parse('{"jsonrpc":"2.0","id":"502cbb29-a3d7-4aaf-9e5d-cb9879ea8320","method":"signalwire.event","params":{"event_type":"webrtc.message","event_channel":"signalwire_437fb1b7c9eee487988f50bedd42abbb132c96015a5f9d2b29834a6ed36ef4be_abeab57c-4629-49ae-848d-a12f8bd2fc58_78429ef1-283b-4fa9-8ebc-16b59f95bb1f","timestamp":1628684206.549961,"project_id":"78429ef1-283b-4fa9-8ebc-16b59f95bb1f","node_id":"2ecd18d4-81f6-4206-817d-0f0884ec9dd3@","params":{"jsonrpc":"2.0","id":7,"method":"verto.mediaParams","params":{"callID":"05274260-163b-43b7-805e-b4b14f92baaf","mediaParams":{"video":{"frameRate":{"ideal":20},"aspectRatio":{"exact":1.7777777910232544},"width":644,"height":362}}}}}}'); | ||
let runSaga = true; | ||
const session = { | ||
// relayProtocol: jsonrpc.params.protocol, | ||
}; | ||
const pubSubChannel = createPubSubChannel(); | ||
const sessionChannel = eventChannel(() => () => { }); | ||
const dispatchedActions = []; | ||
return expectSaga(sessionChannelWatcher, { | ||
session, | ||
pubSubChannel, | ||
sessionChannel, | ||
}) | ||
.provide([ | ||
{ | ||
take({ channel }, next) { | ||
if (runSaga && channel === sessionChannel) { | ||
runSaga = false; | ||
return socketMessageAction(jsonrpc); | ||
} | ||
sessionChannel.close(); | ||
pubSubChannel.close(); | ||
return next(); | ||
}, | ||
put(action, next) { | ||
dispatchedActions.push(action); | ||
return next(); | ||
}, | ||
}, | ||
]) | ||
.put(componentActions.upsert({ | ||
id: '05274260-163b-43b7-805e-b4b14f92baaf', | ||
videoConstraints: { | ||
frameRate: { | ||
ideal: 20, | ||
}, | ||
aspectRatio: { | ||
exact: 1.7777777910232544, | ||
}, | ||
width: 644, | ||
height: 362, | ||
}, | ||
})) | ||
.run() | ||
.finally(() => { | ||
expect(dispatchedActions).toHaveLength(1); | ||
}); | ||
}); | ||
}); | ||
}); | ||
@@ -644,0 +739,0 @@ }); |
@@ -23,2 +23,4 @@ import { PayloadAction } from '@reduxjs/toolkit'; | ||
redirectDestination?: string; | ||
audioConstraints?: MediaTrackConstraints; | ||
videoConstraints?: MediaTrackConstraints; | ||
} | ||
@@ -25,0 +27,0 @@ export interface Message extends SWComponent { |
@@ -73,2 +73,6 @@ import { BaseComponent, BaseComponentOptions, BaseConnectionState, Rooms, JSONRPCRequest } from '@signalwire/core'; | ||
onRoomSubscribed(component: any): void; | ||
/** @internal */ | ||
onVideoConstraints(component: any): void; | ||
/** @internal */ | ||
onAudioConstraints(component: any): void; | ||
updateCamera(constraints: MediaTrackConstraints): Promise<void>; | ||
@@ -75,0 +79,0 @@ updateMicrophone(constraints: MediaTrackConstraints): Promise<void>; |
@@ -207,2 +207,16 @@ import { logger, VertoBye, VertoInfo, VertoInvite, BaseComponent, selectors, } from '@signalwire/core'; | ||
} | ||
/** @internal */ | ||
onVideoConstraints(component) { | ||
logger.debug('onVideoConstraints', component); | ||
if (component === null || component === void 0 ? void 0 : component.videoConstraints) { | ||
this.peer.applyMediaConstraints('video', component.videoConstraints); | ||
} | ||
} | ||
/** @internal */ | ||
onAudioConstraints(component) { | ||
logger.debug('onAudioConstraints', component); | ||
if (component === null || component === void 0 ? void 0 : component.audioConstraints) { | ||
this.peer.applyMediaConstraints('audio', component.audioConstraints); | ||
} | ||
} | ||
updateCamera(constraints) { | ||
@@ -209,0 +223,0 @@ return this.updateConstraints({ |
export { getDevices, getCameraDevices, getMicrophoneDevices, getSpeakerDevices, getDevicesWithPermissions, getCameraDevicesWithPermissions, getMicrophoneDevicesWithPermissions, getSpeakerDevicesWithPermissions, checkPermissions, checkCameraPermissions, checkMicrophonePermissions, checkSpeakerPermissions, assureDeviceId, assureVideoDevice, assureAudioInDevice, assureAudioOutDevice, requestPermissions, createDeviceWatcher, createMicrophoneDeviceWatcher, createSpeakerDeviceWatcher, createCameraDeviceWatcher, } from './utils/deviceHelpers'; | ||
export { supportsMediaDevices, getUserMedia, getDisplayMedia, enumerateDevices, enumerateDevicesByKind, getSupportedConstraints, streamIsValid, supportsMediaOutput, setMediaElementSinkId, stopStream, stopTrack, } from './utils/webrtcHelpers'; | ||
export { supportsMediaDevices, supportsGetUserMedia, supportsGetDisplayMedia, getUserMedia, getDisplayMedia, enumerateDevices, enumerateDevicesByKind, getSupportedConstraints, streamIsValid, supportsMediaOutput, setMediaElementSinkId, stopStream, stopTrack, } from './utils/webrtcHelpers'; | ||
export * from './utils/interfaces'; | ||
export { BaseConnection, BaseConnectionOptions } from './BaseConnection'; | ||
//# sourceMappingURL=index.d.ts.map |
export { getDevices, getCameraDevices, getMicrophoneDevices, getSpeakerDevices, getDevicesWithPermissions, getCameraDevicesWithPermissions, getMicrophoneDevicesWithPermissions, getSpeakerDevicesWithPermissions, checkPermissions, checkCameraPermissions, checkMicrophonePermissions, checkSpeakerPermissions, assureDeviceId, assureVideoDevice, assureAudioInDevice, assureAudioOutDevice, requestPermissions, createDeviceWatcher, createMicrophoneDeviceWatcher, createSpeakerDeviceWatcher, createCameraDeviceWatcher, } from './utils/deviceHelpers'; | ||
export { supportsMediaDevices, getUserMedia, getDisplayMedia, enumerateDevices, enumerateDevicesByKind, getSupportedConstraints, streamIsValid, supportsMediaOutput, setMediaElementSinkId, stopStream, stopTrack, } from './utils/webrtcHelpers'; | ||
export { supportsMediaDevices, supportsGetUserMedia, supportsGetDisplayMedia, getUserMedia, getDisplayMedia, enumerateDevices, enumerateDevicesByKind, getSupportedConstraints, streamIsValid, supportsMediaOutput, setMediaElementSinkId, stopStream, stopTrack, } from './utils/webrtcHelpers'; | ||
export * from './utils/interfaces'; | ||
export { BaseConnection } from './BaseConnection'; | ||
//# sourceMappingURL=index.js.map |
@@ -163,4 +163,9 @@ import { logger } from '@signalwire/core'; | ||
if (sender.track.readyState === 'live') { | ||
logger.info(`Apply ${kind} constraints`, this.call.id, constraints); | ||
await sender.track.applyConstraints(constraints); | ||
const newConstraints = Object.assign(Object.assign({}, sender.track.getConstraints()), constraints); | ||
const deviceId = this.getDeviceId(kind); | ||
if (deviceId && !this.options.screenShare) { | ||
newConstraints.deviceId = { exact: deviceId }; | ||
} | ||
logger.info(`Apply ${kind} constraints`, this.call.id, newConstraints); | ||
await sender.track.applyConstraints(newConstraints); | ||
} | ||
@@ -167,0 +172,0 @@ } |
@@ -35,3 +35,2 @@ export interface ConnectionOptions { | ||
camLabel?: string; | ||
/** @internal */ | ||
speakerId?: string; | ||
@@ -38,0 +37,0 @@ /** @internal */ |
export declare const RTCPeerConnection: (config: RTCConfiguration) => RTCPeerConnection; | ||
export declare const supportsMediaDevices: () => boolean; | ||
export declare const supportsGetUserMedia: () => boolean; | ||
export declare const supportsGetDisplayMedia: () => boolean; | ||
export declare const getMediaDevicesApi: () => MediaDevices; | ||
@@ -4,0 +6,0 @@ export declare const getUserMedia: (constraints?: MediaStreamConstraints) => Promise<MediaStream>; |
@@ -8,2 +8,11 @@ import { logger } from '@signalwire/core'; | ||
}; | ||
export const supportsGetUserMedia = () => { | ||
var _a; | ||
return typeof ((_a = navigator === null || navigator === void 0 ? void 0 : navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia) === 'function'; | ||
}; | ||
export const supportsGetDisplayMedia = () => { | ||
var _a; | ||
// @ts-expect-error | ||
return typeof ((_a = navigator === null || navigator === void 0 ? void 0 : navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getDisplayMedia) === 'function'; | ||
}; | ||
export const getMediaDevicesApi = () => { | ||
@@ -60,3 +69,3 @@ if (!supportsMediaDevices()) { | ||
export const getDisplayMedia = (constraints) => { | ||
// @ts-ignore | ||
// @ts-expect-error | ||
return getMediaDevicesApi().getDisplayMedia(constraints); | ||
@@ -63,0 +72,0 @@ }; |
export declare const RTCPeerConnection: (config: RTCConfiguration) => any; | ||
export declare const getUserMedia: (constraints: MediaStreamConstraints) => any; | ||
export declare const getDisplayMedia: (constraints: MediaStreamConstraints) => any; | ||
export declare const supportsGetUserMedia: () => boolean; | ||
export declare const supportsGetDisplayMedia: () => boolean; | ||
export declare const enumerateDevices: () => any; | ||
@@ -5,0 +7,0 @@ export declare const enumerateDevicesByKind: (filterByKind: string) => Promise<MediaDeviceInfo[]>; |
@@ -15,2 +15,8 @@ import { RTCPeerConnection as RNRTCPeerConnection, mediaDevices as RNmediaDevices, MediaStream as RNMediaStream, | ||
}; | ||
export const supportsGetUserMedia = () => { | ||
return typeof (RNmediaDevices === null || RNmediaDevices === void 0 ? void 0 : RNmediaDevices.getUserMedia) === 'function'; | ||
}; | ||
export const supportsGetDisplayMedia = () => { | ||
return typeof (RNmediaDevices === null || RNmediaDevices === void 0 ? void 0 : RNmediaDevices.getDisplayMedia) === 'function'; | ||
}; | ||
export const enumerateDevices = () => RNmediaDevices.enumerateDevices(); | ||
@@ -17,0 +23,0 @@ export const enumerateDevicesByKind = async (filterByKind) => { |
@@ -6,3 +6,3 @@ { | ||
"license": "MIT", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"main": "dist/cjs/webrtc/src/index.js", | ||
@@ -38,3 +38,3 @@ "module": "dist/mjs/webrtc/src/index.js", | ||
"test": "NODE_ENV=test jest", | ||
"prepare": "npm run build", | ||
"prepublishOnly": "npm run build", | ||
"docs": "typedoc --options typedoc.js --readme README.md", | ||
@@ -44,5 +44,5 @@ "docs:watch": "npm run docs -- --watch" | ||
"dependencies": { | ||
"@signalwire/core": "3.0.0" | ||
"@signalwire/core": "3.1.0" | ||
}, | ||
"types": "dist/cjs/webrtc/src/index.d.ts" | ||
} |
@@ -281,2 +281,18 @@ import { | ||
/** @internal */ | ||
onVideoConstraints(component: any) { | ||
logger.debug('onVideoConstraints', component) | ||
if (component?.videoConstraints) { | ||
this.peer.applyMediaConstraints('video', component.videoConstraints) | ||
} | ||
} | ||
/** @internal */ | ||
onAudioConstraints(component: any) { | ||
logger.debug('onAudioConstraints', component) | ||
if (component?.audioConstraints) { | ||
this.peer.applyMediaConstraints('audio', component.audioConstraints) | ||
} | ||
} | ||
updateCamera(constraints: MediaTrackConstraints) { | ||
@@ -283,0 +299,0 @@ return this.updateConstraints({ |
@@ -26,2 +26,4 @@ export { | ||
supportsMediaDevices, | ||
supportsGetUserMedia, | ||
supportsGetDisplayMedia, | ||
getUserMedia, | ||
@@ -28,0 +30,0 @@ getDisplayMedia, |
@@ -199,4 +199,12 @@ import { logger } from '@signalwire/core' | ||
if (sender.track.readyState === 'live') { | ||
logger.info(`Apply ${kind} constraints`, this.call.id, constraints) | ||
await sender.track.applyConstraints(constraints) | ||
const newConstraints: MediaTrackConstraints = { | ||
...sender.track.getConstraints(), | ||
...constraints, | ||
} | ||
const deviceId = this.getDeviceId(kind) | ||
if (deviceId && !this.options.screenShare) { | ||
newConstraints.deviceId = { exact: deviceId } | ||
} | ||
logger.info(`Apply ${kind} constraints`, this.call.id, newConstraints) | ||
await sender.track.applyConstraints(newConstraints) | ||
} | ||
@@ -203,0 +211,0 @@ } catch (error) { |
@@ -37,3 +37,2 @@ export interface ConnectionOptions { | ||
camLabel?: string | ||
/** @internal */ | ||
speakerId?: string | ||
@@ -40,0 +39,0 @@ /** @internal */ |
@@ -21,2 +21,10 @@ import { | ||
export const supportsGetUserMedia = () => { | ||
return typeof RNmediaDevices?.getUserMedia === 'function' | ||
} | ||
export const supportsGetDisplayMedia = () => { | ||
return typeof RNmediaDevices?.getDisplayMedia === 'function' | ||
} | ||
export const enumerateDevices = () => RNmediaDevices.enumerateDevices() | ||
@@ -23,0 +31,0 @@ |
@@ -11,2 +11,11 @@ import { logger } from '@signalwire/core' | ||
export const supportsGetUserMedia = () => { | ||
return typeof navigator?.mediaDevices?.getUserMedia === 'function' | ||
} | ||
export const supportsGetDisplayMedia = () => { | ||
// @ts-expect-error | ||
return typeof navigator?.mediaDevices?.getDisplayMedia === 'function' | ||
} | ||
export const getMediaDevicesApi = () => { | ||
@@ -84,3 +93,3 @@ if (!supportsMediaDevices()) { | ||
export const getDisplayMedia = (constraints: MediaStreamConstraints) => { | ||
// @ts-ignore | ||
// @ts-expect-error | ||
return getMediaDevicesApi().getDisplayMedia(constraints) | ||
@@ -87,0 +96,0 @@ } |
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1768057
17936
+ Added@signalwire/core@3.1.0(transitive)
- Removed@signalwire/core@3.0.0(transitive)
Updated@signalwire/core@3.1.0