-
Notifications
You must be signed in to change notification settings - Fork 85
Avoid RTPBuffer allocation #390
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #390 +/- ##
==========================================
- Coverage 79.67% 79.54% -0.13%
==========================================
Files 84 84
Lines 4182 4176 -6
==========================================
- Hits 3332 3322 -10
- Misses 679 681 +2
- Partials 171 173 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
JoTurk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool change, thank you.
internal/rtpbuffer/rtpbuffer.go
Outdated
| allowedSizes := make([]uint16, 0) | ||
| correctSize := false | ||
| for i := 0; i < 16; i++ { | ||
| if size == 1<<i { | ||
| correctSize = true | ||
|
|
||
| break | ||
| } | ||
| allowedSizes = append(allowedSizes, 1<<i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can also avoid allocating allowedSizes every time we call IsBufferSizeValid. Maybe just on the error path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! fixed.
internal/rtpbuffer/rtpbuffer.go
Outdated
| }, nil | ||
| } | ||
|
|
||
| func IsBufferSizeValid(size uint16) (bool, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be public and why we can't just return error, bool seems to be redundant here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although returning an error would be sufficient, the function must be public because it is called from the NACK packet code in the RTP buffer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, thank you.
b93395d to
d976f64
Compare
Previously, NewInterceptor validated the RTP buffer size by calling rtpbuffer.NewRTPBuffer this resulted in unnecessary memory allocations during interceptor construction, even though the buffer itself was not used at that stage.
d976f64 to
b78d61e
Compare
Description
Previously, NewInterceptor validated the RTP buffer size by calling rtpbuffer.NewRTPBuffer
this resulted in unnecessary memory allocations during interceptor construction, even though
the buffer itself was not used at that stage.
Reference issue
Fixes #...