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

Add experimental fallback codec support #334

Merged
merged 17 commits into from
Aug 18, 2022

Conversation

lukasIO
Copy link
Contributor

@lukasIO lukasIO commented Jul 20, 2022

This is a draft/suggestion of how to expose custom multi codec publishing encodings to users.

Naming (polycast) of course also up for debate, but as everything is marked as @experimental it should also be fine to rename afterwards

@changeset-bot
Copy link

changeset-bot bot commented Jul 20, 2022

🦋 Changeset detected

Latest commit: 1de74c7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
livekit-client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@lukasIO lukasIO marked this pull request as ready for review July 22, 2022 09:16
@davidzhao
Copy link
Member

thinking a bit about the API, and just reading the options, it doesn't seem intuitive to me what I should be doing there. Let's discuss @lukasIO; maybe there's a simple version of it that could work for the majority of the cases?

Copy link
Member

@davidzhao davidzhao left a comment

Choose a reason for hiding this comment

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

the interface looks much easier to follow!

@@ -492,32 +497,31 @@ export default class LocalParticipant extends Participant {
req.height = height ?? 0;
// for svc codecs, disable simulcast and use vp8 for backup codec
if (track instanceof LocalVideoTrack) {
if (opts?.videoCodec === 'vp9' || opts?.videoCodec === 'av1') {
if (opts.backupCodec && (opts?.videoCodec === 'vp9' || opts?.videoCodec === 'av1')) {
// set scalabilityMode to 'L3T3' by default
opts.scalabilityMode = opts.scalabilityMode ?? 'L3T3';
Copy link
Member

Choose a reason for hiding this comment

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

I think we need to set scalability mode as long as it's AV1, even if a backupCodec isn't set.

We should also remove VP9 references, since we've decided to focus on AV1 and not worry about VP9

};
// clear scalabilityMode setting for backup codec
opts.scalabilityMode = undefined;
opts.videoCodec = videoCodec;
Copy link
Member

Choose a reason for hiding this comment

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

does this get set elsewhere? it gets used here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the link doesn't work, but generally get's set in computeTrackBackupEncodings

opts.videoCodec = videoCodec;

Does that resolve the issue you saw?

Copy link
Member

Choose a reason for hiding this comment

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

ah ha I see it. Just didn't expect that computeXXX would mutate one of its arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's fair. I moved it there in order to keep the arguments untouched wherever possible and then only have a distinct function that needs the mutation to actually do it.

encoding.maxBitrate = encoding.maxBitrate * 0.7;
break;
case 'h264':
encoding.maxBitrate = encoding.maxBitrate * 1.1;
Copy link
Member

Choose a reason for hiding this comment

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

aren't H.264 and VP8 at similar efficiencies?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, we can ignore it by default. I think the efficiency ultimately comes down to which h.264 profile is used

};
// clear scalabilityMode setting for backup codec
opts.scalabilityMode = undefined;
opts.videoCodec = videoCodec;
Copy link
Member

Choose a reason for hiding this comment

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

ah ha I see it. Just didn't expect that computeXXX would mutate one of its arguments.

@lukasIO lukasIO changed the title Add experimental polycast encodings Add experimental fallback codec support Aug 18, 2022
Copy link
Contributor

@cnderrauber cnderrauber left a comment

Choose a reason for hiding this comment

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

looks good!

this.setPreferredCodec(transceiver, track.kind, videoCodec);
track.setSimulcastTrackSender(videoCodec, transceiver.sender);

// TODO do we want to support av1 as a backup codec?
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we will not use av1 as backup, it should be primary codec if exist

@lukasIO lukasIO merged commit 8cb17ec into main Aug 18, 2022
@lukasIO lukasIO deleted the lukas/experimental-polycast-encodings branch August 18, 2022 11:32
@github-actions github-actions bot mentioned this pull request Aug 18, 2022
@davidzhao davidzhao mentioned this pull request Aug 22, 2022
25 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants