Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Multi-Codec Simulcast usage by setting backupCodec to true #923

Merged
merged 2 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions example/sample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const appActions = {
const autoSubscribe = (<HTMLInputElement>$('auto-subscribe')).checked;
const e2eeEnabled = (<HTMLInputElement>$('e2ee')).checked;

setLogLevel(LogLevel.info);
setLogLevel(LogLevel.debug);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks 🙏

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hah, I'm finding myself having to change this each time I use it. it was getting annoying.

updateSearchParams(url, token, cryptoKey);

const roomOpts: RoomOptions = {
Expand All @@ -103,7 +103,7 @@ const appActions = {
roomOpts.publishDefaults?.videoCodec === 'av1' ||
roomOpts.publishDefaults?.videoCodec === 'vp9'
) {
roomOpts.publishDefaults.backupCodec = { codec: 'vp8', encoding: VideoPresets.h720.encoding };
roomOpts.publishDefaults.backupCodec = true;
}

const connectOpts: RoomConnectOptions = {
Expand Down
4 changes: 4 additions & 0 deletions src/room/participant/LocalParticipant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,11 @@ export default class LocalParticipant extends Participant {
];

// set up backup
if (opts.backupCodec === true) {
opts.backupCodec = { codec: 'vp8' };
}
if (opts.backupCodec && videoCodec !== opts.backupCodec.codec) {
// multi-codec simulcast requires dynacast
if (!this.roomOptions.dynacast) {
this.roomOptions.dynacast = true;
}
Expand Down
7 changes: 6 additions & 1 deletion src/room/participant/publishUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,12 @@ export function computeTrackBackupEncodings(
videoCodec: BackupVideoCodec,
opts: TrackPublishOptions,
) {
if (!opts.backupCodec || opts.backupCodec.codec === opts.videoCodec) {
// backupCodec should not be true anymore, default codec is set in LocalParticipant.publish
if (
!opts.backupCodec ||
opts.backupCodec === true ||
opts.backupCodec.codec === opts.videoCodec
) {
// backup codec publishing is disabled
return;
}
Expand Down
10 changes: 8 additions & 2 deletions src/room/track/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ export interface TrackPublishDefaults {
videoEncoding?: VideoEncoding;

/**
* @experimental
* Multi-codec Simulcast
* VP9 and AV1 are not supported by all browser clients. When backupCodec is
* set, when an incompatible client attempts to subscribe to the track, LiveKit
* will automatically publish a secondary track encoded with the backup codec.
*
* You could customize specific encoding parameters of the backup track by
* explicitly setting codec and encoding fields.
*/
backupCodec?: { codec: BackupVideoCodec; encoding: VideoEncoding } | false;
backupCodec?: true | false | { codec: BackupVideoCodec; encoding?: VideoEncoding };

/**
* encoding parameters for screen share track
Expand Down
Loading