Refactor of extmap-allow-mixed in SessionDescription

- Rename member variable and access functions to show connection to the
  extmap-allow-mixed attribute.
- Transfer extmap-allow-mixed setting when new content is added to a
  SessionDescription.
- Add boolean function that shows support of extmap-allow-mixed.
- Add unit tests of extmap-allow-mixed logic.

Bug: webrtc:7990
Change-Id: Ic330fbab7be3e1df81c2d36ce522acc254617178
Reviewed-on: https://webrtc-review.googlesource.com/c/105308
Reviewed-by: Seth Hampson <shampson@webrtc.org>
Commit-Queue: Johannes Kron <kron@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25163}
diff --git a/pc/BUILD.gn b/pc/BUILD.gn
index b6e9c66..37bd504 100644
--- a/pc/BUILD.gn
+++ b/pc/BUILD.gn
@@ -293,6 +293,7 @@
       "rtcpmuxfilter_unittest.cc",
       "rtptransport_unittest.cc",
       "rtptransporttestutil.h",
+      "sessiondescription_unittest.cc",
       "srtpfilter_unittest.cc",
       "srtpsession_unittest.cc",
       "srtptestutil.h",
diff --git a/pc/mediasession.cc b/pc/mediasession.cc
index 889576c..d4a80c0 100644
--- a/pc/mediasession.cc
+++ b/pc/mediasession.cc
@@ -1073,8 +1073,7 @@
   answer->AddCodecs(negotiated_codecs);
   answer->set_protocol(offer->protocol());
 
-  answer->set_mixed_one_two_byte_header_extensions_supported(
-      offer->mixed_one_two_byte_header_extensions_supported());
+  answer->set_extmap_allow_mixed_headers(offer->extmap_allow_mixed_headers());
   RtpHeaderExtensions negotiated_rtp_extensions;
   NegotiateRtpHeaderExtensions(
       local_rtp_extenstions, offer->rtp_header_extensions(),
@@ -1408,8 +1407,7 @@
   // Transport info shared by the bundle group.
   std::unique_ptr<TransportInfo> bundle_transport;
 
-  answer->set_mixed_one_two_byte_header_extensions_supported(
-      offer->mixed_one_two_byte_header_extensions_supported());
+  answer->set_extmap_allow_mixed_headers(offer->extmap_allow_mixed_headers());
 
   // Get list of all possible codecs that respects existing payload type
   // mappings and uses a single payload type space.
diff --git a/pc/mediasession_unittest.cc b/pc/mediasession_unittest.cc
index 3bc2766..0d92147 100644
--- a/pc/mediasession_unittest.cc
+++ b/pc/mediasession_unittest.cc
@@ -1586,19 +1586,18 @@
   MediaSessionOptions opts;
   std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
   // Offer without request of mixed one- and two-byte header extensions.
-  offer->set_mixed_one_two_byte_header_extensions_supported(false);
+  offer->set_extmap_allow_mixed_headers(false);
   ASSERT_TRUE(offer.get() != NULL);
   std::unique_ptr<SessionDescription> answer_no_support(
       f2_.CreateAnswer(offer.get(), opts, NULL));
-  EXPECT_FALSE(
-      answer_no_support->mixed_one_two_byte_header_extensions_supported());
+  EXPECT_FALSE(answer_no_support->extmap_allow_mixed_headers());
 
   // Offer with request of mixed one- and two-byte header extensions.
-  offer->set_mixed_one_two_byte_header_extensions_supported(true);
+  offer->set_extmap_allow_mixed_headers(true);
   ASSERT_TRUE(offer.get() != NULL);
   std::unique_ptr<SessionDescription> answer_support(
       f2_.CreateAnswer(offer.get(), opts, NULL));
-  EXPECT_TRUE(answer_support->mixed_one_two_byte_header_extensions_supported());
+  EXPECT_TRUE(answer_support->extmap_allow_mixed_headers());
 }
 
 TEST_F(MediaSessionDescriptionFactoryTest,
@@ -1614,10 +1613,8 @@
   ASSERT_TRUE(audio_offer);
 
   // Explicit disable of mixed one-two byte header support in offer.
-  video_offer->set_mixed_one_two_byte_header_extensions_supported(
-      MediaContentDescription::kNo);
-  audio_offer->set_mixed_one_two_byte_header_extensions_supported(
-      MediaContentDescription::kNo);
+  video_offer->set_extmap_allow_mixed_headers(MediaContentDescription::kNo);
+  audio_offer->set_extmap_allow_mixed_headers(MediaContentDescription::kNo);
 
   ASSERT_TRUE(offer.get() != NULL);
   std::unique_ptr<SessionDescription> answer_no_support(
@@ -1627,24 +1624,22 @@
   MediaContentDescription* audio_answer =
       answer_no_support->GetContentDescriptionByName("audio");
   EXPECT_EQ(MediaContentDescription::kNo,
-            video_answer->mixed_one_two_byte_header_extensions_supported());
+            video_answer->extmap_allow_mixed_headers());
   EXPECT_EQ(MediaContentDescription::kNo,
-            audio_answer->mixed_one_two_byte_header_extensions_supported());
+            audio_answer->extmap_allow_mixed_headers());
 
   // Enable mixed one-two byte header support in offer.
