peerconnection: invalidate stats cache during SLD/SRD

which may allow caching some relatively persistent statistics
such as codec statistics that only change during renegotiation.

BUG=webrtc:8693

Change-Id: Ifd68c9d666d9f328d0efecb64e4201d003788ca8
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/273324
Commit-Queue: Philipp Hancke <phancke@microsoft.com>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37981}
This commit is contained in:
Philipp Hancke 2022-09-01 15:39:50 +02:00 committed by WebRTC LUCI CQ
parent 5a77e51c17
commit 7baa63ff9c
4 changed files with 13 additions and 10 deletions

View File

@ -950,8 +950,6 @@ class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface {
rtc::scoped_refptr<RtpReceiverInterface> selector,
rtc::scoped_refptr<RTCStatsCollectorCallback> callback) = 0;
// Clear cached stats in the RTCStatsCollector.
// Exposed for testing while waiting for automatic cache clear to work.
// https://bugs.webrtc.org/8693
virtual void ClearStatsCache() {}
// Create a data channel with the provided config, or default config if none

View File

@ -2985,6 +2985,9 @@ CryptoOptions PeerConnection::GetCryptoOptions() {
void PeerConnection::ClearStatsCache() {
RTC_DCHECK_RUN_ON(signaling_thread());
if (legacy_stats_) {
legacy_stats_->InvalidateCache();
}
if (stats_collector_) {
stats_collector_->ClearCachedStatsReport();
}

View File

@ -125,6 +125,8 @@ class PeerConnectionSdpMethods {
virtual void ResetSctpDataMid() = 0;
virtual const FieldTrialsView& trials() const = 0;
virtual void ClearStatsCache() = 0;
};
// Functions defined in this class are called by other objects,

View File

@ -1488,10 +1488,10 @@ RTCError SdpOfferAnswerHandler::ApplyLocalDescription(
RTC_DCHECK_RUN_ON(signaling_thread());
RTC_DCHECK(desc);
// Invalidate the legacy stats cache to make sure that it gets updated next
// time getStats() gets called, as updating the session description affects
// the stats.
pc_->legacy_stats()->InvalidateCache();
// Invalidate the stats caches to make sure that they get
// updated the next time getStats() gets called, as updating the session
// description affects the stats.
pc_->ClearStatsCache();
// Take a reference to the old local description since it's used below to
// compare against the new local description. When setting the new local
@ -1823,10 +1823,10 @@ void SdpOfferAnswerHandler::ApplyRemoteDescription(
RTC_DCHECK_RUN_ON(signaling_thread());
RTC_DCHECK(operation->description());
// Invalidate the [legacy] stats cache to make sure that it gets updated next
// time getStats() gets called, as updating the session description affects
// the stats.
pc_->legacy_stats()->InvalidateCache();
// Invalidate the stats caches to make sure that they get
// updated next time getStats() gets called, as updating the session
// description affects the stats.
pc_->ClearStatsCache();
if (!operation->ReplaceRemoteDescriptionAndCheckEror())
return;