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 0a324269..1839923b 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 ce985598..156e81dc 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 3cc8da51..b257e069 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 02f1378e..67cae5a7 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 99653731..d84beec1 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 ea118f1f..bb19c6c3 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 f4895177..52c97a0d 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 b31eef7a..7fdbf6cc 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 ee8cdf1a..8cc4d3ee 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 9bd9fdf6..12607316 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 5605a0e5..4d72be1e 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 89eb8411..878bb37b 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 04803b29..0986cd6b 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 6ce86d1c..09174836 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 d7a4f67e..151f94b1 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 79617760..4d6a1c41 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 9ce179ed..af2c807a 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 79147e20..f867ca2f 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 d0fee016..a7f606ab 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 6f490240..4586c063 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 3af5bfca..8cb05e91 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 d39ce62e..a9a5ec24 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 fa9d5bfb..b5461ab0 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 912f8659..6ceeb7e5 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 ed5cb656..445965b4 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 43fc0ef7..b595ea71 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 890f9e0b..bd44f768 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 218b2edb..ba6731e7 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 4c22d6de..77009327 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 a5b69940..382739b4 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 71ffdb8d..08a7f631 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 c1c2f0ff..6f72965c 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 cbef89f6..494e9316 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 4a85b1f9..2071950c 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 e2906446..ddb8e592 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 ee0499fa..2ec6c6de 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 3ec72ccc..5312261a 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 32839757..97a2f5f6 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 f6c96079..784399be 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 a6f79e84..aadc44aa 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 26e49844..af4f651a 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 00935e70..7e120f1a 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 aa9687cb..bade021f 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 8a211a4f..73dddaaf 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 3322bb4b..0400a53f 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 5c896ee5..c35b4a8d 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 9de603a6..ec763e29 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 9236bc36..33f28308 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 ea33b425..2210dbda 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 443fb706..c08c0a48 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 8453fdef..2c759aee 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 ac4b8cc7..c377c260 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 68d30a92..f3a67146 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 4f3df7d3..31f29da2 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 039e6fb4..a327cc9e 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 c73fa6b7..37b77736 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 851ab4fa..52c3e5a5 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 b99d679b..3c109410 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 f972454e..5193005d 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 fe198cc9..201e99ab 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 cfed71b5..d41a6c37 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 7306efda..6402a842 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 5a9e8a01..fcabdf7c 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 2d91cece..f3ce4e66 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 31645c0c..c358e75a 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 9fffe166..83e46576 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 3218ff60..ce968f2c 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 4cc9508c..59cc404e 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 b78445a1..6a016eb2 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, } /**