feat: Add experimental rewrite of go2rtc live provider (MSE/WebRTC/MP4/MJPEG) (#2580)

- Closes #2556
- Closes #2450

**Key intended features:**
 - go2rtc compatible
- 100% test coverage to significantly improve ability to test, maintain
and work around browser weirdnesses (e.g. Safari).
 - Written from the ground up in the style of the rest of the project.

**To use:**
 - Change `live_provider` from `go2rtc` to `go2rtc-experimental`.
This commit is contained in:
Dermot Duffy
2026-07-14 14:22:41 -07:00
committed by GitHub
parent 5662e48c22
commit c02c692f68
125 changed files with 9608 additions and 807 deletions
+32 -1
View File
@@ -7,6 +7,7 @@ import type { CameraProxyConfig } from '../../src/camera-manager/types.js';
import type { EventWatcherSubscriptionInterface } from '../../src/card-controller/hass/event-watcher.js';
import type { StateWatcherSubscriptionInterface } from '../../src/card-controller/hass/state-watcher.js';
import { liveProviderSupports2WayAudio } from '../../src/utils/live-provider.js';
import type * as LiveProviderUtils from '../../src/utils/live-provider.js';
import { EntityRegistryManagerMock } from '../ha/registry/entity/mock.js';
import {
callEventWatcherCallback,
@@ -21,7 +22,12 @@ import {
createStateEntity,
} from '../test-utils.js';
vi.mock('../../src/utils/live-provider.js');
// Partially mock to keep the real pure helpers (e.g. `isGo2RTCLiveProvider`
// used by `getProxyConfig`) while mocking the async metadata fetch.
vi.mock('../../src/utils/live-provider.js', async (importOriginal) => ({
...(await importOriginal<typeof LiveProviderUtils>()),
liveProviderSupports2WayAudio: vi.fn(),
}));
describe('Camera', () => {
it('should get config', async () => {
@@ -1068,6 +1074,31 @@ describe('Camera', () => {
ssl_ciphers: 'default' as const,
},
],
[
'when go2rtc-experimental has no url',
{ live_provider: 'go2rtc-experimental' },
{
dynamic: true,
live: false,
media: false,
ssl_verification: true,
ssl_ciphers: 'default' as const,
},
],
[
'when go2rtc-experimental has a url',
{
live_provider: 'go2rtc-experimental',
go2rtc: { url: 'http://localhost:1984' },
},
{
dynamic: true,
live: true,
media: false,
ssl_verification: true,
ssl_ciphers: 'default' as const,
},
],
])(
'%s',
(_name: string, cameraConfig: unknown, expectedResult: CameraProxyConfig) => {