From 8d825346abd8fec488e0107efda7997eba3b2c2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=B2=D0=B3=D0=B5=D0=BD=D0=B8=D0=B9?= Date: Fri, 12 Apr 2024 08:50:11 +0300 Subject: [PATCH 1/7] fix ivideon source --- pkg/ivideon/client.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/ivideon/client.go b/pkg/ivideon/client.go index 0158f08d..c1b055b8 100644 --- a/pkg/ivideon/client.go +++ b/pkg/ivideon/client.go @@ -132,6 +132,9 @@ func (c *Client) Handle() error { case "stream-init": continue + case "metadata": + continue + case "fragment": _, data, err = c.conn.ReadMessage() if err != nil { @@ -183,6 +186,9 @@ func (c *Client) getTracks() error { } switch msg.Type { + case "metadata": + continue + case "stream-init": s := msg.CodecString i := strings.IndexByte(s, '.') From adf49b8475a5fd7db47682a223b434066a741b24 Mon Sep 17 00:00:00 2001 From: Sergey Krashevich Date: Sun, 14 Apr 2024 21:55:22 +0300 Subject: [PATCH 2/7] feat(logging): more usable exec log --- internal/exec/exec.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/exec/exec.go b/internal/exec/exec.go index 36dacfaa..6bc5698a 100644 --- a/internal/exec/exec.go +++ b/internal/exec/exec.go @@ -7,6 +7,7 @@ import ( "fmt" "os" "os/exec" + "strings" "sync" "time" @@ -108,7 +109,7 @@ func handleRTSP(url, path string, cmd *exec.Cmd) (core.Producer, error) { waitersMu.Unlock() }() - log.Debug().Str("url", url).Msg("[exec] run") + log.Debug().Str("url", url).Str("cmd", fmt.Sprintf("%s", strings.Join(cmd.Args, " "))).Msg("[exec] run") ts := time.Now() From 936e84f6e0caa7f3c741268995f10adb6081d3b2 Mon Sep 17 00:00:00 2001 From: Sergey Krashevich Date: Fri, 22 Mar 2024 16:44:48 +0300 Subject: [PATCH 3/7] feat(index.html): implement auto-reload functionality every 5 seconds --- www/index.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/www/index.html b/www/index.html index 4e4f9992..610f033a 100644 --- a/www/index.html +++ b/www/index.html @@ -143,6 +143,9 @@ }); } + // Auto-reload every 5 seconds + setInterval(reload, 5000); + const url = new URL('api', location.href); fetch(url, {cache: 'no-cache'}).then(r => r.json()).then(data => { const info = document.querySelector('.info'); From de7326375dc1de9be797f29214da68c492e573ef Mon Sep 17 00:00:00 2001 From: Sergey Krashevich Date: Thu, 18 Apr 2024 02:41:46 +0300 Subject: [PATCH 4/7] feat(index.html): optimize stream list update and preserve checkbox states --- www/index.html | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/www/index.html b/www/index.html index 610f033a..9af39bdf 100644 --- a/www/index.html +++ b/www/index.html @@ -121,33 +121,51 @@ function reload() { const url = new URL('api/streams', location.href); + const checkboxStates = {}; + tbody.querySelectorAll('input[type="checkbox"][name]').forEach(checkbox => { + checkboxStates[checkbox.name] = checkbox.checked; + }); fetch(url, {cache: 'no-cache'}).then(r => r.json()).then(data => { - tbody.innerHTML = ''; + const existingIds = Array.from(tbody.querySelectorAll('tr')).map(tr => tr.dataset['id']); + const fetchedIds = []; for (const [key, value] of Object.entries(data)) { const name = key.replace(/[<">]/g, ''); // sanitize + fetchedIds.push(name); + + let tr = tbody.querySelector(`tr[data-id="${name}"]`); const online = value && value.consumers ? value.consumers.length : 0; const src = encodeURIComponent(name); - const links = templates.map(link => { - return link.replace('{name}', src); - }).join(' '); + const links = templates.map(link => link.replace('{name}', src)).join(' '); - const tr = document.createElement('tr'); - tr.dataset['id'] = name; + if (!tr) { + tr = document.createElement('tr'); + tr.dataset['id'] = name; + tbody.appendChild(tr); + } + + const isChecked = checkboxStates[name] ? 'checked' : ''; tr.innerHTML = - `` + + `` + `${online} / info` + `${links}`; - tbody.appendChild(tr); } + + // Remove old rows + existingIds.forEach(id => { + if (!fetchedIds.includes(id)) { + const trToRemove = tbody.querySelector(`tr[data-id="${id}"]`); + tbody.removeChild(trToRemove); + } + }); }); } // Auto-reload every 5 seconds setInterval(reload, 5000); - const url = new URL('api', location.href); - fetch(url, {cache: 'no-cache'}).then(r => r.json()).then(data => { + const url2 = new URL('api', location.href); + fetch(url2, {cache: 'no-cache'}).then(r => r.json()).then(data => { const info = document.querySelector('.info'); info.innerText = `Version: ${data.version}, Config: ${data.config_path}`; }); From 5cf343cb691ba43345d9fb9dc10e655dc4f3b8c5 Mon Sep 17 00:00:00 2001 From: Sergey Krashevich Date: Thu, 18 Apr 2024 02:56:32 +0300 Subject: [PATCH 5/7] feat(autoreload): change interval from 5 seconds to 1 second --- www/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/index.html b/www/index.html index 9af39bdf..35c4606d 100644 --- a/www/index.html +++ b/www/index.html @@ -161,8 +161,8 @@ }); } - // Auto-reload every 5 seconds - setInterval(reload, 5000); + // Auto-reload + setInterval(reload, 1000); const url2 = new URL('api', location.href); fetch(url2, {cache: 'no-cache'}).then(r => r.json()).then(data => { From 8495c7350e1d0363db485182da911313745e61c3 Mon Sep 17 00:00:00 2001 From: Alex X Date: Sat, 20 Apr 2024 11:47:03 +0300 Subject: [PATCH 6/7] Add Arch dist to readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index aaed9410..4bc74af7 100644 --- a/README.md +++ b/README.md @@ -1352,6 +1352,7 @@ streams: **Distributions** - [Alpine Linux](https://pkgs.alpinelinux.org/packages?name=go2rtc) +- [Arch User Repository](https://linux-packages.com/aur/package/go2rtc) - [Gentoo](https://github.com/inode64/inode64-overlay/tree/main/media-video/go2rtc) - [NixOS](https://search.nixos.org/packages?query=go2rtc) - [Proxmox Helper Scripts](https://tteck.github.io/Proxmox/) From 166287ce1b7c64509106af1689369568c63e53f4 Mon Sep 17 00:00:00 2001 From: Alex X Date: Sat, 20 Apr 2024 11:57:48 +0300 Subject: [PATCH 7/7] Rename constant back to old name --- www/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/index.html b/www/index.html index 35c4606d..a3015acf 100644 --- a/www/index.html +++ b/www/index.html @@ -164,8 +164,8 @@ // Auto-reload setInterval(reload, 1000); - const url2 = new URL('api', location.href); - fetch(url2, {cache: 'no-cache'}).then(r => r.json()).then(data => { + const url = new URL('api', location.href); + fetch(url, {cache: 'no-cache'}).then(r => r.json()).then(data => { const info = document.querySelector('.info'); info.innerText = `Version: ${data.version}, Config: ${data.config_path}`; });