Skip to content

Commit

Permalink
fix: Fix TypeError in Bidirectional sample on Firefox (#832)
Browse files Browse the repository at this point in the history
* Fix TypeError in Bidirectional sample on Firefox 108

* fix

* fix

* fix
  • Loading branch information
karasusan authored Jan 10, 2023
1 parent 22a662d commit d0930e3
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 23 deletions.
14 changes: 8 additions & 6 deletions WebApp/client/public/bidirectional/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ setupButton.addEventListener('click', setUp);
const hangUpButton = document.getElementById('hangUpButton');
hangUpButton.addEventListener('click', hangUp);

window.addEventListener('beforeunload', async () => {
await sendVideo.stop();
}, true);

setupConfig();

async function setupConfig() {
Expand All @@ -84,7 +80,6 @@ async function startVideo() {
cameraWidthInput.disabled = true;
cameraHeightInput.disabled = true;
startButton.disabled = true;
setupButton.disabled = false;

let width = 0;
let height = 0;
Expand All @@ -98,6 +93,9 @@ async function startVideo() {
}

await sendVideo.startLocalVideo(videoSelect.value, audioSelect.value, width, height);

// enable setup button after initializing local video.
setupButton.disabled = false;
}

async function setUp() {
Expand Down Expand Up @@ -127,6 +125,10 @@ async function setUp() {
}
};

window.addEventListener('beforeunload', async () => {
await renderstreaming.stop();
}, true);

await renderstreaming.start();
await renderstreaming.createConnection(connectionId);
}
Expand Down Expand Up @@ -280,4 +282,4 @@ function clearStatsMessage() {
remoteVideoStatsDiv.innerHTML = '';
messageDiv.style.display = 'none';
messageDiv.innerHTML = '';
}
}
10 changes: 5 additions & 5 deletions WebApp/client/public/bidirectional/js/sendvideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ export class SendVideo {
}

/**
* @param {MediaTrackConstraints} videoSource
* @param {MediaTrackConstraints} audioSource
* @param {number} videoWidth
* @param {number} videoHeight
* @param {MediaTrackConstraints} videoSource
* @param {MediaTrackConstraints} audioSource
* @param {number} videoWidth
* @param {number} videoHeight
*/
async startLocalVideo(videoSource, audioSource, videoWidth, videoHeight) {
try {
Expand Down Expand Up @@ -42,7 +42,7 @@ export class SendVideo {
}

/**
* @param {MediaStreamTrack} track
* @param {MediaStreamTrack} track
*/
addRemoteTrack(track) {
if (this.remoteVideo.srcObject == null) {
Expand Down
10 changes: 5 additions & 5 deletions WebApp/client/src/pointercorrect.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const LetterBoxType = {

export class PointerCorrector {
/**
* @param {Number} videoWidth
* @param {Number} videoWidth
* @param {Number} videoHeight
* @param {DOMRect} rect
*/
Expand Down Expand Up @@ -63,7 +63,7 @@ export class PointerCorrector {
}

/**
* @param {Number} videoWidth
* @param {Number} videoWidth
* @param {Number} videoHeight
* @param {DOMRect} rect
*/
Expand Down Expand Up @@ -99,8 +99,8 @@ export class PointerCorrector {
/**
* Returns rectangle for displaying video with the origin at the left-top of the element.
* Not considered applying CSS like `object-fit`.
* @returns {Object}
*/
* @returns {Object}
*/
get contentRect() {
const letterBoxType = this.letterBoxType;
const letterBoxSize = this.letterBoxSize;
Expand All @@ -116,4 +116,4 @@ export class PointerCorrector {
_reset() {
this._contentRect = this.contentRect;
}
}
}
6 changes: 3 additions & 3 deletions WebApp/client/src/renderstreaming.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class RenderStreaming {

/**
* if not set argument, a generated uuid is used.
* @param {string | null} connectionId
* @param {string | null} connectionId
*/
async createConnection(connectionId) {
this._connectionId = connectionId ? connectionId : uuid4();
Expand Down Expand Up @@ -150,15 +150,15 @@ export class RenderStreaming {
}

/**
* @param {string} label
* @param {string} label
* @returns {RTCDataChannel | null}
*/
createDataChannel(label) {
return this._peer.createDataChannel(this._connectionId, label);
}

/**
* @param {MediaStreamTrack} track
* @param {MediaStreamTrack} track
* @returns {RTCRtpSender | null}
*/
addTrack(track) {
Expand Down
4 changes: 2 additions & 2 deletions WebApp/client/src/signaling.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class Signaling extends EventTarget {
break;
default:
break;
}
}
}
await this.sleep(this.interval);
}
Expand Down Expand Up @@ -344,4 +344,4 @@ export class WebSocketSignaling extends EventTarget {
Logger.log(sendJson);
this.websocket.send(sendJson);
}
}
}
2 changes: 1 addition & 1 deletion WebApp/client/src/touchflags.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ export const TouchFlags =
PrimaryTouch: 1 << 4,
Tap: 1 << 5,
OrphanedPrimaryTouch: 1 << 6,
};
};
2 changes: 1 addition & 1 deletion WebApp/client/src/touchphase.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export const TouchPhase = {
Ended: 3,
Canceled: 4,
Stationary: 5
};
};

0 comments on commit d0930e3

Please sign in to comment.