@whereby.com/browser-sdk 2.0.0 → 2.1.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +0,0 @@
1
- declare function fakeAudioStream(): MediaStream;
2
-
3
- declare function fakeWebcamFrame(canvas: HTMLCanvasElement): void;
4
-
5
- export { fakeAudioStream, fakeWebcamFrame };
@@ -1,70 +0,0 @@
1
- function fakeAudioStream() {
2
- const audioCtx = new AudioContext();
3
- const oscillator = audioCtx.createOscillator();
4
- const destination = audioCtx.createMediaStreamDestination();
5
- oscillator.connect(destination);
6
- oscillator.frequency.value = 400;
7
- oscillator.type = "sine";
8
- setInterval(() => {
9
- if (oscillator.frequency.value <= 900) {
10
- oscillator.frequency.value += 10;
11
- }
12
- else {
13
- oscillator.frequency.value = 200;
14
- }
15
- }, 20);
16
- oscillator.start();
17
- return destination.stream;
18
- }
19
-
20
- let rotationAngle = 0;
21
- function drawWebcamFrame(canvas) {
22
- const context = canvas.getContext("2d");
23
- if (!context) {
24
- console.error("Canvas context not available");
25
- return;
26
- }
27
- const wheelRadius = 100;
28
- const wheelCenterX = canvas.width / 2;
29
- const wheelCenterY = canvas.height / 2;
30
- context.fillStyle = "darkgreen";
31
- context.fillRect(0, 0, canvas.width, canvas.height);
32
- context.save();
33
- context.translate(wheelCenterX, wheelCenterY);
34
- context.rotate(rotationAngle);
35
- const numSlices = 12;
36
- const sliceAngle = (2 * Math.PI) / numSlices;
37
- const colors = ["red", "orange", "yellow", "green", "blue", "purple"];
38
- for (let i = 0; i < numSlices; i++) {
39
- context.beginPath();
40
- context.moveTo(0, 0);
41
- context.arc(0, 0, wheelRadius, i * sliceAngle, (i + 1) * sliceAngle);
42
- context.fillStyle = colors[i % colors.length];
43
- context.fill();
44
- context.closePath();
45
- }
46
- context.restore();
47
- context.fillStyle = "white";
48
- context.font = "42px Arial";
49
- const topText = "Whereby Media Stream";
50
- const topTextWidth = context.measureText(topText).width;
51
- context.fillText(topText, canvas.width / 2 - topTextWidth / 2, 50);
52
- context.font = "32px Arial";
53
- const now = new Date();
54
- const timeText = `time: ${now.getHours().toString().padStart(2, "0")}:${now
55
- .getMinutes()
56
- .toString()
57
- .padStart(2, "0")}:${now.getSeconds().toString().padStart(2, "0")}.${now
58
- .getMilliseconds()
59
- .toString()
60
- .padStart(3, "0")}`;
61
- context.fillText(timeText, 10, canvas.height - 20);
62
- context.fillText(`rotation angle: ${rotationAngle.toFixed(2)}`, canvas.width - canvas.width / 2, canvas.height - 20);
63
- rotationAngle += 0.01;
64
- }
65
- function fakeWebcamFrame(canvas) {
66
- drawWebcamFrame(canvas);
67
- requestAnimationFrame(() => fakeWebcamFrame(canvas));
68
- }
69
-
70
- export { fakeAudioStream, fakeWebcamFrame };