diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2015-09-03 13:20:04 +0200 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2015-09-03 13:20:04 +0200 |
| commit | 88b4688afe762bf155225b8b8016ae81c24afa3b (patch) | |
| tree | dc7b1516ad35dfac41e2fb86d45c1f583b1043a4 /src/base/QXmppJingleIq.cpp | |
| parent | 1d828207bbab3b53ec251ac311d761a99e8977e5 (diff) | |
| download | qxmpp-88b4688afe762bf155225b8b8016ae81c24afa3b.tar.gz | |
improve default candidate selection during SDP generation
Diffstat (limited to 'src/base/QXmppJingleIq.cpp')
| -rw-r--r-- | src/base/QXmppJingleIq.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/base/QXmppJingleIq.cpp b/src/base/QXmppJingleIq.cpp index 26967283..b837a4de 100644 --- a/src/base/QXmppJingleIq.cpp +++ b/src/base/QXmppJingleIq.cpp @@ -559,12 +559,22 @@ bool QXmppJingleIq::Content::parseSdp(const QString &sdp) return true; } +static bool candidateLessThan(const QXmppJingleCandidate &c1, const QXmppJingleCandidate &c2) +{ + if (c1.type() == c2.type()) + return c1.priority() > c2.priority(); + else + return c1.type() == QXmppJingleCandidate::ServerReflexiveType; +} + QString QXmppJingleIq::Content::toSdp() const { // get default candidate QHostAddress localRtpAddress = QHostAddress::Any; quint16 localRtpPort = 0; - foreach (const QXmppJingleCandidate &candidate, d->transportCandidates) { + QList<QXmppJingleCandidate> sortedCandidates = d->transportCandidates; + qSort(sortedCandidates.begin(), sortedCandidates.end(), candidateLessThan); + foreach (const QXmppJingleCandidate &candidate, sortedCandidates) { if (candidate.component() == RTP_COMPONENT) { localRtpAddress = candidate.host(); localRtpPort = candidate.port(); |
