Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/page/sm-test/castlabsStreamManagerProxy/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<p class="centered info-title">Encrypted Playback</p>
</div>
<video id="red5pro-encrypted"
style="background-color: black;"
controls="controls" autoplay="autoplay" playsinline
class="red5pro-subscriber"
width="320" height="240">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
margin: 0!important;
}
</style>
<link rel="stylesheet" href="../../css/modal.css" />
<style>
.modal {
display: unset!important;
}
</style>
</head>
<body>
{{> top-bar }}
Expand Down
22 changes: 20 additions & 2 deletions src/page/sm-test/publishStreamManagerProxyScreenShare/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ NONINFRINGEMENT. IN NO EVENT SHALL INFRARED5, INC. BE LIABLE FOR ANY CLAIM,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
;(function (window, document, red5prosdk) {
;(function (window, document, red5prosdk, showModal) {
'use strict'

var configuration = (function () {
Expand Down Expand Up @@ -211,6 +211,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data: error.message,
})
}
return null
}

const getConfiguration = () => {
Expand Down Expand Up @@ -265,6 +266,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
publisher.on('*', onPublisherEvent)
await publisher.initWithStream(config, stream)
await publisher.publish()
const [videoTrack] = stream.getVideoTracks()
videoTrack.onended = async () => {
if (targetPublisher) {
unpublish(targetPublisher)
Comment on lines +270 to +272
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No null check for videoTrack before accessing onended. If getVideoTracks() returns an empty array, this will throw an error when trying to set onended on undefined.

Suggested change
videoTrack.onended = async () => {
if (targetPublisher) {
unpublish(targetPublisher)
if (videoTrack) {
videoTrack.onended = async () => {
if (targetPublisher) {
unpublish(targetPublisher)
}

Copilot uses AI. Check for mistakes.
}
}
onPublishSuccess(publisher)
streamTitle.innerText = stream1
targetPublisher = publisher
Expand Down Expand Up @@ -301,6 +308,17 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
const startup = async () => {
// Kick off.
const stream = await capture()
if (!stream) {
var content = document.createElement('div')
content.style = 'text-align: center;'
content.innerHTML = `
<p>Failed to capture screen share.</p>
<br/>
<p>If on a Mobile browser, this capability is not available.</p>
`
showModal(content)
return
}
await setupPublisher(stream)
}

Expand All @@ -322,4 +340,4 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
}
window.addEventListener('pagehide', shutdown)
window.addEventListener('beforeunload', shutdown)
})(this, document, window.red5prosdk)
})(this, document, window.red5prosdk, window.showModal)
1 change: 1 addition & 0 deletions src/page/test/castlabs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<p class="centered info-title">Encrypted Playback</p>
</div>
<video id="red5pro-encrypted"
style="background-color: black;"
controls="controls" autoplay="autoplay" playsinline
class="red5pro-subscriber"
width="320" height="240">
Expand Down
6 changes: 6 additions & 0 deletions src/page/test/publishScreenShare/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
margin: 0!important;
}
</style>
<link rel="stylesheet" href="../../css/modal.css" />
<style>
.modal {
display: unset!important;
}
</style>
</head>
<body>
{{> top-bar }}
Expand Down
22 changes: 20 additions & 2 deletions src/page/test/publishScreenShare/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// Chrome & Firefox
;(function (window, document, red5prosdk) {
;(function (window, document, red5prosdk, showModal) {
'use strict'

var configuration = (function () {
Expand Down Expand Up @@ -75,6 +75,17 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

captureButton.addEventListener('click', async () => {
const stream = await capture()
if (!stream) {
var content = document.createElement('div')
content.style = 'text-align: center;'
content.innerHTML = `
<p>Failed to capture screen share.</p>
<br/>
<p>If on a Mobile browser, this capability is not available.</p>
`
showModal(content)
return
}
setupPublisher(stream)
})

Expand Down Expand Up @@ -201,6 +212,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data: error.message,
})
}
return null
}

function unpublish(publisher) {
Expand Down Expand Up @@ -253,6 +265,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
return targetPublisher.publish()
})
.then(function () {
const [videoTrack] = mediaStream.getVideoTracks()
videoTrack.onended = async () => {
if (targetPublisher) {
unpublish(targetPublisher)
Comment on lines +269 to +271
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No null check for videoTrack before accessing onended. If getVideoTracks() returns an empty array, this will throw an error when trying to set onended on undefined.

Suggested change
videoTrack.onended = async () => {
if (targetPublisher) {
unpublish(targetPublisher)
if (videoTrack) {
videoTrack.onended = async () => {
if (targetPublisher) {
unpublish(targetPublisher)
}

Copilot uses AI. Check for mistakes.
}
}
onPublishSuccess(targetPublisher)
})
.catch(function (error) {
Expand Down Expand Up @@ -285,4 +303,4 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
}
window.addEventListener('pagehide', shutdown)
window.addEventListener('beforeunload', shutdown)
})(this, document, window.red5prosdk)
})(this, document, window.red5prosdk, window.showModal)
20 changes: 20 additions & 0 deletions static/script/red5pro-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -705,4 +705,24 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
window.exposeSubscriberGlobally = function (subscriber) {
window.r5pro_subscriber = subscriber
}

window.showModal = (content) => {
const div = document.createElement('div');
div.classList.add('modal');
const container = document.createElement('div');
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The container element lacks CSS classes or styling which may cause layout issues. Consider adding appropriate CSS classes for proper modal structure.

Suggested change
const container = document.createElement('div');
const container = document.createElement('div');
container.classList.add('modal-container');

Copilot uses AI. Check for mistakes.
const button = document.createElement('a');
const close = document.createTextNode('close');
button.href = "#";
button.appendChild(close);
button.classList.add('modal-close');
container.appendChild(button);
container.appendChild(content);
div.appendChild(container);
document.body.appendChild(div);
button.addEventListener('click', (event) => {
event.preventDefault();
document.body.removeChild(div);
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removeChild call could throw an error if the element has already been removed from the DOM. Consider using div.remove() or checking if the parent exists before removal.

Suggested change
document.body.removeChild(div);
div.remove();

Copilot uses AI. Check for mistakes.
return false;
});
}
})(this)