Skip to content

Commit 65ca944

Browse files
Avoid CropAndScale calls in RingRTC
1 parent aba0e02 commit 65ca944

File tree

6 files changed

+39
-26
lines changed

6 files changed

+39
-26
lines changed

ACKNOWLEDGMENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12842,7 +12842,7 @@ For more information on this, and how to apply and follow the GNU AGPL, see
1284212842

1284312843
```
1284412844

12845-
## libsignal-account-keys 0.1.0, libsignal-core 0.1.0, mrp 2.50.3, protobuf 2.50.3, ringrtc 2.50.3, regex-aot 0.1.0, partial-default-derive 0.1.0
12845+
## libsignal-account-keys 0.1.0, libsignal-core 0.1.0, mrp 2.50.4, protobuf 2.50.4, ringrtc 2.50.4, regex-aot 0.1.0, partial-default-derive 0.1.0
1284612846

1284712847
```
1284812848
GNU AFFERO GENERAL PUBLIC LICENSE
@@ -13626,7 +13626,7 @@ THIS SOFTWARE.
1362613626

1362713627
```
1362813628

13629-
## cubeb-core 0.22.0, cubeb-sys 0.22.0, cubeb 0.22.0
13629+
## cubeb-core 0.27.0, cubeb-sys 0.27.0, cubeb 0.27.0
1363013630

1363113631
```
1363213632
Copyright © 2017 Mozilla Foundation

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
"@react-spring/web": "9.7.5",
121121
"@signalapp/libsignal-client": "0.68.0",
122122
"@signalapp/quill-cjs": "2.1.2",
123-
"@signalapp/ringrtc": "2.50.3",
123+
"@signalapp/ringrtc": "2.50.4",
124124
"@signalapp/sqlcipher": "1.0.0",
125125
"@tanstack/react-virtual": "3.11.2",
126126
"@types/fabric": "4.5.3",

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ts/calling/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ export const REQUESTED_VIDEO_WIDTH = 960;
88
export const REQUESTED_VIDEO_HEIGHT = 720;
99
export const REQUESTED_VIDEO_FRAMERATE = 30;
1010

11+
export const REQUESTED_GROUP_VIDEO_WIDTH = 640;
12+
export const REQUESTED_GROUP_VIDEO_HEIGHT = 480;
13+
1114
export const REQUESTED_SCREEN_SHARE_WIDTH = 2880;
1215
export const REQUESTED_SCREEN_SHARE_HEIGHT = 1800;
1316
// 15fps is much nicer but takes up a lot more CPU.

