Change SetLocalContent in channel classes to avoid Invoke.
With these changes, we now often have 0 invokes and at most 1 when
calling SetLocalContent on a channel. Before we had at least 1 and
typically 2.
Summary of changes.
* Updating RtpExtension::DeduplicateHeaderExtensions to return a sorted
vector (+test) for easy detection of changes.
* Before updating the transport on the network thread, detect if
actual changes to the demuxer criteria or changes to the rtp header
extensions have been made.
* Consolidate both transport updates to a single call instead of two.
* Added DCHECK guards to catch regressions in number of invokes.
A possible upcoming improvement is to update the transport
asynchronously.
Bug: webrtc:13536
Change-Id: I71ef7b181635a796ffa1e3a02a0f661d28a4870c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/244700
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35638}
diff --git a/api/rtp_parameters.cc b/api/rtp_parameters.cc
index feba393..c48b8da 100644
--- a/api/rtp_parameters.cc
+++ b/api/rtp_parameters.cc
@@ -11,6 +11,7 @@
#include <algorithm>
#include <string>
+#include <tuple>
#include <utility>
#include "api/array_view.h"
@@ -280,6 +281,14 @@
}
}
+ // Sort the returned vector to make comparisons of header extensions reliable.
+ // In order of priority, we sort by uri first, then encrypt and id last.
+ std::sort(filtered.begin(), filtered.end(),
+ [](const RtpExtension& a, const RtpExtension& b) {
+ return std::tie(a.uri, a.encrypt, a.id) <
+ std::tie(b.uri, b.encrypt, b.id);
+ });
+
return filtered;
}
} // namespace webrtc