From d5643ffab3db668e72b9c932e87a3ab7823cd990 Mon Sep 17 00:00:00 2001 From: Todd Anderson Date: Wed, 22 Jan 2025 21:03:15 +0100 Subject: [PATCH] feat: adding port mux setting. --- src/page/index.html | 33 ++++++ src/page/test/conference-api/index.js | 8 +- src/page/test/conference-streams-api/index.js | 10 +- src/page/test/conference/index.js | 8 +- src/page/test/conferenceComposite/index.js | 10 +- src/page/test/conferenceParticipant/index.js | 11 +- src/page/test/playbackVOD/index.js | 13 ++- src/page/test/publish/index.js | 9 +- src/page/test/publish1080/index.js | 11 +- src/page/test/publishAMFMetadata/index.js | 11 +- src/page/test/publishAppend/index.js | 11 +- .../publishAudioCustomSettingsWebRTC/index.js | 13 ++- src/page/test/publishAuth/index.js | 11 +- .../test/publishAvailableHDSettings/index.js | 13 ++- src/page/test/publishCall/index.js | 9 +- src/page/test/publishCameraSource/index.js | 9 +- src/page/test/publishCameraSwap/index.js | 9 +- src/page/test/publishCodecSupport/index.js | 9 +- .../test/publishCustomSettingsWebRTC/index.js | 10 +- src/page/test/publishDataChannel/index.js | 9 +- src/page/test/publishEncodings/index.js | 9 +- src/page/test/publishHQAudio/index.js | 9 +- src/page/test/publishImageCapture/index.js | 9 +- .../test/publishMediaStreamCamera/index.js | 9 +- src/page/test/publishMute/index.js | 9 +- src/page/test/publishRecord/index.js | 9 +- src/page/test/publishRemoteCall/index.js | 9 +- src/page/test/publishRoundTripAuth/index.js | 9 +- src/page/test/publishScreenShare/index.js | 9 +- .../publishScreenShareWithExtension/index.js | 9 +- src/page/test/publishSendLog/index.js | 9 +- src/page/test/publishSocialPusher/index.js | 9 +- src/page/test/publishUnpublish/index.js | 9 +- src/page/test/publishVP8/index.js | 9 +- src/page/test/publishValidation/index.js | 9 +- src/page/test/publishWHIP/index.js | 9 +- src/page/test/subscribe/index.js | 9 +- src/page/test/subscribe360/index.js | 9 +- src/page/test/subscribeAMFMetadata/index.js | 12 +- .../test/subscribeAMFMetadataVOD/index.js | 11 +- src/page/test/subscribeAudioOnly/index.js | 10 +- src/page/test/subscribeAuth/index.js | 9 +- src/page/test/subscribeCall/index.js | 9 +- src/page/test/subscribeCluster/index.js | 8 +- src/page/test/subscribeCodecSupport/index.js | 11 +- src/page/test/subscribeDataChannel/index.js | 9 +- src/page/test/subscribeHLS/index.js | 10 +- src/page/test/subscribeImageCapture/index.js | 9 +- src/page/test/subscribeInterstitial/index.js | 9 +- src/page/test/subscribeLiveVOD/index.js | 11 +- src/page/test/subscribeMobile/index.js | 9 +- src/page/test/subscribeMute/index.js | 9 +- src/page/test/subscribeReconnect/index.js | 9 +- src/page/test/subscribeRemoteCall/index.js | 10 +- .../test/subscribeRetryOnInvalidName/index.js | 9 +- src/page/test/subscribeRoundTripAuth/index.js | 9 +- src/page/test/subscribeScreenShare/index.js | 9 +- src/page/test/subscribeSendLog/index.js | 9 +- src/page/test/subscribeStandby/index.js | 9 +- src/page/test/subscribeSwitch/index.js | 9 +- src/page/test/subscribeTwoStreams/index.js | 9 +- src/page/test/subscribeValidation/index.js | 9 +- src/page/test/subscribeVideoMute/index.js | 9 +- src/page/test/subscribeWHEP/index.js | 9 +- src/page/test/subscribeh264/index.js | 9 +- src/page/test/subscribevp8/index.js | 9 +- src/page/test/twoWay/index.js | 8 +- static/script/red5pro-utils.js | 110 ++++++++++-------- static/script/testbed-config.js | 1 + 69 files changed, 447 insertions(+), 324 deletions(-) diff --git a/src/page/index.html b/src/page/index.html index 0a324269b..1839923b4 100644 --- a/src/page/index.html +++ b/src/page/index.html @@ -19,6 +19,10 @@ .hidden { display: none; } + + .settings-field > input:disabled { + opacity: 0.5; + } @@ -68,6 +72,14 @@

General

+

+ + +

+

+ + +


@@ -281,6 +293,9 @@

Mixer Specific