ts/services/calling.ts

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ import {
100100
REQUESTED_VIDEO_WIDTH,
101101
REQUESTED_VIDEO_HEIGHT,
102102
REQUESTED_VIDEO_FRAMERATE,
103+
REQUESTED_GROUP_VIDEO_WIDTH,
104+
REQUESTED_GROUP_VIDEO_HEIGHT,
103105
REQUESTED_SCREEN_SHARE_WIDTH,
104106
REQUESTED_SCREEN_SHARE_HEIGHT,
105107
REQUESTED_SCREEN_SHARE_FRAMERATE,
@@ -408,6 +410,18 @@ function getLogId(
408410
return `${source}(${idForLogging}${additionalText})`;
409411
}
410412

413+
const DIRECT_CALL_OPTIONS: GumVideoCaptureOptions = {
414+
maxWidth: REQUESTED_VIDEO_WIDTH,
415+
maxHeight: REQUESTED_VIDEO_HEIGHT,
416+
maxFramerate: REQUESTED_VIDEO_FRAMERATE,
417+
};
418+
419+
const GROUP_CALL_OPTIONS: GumVideoCaptureOptions = {
420+
maxWidth: REQUESTED_GROUP_VIDEO_WIDTH,
421+
maxHeight: REQUESTED_GROUP_VIDEO_HEIGHT,
422+
maxFramerate: REQUESTED_VIDEO_FRAMERATE,
423+
};
424+
411425
export class CallingClass {
412426
readonly #videoCapturer: GumVideoCapturer;
413427

@@ -436,11 +450,7 @@ export class CallingClass {
436450
#sendProfileKeysForAdhocCallCache: Set<AciString>;
437451

438452
constructor() {
439-
this.#videoCapturer = new GumVideoCapturer({
440-
maxWidth: REQUESTED_VIDEO_WIDTH,
441-
maxHeight: REQUESTED_VIDEO_HEIGHT,
442-
maxFramerate: REQUESTED_VIDEO_FRAMERATE,
443-
});
453+
this.#videoCapturer = new GumVideoCapturer(DIRECT_CALL_OPTIONS);
444454
this.videoRenderer = new CanvasVideoRenderer();
445455

446456
this.#callsLookup = {};
@@ -619,7 +629,7 @@ export class CallingClass {
619629
await this.#startDeviceReselectionTimer();
620630

621631
const enableLocalCameraIfNecessary = hasLocalVideo
622-
? () => drop(this.enableLocalCamera())
632+
? () => drop(this.enableLocalCamera(callMode))
623633
: noop;
624634

625635
switch (callMode) {
@@ -970,7 +980,7 @@ export class CallingClass {
970980
groupCall.setOutgoingVideoMuted(!hasLocalVideo);
971981

972982
if (hasLocalVideo) {
973-
drop(this.enableLocalCamera());
983+
drop(this.enableLocalCamera(CallMode.Group));
974984
}
975985

976986
return {
@@ -1394,7 +1404,7 @@ export class CallingClass {
13941404

13951405
groupCall.setOutgoingAudioMuted(!hasLocalAudio);
13961406
groupCall.setOutgoingVideoMuted(!hasLocalVideo);
1397-
drop(this.enableCaptureAndSend(groupCall, null, logId));
1407+
drop(this.enableCaptureAndSend(groupCall, undefined, logId));
13981408

13991409
if (shouldRing) {
14001410
groupCall.ringAll();
@@ -1469,7 +1479,7 @@ export class CallingClass {
14691479
} else if (localDeviceState.videoMuted) {
14701480
this.disableLocalVideo();
14711481
} else {
1472-
drop(this.enableCaptureAndSend(groupCall, null, logId));
1482+
drop(this.enableCaptureAndSend(groupCall, undefined, logId));
14731483
}
14741484

14751485
// Call enters the Joined state, once per call.
@@ -2613,24 +2623,24 @@ export class CallingClass {
26132623
RingRTC.setAudioOutput(device.index);
26142624
}
26152625

2616-
async enableLocalCamera(): Promise<void> {
2626+
async enableLocalCamera(mode: CallMode): Promise<void> {
26172627
await window.reduxActions.globalModals.ensureSystemMediaPermissions(
26182628
'camera',
26192629
'call'
26202630
);
2621-
await this.#videoCapturer.enableCapture();
2631+
2632+
await this.#videoCapturer.enableCapture(
2633+
mode === CallMode.Direct ? undefined : GROUP_CALL_OPTIONS
2634+
);
26222635
}
26232636

26242637
async enableCaptureAndSend(
26252638
call: GroupCall | Call,
2626-
options?: GumVideoCaptureOptions | null,
2627-
logId?: string
2639+
options = call instanceof GroupCall ? GROUP_CALL_OPTIONS : undefined,
2640+
logId = 'enableCaptureAndSend'
26282641
): Promise<void> {
26292642
try {
2630-
await this.#videoCapturer.enableCaptureAndSend(
2631-
call,
2632-
options ?? undefined
2633-
);
2643+
await this.#videoCapturer.enableCaptureAndSend(call, options);
26342644
} catch (err) {
26352645
log.error(
26362646
`${

ts/state/ducks/calling.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1946,7 +1946,7 @@ function setLocalVideo(
19461946
payload.enabled
19471947
);
19481948
} else if (payload.enabled) {
1949-
await calling.enableLocalCamera();
1949+
await calling.enableLocalCamera(activeCall.callMode);
19501950
} else {
19511951
calling.disableLocalVideo();
19521952
}

0 commit comments

Comments
 (0)