Browse channels before tuning and contain Tunarr memory usage

This commit is contained in:
Josh
2026-11-13 12:47:48 -05:00
parent 737c0f0c0c
commit f84c943438
7 changed files with 82 additions and 33 deletions

View File

@@ -5,6 +5,8 @@ RETROTV_NAME=retroLabs
RETROTV_MEDIA_DIR=./data/media RETROTV_MEDIA_DIR=./data/media
TUNARR_LOOPBACK_PORT=14242 TUNARR_LOOPBACK_PORT=14242
TUNARR_CPUS=2 TUNARR_CPUS=2
TUNARR_MEMORY_LIMIT=2800m
TUNARR_SESSION_STALENESS_MS=15000
# NWS point coordinates, latitude and longitude. Leave blank to disable. # NWS point coordinates, latitude and longitude. Leave blank to disable.
RETROTV_WEATHER_POINT= RETROTV_WEATHER_POINT=

View File

@@ -26,7 +26,7 @@ docker compose ps
docker compose logs -f bridge tunarr docker compose logs -f bridge tunarr
``` ```
Use `http://<LAN-IP>:4242/web/` for the programming UI and `/api/v1/health` for the bridge health check. Tunarr's internal port 8000 is published only on host loopback port 14242. The bridge uses host networking for SSDP on UDP 1900 and binds HTTP to the configured LAN IP. Admin and device access currently share the trusted LAN with no bridge-level authentication. Compose persists Tunarr's configuration and the bridge's UUID in named volumes. Tunarr defaults to two CPU cores of capacity to limit the impact of scans and transcoding on the host. Set `TUNARR_CPUS` in `.env` to change the limit. Use `http://<LAN-IP>:4242/web/` for the programming UI and `/api/v1/health` for the bridge health check. Tunarr's internal port 8000 is published only on host loopback port 14242. The bridge uses host networking for SSDP on UDP 1900 and binds HTTP to the configured LAN IP. Admin and device access currently share the trusted LAN with no bridge-level authentication. Compose persists Tunarr's configuration and the bridge's UUID in named volumes. Tunarr defaults to two CPU cores of capacity to limit the impact of scans and transcoding on the host. Set `TUNARR_CPUS` in `.env` to change the limit. Tunarr also defaults to a 2800 MiB memory cap without container swap to contain memory pressure during concurrent streams. Set `TUNARR_MEMORY_LIMIT` to adjust it. Idle HLS connections become eligible for cleanup after 15 seconds, with Tunarr checking on its scheduled cleanup pass.
## NVIDIA transcoding on this host ## NVIDIA transcoding on this host

View File

@@ -2,10 +2,13 @@ services:
tunarr: tunarr:
image: ghcr.io/chrisbenincasa/tunarr:2026.11.2@sha256:50919e89db8c60f7fe9f3561f84ef77fb5710ccaac5db5599e9b9993c519dea9 image: ghcr.io/chrisbenincasa/tunarr:2026.11.2@sha256:50919e89db8c60f7fe9f3561f84ef77fb5710ccaac5db5599e9b9993c519dea9
cpus: ${TUNARR_CPUS:-2} cpus: ${TUNARR_CPUS:-2}
mem_limit: ${TUNARR_MEMORY_LIMIT:-2800m}
memswap_limit: ${TUNARR_MEMORY_LIMIT:-2800m}
restart: unless-stopped restart: unless-stopped
environment: environment:
TZ: America/New_York TZ: America/New_York
TUNARR_SERVER_TRUST_PROXY: "true" TUNARR_SERVER_TRUST_PROXY: "true"
TUNARR_SESSION_STALENESS_MS: ${TUNARR_SESSION_STALENESS_MS:-15000}
ports: ports:
- "127.0.0.1:${TUNARR_LOOPBACK_PORT:-14242}:8000" - "127.0.0.1:${TUNARR_LOOPBACK_PORT:-14242}:8000"
volumes: volumes:

View File

@@ -17,12 +17,11 @@ On first launch, the app searches for the bridge. If multicast discovery is
unavailable, select **Enter server address** and enter the bridge host's LAN unavailable, select **Enter server address** and enter the bridge host's LAN
IP or hostname. Use `IP:port` if the bridge uses a port other than `4242`. IP or hostname. Use `IP:port` if the bridge uses a port other than `4242`.
- **Up / Down** tunes the previous or next channel. - **Up / Down** opens the guide on the adjacent channel. In the guide, it moves the highlight without tuning.
- **OK** shows the banner or retries a failed channel. - **OK** tunes the highlighted channel in the guide. During playback it shows the banner or retries a failed channel.
- **Left / Replay** returns to the last channel. - **Left / Replay** returns to the last channel.
- **Star** opens the program guide, channel refresh, and server selection. - **Star** opens the guide. Press it from the guide for channel refresh and server selection.
- **Back** closes the guide or menu, then exits from the tuner. - **Back** closes the guide or menu, then exits from the tuner.
The guide shows current and upcoming titles. The weather channel is a native The app opens on the guide. The details pane shows current and upcoming titles for the highlighted channel. Channel 99 displays local weather. Playback starts from the live HLS playlist supplied by the bridge.
placeholder. Playback starts from the live HLS playlist supplied by the bridge.
SSDP discovery, playback, and live timing require validation on Roku hardware. SSDP discovery, playback, and live timing require validation on Roku hardware.