-  video_offer->set_mixed_one_two_byte_header_extensions_supported(
-      MediaContentDescription::kMedia);
-  audio_offer->set_mixed_one_two_byte_header_extensions_supported(
-      MediaContentDescription::kMedia);
+  video_offer->set_extmap_allow_mixed_headers(MediaContentDescription::kMedia);
+  audio_offer->set_extmap_allow_mixed_headers(MediaContentDescription::kMedia);
   ASSERT_TRUE(offer.get() != NULL);
   std::unique_ptr<SessionDescription> answer_support(
       f2_.CreateAnswer(offer.get(), opts, NULL));
   video_answer = answer_support->GetContentDescriptionByName("video");
   audio_answer = answer_support->GetContentDescriptionByName("audio");
   EXPECT_EQ(MediaContentDescription::kMedia,
-            video_answer->mixed_one_two_byte_header_extensions_supported());
+            video_answer->extmap_allow_mixed_headers());
   EXPECT_EQ(MediaContentDescription::kMedia,
-            audio_answer->mixed_one_two_byte_header_extensions_supported());
+            audio_answer->extmap_allow_mixed_headers());
 }
 
 // Create an audio and video offer with:
diff --git a/pc/sessiondescription.cc b/pc/sessiondescription.cc
index f3e89b4..ce2a406 100644
--- a/pc/sessiondescription.cc
+++ b/pc/sessiondescription.cc
@@ -84,21 +84,6 @@
 }
 
 SessionDescription::SessionDescription() = default;
