mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-21 04:58:14 +00:00
Fix once and for all the random port selection in the media session.
This commit is contained in:
parent
88fb7651f6
commit
57e9fbd1c4
1 changed files with 4 additions and 1 deletions
|
|
@ -916,8 +916,11 @@ int MediaSessionPrivate::selectRandomPort (int streamIndex, pair<int, int> portR
|
|||
L_Q();
|
||||
for (int nbTries = 0; nbTries < 100; nbTries++) {
|
||||
bool alreadyUsed = false;
|
||||
unsigned int rangeSize = static_cast<unsigned int>(portRange.second - portRange.first);
|
||||
unsigned int randomInRangeSize = ortp_random() % rangeSize;
|
||||
unsigned int mask = 1;
|
||||
int triedPort = static_cast<int>((ortp_random() % static_cast<unsigned int>((portRange.second - portRange.first) + portRange.first)) & ~mask);
|
||||
unsigned int realRandom = randomInRangeSize + static_cast<unsigned int >(portRange.first);
|
||||
int triedPort = static_cast<int>(realRandom & ~mask);
|
||||
if (triedPort < portRange.first) triedPort = portRange.first + 2;
|
||||
for (const bctbx_list_t *elem = linphone_core_get_calls(q->getCore()->getCCore()); elem != nullptr; elem = bctbx_list_next(elem)) {
|
||||
LinphoneCall *lcall = reinterpret_cast<LinphoneCall *>(bctbx_list_get_data(elem));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue