mirror of
https://github.com/aler9/rtsp-simple-server
synced 2025-09-26 19:51:26 +08:00
This should decrease the delay before WebRTC sessions are marked as closed.
This commit is contained in:
@@ -161,6 +161,7 @@ const video = document.getElementById('video');
|
||||
const controls = document.getElementById('controls');
|
||||
const message = document.getElementById('message');
|
||||
const publishButton = document.getElementById('publish-button');
|
||||
let publisher = null;
|
||||
|
||||
const videoForm = {
|
||||
device: document.getElementById('video-device'),
|
||||
@@ -185,7 +186,7 @@ const setMessage = (str) => {
|
||||
const onStream = (stream) => {
|
||||
video.srcObject = stream;
|
||||
|
||||
new MediaMTXWebRTCPublisher({
|
||||
publisher = new MediaMTXWebRTCPublisher({
|
||||
url: new URL('whip', window.location.href) + window.location.search,
|
||||
stream,
|
||||
videoCodec: videoForm.codec.value,
|
||||
@@ -421,6 +422,12 @@ window.addEventListener('load', () => {
|
||||
populateOptions();
|
||||
});
|
||||
|
||||
window.addEventListener('beforeunload', () => {
|
||||
if (publisher !== null) {
|
||||
publisher.close();
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
@@ -49,6 +49,7 @@ html, body {
|
||||
const video = document.getElementById('video');
|
||||
const message = document.getElementById('message');
|
||||
let defaultControls = false;
|
||||
let reader = null;
|
||||
|
||||
const setMessage = (str) => {
|
||||
if (str !== '') {
|
||||
@@ -83,7 +84,7 @@ const loadAttributesFromQuery = () => {
|
||||
window.addEventListener('load', () => {
|
||||
loadAttributesFromQuery();
|
||||
|
||||
new MediaMTXWebRTCReader({
|
||||
reader = new MediaMTXWebRTCReader({
|
||||
url: new URL('whep', window.location.href) + window.location.search,
|
||||
onError: (err) => {
|
||||
setMessage(err);
|
||||
@@ -95,6 +96,12 @@ window.addEventListener('load', () => {
|
||||
});
|
||||
});
|
||||
|
||||
window.addEventListener('beforeunload', () => {
|
||||
if (reader !== null) {
|
||||
reader.close();
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
Reference in New Issue
Block a user