RtpSender's RtpParameters were invalidated in a call to SLD/SRD.

RtpSender uses a transactional model when getting and setting RtpParameters.
One must call GetParameters() and then can use the returned object in a
subsequent call to SetParameters().
PeerConnection was calling GetParameters() and SetParameters() during
negotiation in SetLocalDescription and SetRemoteDescription effectively
invalidating any parameters that the client previously held.
This change introduces an internal way for the platform to modify
parameters without invalidating the transactional model, provided that
the modification is not severe.
Ex. removing simulcast layers is a severe modification and will
invalidate any outstanding parameters.

Bug: webrtc:10339
Change-Id: I362e8ca4d9556e04a1aa7a3e74e2c275f8d16fbc
Reviewed-on: https://webrtc-review.googlesource.com/c/124504
Reviewed-by: Seth Hampson <shampson@webrtc.org>
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Commit-Queue: Amit Hilbuch <amithi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26864}
diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc
index 0288afc..d3b9258 100644
--- a/pc/peer_connection.cc
+++ b/pc/peer_connection.cc
@@ -3015,7 +3015,7 @@
     const std::vector<SimulcastLayer>& layers,
     rtc::scoped_refptr<RtpSenderInternal> sender) {
   RTC_DCHECK(sender);
-  RtpParameters parameters = sender->GetParameters();
+  RtpParameters parameters = sender->GetParametersInternal();
   std::vector<std::string> disabled_layers;
 
   // The simulcast envelope cannot be changed, only the status of the streams.
@@ -3034,7 +3034,7 @@
     encoding.active = !iter->is_paused;
   }
 
-  RTCError result = sender->SetParameters(parameters);
+  RTCError result = sender->SetParametersInternal(parameters);
   if (result.ok()) {
     result = sender->DisableEncodingLayers(disabled_layers);
   }
@@ -3045,7 +3045,7 @@
 static RTCError DisableSimulcastInSender(
     rtc::scoped_refptr<RtpSenderInternal> sender) {
   RTC_DCHECK(sender);
-  RtpParameters parameters = sender->GetParameters();
+  RtpParameters parameters = sender->GetParametersInternal();
   if (parameters.encodings.size() <= 1) {
     return RTCError::OK();
   }
@@ -4243,7 +4243,8 @@
 
   // The following sets up RIDs and Simulcast.
   // RIDs are included if Simulcast is requested or if any RID was specified.
-  RtpParameters send_parameters = transceiver->sender()->GetParameters();
+  RtpParameters send_parameters =
+      transceiver->internal()->sender_internal()->GetParametersInternal();
   bool has_rids = std::any_of(send_parameters.encodings.begin(),
                               send_parameters.encodings.end(),
                               [](const RtpEncodingParameters& encoding) {