Group calling: add overflow area
This commit is contained in:
parent
8e1391c70c
commit
fbfcdbf84e
13 changed files with 713 additions and 116 deletions
62
ts/test-both/helpers/fakeGetGroupCallVideoFrameSource.ts
Normal file
62
ts/test-both/helpers/fakeGetGroupCallVideoFrameSource.ts
Normal file
|
@ -0,0 +1,62 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
import { VideoFrameSource } from '../../types/Calling';
|
||||
|
||||
const COLORS: Array<[number, number, number]> = [
|
||||
[0xff, 0x00, 0x00],
|
||||
[0xff, 0x99, 0x00],
|
||||
[0xff, 0xff, 0x00],
|
||||
[0x00, 0xff, 0x00],
|
||||
[0x00, 0x99, 0xff],
|
||||
[0xff, 0x00, 0xff],
|
||||
[0x99, 0x33, 0xff],
|
||||
];
|
||||
|
||||
class FakeGroupCallVideoFrameSource implements VideoFrameSource {
|
||||
private readonly sourceArray: Uint8Array;
|
||||
|
||||
private readonly dimensions: [number, number];
|
||||
|
||||
constructor(width: number, height: number, r: number, g: number, b: number) {
|
||||
const length = width * height * 4;
|
||||
|
||||
this.sourceArray = new Uint8Array(length);
|
||||
for (let i = 0; i < length; i += 4) {
|
||||
this.sourceArray[i] = r;
|
||||
this.sourceArray[i + 1] = g;
|
||||
this.sourceArray[i + 2] = b;
|
||||
this.sourceArray[i + 3] = 255;
|
||||
}
|
||||
|
||||
this.dimensions = [width, height];
|
||||
}
|
||||
|
||||
receiveVideoFrame(
|
||||
destinationBuffer: ArrayBuffer
|
||||
): [number, number] | undefined {
|
||||
// Simulate network jitter. Also improves performance when testing.
|
||||
if (Math.random() < 0.5) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
new Uint8Array(destinationBuffer).set(this.sourceArray);
|
||||
return this.dimensions;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This produces a fake video frame source that is a single color.
|
||||
*
|
||||
* The aspect ratio is fixed at 1.3 because that matches many of our stories.
|
||||
*/
|
||||
export function fakeGetGroupCallVideoFrameSource(
|
||||
demuxId: number
|
||||
): VideoFrameSource {
|
||||
const color = COLORS[demuxId % COLORS.length];
|
||||
if (!color) {
|
||||
throw new Error('Expected a color, but it was not found');
|
||||
}
|
||||
const [r, g, b] = color;
|
||||
|
||||
return new FakeGroupCallVideoFrameSource(13, 10, r, g, b);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue