Skip to content

Commit 03ac1d3

Browse files
committed
fix(live): use sub-stream in 1x1 dashboard (#578)
1 parent 38bda78 commit 03ac1d3

3 files changed

Lines changed: 25 additions & 10 deletions

File tree

‎tests/integration/specs/substream-fullscreen.ui.spec.ts‎

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
/**
2-
* Sub-stream ↔ main-stream swap on per-cell fullscreen (#366)
2+
* Sub-stream ↔ main-stream swap on per-cell fullscreen (#366, #578)
33
*
4-
* When a stream is configured with sub_stream_url and rendered in a grid
5-
* (>1 cell), the video cell uses the `{name}_sub` go2rtc source. Entering
6-
* native fullscreen on that specific cell must swap it to the main stream
7-
* so the user sees full-resolution video, not the low-res dashboard feed.
4+
* When a stream is configured with sub_stream_url and rendered on the
5+
* dashboard, the video cell uses the `{name}_sub` go2rtc source regardless
6+
* of the selected grid size. Entering native fullscreen on that specific
7+
* cell must swap it to the main stream so the user sees full-resolution
8+
* video, not the low-res dashboard feed.
89
*
910
* We assert this via the `data-sub-stream` attribute on each `.video-cell`,
1011
* which mirrors the `useSubStream` prop resolved by LiveView / WebRTCView.
@@ -119,13 +120,26 @@ test.describe('Sub-stream swap on per-cell fullscreen @ui @liveview', () => {
119120
await expect(cellB).toHaveAttribute('data-sub-stream', 'true');
120121
});
121122

122-
test('single-stream layout never uses sub-stream', async ({ page }) => {
123+
test('single-stream layout uses sub-stream until fullscreen', async ({ page }) => {
123124
await page.goto('/index.html?cols=1&rows=1&stream=cam_a', { waitUntil: 'domcontentloaded' });
124125

125126
const cellA = page.locator('.video-cell[data-stream-name="cam_a"]').first();
126127
await expect(cellA).toBeVisible({ timeout: 15000 });
127128

128-
// 1×1 layout always shows the main stream (full-screen/recording quality).
129+
// Grid dimensions do not select stream quality: a 1×1 dashboard tile
130+
// still uses the configured low-resolution source.
131+
await expect(cellA).toHaveAttribute('data-sub-stream', 'true');
132+
133+
await page.evaluate(() => {
134+
const target = document.querySelector('.video-cell[data-stream-name="cam_a"]');
135+
Object.defineProperty(document, 'fullscreenElement', {
136+
configurable: true,
137+
get: () => target,
138+
});
139+
document.dispatchEvent(new Event('fullscreenchange'));
140+
});
141+
142+
// Only actual fullscreen upgrades the tile to the main stream.
129143
await expect(cellA).toHaveAttribute('data-sub-stream', 'false');
130144
});
131145
});

‎web/js/components/preact/LiveView.jsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,8 @@ export function LiveView({audioDisabled = false, isAutoDisabled = false, isWebRT
976976
}}
977977
defaultTransport="webrtc"
978978
forcedTransport={forcedTransport}
979-
useSubStream={!isSingleStream && fullscreenCellStream !== stream.name && (stream.has_sub_stream || !!stream.sub_stream_url)}
979+
useSubStream={fullscreenCellStream !== stream.name && (stream.has_sub_stream || !!stream.sub_stream_url)}
980+
fullscreenUpgraded={fullscreenCellStream === stream.name && (stream.has_sub_stream || !!stream.sub_stream_url)}
980981
onToggleFullscreen={toggleStreamFullscreen}
981982
streamId={stream.name}
982983
showLabels={showLabels}

‎web/js/components/preact/WebRTCView.jsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -997,8 +997,8 @@ export function WebRTCView({ audioDisabled = false, isAutoDisabled = false, isWe
997997
}}
998998
defaultTransport="webrtc"
999999
forcedTransport={forcedTransport}
1000-
useSubStream={!isSingleStream && fullscreenCellStream !== stream.name && (stream.has_sub_stream || !!stream.sub_stream_url)}
1001-
fullscreenUpgraded={!isSingleStream && fullscreenCellStream === stream.name && (stream.has_sub_stream || !!stream.sub_stream_url)}
1000+
useSubStream={fullscreenCellStream !== stream.name && (stream.has_sub_stream || !!stream.sub_stream_url)}
1001+
fullscreenUpgraded={fullscreenCellStream === stream.name && (stream.has_sub_stream || !!stream.sub_stream_url)}
10021002
onToggleFullscreen={toggleStreamFullscreen}
10031003
streamId={stream.name}
10041004
showLabels={showLabels}

0 commit comments

Comments
 (0)