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

chore(android): add null check for id of videoFormat #4174

Conversation

seyedmostafahasani
Copy link
Collaborator

Summary

Add a null check for videoFormat.id.

Motivation

Fix a potential issue where videoFormat.id could be null.

Changes

Test plan

The sample app should no longer crash when playing RTSP video types.

Copy link
Collaborator

@freeboub freeboub left a comment

Choose a reason for hiding this comment

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

This track id is not documented in onLoad... It would make sense to document it !

In a more general matter, don't you think it would be better to fix it inside onVideoBandwidthUpdate and onVideoLoad.
If track id is provided, add the field, if null do put the field in the event (and the same for height/width).
These kind of default/fallback values are coming from the hat and doesn't really make sens ', 0, 0, "-1" '

that said, I think this code:
`
int width = videoFormat != null ? (isRotatedContent ? videoFormat.height : videoFormat.width) : 0;
int height = videoFormat != null ? (isRotatedContent ? videoFormat.width : videoFormat.height) : 0;
``
should also be present before onVideoBandwidthUpdate call ...
I know it is not your code...

Thank you.

@freeboub
Copy link
Collaborator

small safety PR, 3 feedbacks around the code, sorry ...

@seyedmostafahasani
Copy link
Collaborator Author

@freeboub
Thank you for your suggestions!

@KrzysztofMoch KrzysztofMoch merged commit 1ef2b3a into TheWidlarzGroup:master Sep 17, 2024
4 checks passed
@seyedmostafahasani seyedmostafahasani deleted the android/null-check-videoFormat-id branch September 17, 2024 13:43
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