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

mimeTypeToVideoCodecString should not throw #1302

Merged
merged 2 commits into from
Oct 26, 2024
Merged

mimeTypeToVideoCodecString should not throw #1302

merged 2 commits into from
Oct 26, 2024

Conversation

davidzhao
Copy link
Member

The current implementation is not resilient to codecs changes. If a new codec is introduced, previously working code would start failing.

The current implementation is not resilient to codecs changes.
If a new codec is introduced, previously working code would start failing.
Copy link

changeset-bot bot commented Oct 25, 2024

🦋 Changeset detected

Latest commit: aeb3d87

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

Copy link
Contributor

github-actions bot commented Oct 25, 2024

size-limit report 📦

Path Size
dist/livekit-client.esm.mjs 85.57 KB (-0.04% 🔽)
dist/livekit-client.umd.js 91.63 KB (-0.03% 🔽)

@davidzhao davidzhao requested review from bcherry and lukasIO October 26, 2024 00:14
@davidzhao davidzhao merged commit ed3666d into main Oct 26, 2024
3 checks passed
@davidzhao davidzhao deleted the do-not-throw branch October 26, 2024 16:25
@github-actions github-actions bot mentioned this pull request Oct 26, 2024
throw Error(`Video codec not supported: ${codec}`);
}
return codec;
return mimeType.split('/')[1].toLowerCase() as VideoCodec;
Copy link
Contributor

@lukasIO lukasIO Nov 2, 2024

Choose a reason for hiding this comment

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

I'm not sure whether forcing this cast is the right fix.
This incorrectly returns strings that are not part of the client defined VideoCodec type.

If a method is needed that just strips away video/ from the mimetype without throwing, I think that should return a string instead

Copy link
Member Author

Choose a reason for hiding this comment

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

that's a fair point. my main goal is to ensure it doesn't throwing just because there's a piece of data that it doesn't understand.

perhaps the more systematic question is how do we handle new video codecs that the server/browser might contain that our client isn't aware of. we'd have to be defensive about it

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