Skip to content

Commit

Permalink
Merge pull request #125 from OnFreund/camera
Browse files Browse the repository at this point in the history
Show camera on auto call
  • Loading branch information
TECH7Fox authored Aug 25, 2024
2 parents 6c64ed2 + 7fd8749 commit 5eb0036
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/sipjs-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -911,18 +911,7 @@ class SipJsCard extends LitElement {
// See: https://github.com/versatica/JsSIP/issues/750
if (this.sipPhoneSession.direction === 'incoming') {
var extension = this.sipPhoneSession.remote_identity.uri.user;
this.config.extensions.forEach((element: { extension: any; camera: boolean; }) => {
if (element.extension == extension) {
this.currentCamera = (element.camera ? element.camera : undefined);
}
});
if(typeof this.config.custom !== 'undefined') {
this.config.custom.forEach((element: { number: any; camera: boolean; }) => {
if (element.number == extension) {
this.currentCamera = (element.camera ? element.camera : undefined);
}
});
}
this.currentCamera = this.cameraForExtension(extension);

this.sipPhoneSession.on("peerconnection", (event: PeerConnectionEvent) => {
console.log('Call: peerconnection(incoming)');
Expand Down Expand Up @@ -960,11 +949,20 @@ class SipJsCard extends LitElement {
});

var urlParams = new URLSearchParams(window.location.search);
if (urlParams.get('call')) {
const extension = urlParams.get('call');
if (extension) {
this.openPopup();
this._call(urlParams.get('call'), undefined); // TODO: Add camera here or in the _call function itself.
const camera = this.cameraForExtension(extension);
this._call(extension, camera);
}
}
cameraForExtension(extension: string) {
let found = this.config.extensions.find((element: { extension: string; camera: string; }) => element.extension == extension);
if (!found && typeof this.config.custom !== 'undefined') {
found = this.config.custom.find((element: { number: string; camera: string; }) => element.number == extension);
};
return (found && found.camera ? found.camera : undefined)
}
}

(window as any).customCards = (window as any).customCards || [];
Expand Down

0 comments on commit 5eb0036

Please sign in to comment.