Skip to content

Commit e0ba8d2

Browse files
author
Yuqi Huang
committed
Add periodic logging for WebRTC ingestion mode
1 parent 283bdef commit e0ba8d2

File tree

5 files changed

+176
-257
lines changed

5 files changed

+176
-257
lines changed

examples/answerer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class Answerer {
9797
// `candidate` will be the empty string if the event indicates that there are no further candidates
9898
// to come in this generation, or null if all ICE gathering on all transports is complete.
9999
// https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/icecandidate_event
100-
if (candidate) {
100+
if (candidate && candidate.candidate) {
101101
console.log(this._loggingPrefix, 'Generated ICE candidate for', this._remoteClientId || 'remote');
102102
console.debug(this._loggingPrefix, 'ICE candidate:', candidate);
103103

@@ -110,6 +110,8 @@ class Answerer {
110110
console.log(this._loggingPrefix, 'Not sending ICE candidate to', this._remoteClientId || 'remote');
111111
}
112112
}
113+
} else if (candidate && !candidate.candidate) {
114+
//firefox special case, candidate with null candidate field
113115
} else {
114116
console.log(this._loggingPrefix, 'All ICE candidates have been generated for', this._remoteClientId || 'remote');
115117

examples/master.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,10 @@ registerMasterSignalingClientCallbacks = (signalingClient, formValues, onStatsRe
228228
// If in WebRTC ingestion mode, retry if no connection was established within 30 seconds.
229229
// Note: This is an interim setting - the viewer application will retry after 30 seconds if the connection through the WebRTC Ingestion mode is not successful.
230230
if (master.channelHelper.isIngestionEnabled()) {
231-
for (let i = 5; i <= 30; i += 5) {
231+
const CHECK_INTERVAL_SECONDS = 5;
232+
const RETRY_TIMEOUT_SECONDS = 30;
233+
234+
for (let i = CHECK_INTERVAL_SECONDS; i <= RETRY_TIMEOUT_SECONDS; i += CHECK_INTERVAL_SECONDS) {
232235
setTimeout(function () {
233236
// check the state each 5 seconds
234237
//enter retry if still connecting after 30 seconds
@@ -237,14 +240,14 @@ registerMasterSignalingClientCallbacks = (signalingClient, formValues, onStatsRe
237240
answerer.getPeerConnection().connectionState !== 'failed' &&
238241
answerer.getPeerConnection().connectionState !== 'closed'
239242
) {
240-
if (i < 30) {
243+
if (i < RETRY_TIMEOUT_SECONDS) {
241244
console.log(`[${role}] Still connecting after ${i} seconds.`);
242245
} else {
243-
console.error(`[${role}] Connection was not successful - Will retry after 30 seconds.`);
246+
console.error(`[${role}] Connection was not successful - Will retry after ${RETRY_TIMEOUT_SECONDS} seconds.`);
244247
onPeerConnectionFailed(remoteClientId, false, false);
245248
}
246249
}
247-
}, i* 1000);
250+
}, i * 1000);
248251
}
249252
}
250253
});

examples/viewer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ async function startViewer(localView, remoteView, formValues, onStatsReport, rem
769769

770770
// Send any ICE candidates to the other peer
771771
viewer.peerConnection.addEventListener('icecandidate', ({ candidate }) => {
772-
if (candidate) {
772+
if (candidate && candidate.candidate) {
773773
console.log('[VIEWER] Generated ICE candidate');
774774
console.debug('ICE candidate:', candidate);
775775

@@ -782,6 +782,8 @@ async function startViewer(localView, remoteView, formValues, onStatsReport, rem
782782
console.log('[VIEWER] Not sending ICE candidate');
783783
}
784784
}
785+
} else if (candidate && !candidate.candidate) {
786+
//firefox special case, candidate with null candidate field
785787
} else {
786788
console.log('[VIEWER] All ICE candidates have been generated');
787789

0 commit comments

Comments
 (0)