refactor(desktop): replace the native voice engine with a standalone hardware encoder (#1677)

This commit is contained in:
Hampus authored and GitHub committed 2026-08-16 19:24:31 +02:00
1 parent 98c40c6979
commit ccdd85b099
893 files changed
+620 -371790

No files matched your search

@@ -86,12 +86,7 @@ function makeNativeAddon({
};
}
function loadNativeScreenCapture({
platform = 'linux',
addon,
tccStatus = 'not-determined',
frameSinkHandle = null,
} = {}) {
function loadNativeScreenCapture({platform = 'linux', addon, tccStatus = 'not-determined'} = {}) {
const handlers = new Map();
const calls = {
logs: {debug: [], warn: []},
@@ -149,12 +144,6 @@ function loadNativeScreenCapture({
if (specifier === './MacTcc') {
return {getTccStatus: () => tccStatus};
}
if (specifier === './NativeVoiceEngine') {
return {
createNativeVoiceEngineScreenFrameSinkHandle: (captureId) =>
typeof frameSinkHandle === 'function' ? frameSinkHandle(captureId) : frameSinkHandle,
};
}
if (specifier === './NativeScreenCaptureValidation') {
return {
isValidStartOptions: () => true,
@@ -242,15 +231,10 @@ describe('NativeScreenCapture source identity and capability reporting', () => {
});
test('starts display and window captures with exact source id and kind and reports diagnostics', async () => {
const frameSinkHandles = {
'capture-1': {native: true, captureId: 'capture-1'},
'capture-2': {native: true, captureId: 'capture-2'},
};
const {addon, captures} = makeNativeAddon();
const harness = loadNativeScreenCapture({
platform: 'linux',
addon,
frameSinkHandle: (captureId) => frameSinkHandles[captureId] ?? null,
});
const {sender, sent} = makeSender();
harness.module.registerNativeScreenCaptureHandlers();
@@ -296,7 +280,6 @@ describe('NativeScreenCapture source identity and capability reporting', () => {
showCursorClicks: true,
captureRect: {x: 10, y: 20, width: 300, height: 200},
nativeFrameSinkRequired: true,
frameSinkHandle: frameSinkHandles['capture-1'],
},
{
sourceId: 'window:4242',
@@ -311,7 +294,6 @@ describe('NativeScreenCapture source identity and capability reporting', () => {
showCursorClicks: false,
captureRect: undefined,
nativeFrameSinkRequired: true,
frameSinkHandle: frameSinkHandles['capture-2'],
},
]);
assert.equal(displayResult.captureId, 'capture-1');
@@ -342,37 +324,11 @@ describe('NativeScreenCapture source identity and capability reporting', () => {
assert.equal(captures[1].stopCount, 1);
});
test('fails fast when native frame sink is required but unavailable', async () => {
const {addon, captures} = makeNativeAddon();
const harness = loadNativeScreenCapture({platform: 'linux', addon});
const {sender} = makeSender();
harness.module.registerNativeScreenCaptureHandlers();
await assert.rejects(
() =>
harness.handlers.get('native-screen-capture:start')(
{sender},
{
sourceId: 'window:4242',
sourceKind: 'window',
width: 1280,
height: 720,
captureId: 'preselected-capture-id',
nativeFrameSinkRequired: true,
},
),
/requires a native frame sink handle/,
);
assert.equal(captures.length, 0);
});
test('passes caller-provided capture id and native sink handle to the platform wrapper', async () => {
const frameSinkHandle = {native: true};
test('passes caller-provided capture id to the platform wrapper', async () => {
const {addon, captures} = makeNativeAddon();
const harness = loadNativeScreenCapture({
platform: 'linux',
addon,
frameSinkHandle: (captureId) => (captureId === 'preselected-capture-id' ? frameSinkHandle : null),
});
const {sender, sent} = makeSender();
harness.module.registerNativeScreenCaptureHandlers();
@@ -403,7 +359,6 @@ describe('NativeScreenCapture source identity and capability reporting', () => {
showCursorClicks: false,
captureRect: undefined,
nativeFrameSinkRequired: true,
frameSinkHandle,
});
assert.deepEqual(sent, []);
});
@@ -518,7 +473,6 @@ describe('NativeScreenCapture source identity and capability reporting', () => {
const harness = loadNativeScreenCapture({
platform: 'win32',
addon,
frameSinkHandle: (captureId) => ({native: true, captureId}),
});
harness.module.registerNativeScreenCaptureHandlers();
const {sender} = makeSender();