Merge remote-tracking branch 'upstream/master' into logs-reverse-order

This commit is contained in:
Sergey Krashevich
2024-04-20 13:55:32 +03:00
11 changed files with 203 additions and 94 deletions

View File

@@ -1352,6 +1352,7 @@ streams:
**Distributions** **Distributions**
- [Alpine Linux](https://pkgs.alpinelinux.org/packages?name=go2rtc) - [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) - [Gentoo](https://github.com/inode64/inode64-overlay/tree/main/media-video/go2rtc)
- [NixOS](https://search.nixos.org/packages?query=go2rtc) - [NixOS](https://search.nixos.org/packages?query=go2rtc)
- [Proxmox Helper Scripts](https://tteck.github.io/Proxmox/) - [Proxmox Helper Scripts](https://tteck.github.io/Proxmox/)

View File

@@ -1,8 +1,9 @@
# syntax=docker/dockerfile:labs # syntax=docker/dockerfile:labs
# 0. Prepare images # 0. Prepare images
# only debian 12 (bookworm) has latest ffmpeg # only debian 13 (trixie) has latest ffmpeg
ARG DEBIAN_VERSION="bookworm-slim" # https://packages.debian.org/trixie/ffmpeg
ARG DEBIAN_VERSION="trixie-slim"
ARG GO_VERSION="1.21-bookworm" ARG GO_VERSION="1.21-bookworm"
ARG NGROK_VERSION="3" ARG NGROK_VERSION="3"
@@ -44,13 +45,16 @@ RUN rm -f /etc/apt/apt.conf.d/docker-clean \
# Install ffmpeg, bash (for run.sh), tini (for signal handling), # Install ffmpeg, bash (for run.sh), tini (for signal handling),
# and other common tools for the echo source. # and other common tools for the echo source.
# non-free for Intel QSV support (not used by go2rtc, just for tests) # non-free for Intel QSV support (not used by go2rtc, just for tests)
# mesa-va-drivers for AMD APU
# libasound2-plugins for ALSA support # libasound2-plugins for ALSA support
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked --mount=type=cache,target=/var/lib/apt,sharing=locked \ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked --mount=type=cache,target=/var/lib/apt,sharing=locked \
echo 'deb http://deb.debian.org/debian bookworm non-free' > /etc/apt/sources.list.d/debian-non-free.list && \ echo 'deb http://deb.debian.org/debian trixie non-free' > /etc/apt/sources.list.d/debian-non-free.list && \
apt-get -y update && apt-get -y install tini ffmpeg \ apt-get -y update && apt-get -y install tini ffmpeg \
python3 curl jq \ python3 curl jq \
intel-media-va-driver-non-free \ intel-media-va-driver-non-free \
libasound2-plugins mesa-va-drivers \
libasound2-plugins && \
apt-get clean && rm -rf /var/lib/apt/lists/*
COPY --link --from=rootfs / / COPY --link --from=rootfs / /

View File

@@ -7,6 +7,7 @@ import (
"fmt" "fmt"
"os" "os"
"os/exec" "os/exec"
"strings"
"sync" "sync"
"time" "time"
@@ -108,7 +109,7 @@ func handleRTSP(url, path string, cmd *exec.Cmd) (core.Producer, error) {
waitersMu.Unlock() 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() ts := time.Now()

View File

@@ -73,9 +73,6 @@ func (t *Receiver) Replace(target *Receiver) {
// move this receiver senders to new receiver // move this receiver senders to new receiver
t.mu.Lock() t.mu.Lock()
senders := t.senders senders := t.senders
// fix https://github.com/AlexxIT/go2rtc/issues/828
// TODO: fix the reason, not the consequence
t.senders = nil
t.mu.Unlock() t.mu.Unlock()
target.mu.Lock() target.mu.Lock()

View File

@@ -132,6 +132,9 @@ func (c *Client) Handle() error {
case "stream-init": case "stream-init":
continue continue
case "metadata":
continue
case "fragment": case "fragment":
_, data, err = c.conn.ReadMessage() _, data, err = c.conn.ReadMessage()
if err != nil { if err != nil {
@@ -183,6 +186,9 @@ func (c *Client) getTracks() error {
} }
switch msg.Type { switch msg.Type {
case "metadata":
continue
case "stream-init": case "stream-init":
s := msg.CodecString s := msg.CodecString
i := strings.IndexByte(s, '.') i := strings.IndexByte(s, '.')

View File

@@ -219,6 +219,9 @@ func (c *Conn) SetupMedia(media *core.Media) (byte, error) {
rawURL += "/" rawURL += "/"
} }
rawURL += media.ID rawURL += media.ID
} else if strings.HasPrefix(rawURL, "rtsp://rtsp://") {
// fix https://github.com/AlexxIT/go2rtc/issues/830
rawURL = rawURL[7:]
} }
trackURL, err := urlParse(rawURL) trackURL, err := urlParse(rawURL)
if err != nil { if err != nil {

View File

@@ -5,11 +5,6 @@
<meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1, maximum-scale=1"> <meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1, maximum-scale=1">
<meta http-equiv="X-UA-Compatible" content="ie=edge"> <meta http-equiv="X-UA-Compatible" content="ie=edge">
<style> <style>
body {
font-family: Arial, Helvetica, sans-serif;
background-color: white;
}
body { body {
margin: 0; margin: 0;
padding: 0; padding: 0;
@@ -27,33 +22,11 @@
padding: 10px; padding: 10px;
} }
table {
background-color: white;
text-align: left;
border-collapse: collapse;
}
table td, table th {
border: 1px solid black;
padding: 5px 5px;
}
table tbody td { table tbody td {
font-size: 13px; font-size: 13px;
} }
table thead {
background: #CFCFCF;
background: linear-gradient(to bottom, #dbdbdb 0%, #d3d3d3 66%, #CFCFCF 100%);
border-bottom: 3px solid black;
}
table thead th {
font-size: 15px;
font-weight: bold;
color: black;
text-align: center;
}
</style> </style>
</head> </head>
<body> <body>

View File

@@ -8,39 +8,18 @@
<title>go2rtc</title> <title>go2rtc</title>
<style> <style>
body { body {
font-family: Arial, Helvetica, sans-serif; margin: 0;
background-color: white; padding: 0;
} display: flex;
flex-direction: column;
table {
background-color: white;
text-align: left;
border-collapse: collapse;
}
table td, table th {
border: 1px solid black;
padding: 5px 5px;
} }
table tbody td { table tbody td {
font-size: 13px; font-size: 13px;
} }
table thead {
background: #CFCFCF;
background: linear-gradient(to bottom, #dbdbdb 0%, #d3d3d3 66%, #CFCFCF 100%);
border-bottom: 3px solid black;
}
table thead th {
font-size: 15px;
font-weight: bold;
color: black;
text-align: center;
}
label { label {
display: flex; display: flex;
align-items: center; align-items: center;
@@ -121,28 +100,49 @@
function reload() { function reload() {
const url = new URL('api/streams', location.href); 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 => { 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)) { for (const [key, value] of Object.entries(data)) {
const name = key.replace(/[<">]/g, ''); // sanitize 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 online = value && value.consumers ? value.consumers.length : 0;
const src = encodeURIComponent(name); const src = encodeURIComponent(name);
const links = templates.map(link => { const links = templates.map(link => link.replace('{name}', src)).join(' ');
return link.replace('{name}', src);
}).join(' ');
const tr = document.createElement('tr'); if (!tr) {
tr.dataset['id'] = name; tr = document.createElement('tr');
tr.dataset['id'] = name;
tbody.appendChild(tr);
}
const isChecked = checkboxStates[name] ? 'checked' : '';
tr.innerHTML = tr.innerHTML =
`<td><label><input type="checkbox" name="${name}">${name}</label></td>` + `<td><label><input type="checkbox" name="${name}" ${isChecked}>${name}</label></td>` +
`<td><a href="api/streams?src=${src}">${online} / info</a></td>` + `<td><a href="api/streams?src=${src}">${online} / info</a></td>` +
`<td>${links}</td>`; `<td>${links}</td>`;
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
setInterval(reload, 1000);
const url = new URL('api', location.href); const url = new URL('api', location.href);
fetch(url, {cache: 'no-cache'}).then(r => r.json()).then(data => { fetch(url, {cache: 'no-cache'}).then(r => r.json()).then(data => {
const info = document.querySelector('.info'); const info = document.querySelector('.info');

View File

@@ -5,10 +5,6 @@
<meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1, maximum-scale=1"> <meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1, maximum-scale=1">
<meta http-equiv="X-UA-Compatible" content="ie=edge"> <meta http-equiv="X-UA-Compatible" content="ie=edge">
<style> <style>
body {
font-family: Arial, Helvetica, sans-serif;
background-color: white;
}
body { body {
margin: 0; margin: 0;

View File

@@ -19,34 +19,17 @@
height: 100%; height: 100%;
} }
table {
background-color: white;
text-align: left;
border-collapse: collapse;
}
table td, table th {
border: 1px solid black;
padding: 5px 5px;
}
table tbody td { table tbody td {
font-size: 13px; font-size: 13px;
vertical-align: top; vertical-align: top;
} }
table thead {
background: #CFCFCF;
background: linear-gradient(to bottom, #dbdbdb 0%, #d3d3d3 66%, #CFCFCF 100%);
border-bottom: 3px solid black;
}
table thead th {
font-size: 15px;
font-weight: bold;
color: black;
text-align: center;
}
</style> </style>
</head> </head>
<body> <body>

View File

@@ -18,7 +18,6 @@ i {
nav { nav {
display: block; display: block;
/*width: 660px;*/
margin: 0 auto 10px; margin: 0 auto 10px;
} }
@@ -41,6 +40,97 @@ nav a:hover {
nav li { nav li {
display: inline; display: inline;
} }
body {
font-family: Arial, Helvetica, sans-serif;
background-color: white;
}
table {
background-color: white;
text-align: left;
border-collapse: collapse;
}
table thead {
background: #CFCFCF;
background: linear-gradient(to bottom, #dbdbdb 0%, #d3d3d3 66%, #CFCFCF 100%);
border-bottom: 3px solid black;
}
table thead th {
font-size: 15px;
font-weight: bold;
color: black;
text-align: center;
}
table td, table th {
border: 1px solid black;
padding: 5px 5px;
}
/* Dark mode styles */
body.dark-mode {
background-color: #121212;
color: #e0e0e0;
}
body.dark-mode nav ul {
background: #333;
}
body.dark-mode a {
background: rgba(45, 45, 45, .8);
border-right: 1px solid #2c2c2c;
color: #c7c7c7;
}
body.dark-mode a:hover {
background: #555;
}
body.dark-mode a:visited {
color: #999;
}
body.dark-mode table {
background-color: #222;
color: #ddd;
}
body.dark-mode table thead {
background: linear-gradient(to bottom, #444 0%, #3d3d3d 66%, #333 100%);
border-bottom: 3px solid #888;
}
body.dark-mode table thead th {
font-size: 15px;
font-weight: bold;
color: #ddd;
text-align: center;
}
body.dark-mode table td, body.dark-mode table th {
border: 1px solid #444;
}
body.dark-mode button {
background: rgba(255, 255, 255, .1);
border: 1px solid #444;
color: #ccc;
}
body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
background-color: #333;
color: #e0e0e0;
border: 1px solid #444;
}
body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
color: #bbb;
}
body.dark-mode hr {
border-top: 1px solid #444;
}
</style> </style>
<nav> <nav>
<ul> <ul>
@@ -48,6 +138,61 @@ nav li {
<li><a href="add.html">Add</a></li> <li><a href="add.html">Add</a></li>
<li><a href="editor.html">Config</a></li> <li><a href="editor.html">Config</a></li>
<li><a href="log.html">Log</a></li> <li><a href="log.html">Log</a></li>
<li><a href="#" id="darkModeToggle">
&#127769;
</a>
</li>
</ul> </ul>
</nav> </nav>
` + document.body.innerHTML; ` + document.body.innerHTML;
const sunIcon = '&#9728;&#65039;';
const moonIcon = '&#127765;';
document.addEventListener('DOMContentLoaded', () => {
const darkModeToggle = document.getElementById('darkModeToggle');
const prefersDarkScheme = window.matchMedia('(prefers-color-scheme: dark)');
const isDarkModeEnabled = () => document.body.classList.contains('dark-mode');
// Update the toggle button based on the dark mode state
const updateToggleButton = () => {
if (isDarkModeEnabled()) {
darkModeToggle.innerHTML = sunIcon;
darkModeToggle.setAttribute('aria-label', 'Enable light mode');
} else {
darkModeToggle.innerHTML = moonIcon;
darkModeToggle.setAttribute('aria-label', 'Enable dark mode');
}
};
const updateDarkMode = () => {
if (localStorage.getItem('darkMode') === 'enabled' || prefersDarkScheme.matches && localStorage.getItem('darkMode') !== 'disabled') {
document.body.classList.add('dark-mode');
} else {
document.body.classList.remove('dark-mode');
}
updateEditorTheme();
updateToggleButton();
};
// Update the editor theme based on the dark mode state
const updateEditorTheme = () => {
if (typeof editor !== 'undefined') {
editor.setTheme(isDarkModeEnabled() ? "ace/theme/tomorrow_night_eighties" : "ace/theme/github"); }
};
// Initial update for dark mode and toggle button
updateDarkMode();
// Listen for changes in the system's color scheme preference
prefersDarkScheme.addEventListener('change', updateDarkMode); // Modern approach
// Toggle dark mode and update local storage on button click
darkModeToggle.addEventListener('click', () => {
const enabled = document.body.classList.toggle('dark-mode');
localStorage.setItem('darkMode', enabled ? 'enabled' : 'disabled');
updateToggleButton(); // Update the button after toggling
updateEditorTheme();
});
});