View File

@@ -1,5 +1,7 @@
sub showPanel(mode as string, title as string, status as string, titles as object) sub showPanel(mode as string, title as string, status as string, titles as object)
m.panelMode = mode m.panelMode = mode
m.guideDetails.visible = false
m.menu.itemSize = [1150, 50]
m.panelTitle.text = title m.panelTitle.text = title
m.panelStatus.text = status m.panelStatus.text = status
content = CreateObject("roSGNode", "ContentNode") content = CreateObject("roSGNode", "ContentNode")
@@ -51,11 +53,12 @@ sub onMenuSelect(event as object)
findServer("", false) findServer("", false)
end if end if
else if m.panelMode = "guide" else if m.panelMode = "guide"
if index < 0 or index >= m.guideIds.Count() then return
id = m.guideIds[index] id = m.guideIds[index]
for i = 0 to m.channels.Count() - 1 for i = 0 to m.channels.Count() - 1
if m.channels[i].id = id if m.channels[i].id = id
closePanel() closePanel()
tune(i) if i <> m.channelIndex then tune(i)
exit for exit for
end if end if
end for end for
@@ -64,42 +67,73 @@ sub onMenuSelect(event as object)
end if end if
end sub end sub
sub openGuide() sub openGuide(offset = 0 as integer)
if m.guideRequest <> invalid if m.guideRequest <> invalid
m.guideRequest.UnobserveFieldScoped("result") m.guideRequest.UnobserveFieldScoped("result")
m.guideRequest.control = "stop" m.guideRequest.control = "stop"
end if end if
m.guideOffset = offset
showPanel("guideLoading", "Program guide", "Loading the schedule…", []) showPanel("guideLoading", "Program guide", "Loading the schedule…", [])
m.guideRequest = startRequest({url: m.server.baseUrl + "/api/v1/guide?hours=3"}, "onGuide") m.guideRequest = startRequest({url: m.server.baseUrl + "/api/v1/guide?hours=3"}, "onGuide")
end sub end sub
sub onGuide(event as object) sub onGuide(event as object)
if m.guideRequest = invalid or not m.guideRequest.IsSameNode(event.GetRoSGNode()) then return
m.guideRequest = invalid m.guideRequest = invalid
if m.panelMode <> "guideLoading" then return if m.panelMode <> "guideLoading" then return
data = event.GetData().data data = event.GetData().data
if data = invalid or GetInterface(data.channels, "ifArray") = invalid if data = invalid or GetInterface(data.channels, "ifArray") = invalid or data.channels.Count() = 0
showPanel("guideError", "Program guide", "Could not load the schedule.", ["Retry"]) showPanel("guideError", "Program guide", "Could not load the schedule.", ["Retry"])
return return
end if end if
syncClock(data.serverTime) syncClock(data.serverTime)
now = currentEpoch()
m.guideIds = [] m.guideIds = []
m.guideChannels = data.channels
titles = [] titles = []
for each channel in data.channels selected = 0
for each channel in m.guideChannels
if m.channelIndex >= 0 and channel.id = m.channels[m.channelIndex].id then selected = titles.Count()
titles.Push(channelLabel(channel))
m.guideIds.Push(channel.id)
end for
selected = (selected + m.guideOffset + titles.Count()) mod titles.Count()
showPanel("guide", "Program guide", "Up / Down Browse OK Watch Star Options", titles)
m.menu.itemSize = [430, 50]
m.guideDetails.visible = true
m.menu.jumpToItem = selected
showGuideDetails(selected)
end sub
sub onGuideFocus(event as object)
if m.panelMode = "guide" then showGuideDetails(event.GetData())
end sub
sub showGuideDetails(index as integer)
if index < 0 or index >= m.guideChannels.Count() then return
channel = m.guideChannels[index]
m.guideChannelTitle.text = channelLabel(channel)
m.guideNow.text = ""
m.guideNext.text = ""
m.guideLater.text = ""
if channel.type = "weather"
m.guideNow.text = "LOCAL WEATHER"
m.guideNext.text = "Current conditions, forecasts and alerts"
return
end if
now = currentEpoch()
upcoming = []
current = invalid current = invalid
upcoming = invalid
if GetInterface(channel.programs, "ifArray") <> invalid
for each program in channel.programs for each program in channel.programs
if parseUtc(program.start) > now if parseUtc(program.start) > now
upcoming = program upcoming.Push(program)
exit for
else if parseUtc(program.stop) > now else if parseUtc(program.stop) > now
current = program current = program
end if end if
end for end for
end if m.guideNow.text = "NOW" + Chr(10) + programTitle(current)
titles.Push(channelLabel(channel) + " | " + programTitle(current) + " / " + programTitle(upcoming)) nextProgram = invalid
m.guideIds.Push(channel.id) if upcoming.Count() > 0 then nextProgram = upcoming[0]
end for m.guideNext.text = "NEXT" + Chr(10) + programTitle(nextProgram)
showPanel("guide", "Program guide", "CHANNEL | NOW / NEXT", titles) if upcoming.Count() > 1 then m.guideLater.text = "LATER" + Chr(10) + programTitle(upcoming[1])
end sub end sub

