Integrate RTP Header extension API with SDP munging

in order to not regress existing use-cases while following rules
described by the specification. This change now makes the existing
regression test pass after the spec-compliant modifications.

BUG=chromium:1051821

Change-Id: Ia384adf9a172ed88b5ec6a3cc5c478764a686cb9
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/299002
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Philipp Hancke <phancke@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#39726}
diff --git a/pc/media_session_unittest.cc b/pc/media_session_unittest.cc
index 8f38f6a..6ba5032 100644
--- a/pc/media_session_unittest.cc
+++ b/pc/media_session_unittest.cc
@@ -2018,7 +2018,7 @@
 }
 
 TEST_F(MediaSessionDescriptionFactoryTest,
-       AppendsStoppedExtensionIfKnownAndPresentInTheOffer) {
+       AllowsStoppedExtensionsToBeRemovedFromSubsequentOffer) {
   MediaSessionOptions opts;
   AddMediaDescriptionOptions(MEDIA_TYPE_VIDEO, "video",
                              RtpTransceiverDirection::kSendRecv, kActive,
@@ -2026,12 +2026,12 @@
   opts.media_description_options.back().header_extensions = {
       webrtc::RtpHeaderExtensionCapability("uri1", 1,
                                            RtpTransceiverDirection::kSendRecv),
-      webrtc::RtpHeaderExtensionCapability("uri2", 1,
+      webrtc::RtpHeaderExtensionCapability("uri2", 2,
                                            RtpTransceiverDirection::kSendRecv)};
   auto offer = f1_.CreateOffer(opts, nullptr);
 
-  // Now add "uri2" as stopped to the options verify that the offer contains
-  // uri2 since it's already present since before.
+  // Check that a subsequent offer after setting "uri2" to stopped no longer
+  // contains the extension.
   opts.media_description_options.back().header_extensions = {
       webrtc::RtpHeaderExtensionCapability("uri1", 1,
                                            RtpTransceiverDirection::kSendRecv),
@@ -2043,8 +2043,7 @@
       ElementsAre(Property(
           &ContentInfo::media_description,
           Pointee(Property(&MediaContentDescription::rtp_header_extensions,
-                           ElementsAre(Field(&RtpExtension::uri, "uri1"),
-                                       Field(&RtpExtension::uri, "uri2")))))));
+                           ElementsAre(Field(&RtpExtension::uri, "uri1")))))));
 }
 
 TEST_F(MediaSessionDescriptionFactoryTest,