-
Notifications
You must be signed in to change notification settings - Fork 376
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
fix learning address for asymmetric rtp #1682
base: master
Are you sure you want to change the base?
fix learning address for asymmetric rtp #1682
Conversation
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.
Still not quite sure about the logic here 😅
@@ -2396,15 +2396,8 @@ static bool media_packet_address_check(struct packet_handler_ctx *phc) | |||
|
|||
PS_SET(phc->mp.stream, RECEIVED); | |||
|
|||
/* do not pay attention to source addresses of incoming packets for asymmetric streams */ | |||
if (MEDIA_ISSET(phc->mp.media, ASYMMETRIC) || phc->mp.stream->el_flags == EL_OFF) { | |||
if (phc->mp.stream->el_flags == EL_OFF || rtpe_config.endpoint_learning == EL_OFF) |
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.
Checking rtpe_config.endpoint_learning
shouldn't be necessary, as stream->el_flags
should be set to the appropriate value already
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.
yes i agree rtpe_config.endpoint_learning check is not necessary
endpoint = !MEDIA_ISSET(phc->mp.media, ASYMMETRIC) ? phc->mp.stream->endpoint : phc->mp.stream->learned_endpoint; | ||
if (!MEDIA_ISSET(phc->mp.media, ASYMMETRIC)) | ||
phc->mp.stream->endpoint = *use_endpoint_confirm; | ||
|
||
phc->mp.stream->learned_endpoint = *use_endpoint_confirm; | ||
if (memcmp(&endpoint, &phc->mp.stream->endpoint, sizeof(endpoint))) { | ||
if (memcmp(&endpoint, !MEDIA_ISSET(phc->mp.media, ASYMMETRIC) ? &phc->mp.stream->endpoint : &phc->mp.stream->learned_endpoint , sizeof(endpoint))) { |
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.
All these 3 case distinctions are based on the same condition, so you could reduce this to just one if/else.
In particular, if ASYMMETRIC is set, then the final memcmp() condition will never be true, because it ends up comparing learned_endpoint
against endpoint
, and endpoint
has just been set to learned_endpoint
3 lines earlier, with no chance of it ending up something different, no?
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.
do you mean something like
if (MEDIA_ISSET(phc->mp.media, ASYMMETRIC)){
endpoint = phc->mp.stream->learned_endpoint;
}else{
endpoint = phc->mp.stream->endpoint;
phc->mp.stream->endpoint = *use_endpoint_confirm;
}
phc->mp.stream->learned_endpoint = *use_endpoint_confirm;
In particular, if ASYMMETRIC is set, then the final memcmp() condition will never be true,
yes but isn't that a specific case ? the same logic applies if ASYMMETRIC is not set we will end up comparing stream->endpoint to endpoint (set to stream->endpoint earlier). we are comparing old value with current value.
with no chance of it ending up something different, no?
yes if the value does not change but it could change (especially for asymmetric) but the same logic applies for non ASYMMETRIC stream i think ?
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.
do you mean something like
if (MEDIA_ISSET(phc->mp.media, ASYMMETRIC)){ endpoint = phc->mp.stream->learned_endpoint; }else{ endpoint = phc->mp.stream->endpoint; phc->mp.stream->endpoint = *use_endpoint_confirm; } phc->mp.stream->learned_endpoint = *use_endpoint_confirm;
Yes exactly.
In particular, if ASYMMETRIC is set, then the final memcmp() condition will never be true,
yes but isn't that a specific case ? the same logic applies if ASYMMETRIC is not set we will end up comparing stream->endpoint to endpoint (set to stream->endpoint earlier). we are comparing old value with current value.
with no chance of it ending up something different, no?
yes if the value does not change but it could change (especially for asymmetric) but the same logic applies for non ASYMMETRIC stream i think ?
I don't see how it could change. Consider your code above, with MEDIA_ISSET(phc->mp.media, ASYMMETRIC) being true. You set endpoint
to learned_endpoint
. And then immediately after you compare endpoint
against learned_endpoint
. How could these two ever be different?
For the non-asymmetric case you compare the previously learned endpoint (saved in endpoint
) with the newly learned endpoint (use_endpoint_confirm
stored into phc->mp.stream->endpoint
) and use that to trigger a log message. (Not that the log message is crucial, but it makes me think that the logic isn't sound)
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.
I don't see how it could change. Consider your code above, with MEDIA_ISSET(phc->mp.media, ASYMMETRIC) being true. You set endpoint to learned_endpoint. And then immediately after you compare endpoint against learned_endpoint. How could these two ever be different?
because before memcmp we update learned_endpoint
phc->mp.stream->learned_endpoint = *use_endpoint_confirm;
fixes for #1679 and #1680