View File

@@ -1,5 +1,5 @@
sub init() sub init()
for each id in ["video", "weather", "banner", "channelTitle", "clock", "nowTitle", "nextTitle", "progressTrack", "progress", "playbackStatus", "panel", "panelTitle", "panelStatus", "menu", "bannerTimer", "clockTimer", "retryTimer"] for each id in ["video", "weather", "banner", "channelTitle", "clock", "nowTitle", "nextTitle", "progressTrack", "progress", "playbackStatus", "panel", "panelTitle", "panelStatus", "menu", "bannerTimer", "clockTimer", "retryTimer", "guideDetails", "guideChannelTitle", "guideNow", "guideNext", "guideLater"]
m[id] = m.top.FindNode(id) m[id] = m.top.FindNode(id)
end for end for
m.channels = [] m.channels = []
@@ -11,6 +11,7 @@ sub init()
m.clockReference = CreateObject("roTimespan") m.clockReference = CreateObject("roTimespan")
m.menu.ObserveField("itemSelected", "onMenuSelect") m.menu.ObserveField("itemSelected", "onMenuSelect")
m.menu.ObserveField("itemFocused", "onGuideFocus")
m.video.ObserveField("state", "onVideoState") m.video.ObserveField("state", "onVideoState")
initWeather() initWeather()
m.bannerTimer.ObserveField("fire", "hideBanner") m.bannerTimer.ObserveField("fire", "hideBanner")
@@ -83,9 +84,8 @@ sub onChannels(event as object)
return return
end if end if
closePanel()
m.previousIndex = -1 m.previousIndex = -1
tune(0) openGuide()
end sub end sub
function startRequest(request as object, callback as string) as object function startRequest(request as object, callback as string) as object
@@ -305,11 +305,11 @@ function onKeyEvent(key as string, press as boolean) as boolean
closePanel() closePanel()
return true return true
end if end if
if key = "options" and m.channelIndex >= 0 if key = "options" and m.channels.Count() > 0
if m.panel.visible if m.panelMode = "guide"
closePanel()
else
showPanel("options", "retroLabs", m.server.name + " " + m.server.baseUrl, ["Program guide", "Refresh channels", "Change server"]) showPanel("options", "retroLabs", m.server.name + " " + m.server.baseUrl, ["Program guide", "Refresh channels", "Change server"])
else
openGuide()
end if end if
return true return true
end if end if
@@ -318,7 +318,7 @@ function onKeyEvent(key as string, press as boolean) as boolean
if key = "up" or key = "down" if key = "up" or key = "down"
direction = 1 direction = 1
if key = "up" then direction = -1 if key = "up" then direction = -1
tune((m.channelIndex + direction + m.channels.Count()) MOD m.channels.Count()) openGuide(direction)
return true return true
else if key = "left" or key = "replay" else if key = "left" or key = "replay"
if m.previousIndex >= 0 then tune(m.previousIndex) if m.previousIndex >= 0 then tune(m.previousIndex)

View File

@@ -47,6 +47,17 @@
<LabelList id="menu" translation="[65,202]" itemSize="[1150,50]" itemSpacing="[0,4]" <LabelList id="menu" translation="[65,202]" itemSize="[1150,50]" itemSpacing="[0,4]"
numRows="8" color="0xF8F7EFFF" focusedColor="0x101A32FF" font="font:SmallSystemFont" numRows="8" color="0xF8F7EFFF" focusedColor="0x101A32FF" font="font:SmallSystemFont"
focusedFont="font:SmallBoldSystemFont" focusBitmapBlendColor="0x78E5EBFF" /> focusedFont="font:SmallBoldSystemFont" focusBitmapBlendColor="0x78E5EBFF" />
<Group id="guideDetails" translation="[520,202]" visible="false">
<Rectangle width="690" height="432" color="0x1B2B48FF" />
<Label id="guideChannelTitle" translation="[24,14]" width="640" height="45"
font="font:MediumBoldSystemFont" color="0x78E5EBFF" />
<Label id="guideNow" translation="[24,78]" width="640" height="100"
font="font:SmallSystemFont" wrap="true" numLines="3" />
<Label id="guideNext" translation="[24,192]" width="640" height="100"
font="font:SmallSystemFont" wrap="true" numLines="3" />
<Label id="guideLater" translation="[24,306]" width="640" height="100"
font="font:SmallSystemFont" wrap="true" numLines="3" />
</Group>
</Group> </Group>
<Timer id="bannerTimer" duration="5" /> <Timer id="bannerTimer" duration="5" />
<Timer id="clockTimer" duration="1" repeat="true" /> <Timer id="clockTimer" duration="1" repeat="true" />