var authPasswordField = document.getElementById('auth-password-field'); var authTokenField = document.getElementById('auth-token-field'); + var portMuxToggle = document.getElementById('port-mux-toggle'); + var portMuxField = document.getElementById('port-mux-field'); + function hideShowICEOptions() { var isTurnServer = turnRegex.test(iceField.value); var i = iceOptions.length; @@ -496,6 +511,19 @@

Mixer Specific

populate(configuration); }); + portMuxToggle.addEventListener('change', function () { + portMuxField.disabled = !portMuxToggle.checked; + configuration.usePortMux = portMuxToggle.checked ? parseInt(portMuxField.value) : NaN; + seal(configuration); + }); + + portMuxField.addEventListener('blur', function () { + var value = parseInt(portMuxField.value) + configuration.usePortMux = portMuxToggle.checked ? value : NaN; + portMuxField.value = isNaN(value) ? null : value; + seal(configuration); + }); + function populate(config) { hostField.value = config.host; appField.value = config.app; @@ -529,6 +557,11 @@

Mixer Specific

mixerBackendSocketField.value = config.mixerBackendSocketField; mixerAuthenticationEnabledField.checked = config.mixerAuthenticationEnabled ? config.mixerAuthenticationEnabled : false + var hasPortMux = config.usePortMux && !isNaN(config.usePortMux); + portMuxToggle.checked = hasPortMux; + portMuxField.disabled = !hasPortMux; + portMuxField.value = hasPortMux ? config.usePortMux : null; + function selectFieldFromConfiguration(value, selectElem) { var i = selectElem.childNodes.length; var option; diff --git a/src/page/test/conference-api/index.js b/src/page/test/conference-api/index.js index ce9855980..156e81dc8 100644 --- a/src/page/test/conference-api/index.js +++ b/src/page/test/conference-api/index.js @@ -144,9 +144,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } const getSocketLocationFromProtocol = () => { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } const getAuthenticationParams = () => { diff --git a/src/page/test/conference-streams-api/index.js b/src/page/test/conference-streams-api/index.js index 3cc8da514..b257e0698 100644 --- a/src/page/test/conference-streams-api/index.js +++ b/src/page/test/conference-streams-api/index.js @@ -69,10 +69,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var protocol = serverSettings.protocol var isSecure = protocol === 'https' - function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + const getSocketLocationFromProtocol = () => { + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } function getUserMediaConfiguration() { diff --git a/src/page/test/conference/index.js b/src/page/test/conference/index.js index 02f1378ee..67cae5a71 100644 --- a/src/page/test/conference/index.js +++ b/src/page/test/conference/index.js @@ -220,9 +220,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } function onPublisherEvent(event) { diff --git a/src/page/test/conferenceComposite/index.js b/src/page/test/conferenceComposite/index.js index 996537311..d84beec1b 100644 --- a/src/page/test/conferenceComposite/index.js +++ b/src/page/test/conferenceComposite/index.js @@ -63,10 +63,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var protocol = serverSettings.protocol var isSecure = protocol == 'https' - function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + const getSocketLocationFromProtocol = () => { + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } function getAuthenticationParams() { diff --git a/src/page/test/conferenceParticipant/index.js b/src/page/test/conferenceParticipant/index.js index ea118f1fd..bb19c6c36 100644 --- a/src/page/test/conferenceParticipant/index.js +++ b/src/page/test/conferenceParticipant/index.js @@ -71,11 +71,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var participant var protocol = serverSettings.protocol - var isSecure = protocol == 'https' - function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + const getSocketLocationFromProtocol = () => { + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } var bitrate = 0 diff --git a/src/page/test/playbackVOD/index.js b/src/page/test/playbackVOD/index.js index f4895177a..52c97a0d2 100644 --- a/src/page/test/playbackVOD/index.js +++ b/src/page/test/playbackVOD/index.js @@ -86,10 +86,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var protocol = serverSettings.protocol var isSecure = protocol === 'https' - function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + const getSocketLocationFromProtocol = () => { + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } var defaultConfiguration = (function (useVideo, useAudio) { @@ -142,12 +144,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } async function getFileURL(filename) { + const { port } = getSocketLocationFromProtocol() var baseURL = protocol + '://' + configuration.host + ':' + - (isSecure ? serverSettings.hlssport : serverSettings.hlsport) + + port + '/' + configuration.app let url diff --git a/src/page/test/publish/index.js b/src/page/test/publish/index.js index b31eef7af..7fdbf6cc1 100644 --- a/src/page/test/publish/index.js +++ b/src/page/test/publish/index.js @@ -66,11 +66,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var resolutionField = document.getElementById('resolution-field') var protocol = serverSettings.protocol - var isSecure = protocol == 'https' function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } var bitrate = 0 diff --git a/src/page/test/publish1080/index.js b/src/page/test/publish1080/index.js index ee8cdf1a2..8cc4d3ee4 100644 --- a/src/page/test/publish1080/index.js +++ b/src/page/test/publish1080/index.js @@ -89,11 +89,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } var protocol = serverSettings.protocol - var isSecure = protocol == 'https' - function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + const getSocketLocationFromProtocol = () => { + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } var defaultConfiguration = { diff --git a/src/page/test/publishAMFMetadata/index.js b/src/page/test/publishAMFMetadata/index.js index 9bd9fdf63..126073162 100644 --- a/src/page/test/publishAMFMetadata/index.js +++ b/src/page/test/publishAMFMetadata/index.js @@ -68,11 +68,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. let metadataField = document.getElementById('metadata-field') var protocol = serverSettings.protocol - var isSecure = protocol == 'https' - function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + const getSocketLocationFromProtocol = () => { + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } var bitrate = 0 diff --git a/src/page/test/publishAppend/index.js b/src/page/test/publishAppend/index.js index 5605a0e54..4d72be1ed 100644 --- a/src/page/test/publishAppend/index.js +++ b/src/page/test/publishAppend/index.js @@ -90,11 +90,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } var protocol = serverSettings.protocol - var isSecure = protocol == 'https' - function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + const getSocketLocationFromProtocol = () => { + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } var defaultConfiguration = { diff --git a/src/page/test/publishAudioCustomSettingsWebRTC/index.js b/src/page/test/publishAudioCustomSettingsWebRTC/index.js index 89eb84119..878bb37bc 100644 --- a/src/page/test/publishAudioCustomSettingsWebRTC/index.js +++ b/src/page/test/publishAudioCustomSettingsWebRTC/index.js @@ -188,8 +188,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. streamTitle.innerText = configuration.stream1 var protocol = serverSettings.protocol - var isSecure = protocol == 'https' - var isPublishable = true function setPublishableState(isPublishableFlag) { isPublishable = isPublishableFlag @@ -205,11 +203,14 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } setPublishableState(true) - function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + const getSocketLocationFromProtocol = () => { + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } + var defaultConfiguration = { protocol: getSocketLocationFromProtocol().protocol, port: getSocketLocationFromProtocol().port, diff --git a/src/page/test/publishAuth/index.js b/src/page/test/publishAuth/index.js index 04803b290..0986cd6bb 100644 --- a/src/page/test/publishAuth/index.js +++ b/src/page/test/publishAuth/index.js @@ -95,11 +95,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. streamTitle.innerText = configuration.stream1 var protocol = serverSettings.protocol - var isSecure = protocol == 'https' - function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + const getSocketLocationFromProtocol = () => { + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } function onPublisherEvent(event) { diff --git a/src/page/test/publishAvailableHDSettings/index.js b/src/page/test/publishAvailableHDSettings/index.js index 6ce86d1c6..091748362 100644 --- a/src/page/test/publishAvailableHDSettings/index.js +++ b/src/page/test/publishAvailableHDSettings/index.js @@ -181,8 +181,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. streamTitle.innerText = configuration.stream1 var protocol = serverSettings.protocol - var isSecure = protocol == 'https' - var isPublishable = true function setPublishableState(isPublishableFlag) { isPublishable = isPublishableFlag @@ -198,11 +196,14 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } setPublishableState(true) - function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + const getSocketLocationFromProtocol = () => { + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } + var defaultConfiguration = { protocol: getSocketLocationFromProtocol().protocol, port: getSocketLocationFromProtocol().port, diff --git a/src/page/test/publishCall/index.js b/src/page/test/publishCall/index.js index d7a4f67e4..151f94b19 100644 --- a/src/page/test/publishCall/index.js +++ b/src/page/test/publishCall/index.js @@ -119,11 +119,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. }) var protocol = serverSettings.protocol - var isSecure = protocol == 'https' function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } function enableCallButton() { diff --git a/src/page/test/publishCameraSource/index.js b/src/page/test/publishCameraSource/index.js index 796177605..4d6a1c410 100644 --- a/src/page/test/publishCameraSource/index.js +++ b/src/page/test/publishCameraSource/index.js @@ -93,11 +93,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. streamTitle.innerText = configuration.stream1 var protocol = serverSettings.protocol - var isSecure = protocol == 'https' function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } var defaultConfiguration = { diff --git a/src/page/test/publishCameraSwap/index.js b/src/page/test/publishCameraSwap/index.js index 9ce179ed0..af2c807a5 100644 --- a/src/page/test/publishCameraSwap/index.js +++ b/src/page/test/publishCameraSwap/index.js @@ -111,11 +111,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } var protocol = serverSettings.protocol - var isSecure = protocol == 'https' function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } var defaultConfiguration = { diff --git a/src/page/test/publishCodecSupport/index.js b/src/page/test/publishCodecSupport/index.js index 79147e20e..f867ca2fa 100644 --- a/src/page/test/publishCodecSupport/index.js +++ b/src/page/test/publishCodecSupport/index.js @@ -94,11 +94,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. streamTitle.innerText = configuration.stream1 const protocol = serverSettings.protocol - const isSecure = protocol == 'https' const getSocketLocationFromProtocol = () => { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } let defaultConfiguration = { diff --git a/src/page/test/publishCustomSettingsWebRTC/index.js b/src/page/test/publishCustomSettingsWebRTC/index.js index d0fee0164..a7f606abd 100644 --- a/src/page/test/publishCustomSettingsWebRTC/index.js +++ b/src/page/test/publishCustomSettingsWebRTC/index.js @@ -202,8 +202,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. streamTitle.innerText = configuration.stream1 var protocol = serverSettings.protocol - var isSecure = protocol == 'https' - var isPublishable = true function setPublishableState(isPublishableFlag) { isPublishable = isPublishableFlag @@ -220,9 +218,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. setPublishableState(true) function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } var defaultConfiguration = { protocol: getSocketLocationFromProtocol().protocol, diff --git a/src/page/test/publishDataChannel/index.js b/src/page/test/publishDataChannel/index.js index 6f4902400..4586c0632 100644 --- a/src/page/test/publishDataChannel/index.js +++ b/src/page/test/publishDataChannel/index.js @@ -201,11 +201,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. }) var protocol = serverSettings.protocol - var isSecure = protocol == 'https' function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } function onPublisherEvent(event) { diff --git a/src/page/test/publishEncodings/index.js b/src/page/test/publishEncodings/index.js index 3af5bfcae..8cb05e912 100644 --- a/src/page/test/publishEncodings/index.js +++ b/src/page/test/publishEncodings/index.js @@ -94,11 +94,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } var protocol = serverSettings.protocol - var isSecure = protocol == 'https' function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } var defaultConfiguration = { diff --git a/src/page/test/publishHQAudio/index.js b/src/page/test/publishHQAudio/index.js index d39ce62e8..a9a5ec24c 100644 --- a/src/page/test/publishHQAudio/index.js +++ b/src/page/test/publishHQAudio/index.js @@ -89,11 +89,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } var protocol = serverSettings.protocol - var isSecure = protocol == 'https' function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } function onPublisherEvent(event) { diff --git a/src/page/test/publishImageCapture/index.js b/src/page/test/publishImageCapture/index.js index fa9d5bfbe..b5461ab01 100644 --- a/src/page/test/publishImageCapture/index.js +++ b/src/page/test/publishImageCapture/index.js @@ -92,11 +92,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } var protocol = serverSettings.protocol - var isSecure = protocol == 'https' function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } var defaultConfiguration = { protocol: getSocketLocationFromProtocol().protocol, diff --git a/src/page/test/publishMediaStreamCamera/index.js b/src/page/test/publishMediaStreamCamera/index.js index 912f86590..6ceeb7e55 100644 --- a/src/page/test/publishMediaStreamCamera/index.js +++ b/src/page/test/publishMediaStreamCamera/index.js @@ -100,11 +100,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var current_selection = undefined var protocol = serverSettings.protocol - var isSecure = protocol == 'https' function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } function onPublisherEvent(event) { diff --git a/src/page/test/publishMute/index.js b/src/page/test/publishMute/index.js index ed5cb6563..445965b4b 100644 --- a/src/page/test/publishMute/index.js +++ b/src/page/test/publishMute/index.js @@ -93,11 +93,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } var protocol = serverSettings.protocol - var isSecure = protocol == 'https' function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } var defaultConfiguration = { diff --git a/src/page/test/publishRecord/index.js b/src/page/test/publishRecord/index.js index 43fc0ef7f..b595ea718 100644 --- a/src/page/test/publishRecord/index.js +++ b/src/page/test/publishRecord/index.js @@ -89,11 +89,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } var protocol = serverSettings.protocol - var isSecure = protocol == 'https' function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } var defaultConfiguration = { diff --git a/src/page/test/publishRemoteCall/index.js b/src/page/test/publishRemoteCall/index.js index 890f9e0b8..bd44f7685 100644 --- a/src/page/test/publishRemoteCall/index.js +++ b/src/page/test/publishRemoteCall/index.js @@ -105,11 +105,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. }) var protocol = serverSettings.protocol - var isSecure = protocol == 'https' function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } function onPublisherEvent(event) { diff --git a/src/page/test/publishRoundTripAuth/index.js b/src/page/test/publishRoundTripAuth/index.js index 218b2edb5..ba6731e70 100644 --- a/src/page/test/publishRoundTripAuth/index.js +++ b/src/page/test/publishRoundTripAuth/index.js @@ -97,11 +97,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. streamTitle.innerText = configuration.stream1 var protocol = serverSettings.protocol - var isSecure = protocol == 'https' function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } function onPublisherEvent(event) { diff --git a/src/page/test/publishScreenShare/index.js b/src/page/test/publishScreenShare/index.js index 4c22d6def..770093273 100644 --- a/src/page/test/publishScreenShare/index.js +++ b/src/page/test/publishScreenShare/index.js @@ -121,11 +121,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. streamTitle.innerText = configuration.stream1 var protocol = serverSettings.protocol - var isSecure = protocol == 'https' function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } function onPublisherEvent(event) { diff --git a/src/page/test/publishScreenShareWithExtension/index.js b/src/page/test/publishScreenShareWithExtension/index.js index a5b699407..382739b41 100644 --- a/src/page/test/publishScreenShareWithExtension/index.js +++ b/src/page/test/publishScreenShareWithExtension/index.js @@ -105,11 +105,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. streamTitle.innerText = configuration.stream1 var protocol = serverSettings.protocol - var isSecure = protocol == 'https' function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } function onBitrateUpdate(bitrate, packetsSent) { diff --git a/src/page/test/publishSendLog/index.js b/src/page/test/publishSendLog/index.js index 71ffdb8d0..08a7f6316 100644 --- a/src/page/test/publishSendLog/index.js +++ b/src/page/test/publishSendLog/index.js @@ -100,11 +100,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. }) var protocol = serverSettings.protocol - var isSecure = protocol == 'https' function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } function onPublisherEvent(event) { diff --git a/src/page/test/publishSocialPusher/index.js b/src/page/test/publishSocialPusher/index.js index c1c2f0ff5..6f72965cc 100644 --- a/src/page/test/publishSocialPusher/index.js +++ b/src/page/test/publishSocialPusher/index.js @@ -66,11 +66,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var resolutionField = document.getElementById('resolution-field') var protocol = serverSettings.protocol - var isSecure = protocol == 'https' function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } var bitrate = 0 diff --git a/src/page/test/publishUnpublish/index.js b/src/page/test/publishUnpublish/index.js index cbef89f69..494e9316f 100644 --- a/src/page/test/publishUnpublish/index.js +++ b/src/page/test/publishUnpublish/index.js @@ -97,11 +97,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var statisticsField = document.getElementById('statistics-field') var protocol = serverSettings.protocol - var isSecure = protocol == 'https' function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } function onBitrateUpdate(bitrate, packetsSent) { diff --git a/src/page/test/publishVP8/index.js b/src/page/test/publishVP8/index.js index 4a85b1f96..2071950c5 100644 --- a/src/page/test/publishVP8/index.js +++ b/src/page/test/publishVP8/index.js @@ -66,11 +66,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var resolutionField = document.getElementById('resolution-field') var protocol = serverSettings.protocol - var isSecure = protocol == 'https' function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } var bitrate = 0 diff --git a/src/page/test/publishValidation/index.js b/src/page/test/publishValidation/index.js index e2906446d..ddb8e5927 100644 --- a/src/page/test/publishValidation/index.js +++ b/src/page/test/publishValidation/index.js @@ -69,11 +69,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var validationAddButton = document.getElementById('add-param-btn') var protocol = serverSettings.protocol - var isSecure = protocol == 'https' function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } var bitrate = 0 diff --git a/src/page/test/publishWHIP/index.js b/src/page/test/publishWHIP/index.js index ee0499fa5..2ec6c6de4 100644 --- a/src/page/test/publishWHIP/index.js +++ b/src/page/test/publishWHIP/index.js @@ -70,11 +70,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. const resolutionField = document.getElementById('resolution-field') const protocol = serverSettings.protocol - const isSecure = protocol == 'https' const getSocketLocationFromProtocol = () => { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } let bitrate = 0 diff --git a/src/page/test/subscribe/index.js b/src/page/test/subscribe/index.js index 3ec72cccb..5312261ae 100644 --- a/src/page/test/subscribe/index.js +++ b/src/page/test/subscribe/index.js @@ -66,7 +66,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var resolutionField = document.getElementById('resolution-field') var protocol = serverSettings.protocol - var isSecure = protocol === 'https' var bitrate = 0 var packetsReceived = 0 @@ -94,9 +93,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // Determines the ports and protocols based on being served over TLS. function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } // Base configuration to extend in providing specific tech failover configurations. diff --git a/src/page/test/subscribe360/index.js b/src/page/test/subscribe360/index.js index 328397576..97a2f5f60 100644 --- a/src/page/test/subscribe360/index.js +++ b/src/page/test/subscribe360/index.js @@ -67,7 +67,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var resolutionField = document.getElementById('resolution-field') var protocol = serverSettings.protocol - var isSecure = protocol === 'https' var bitrate = 0 var packetsReceived = 0 @@ -94,9 +93,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // Determines the ports and protocols based on being served over TLS. function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } // Base configuration to extend in providing specific tech failover configurations. diff --git a/src/page/test/subscribeAMFMetadata/index.js b/src/page/test/subscribeAMFMetadata/index.js index f6c96079f..784399bec 100644 --- a/src/page/test/subscribeAMFMetadata/index.js +++ b/src/page/test/subscribeAMFMetadata/index.js @@ -65,9 +65,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var packetsField = document.getElementById('packets-field') var resolutionField = document.getElementById('resolution-field') - var protocol = serverSettings.protocol - var isSecure = protocol === 'https' - var bitrate = 0 var packetsReceived = 0 var frameWidth = 0 @@ -93,10 +90,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } // Determines the ports and protocols based on being served over TLS. + var protocol = serverSettings.protocol function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } // Base configuration to extend in providing specific tech failover configurations. diff --git a/src/page/test/subscribeAMFMetadataVOD/index.js b/src/page/test/subscribeAMFMetadataVOD/index.js index a6f79e84e..aadc44aac 100644 --- a/src/page/test/subscribeAMFMetadataVOD/index.js +++ b/src/page/test/subscribeAMFMetadataVOD/index.js @@ -84,9 +84,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var protocol = serverSettings.protocol var isSecure = protocol === 'https' function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } var defaultConfiguration = (function (useVideo, useAudio) { @@ -139,12 +141,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } function getFileURL(filename) { + const { port } = getSocketLocationFromProtocol() var baseURL = protocol + '://' + configuration.host + ':' + - (isSecure ? serverSettings.hlssport : serverSettings.hlsport) + + port + '/' + configuration.app if (isMP4File(filename)) { diff --git a/src/page/test/subscribeAudioOnly/index.js b/src/page/test/subscribeAudioOnly/index.js index 26e498445..af4f651a7 100644 --- a/src/page/test/subscribeAudioOnly/index.js +++ b/src/page/test/subscribeAudioOnly/index.js @@ -85,12 +85,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } var protocol = serverSettings.protocol - var isSecure = protocol == 'https' - function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } function getAuthenticationParams() { diff --git a/src/page/test/subscribeAuth/index.js b/src/page/test/subscribeAuth/index.js index 00935e708..7e120f1a5 100644 --- a/src/page/test/subscribeAuth/index.js +++ b/src/page/test/subscribeAuth/index.js @@ -70,7 +70,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var resolutionField = document.getElementById('resolution-field') var protocol = serverSettings.protocol - var isSecure = protocol === 'https' var bitrate = 0 var packetsReceived = 0 @@ -96,9 +95,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } streamTitle.innerText = configuration.stream1 diff --git a/src/page/test/subscribeCall/index.js b/src/page/test/subscribeCall/index.js index aa9687cbf..bade021ff 100644 --- a/src/page/test/subscribeCall/index.js +++ b/src/page/test/subscribeCall/index.js @@ -120,11 +120,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } var protocol = serverSettings.protocol - var isSecure = protocol === 'https' function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } function enableCallButton() { diff --git a/src/page/test/subscribeCluster/index.js b/src/page/test/subscribeCluster/index.js index 8a211a4f6..73dddaafa 100644 --- a/src/page/test/subscribeCluster/index.js +++ b/src/page/test/subscribeCluster/index.js @@ -101,9 +101,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } streamTitle.innerText = configuration.stream1 diff --git a/src/page/test/subscribeCodecSupport/index.js b/src/page/test/subscribeCodecSupport/index.js index 3322bb4b9..0400a53f1 100644 --- a/src/page/test/subscribeCodecSupport/index.js +++ b/src/page/test/subscribeCodecSupport/index.js @@ -70,7 +70,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. const resolutionField = document.getElementById('resolution-field') const protocol = serverSettings.protocol - const isSecure = protocol === 'https' let bitrate = 0 let packetsReceived = 0 @@ -97,10 +96,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } // Determines the ports and protocols based on being served over TLS. - const getSocketLocationFromProtocol = () => { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + function getSocketLocationFromProtocol() { + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } // Base configuration to extend in providing specific tech failover configurations. diff --git a/src/page/test/subscribeDataChannel/index.js b/src/page/test/subscribeDataChannel/index.js index 5c896ee55..c35b4a8d2 100644 --- a/src/page/test/subscribeDataChannel/index.js +++ b/src/page/test/subscribeDataChannel/index.js @@ -69,7 +69,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var resolutionField = document.getElementById('resolution-field') var protocol = serverSettings.protocol - var isSecure = protocol === 'https' var bitrate = 0 var packetsReceived = 0 @@ -97,9 +96,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // Determines the ports and protocols based on being served over TLS. function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } // Base configuration to extend in providing specific tech failover configurations. diff --git a/src/page/test/subscribeHLS/index.js b/src/page/test/subscribeHLS/index.js index 9de603a69..ec763e294 100644 --- a/src/page/test/subscribeHLS/index.js +++ b/src/page/test/subscribeHLS/index.js @@ -63,9 +63,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var protocol = serverSettings.protocol var isSecure = protocol === 'https' function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } var defaultConfiguration = (function (useVideo, useAudio) { @@ -179,7 +181,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var config = Object.assign({}, configuration, defaultConfiguration) var hlsConfig = Object.assign({}, config, { protocol: protocol, - port: isSecure ? serverSettings.hlssport : serverSettings.hlsport, + port: getSocketLocationFromProtocol().port, streamName: config.stream1, mimeType: 'application/x-mpegURL', }) diff --git a/src/page/test/subscribeImageCapture/index.js b/src/page/test/subscribeImageCapture/index.js index 9236bc362..33f28308f 100644 --- a/src/page/test/subscribeImageCapture/index.js +++ b/src/page/test/subscribeImageCapture/index.js @@ -76,7 +76,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var resolutionField = document.getElementById('resolution-field') var protocol = serverSettings.protocol - var isSecure = protocol === 'https' var bitrate = 0 var packetsReceived = 0 @@ -103,9 +102,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // Determines the ports and protocols based on being served over TLS. function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } var defaultConfiguration = (function (useVideo, useAudio) { diff --git a/src/page/test/subscribeInterstitial/index.js b/src/page/test/subscribeInterstitial/index.js index ea33b4254..2210dbda9 100644 --- a/src/page/test/subscribeInterstitial/index.js +++ b/src/page/test/subscribeInterstitial/index.js @@ -66,7 +66,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var resolutionField = document.getElementById('resolution-field') var protocol = serverSettings.protocol - var isSecure = protocol === 'https' var bitrate = 0 var packetsReceived = 0 @@ -185,9 +184,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // Determines the ports and protocols based on being served over TLS. function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } // Base configuration to extend in providing specific tech failover configurations. diff --git a/src/page/test/subscribeLiveVOD/index.js b/src/page/test/subscribeLiveVOD/index.js index 443fb7067..c08c0a48b 100644 --- a/src/page/test/subscribeLiveVOD/index.js +++ b/src/page/test/subscribeLiveVOD/index.js @@ -52,7 +52,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. let instanceId = Math.floor(Math.random() * 0x10000).toString(16) let protocol = serverSettings.protocol - let isSecure = protocol === 'https' const subscribeButton = document.getElementById('subscribe-button') const baseCheck = document.getElementById('base-check') @@ -94,10 +93,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } // Determines the ports and protocols based on being served over TLS. - const getSocketLocationFromProtocol = () => { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + function getSocketLocationFromProtocol() { + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } // Base configuration to extend in providing specific tech failover configurations. diff --git a/src/page/test/subscribeMobile/index.js b/src/page/test/subscribeMobile/index.js index 8453fdef9..2c759aeee 100644 --- a/src/page/test/subscribeMobile/index.js +++ b/src/page/test/subscribeMobile/index.js @@ -66,7 +66,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var resolutionField = document.getElementById('resolution-field') var protocol = serverSettings.protocol - var isSecure = protocol === 'https' var bitrate = 0 var packetsReceived = 0 @@ -92,9 +91,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } var defaultConfiguration = (function (useVideo, useAudio) { diff --git a/src/page/test/subscribeMute/index.js b/src/page/test/subscribeMute/index.js index ac4b8cc7c..c377c2604 100644 --- a/src/page/test/subscribeMute/index.js +++ b/src/page/test/subscribeMute/index.js @@ -68,7 +68,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var muteVideoButton = document.getElementById('mute-video-button') var protocol = serverSettings.protocol - var isSecure = protocol === 'https' var bitrate = 0 var packetsReceived = 0 @@ -128,9 +127,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // Determines the ports and protocols based on being served over TLS. function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } // Base configuration to extend in ptoviding specific tech failover configurations. diff --git a/src/page/test/subscribeReconnect/index.js b/src/page/test/subscribeReconnect/index.js index 68d30a924..f3a671464 100644 --- a/src/page/test/subscribeReconnect/index.js +++ b/src/page/test/subscribeReconnect/index.js @@ -66,7 +66,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var resolutionField = document.getElementById('resolution-field') var protocol = serverSettings.protocol - var isSecure = protocol === 'https' var dryStreamTimer = 0 var dryStreamTimerDelay = 5 * 1000 // 5 seconds @@ -110,9 +109,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } streamTitle.innerText = configuration.stream1 diff --git a/src/page/test/subscribeRemoteCall/index.js b/src/page/test/subscribeRemoteCall/index.js index 4f3df7d3d..31f29da2d 100644 --- a/src/page/test/subscribeRemoteCall/index.js +++ b/src/page/test/subscribeRemoteCall/index.js @@ -67,7 +67,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var resolutionField = document.getElementById('resolution-field') var protocol = serverSettings.protocol - var isSecure = protocol === 'https' var bitrate = 0 var packetsReceived = 0 @@ -93,11 +92,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } - var defaultConfiguration = (function (useVideo, useAudio) { var c = { protocol: getSocketLocationFromProtocol().protocol, diff --git a/src/page/test/subscribeRetryOnInvalidName/index.js b/src/page/test/subscribeRetryOnInvalidName/index.js index 039e6fb4d..a327cc9e4 100644 --- a/src/page/test/subscribeRetryOnInvalidName/index.js +++ b/src/page/test/subscribeRetryOnInvalidName/index.js @@ -75,7 +75,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var resolutionField = document.getElementById('resolution-field') var protocol = serverSettings.protocol - var isSecure = protocol === 'https' var bitrate = 0 var packetsReceived = 0 @@ -101,9 +100,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } streamTitle.innerText = configuration.stream1 diff --git a/src/page/test/subscribeRoundTripAuth/index.js b/src/page/test/subscribeRoundTripAuth/index.js index c73fa6b7f..37b777366 100644 --- a/src/page/test/subscribeRoundTripAuth/index.js +++ b/src/page/test/subscribeRoundTripAuth/index.js @@ -72,7 +72,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var resolutionField = document.getElementById('resolution-field') var protocol = serverSettings.protocol - var isSecure = protocol === 'https' var bitrate = 0 var packetsReceived = 0 @@ -98,9 +97,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } streamTitle.innerText = configuration.stream1 diff --git a/src/page/test/subscribeScreenShare/index.js b/src/page/test/subscribeScreenShare/index.js index 851ab4fae..52c3e5a5a 100644 --- a/src/page/test/subscribeScreenShare/index.js +++ b/src/page/test/subscribeScreenShare/index.js @@ -70,7 +70,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var resolutionField = document.getElementById('resolution-field') var protocol = serverSettings.protocol - var isSecure = protocol === 'https' var bitrate = 0 var packetsReceived = 0 @@ -96,9 +95,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } var defaultConfiguration = (function (useVideo, useAudio) { diff --git a/src/page/test/subscribeSendLog/index.js b/src/page/test/subscribeSendLog/index.js index b99d679b1..3c1094107 100644 --- a/src/page/test/subscribeSendLog/index.js +++ b/src/page/test/subscribeSendLog/index.js @@ -68,7 +68,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var resolutionField = document.getElementById('resolution-field') var protocol = serverSettings.protocol - var isSecure = protocol === 'https' var bitrate = 0 var packetsReceived = 0 @@ -103,9 +102,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. }) function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } var defaultConfiguration = (function (useVideo, useAudio) { diff --git a/src/page/test/subscribeStandby/index.js b/src/page/test/subscribeStandby/index.js index f972454e2..5193005db 100644 --- a/src/page/test/subscribeStandby/index.js +++ b/src/page/test/subscribeStandby/index.js @@ -67,7 +67,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var standbyButton = document.getElementById('standby-button') var protocol = serverSettings.protocol - var isSecure = protocol === 'https' var bitrate = 0 var packetsReceived = 0 @@ -111,9 +110,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // Determines the ports and protocols based on being served over TLS. function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } // Base configuration to extend in ptoviding specific tech failover configurations. diff --git a/src/page/test/subscribeSwitch/index.js b/src/page/test/subscribeSwitch/index.js index fe198cc9b..201e99ab8 100644 --- a/src/page/test/subscribeSwitch/index.js +++ b/src/page/test/subscribeSwitch/index.js @@ -66,7 +66,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var resolutionField = document.getElementById('resolution-field') var protocol = serverSettings.protocol - var isSecure = protocol === 'https' var bitrate = 0 var packetsReceived = 0 @@ -111,9 +110,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // Determines the ports and protocols based on being served over TLS. function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } // Base configuration to extend in providing specific tech failover configurations. diff --git a/src/page/test/subscribeTwoStreams/index.js b/src/page/test/subscribeTwoStreams/index.js index cfed71b5c..d41a6c37d 100644 --- a/src/page/test/subscribeTwoStreams/index.js +++ b/src/page/test/subscribeTwoStreams/index.js @@ -68,13 +68,14 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var streamTitle2 = document.getElementById('stream2-title') var protocol = serverSettings.protocol - var isSecure = protocol === 'https' // Determines the ports and protocols based on being served over TLS. function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } // Base configuration to extend in ptoviding specific tech failover configurations. diff --git a/src/page/test/subscribeValidation/index.js b/src/page/test/subscribeValidation/index.js index 7306efda1..6402a8422 100644 --- a/src/page/test/subscribeValidation/index.js +++ b/src/page/test/subscribeValidation/index.js @@ -69,7 +69,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var validationAddButton = document.getElementById('add-param-btn') var protocol = serverSettings.protocol - var isSecure = protocol === 'https' var bitrate = 0 var packetsReceived = 0 @@ -97,9 +96,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // Determines the ports and protocols based on being served over TLS. function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } // Base configuration to extend in providing specific tech failover configurations. diff --git a/src/page/test/subscribeVideoMute/index.js b/src/page/test/subscribeVideoMute/index.js index 5a9e8a018..fcabdf7c0 100644 --- a/src/page/test/subscribeVideoMute/index.js +++ b/src/page/test/subscribeVideoMute/index.js @@ -74,7 +74,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var resolutionField = document.getElementById('resolution-field') var protocol = serverSettings.protocol - var isSecure = protocol === 'https' var bitrate = 0 var packetsReceived = 0 @@ -101,9 +100,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // Determines the ports and protocols based on being served over TLS. function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } // Base configuration to extend in providing specific tech failover configurations. diff --git a/src/page/test/subscribeWHEP/index.js b/src/page/test/subscribeWHEP/index.js index 2d91cecef..f3ce4e66b 100644 --- a/src/page/test/subscribeWHEP/index.js +++ b/src/page/test/subscribeWHEP/index.js @@ -71,7 +71,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. const resolutionField = document.getElementById('resolution-field') const protocol = serverSettings.protocol - const isSecure = protocol === 'https' let bitrate = 0 let packetsReceived = 0 @@ -99,9 +98,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // Determines the ports and protocols based on being served over TLS. const getSocketLocationFromProtocol = () => { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } // Base configuration to extend in providing specific tech failover configurations. diff --git a/src/page/test/subscribeh264/index.js b/src/page/test/subscribeh264/index.js index 31645c0c0..c358e75ad 100644 --- a/src/page/test/subscribeh264/index.js +++ b/src/page/test/subscribeh264/index.js @@ -66,7 +66,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var resolutionField = document.getElementById('resolution-field') var protocol = serverSettings.protocol - var isSecure = protocol === 'https' var bitrate = 0 var packetsReceived = 0 @@ -92,9 +91,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } var defaultConfiguration = (function (useVideo, useAudio) { diff --git a/src/page/test/subscribevp8/index.js b/src/page/test/subscribevp8/index.js index 9fffe166d..83e465767 100644 --- a/src/page/test/subscribevp8/index.js +++ b/src/page/test/subscribevp8/index.js @@ -66,7 +66,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var resolutionField = document.getElementById('resolution-field') var protocol = serverSettings.protocol - var isSecure = protocol === 'https' var bitrate = 0 var packetsReceived = 0 @@ -92,9 +91,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } var defaultConfiguration = (function (useVideo, useAudio) { diff --git a/src/page/test/twoWay/index.js b/src/page/test/twoWay/index.js index 3218ff602..ce968f2c9 100644 --- a/src/page/test/twoWay/index.js +++ b/src/page/test/twoWay/index.js @@ -71,9 +71,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var protocol = serverSettings.protocol var isSecure = protocol === 'https' function getSocketLocationFromProtocol() { - return !isSecure - ? { protocol: 'ws', port: serverSettings.wsport } - : { protocol: 'wss', port: serverSettings.wssport } + return window.getSocketProtocolPort( + protocol, + serverSettings, + configuration.usePortMux + ) } var defaultSubscriberConfiguration = (function (useVideo, useAudio) { diff --git a/static/script/red5pro-utils.js b/static/script/red5pro-utils.js index 4cc9508ca..59cc404e8 100644 --- a/static/script/red5pro-utils.js +++ b/static/script/red5pro-utils.js @@ -334,52 +334,51 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } } -// more robust, synchronous version of authenticate - const authenticate2 = (smHost, smVersion = 'v1', smUser, smPassword) => { - console.log('Request Authentication'); - - const url = `https://${smHost}/as/${smVersion}/auth/login`; - const token = 'Basic ' + btoa(smUser + ':' + smPassword); - const xhr = new XMLHttpRequest(); - - try { - // Open the request as PUT - xhr.open('PUT', url, false); // false makes it synchronous - xhr.withCredentials = true; // Enable cookies - xhr.setRequestHeader('Authorization', token); - xhr.setRequestHeader('Content-Type', 'application/json'); - - // Send the request - xhr.send(); - - const contentType = xhr.getResponseHeader('Content-Type') || ''; - let responseBody; - - // Try parsing the response - try { - responseBody = JSON.parse(xhr.responseText); // Safe JSON parsing - } catch (parseError) { - console.error('Error parsing JSON response:', parseError); - throw new Error(`HTTP ${xhr.status}: JSON parse error`); - } - - // Handle HTTP errors - switch (xhr.status) { - case 200: - console.log('Authentication successful'); - return responseBody.token; // Return the authentication token - case 401: - throw new Error('HTTP 401: Unauthorized'); - default: - throw new Error(`HTTP ${xhr.status}: Unexpected error`); - } - } catch (error) { - // Handle any unexpected network or processing errors - console.error('Error in authenticate:', error); - throw error; // Re-throw for the caller to catch - } - }; - + // more robust, synchronous version of authenticate + const authenticate2 = (smHost, smVersion = 'v1', smUser, smPassword) => { + console.log('Request Authentication') + + const url = `https://${smHost}/as/${smVersion}/auth/login` + const token = 'Basic ' + btoa(smUser + ':' + smPassword) + const xhr = new XMLHttpRequest() + + try { + // Open the request as PUT + xhr.open('PUT', url, false) // false makes it synchronous + xhr.withCredentials = true // Enable cookies + xhr.setRequestHeader('Authorization', token) + xhr.setRequestHeader('Content-Type', 'application/json') + + // Send the request + xhr.send() + + const contentType = xhr.getResponseHeader('Content-Type') || '' + let responseBody + + // Try parsing the response + try { + responseBody = JSON.parse(xhr.responseText) // Safe JSON parsing + } catch (parseError) { + console.error('Error parsing JSON response:', parseError) + throw new Error(`HTTP ${xhr.status}: JSON parse error`) + } + + // Handle HTTP errors + switch (xhr.status) { + case 200: + console.log('Authentication successful') + return responseBody.token // Return the authentication token + case 401: + throw new Error('HTTP 401: Unauthorized') + default: + throw new Error(`HTTP ${xhr.status}: Unexpected error`) + } + } catch (error) { + // Handle any unexpected network or processing errors + console.error('Error in authenticate:', error) + throw error // Re-throw for the caller to catch + } + } /** * Request to get Origin data to broadcast on stream manager proxy. @@ -477,7 +476,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } } - const getProvision = async (host, version, nodeGroup, provisionGuid, token) => { + const getProvision = async ( + host, + version, + nodeGroup, + provisionGuid, + token + ) => { const url = `https://${host}/as/${version}/streams/provision/${nodeGroup}/${provisionGuid}` const result = await fetch(url, { method: 'GET', @@ -580,6 +585,17 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. window.getStreamList = getCompleteStreamList window.getIsStreamAvailable = getIsStreamAvailable + window.getSocketProtocolPort = (httpProtocol, settings, portMux = NaN) => { + const { wsport, wssport } = settings + const protocol = httpProtocol || window.location.protocol + const isSecure = protocol.match(/^https/) + return { + protocol: isSecure ? 'wss' : 'ws', + port: + !portMux || isNaN(portMux) ? (isSecure ? wssport : wsport) : portMux, + } + } + window.isEmpty = function (str) { return (str && str.length === 0) || !str } diff --git a/static/script/testbed-config.js b/static/script/testbed-config.js index b78445a19..6a016eb2c 100644 --- a/static/script/testbed-config.js +++ b/static/script/testbed-config.js @@ -152,6 +152,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. mixerBackendSocketField: '', mixerAuthenticationEnabled: false, preferWhipWhep: true, + usePortMux: NaN, } /**