-
-SessionDescription::SessionDescription(const ContentInfos& contents)
-    : contents_(contents) {}
-
-SessionDescription::SessionDescription(const ContentInfos& contents,
-                                       const ContentGroups& groups)
-    : contents_(contents), content_groups_(groups) {}
-
-SessionDescription::SessionDescription(const ContentInfos& contents,
-                                       const TransportInfos& transports,
-                                       const ContentGroups& groups)
-    : contents_(contents),
-      transport_infos_(transports),
-      content_groups_(groups) {}
-
 SessionDescription::SessionDescription(const SessionDescription&) = default;
 
 SessionDescription::~SessionDescription() {
@@ -162,7 +147,7 @@
   ContentInfo content(type);
   content.name = name;
   content.description = description;
-  contents_.push_back(std::move(content));
+  AddContent(&content);
 }
 
 void SessionDescription::AddContent(const std::string& name,
@@ -173,7 +158,7 @@
   content.name = name;
   content.rejected = rejected;
   content.description = description;
-  contents_.push_back(std::move(content));
+  AddContent(&content);
 }
 
 void SessionDescription::AddContent(const std::string& name,
@@ -186,7 +171,16 @@
   content.rejected = rejected;
   content.bundle_only = bundle_only;
   content.description = description;
-  contents_.push_back(std::move(content));
+  AddContent(&content);
+}
+
+void SessionDescription::AddContent(ContentInfo* content) {
+  if (extmap_allow_mixed_headers()) {
+    // Mixed support on session level overrides setting on media level.
+    content->description->set_extmap_allow_mixed_headers(
+        MediaContentDescription::kSession);
+  }
+  contents_.push_back(std::move(*content));
 }
 
 bool SessionDescription::RemoveContentByName(const std::string& name) {
diff --git a/pc/sessiondescription.h b/pc/sessiondescription.h
index 4fdbf3b..4980dbf 100644
--- a/pc/sessiondescription.h
+++ b/pc/sessiondescription.h
@@ -185,18 +185,21 @@
 
   // Determines if it's allowed to mix one- and two-byte rtp header extensions
   // within the same rtp stream.
-  enum ExtmapAllowMixed { kNo, kSession, kMedia };
-  void set_mixed_one_two_byte_header_extensions_supported(
-      ExtmapAllowMixed supported) {
-    if (supported == kMedia &&
-        mixed_one_two_byte_header_extensions_supported_ == kSession) {
+  enum ExtmapAllowMixedHeaders { kNo, kSession, kMedia };
+  void set_extmap_allow_mixed_headers(
+      ExtmapAllowMixedHeaders new_extmap_allow_mixed) {
+    if (new_extmap_allow_mixed == kMedia &&
+        extmap_allow_mixed_headers_ == kSession) {
       // Do not downgrade from session level to media level.
       return;
     }
-    mixed_one_two_byte_header_extensions_supported_ = supported;
+    extmap_allow_mixed_headers_ = new_extmap_allow_mixed;
   }
-  ExtmapAllowMixed mixed_one_two_byte_header_extensions_supported() const {
-    return mixed_one_two_byte_header_extensions_supported_;
+  ExtmapAllowMixedHeaders extmap_allow_mixed_headers() const {
+    return extmap_allow_mixed_headers_;
+  }
+  bool mixed_one_two_byte_header_extensions_supported() const {
+    return extmap_allow_mixed_headers_ != kNo;
   }
 
  protected:
@@ -215,7 +218,7 @@
   // Mixed one- and two-byte header not included in offer on media level or
   // session level, but we will respond that we support it. The plan is to add
   // it to our offer on session level. See todo in SessionDescription.
-  ExtmapAllowMixed mixed_one_two_byte_header_extensions_supported_ = kNo;
+  ExtmapAllowMixedHeaders extmap_allow_mixed_headers_ = kNo;
 };
 
 // TODO(bugs.webrtc.org/8620): Remove this alias once downstream projects have
@@ -398,11 +401,6 @@
 class SessionDescription {
  public:
   SessionDescription();
-  explicit SessionDescription(const ContentInfos& contents);
-  SessionDescription(const ContentInfos& contents, const ContentGroups& groups);
-  SessionDescription(const ContentInfos& contents,
-                     const TransportInfos& transports,
-                     const ContentGroups& groups);
   ~SessionDescription();
 
   SessionDescription* Copy() const;
@@ -432,6 +430,8 @@
                   bool rejected,
                   bool bundle_only,
                   MediaContentDescription* description);
+  void AddContent(ContentInfo* content);
+
   bool RemoveContentByName(const std::string& name);
 
   // Transport accessors.
@@ -477,19 +477,23 @@
 
   // Determines if it's allowed to mix one- and two-byte rtp header extensions
   // within the same rtp stream.
-  void set_mixed_one_two_byte_header_extensions_supported(bool supported) {
-    mixed_one_two_byte_header_extensions_supported_ = supported;
-    MediaContentDescription::ExtmapAllowMixed extmap_allow_mixed =
+  void set_extmap_allow_mixed_headers(bool supported) {
+    extmap_allow_mixed_headers_ = supported;
+    MediaContentDescription::ExtmapAllowMixedHeaders media_level_setting =
         supported ? MediaContentDescription::kSession
                   : MediaContentDescription::kNo;
     for (auto& content : contents_) {
-      content.media_description()
-          ->set_mixed_one_two_byte_header_extensions_supported(
-              extmap_allow_mixed);
+      // Do not set to kNo if the current setting is kMedia.
+      if (supported ||
+          content.media_description()->extmap_allow_mixed_headers() !=
+              MediaContentDescription::kMedia) {
+        content.media_description()->set_extmap_allow_mixed_headers(
+            media_level_setting);
+      }
     }
   }
-  bool mixed_one_two_byte_header_extensions_supported() const {
-    return mixed_one_two_byte_header_extensions_supported_;
+  bool extmap_allow_mixed_headers() const {
+    return extmap_allow_mixed_headers_;
   }
 
  private:
@@ -506,7 +510,7 @@
   // session level. It's currently not included in offer by default because
   // clients prior to https://bugs.webrtc.org/9712 cannot parse this correctly.
   // If it's included in offer to us we will respond that we support it.
-  bool mixed_one_two_byte_header_extensions_supported_ = false;
+  bool extmap_allow_mixed_headers_ = false;
 };
 
 // Indicates whether a session description was sent by the local client or
diff --git a/pc/sessiondescription_unittest.cc b/pc/sessiondescription_unittest.cc
new file mode 100644
index 0000000..b539524
--- /dev/null
+++ b/pc/sessiondescription_unittest.cc
@@ -0,0 +1,134 @@
+/*
+ *  Copyright 2018 The WebRTC project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+#include "pc/sessiondescription.h"
+#include "rtc_base/gunit.h"
+
+namespace cricket {
+
+TEST(MediaContentDescriptionTest, ExtmapAllowMixedDefaultValue) {
+  VideoContentDescription video_desc;
+  EXPECT_EQ(MediaContentDescription::kNo,
+            video_desc.extmap_allow_mixed_headers());
+}
+
+TEST(MediaContentDescriptionTest, SetExtmapAllowMixed) {
+  VideoContentDescription video_desc;
+  video_desc.set_extmap_allow_mixed_headers(MediaContentDescription::kNo);
+  EXPECT_EQ(MediaContentDescription::kNo,
+            video_desc.extmap_allow_mixed_headers());
+  video_desc.set_extmap_allow_mixed_headers(MediaContentDescription::kMedia);
+  EXPECT_EQ(MediaContentDescription::kMedia,
+            video_desc.extmap_allow_mixed_headers());
+  video_desc.set_extmap_allow_mixed_headers(MediaContentDescription::kSession);
+  EXPECT_EQ(MediaContentDescription::kSession,
+            video_desc.extmap_allow_mixed_headers());
+
+  // Not allowed to downgrade from kSession to kMedia.
+  video_desc.set_extmap_allow_mixed_headers(MediaContentDescription::kMedia);
+  EXPECT_EQ(MediaContentDescription::kSession,
+            video_desc.extmap_allow_mixed_headers());
+
+  // Always okay to set not supported.
+  video_desc.set_extmap_allow_mixed_headers(MediaContentDescription::kNo);
+  EXPECT_EQ(MediaContentDescription::kNo,
+            video_desc.extmap_allow_mixed_headers());
+  video_desc.set_extmap_allow_mixed_headers(MediaContentDescription::kMedia);
+  EXPECT_EQ(MediaContentDescription::kMedia,
+            video_desc.extmap_allow_mixed_headers());
+  video_desc.set_extmap_allow_mixed_headers(MediaContentDescription::kNo);
+  EXPECT_EQ(MediaContentDescription::kNo,
+            video_desc.extmap_allow_mixed_headers());
+}
+
+TEST(MediaContentDescriptionTest, MixedOneTwoByteHeaderSupported) {
+  VideoContentDescription video_desc;
+  video_desc.set_extmap_allow_mixed_headers(MediaContentDescription::kNo);
+  EXPECT_FALSE(video_desc.mixed_one_two_byte_header_extensions_supported());
+  video_desc.set_extmap_allow_mixed_headers(MediaContentDescription::kMedia);
+  EXPECT_TRUE(video_desc.mixed_one_two_byte_header_extensions_supported());
+  video_desc.set_extmap_allow_mixed_headers(MediaContentDescription::kSession);
+  EXPECT_TRUE(video_desc.mixed_one_two_byte_header_extensions_supported());
+}
+
+TEST(SessionDescriptionTest, SetExtmapAllowMixed) {
+  SessionDescription session_desc;
+  session_desc.set_extmap_allow_mixed_headers(true);
+  EXPECT_TRUE(session_desc.extmap_allow_mixed_headers());
+  session_desc.set_extmap_allow_mixed_headers(false);
+  EXPECT_FALSE(session_desc.extmap_allow_mixed_headers());
+}
+
+TEST(SessionDescriptionTest, SetExtmapAllowMixedPropagatesToMediaLevel) {
+  SessionDescription session_desc;
+  MediaContentDescription* video_desc = new VideoContentDescription();
+  session_desc.AddContent("video", MediaProtocolType::kRtp, video_desc);
+
+  // Setting true on session level propagates to media level.
+  session_desc.set_extmap_allow_mixed_headers(true);
+  EXPECT_EQ(MediaContentDescription::kSession,
+            video_desc->extmap_allow_mixed_headers());
+
+  // Don't downgrade from session level to media level
+  video_desc->set_extmap_allow_mixed_headers(MediaContentDescription::kMedia);
+  EXPECT_EQ(MediaContentDescription::kSession,
+            video_desc->extmap_allow_mixed_headers());
+
+  // Setting false on session level propagates to media level if the current
+  // state is kSession.
+  session_desc.set_extmap_allow_mixed_headers(false);
+  EXPECT_EQ(MediaContentDescription::kNo,
+            video_desc->extmap_allow_mixed_headers());
+
+  // Now possible to set at media level.
+  video_desc->set_extmap_allow_mixed_headers(MediaContentDescription::kMedia);
+  EXPECT_EQ(MediaContentDescription::kMedia,
+            video_desc->extmap_allow_mixed_headers());
+
+  // Setting false on session level does not override on media level if current
+  // state is kMedia.
+  session_desc.set_extmap_allow_mixed_headers(false);
+  EXPECT_EQ(MediaContentDescription::kMedia,
+            video_desc->extmap_allow_mixed_headers());
+
+  // Setting true on session level overrides setting on media level.
+  session_desc.set_extmap_allow_mixed_headers(true);
+  EXPECT_EQ(MediaContentDescription::kSession,
+            video_desc->extmap_allow_mixed_headers());
+}
+
+TEST(SessionDescriptionTest, AddContentTransfersExtmapAllowMixedSetting) {
+  SessionDescription session_desc;
+  session_desc.set_extmap_allow_mixed_headers(false);
+  MediaContentDescription* audio_desc = new AudioContentDescription();
+  audio_desc->set_extmap_allow_mixed_headers(MediaContentDescription::kMedia);
+
+  // If session setting is false, media level setting is preserved when new
+  // content is added.
+  session_desc.AddContent("audio", MediaProtocolType::kRtp, audio_desc);
+  EXPECT_EQ(MediaContentDescription::kMedia,
+            audio_desc->extmap_allow_mixed_headers());
+
+  // If session setting is true, it's transferred to media level when new
+  // content is added.
+  session_desc.set_extmap_allow_mixed_headers(true);
+  MediaContentDescription* video_desc = new VideoContentDescription();
+  session_desc.AddContent("video", MediaProtocolType::kRtp, video_desc);
+  EXPECT_EQ(MediaContentDescription::kSession,
+            video_desc->extmap_allow_mixed_headers());
+
+  // Session level setting overrides media level when new content is added.
+  MediaContentDescription* data_desc = new DataContentDescription;
+  data_desc->set_extmap_allow_mixed_headers(MediaContentDescription::kMedia);
+  session_desc.AddContent("data", MediaProtocolType::kRtp, data_desc);
+  EXPECT_EQ(MediaContentDescription::kSession,
+            data_desc->extmap_allow_mixed_headers());
+}
+
+}  // namespace cricket
diff --git a/pc/webrtcsdp.cc b/pc/webrtcsdp.cc
index 1260582..cf6b10d 100644
--- a/pc/webrtcsdp.cc
+++ b/pc/webrtcsdp.cc
@@ -856,7 +856,7 @@
   }
 
   // Mixed one- and two-byte header extension.
-  if (desc->mixed_one_two_byte_header_extensions_supported()) {
+  if (desc->extmap_allow_mixed_headers()) {
     InitAttrLine(kAttributeExtmapAllowMixed, &os);
     AddLine(os.str(), &message);
   }
@@ -1496,7 +1496,7 @@
   // The attribute MUST be either on session level or media level. We support
   // responding on both levels, however, we don't respond on media level if it's
   // set on session level.
-  if (media_desc->mixed_one_two_byte_header_extensions_supported() ==
+  if (media_desc->extmap_allow_mixed_headers() ==
       MediaContentDescription::kMedia) {
     InitAttrLine(kAttributeExtmapAllowMixed, &os);
     AddLine(os.str(), message);
@@ -2015,7 +2015,7 @@
   std::string line;
 
   desc->set_msid_supported(false);
-  desc->set_mixed_one_two_byte_header_extensions_supported(false);
+  desc->set_extmap_allow_mixed_headers(false);
   // RFC 4566
   // v=  (protocol version)
   if (!GetLineWithType(message, pos, &line, kLineTypeVersion)) {
@@ -2153,7 +2153,7 @@
       desc->set_msid_supported(
           CaseInsensitiveFind(semantics, kMediaStreamSemantic));
     } else if (HasAttribute(line, kAttributeExtmapAllowMixed)) {
-      desc->set_mixed_one_two_byte_header_extensions_supported(true);
+      desc->set_extmap_allow_mixed_headers(true);
     } else if (HasAttribute(line, kAttributeExtmap)) {
       RtpExtension extmap;
       if (!ParseExtmap(line, &extmap, error)) {
@@ -2525,10 +2525,6 @@
     }
 
     if (IsRtp(protocol)) {
-      if (desc->mixed_one_two_byte_header_extensions_supported()) {
-        content->set_mixed_one_two_byte_header_extensions_supported(
-            MediaContentDescription::kSession);
-      }
       // Set the extmap.
       if (!session_extmaps.empty() &&
           !content->rtp_header_extensions().empty()) {
@@ -2929,7 +2925,7 @@
       } else if (HasAttribute(line, kAttributeSendRecv)) {
         media_desc->set_direction(RtpTransceiverDirection::kSendRecv);
       } else if (HasAttribute(line, kAttributeExtmapAllowMixed)) {
-        media_desc->set_mixed_one_two_byte_header_extensions_supported(
+        media_desc->set_extmap_allow_mixed_headers(
             MediaContentDescription::kMedia);
       } else if (HasAttribute(line, kAttributeExtmap)) {
         RtpExtension extmap;
diff --git a/pc/webrtcsdp_unittest.cc b/pc/webrtcsdp_unittest.cc
index 3111724..0ef15c8 100644
--- a/pc/webrtcsdp_unittest.cc
+++ b/pc/webrtcsdp_unittest.cc
@@ -1285,8 +1285,8 @@
     EXPECT_EQ(cd1->streams(), cd2->streams());
 
     // extmap-allow-mixed
-    EXPECT_EQ(cd1->mixed_one_two_byte_header_extensions_supported(),
-              cd2->mixed_one_two_byte_header_extensions_supported());
+    EXPECT_EQ(cd1->extmap_allow_mixed_headers(),
+              cd2->extmap_allow_mixed_headers());
 
     // extmap
     ASSERT_EQ(cd1->rtp_header_extensions().size(),
@@ -1404,8 +1404,8 @@
 
     // global attributes
     EXPECT_EQ(desc1.msid_supported(), desc2.msid_supported());
-    EXPECT_EQ(desc1.mixed_one_two_byte_header_extensions_supported(),
-              desc2.mixed_one_two_byte_header_extensions_supported());
+    EXPECT_EQ(desc1.extmap_allow_mixed_headers(),
+              desc2.extmap_allow_mixed_headers());
   }
 
   bool CompareSessionDescription(const JsepSessionDescription& desc1,
@@ -2102,8 +2102,7 @@
 }
 
 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithExtmapAllowMixed) {
-  jdesc_.description()->set_mixed_one_two_byte_header_extensions_supported(
-      true);
+  jdesc_.description()->set_extmap_allow_mixed_headers(true);
   TestSerialize(jdesc_);
 }
 
@@ -2114,9 +2113,9 @@
   cricket::MediaContentDescription* audio_desc =
       jdesc_.description()->GetContentDescriptionByName(kAudioContentName);
   ASSERT_TRUE(audio_desc);
-  video_desc->set_mixed_one_two_byte_header_extensions_supported(
+  video_desc->set_extmap_allow_mixed_headers(
       cricket::MediaContentDescription::kMedia);
-  audio_desc->set_mixed_one_two_byte_header_extensions_supported(
+  audio_desc->set_extmap_allow_mixed_headers(
       cricket::MediaContentDescription::kMedia);
   TestSerialize(jdesc_);
 }
@@ -2458,46 +2457,8 @@
   EXPECT_TRUE(CompareSessionDescription(jdesc_, jdesc));
 }
 
-TEST_F(WebRtcSdpTest, SessionLevelMixedHeaderExtensionsAlsoSetsMediaSetting) {
-  cricket::MediaContentDescription* video_desc =
-      jdesc_.description()->GetContentDescriptionByName(kVideoContentName);
-  ASSERT_TRUE(video_desc);
-  cricket::MediaContentDescription* audio_desc =
-      jdesc_.description()->GetContentDescriptionByName(kAudioContentName);
-  ASSERT_TRUE(audio_desc);
-
-  // Setting true on session level propagates to media level.
-  jdesc_.description()->set_mixed_one_two_byte_header_extensions_supported(
-      true);
-  EXPECT_EQ(cricket::MediaContentDescription::kSession,
-            video_desc->mixed_one_two_byte_header_extensions_supported());
-  EXPECT_EQ(cricket::MediaContentDescription::kSession,
-            audio_desc->mixed_one_two_byte_header_extensions_supported());
-
-  // Don't downgrade from session level to media level
-  video_desc->set_mixed_one_two_byte_header_extensions_supported(
-      cricket::MediaContentDescription::kMedia);
-  EXPECT_EQ(cricket::MediaContentDescription::kSession,
-            video_desc->mixed_one_two_byte_header_extensions_supported());
-
-  // Setting false on session level propagates to media level.
-  jdesc_.description()->set_mixed_one_two_byte_header_extensions_supported(
-      false);
-  EXPECT_EQ(cricket::MediaContentDescription::kNo,
-            video_desc->mixed_one_two_byte_header_extensions_supported());
-  EXPECT_EQ(cricket::MediaContentDescription::kNo,
-            audio_desc->mixed_one_two_byte_header_extensions_supported());
-
-  // Now possible to set at media level.
-  video_desc->set_mixed_one_two_byte_header_extensions_supported(
-      cricket::MediaContentDescription::kMedia);
-  EXPECT_EQ(cricket::MediaContentDescription::kMedia,
-            video_desc->mixed_one_two_byte_header_extensions_supported());
-}
-
 TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithExtmapAllowMixed) {
-  jdesc_.description()->set_mixed_one_two_byte_header_extensions_supported(
-      true);
+  jdesc_.description()->set_extmap_allow_mixed_headers(true);
   std::string sdp_with_extmap_allow_mixed = kSdpFullString;
   InjectAfter("t=0 0\r\n", kExtmapAllowMixed, &sdp_with_extmap_allow_mixed);
   // Deserialize
@@ -2508,8 +2469,7 @@
 }
 
 TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithoutExtmapAllowMixed) {
-  jdesc_.description()->set_mixed_one_two_byte_header_extensions_supported(
-      false);
+  jdesc_.description()->set_extmap_allow_mixed_headers(false);
   std::string sdp_without_extmap_allow_mixed = kSdpFullString;
   // Deserialize
   JsepSessionDescription jdesc_deserialized(kDummyType);
@@ -2526,9 +2486,9 @@
   cricket::MediaContentDescription* audio_desc =
       jdesc_.description()->GetContentDescriptionByName(kAudioContentName);
   ASSERT_TRUE(audio_desc);
-  video_desc->set_mixed_one_two_byte_header_extensions_supported(
+  video_desc->set_extmap_allow_mixed_headers(
       cricket::MediaContentDescription::kMedia);
-  audio_desc->set_mixed_one_two_byte_header_extensions_supported(
+  audio_desc->set_extmap_allow_mixed_headers(
       cricket::MediaContentDescription::kMedia);
 
   std::string sdp_with_extmap_allow_mixed = kSdpFullString;