@signalwire/js
Advanced tools
Comparing version 1.3.0-alpha.7.4 to 1.3.0-alpha.7.5
@@ -16,2 +16,3 @@ import { PeerType } from './constants'; | ||
restoreTrackSender(kind: string): Promise<void>; | ||
getDeviceId(kind: string): string; | ||
applyMediaConstraints(kind: string, constraints: MediaTrackConstraints): Promise<void>; | ||
@@ -18,0 +19,0 @@ startNegotiation(): Promise<void>; |
@@ -16,3 +16,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
import { trigger } from '../services/Handler'; | ||
import { Invite, Attach, Answer } from '../messages/Verto'; | ||
import { Invite, Attach, Answer, Modify } from '../messages/Verto'; | ||
export default class RTCPeer { | ||
@@ -78,2 +78,15 @@ constructor(call, type, options) { | ||
} | ||
getDeviceId(kind) { | ||
try { | ||
const sender = this.instance.getSenders().find(({ track }) => track.kind === kind); | ||
if (!sender || !sender.track) { | ||
return null; | ||
} | ||
const { deviceId = null } = sender.track.getSettings(); | ||
return deviceId; | ||
} | ||
catch (error) { | ||
logger.error('RTCPeer getDeviceId error', kind, error); | ||
} | ||
} | ||
applyMediaConstraints(kind, constraints) { | ||
@@ -188,4 +201,9 @@ return __awaiter(this, void 0, void 0, function* () { | ||
case PeerType.Offer: | ||
this.call.setState(State.Requesting); | ||
msg = new Invite(tmpParams); | ||
if (this.call.active) { | ||
msg = new Modify(Object.assign(Object.assign({}, this.call.messagePayload), { sdp, action: 'updateMedia' })); | ||
} | ||
else { | ||
this.call.setState(State.Requesting); | ||
msg = new Invite(tmpParams); | ||
} | ||
break; | ||
@@ -192,0 +210,0 @@ case PeerType.Answer: |
@@ -67,2 +67,6 @@ import BrowserSession from '../BrowserSession'; | ||
get isMainCall(): boolean; | ||
get cameraId(): string; | ||
get microphoneId(): string; | ||
_upgrade(): Promise<void>; | ||
updateDevices(constraints: MediaStreamConstraints): Promise<void>; | ||
invite(): void; | ||
@@ -90,3 +94,2 @@ answer(): void; | ||
restoreOutboundVideo(): void; | ||
_upgrade(): Promise<void>; | ||
setState(state: State): void; | ||
@@ -93,0 +96,0 @@ private _changeHold; |
@@ -94,2 +94,69 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
} | ||
get cameraId() { | ||
return this.peer ? this.peer.getDeviceId('video') : null; | ||
} | ||
get microphoneId() { | ||
return this.peer ? this.peer.getDeviceId('audio') : null; | ||
} | ||
_upgrade() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
logger.warn(`Untested upgrade method!`); | ||
this.doReinvite = true; | ||
this.peer.type = PeerType.Offer; | ||
const stream = yield getUserMedia({ video: true }); | ||
stream.getTracks().forEach(t => { | ||
this.options.localStream.addTrack(t); | ||
this.peer.instance.addTrack(t, this.options.localStream); | ||
}); | ||
}); | ||
} | ||
updateDevices(constraints) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
console.debug('updateDevices trying constraints', constraints); | ||
const newStream = yield getUserMedia(constraints); | ||
console.debug('updateDevices got stream', newStream); | ||
const { instance } = this.peer; | ||
const tracks = newStream.getTracks(); | ||
console.debug('updateDevices with tracks', tracks); | ||
for (let i = 0; i < tracks.length; i++) { | ||
const newTrack = tracks[i]; | ||
console.debug('updateDevices trying =>', newTrack); | ||
const sender = instance.getSenders().find(({ track }) => (track && track.kind === newTrack.kind)); | ||
if (sender) { | ||
console.debug('updateDevices FOUND - replaceTrack on it and on localStream'); | ||
yield sender.replaceTrack(newTrack); | ||
console.debug('updateDevices replaceTrack SUCCESS'); | ||
this.options.localStream.getTracks().forEach(track => { | ||
if (track.kind === newTrack.kind && track.id !== newTrack.id) { | ||
console.debug('updateDevices stop old track and apply new one - '); | ||
track.stop(); | ||
track.dispatchEvent(new Event('ended')); | ||
this.options.localStream.removeTrack(track); | ||
this.options.localStream.addTrack(newTrack); | ||
} | ||
}); | ||
} | ||
else { | ||
console.debug('updateDevices NOT FOUND - addTrack and start dancing!'); | ||
this.peer.type = PeerType.Offer; | ||
this.doReinvite = true; | ||
this.options.localStream.addTrack(newTrack); | ||
instance.addTrack(newTrack, this.options.localStream); | ||
} | ||
console.debug('updateDevices Simply update mic/cam'); | ||
if (newTrack.kind === 'audio') { | ||
this.options.micId = newTrack.getSettings().deviceId; | ||
} | ||
else if (newTrack.kind === 'video') { | ||
this.options.camId = newTrack.getSettings().deviceId; | ||
} | ||
} | ||
console.debug('updateDevices done!'); | ||
} | ||
catch (error) { | ||
console.error('updateDevices', error); | ||
} | ||
}); | ||
} | ||
invite() { | ||
@@ -177,14 +244,2 @@ this.direction = Direction.Outbound; | ||
} | ||
_upgrade() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
logger.warn(`Untested upgrade method!`); | ||
this.doReinvite = true; | ||
this.peer.type = PeerType.Offer; | ||
const stream = yield getUserMedia({ video: true }); | ||
stream.getTracks().forEach(t => { | ||
this.options.localStream.addTrack(t); | ||
this.peer.instance.addTrack(t, this.options.localStream); | ||
}); | ||
}); | ||
} | ||
setState(state) { | ||
@@ -319,2 +374,3 @@ this._prevState = this._state; | ||
if (this.doReinvite) { | ||
console.debug('doReinvite IS ACTIVE!', params); | ||
return logger.warn('>>>> This leg alreay sent a reinvite??'); | ||
@@ -321,0 +377,0 @@ } |
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.7.4"; | ||
export declare const VERSION = "1.3.0-alpha.7.5"; | ||
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.7.4'; | ||
export const VERSION = '1.3.0-alpha.7.5'; | ||
setAgentName(`JavaScript SDK/${VERSION}`); | ||
export { Relay, Verto, CantinaAuth }; |
{ | ||
"name": "@signalwire/js", | ||
"version": "1.3.0-alpha.7.4", | ||
"version": "1.3.0-alpha.7.5", | ||
"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
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
310961
4410