Add SetRtcpXr - set extended RTCP attributes without recreate.

Bug: webrtc:11993
Change-Id: Ie64b37c1e8a3f5b6fbcf671fce4ed642c74521cd
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/271300
Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37776}
diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h
index f4ed0a9..79edf9d 100644
--- a/call/video_receive_stream.h
+++ b/call/video_receive_stream.h
@@ -305,6 +305,8 @@
 
   virtual void SetUlpfecPayloadType(int ulpfec_payload_type) = 0;
 
+  virtual void SetRtcpXr(Config::Rtp::RtcpXr rtcp_xr) = 0;
+
  protected:
   virtual ~VideoReceiveStreamInterface() {}
 };
diff --git a/media/engine/fake_webrtc_call.h b/media/engine/fake_webrtc_call.h
index b076fd9..f34bb5b 100644
--- a/media/engine/fake_webrtc_call.h
+++ b/media/engine/fake_webrtc_call.h
@@ -302,6 +302,10 @@
     config_.rtp.ulpfec_payload_type = ulpfec_payload_type;
   }
 
+  void SetRtcpXr(Config::Rtp::RtcpXr rtcp_xr) override {
+    config_.rtp.rtcp_xr = rtcp_xr;
+  }
+
   void Start() override;
   void Stop() override;
 
diff --git a/media/engine/webrtc_video_engine.cc b/media/engine/webrtc_video_engine.cc
index c39bf67..b02fa4d 100644
--- a/media/engine/webrtc_video_engine.cc
+++ b/media/engine/webrtc_video_engine.cc
@@ -3010,9 +3010,8 @@
 
   const bool has_rtr = HasRrtr(codec.codec);
   if (has_rtr != config_.rtp.rtcp_xr.receiver_reference_time_report) {
-    // TODO(tommi): Look into if/when this happens in practice.
     config_.rtp.rtcp_xr.receiver_reference_time_report = has_rtr;
-    recreate_needed = true;
+    stream_->SetRtcpXr(config_.rtp.rtcp_xr);
   }
 
   if (codec.ulpfec.red_rtx_payload_type != -1) {
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index 9aa5f0a..2b765d9 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -959,6 +959,11 @@
   rtp_rtcp_->SetRTCPStatus(mode);
 }
 
+void RtpVideoStreamReceiver2::SetReferenceTimeReport(bool enabled) {
+  RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
+  rtp_rtcp_->SetNonSenderRttMeasurement(enabled);
+}
+
 void RtpVideoStreamReceiver2::SetPacketSink(
     RtpPacketSinkInterface* packet_sink) {
   RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
diff --git a/video/rtp_video_stream_receiver2.h b/video/rtp_video_stream_receiver2.h
index 4fa216c..ab84007 100644
--- a/video/rtp_video_stream_receiver2.h
+++ b/video/rtp_video_stream_receiver2.h
@@ -185,6 +185,8 @@
   // Forwards the call to set rtcp_sender_ to the RTCP mode of the rtcp sender.
   void SetRtcpMode(RtcpMode mode);
 
+  void SetReferenceTimeReport(bool enabled);
+
   // Sets or clears the callback sink that gets called for RTP packets. Used for
   // packet handlers such as FlexFec. Must be called on the packet delivery
   // thread (same context as `OnRtpPacket` is called on).
diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc
index 5015c2d..1b8c519 100644
--- a/video/video_receive_stream2.cc
+++ b/video/video_receive_stream2.cc
@@ -556,6 +556,12 @@
   rtp_video_stream_receiver_.set_ulpfec_payload_type(payload_type);
 }
 
+void VideoReceiveStream2::SetRtcpXr(Config::Rtp::RtcpXr rtcp_xr) {
+  RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
+  rtp_video_stream_receiver_.SetReferenceTimeReport(
+      rtcp_xr.receiver_reference_time_report);
+}
+
 void VideoReceiveStream2::CreateAndRegisterExternalDecoder(
     const Decoder& decoder) {
   TRACE_EVENT0("webrtc",
diff --git a/video/video_receive_stream2.h b/video/video_receive_stream2.h
index fccec05..01cbf73 100644
--- a/video/video_receive_stream2.h
+++ b/video/video_receive_stream2.h
@@ -152,6 +152,7 @@
   void SetLossNotificationEnabled(bool enabled) override;
   void SetNackHistory(TimeDelta history) override;
   void SetUlpfecPayloadType(int payload_type) override;
+  void SetRtcpXr(Config::Rtp::RtcpXr rtcp_xr) override;
 
   webrtc::VideoReceiveStreamInterface::Stats GetStats() const override;