You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
6.1 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Copyright 2018 The WebRTC project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #include "pc/session_description.h"
  11. #include <memory>
  12. #include "test/gtest.h"
  13. namespace cricket {
  14. TEST(MediaContentDescriptionTest, ExtmapAllowMixedDefaultValue) {
  15. VideoContentDescription video_desc;
  16. EXPECT_EQ(MediaContentDescription::kNo, video_desc.extmap_allow_mixed_enum());
  17. }
  18. TEST(MediaContentDescriptionTest, SetExtmapAllowMixed) {
  19. VideoContentDescription video_desc;
  20. video_desc.set_extmap_allow_mixed_enum(MediaContentDescription::kNo);
  21. EXPECT_EQ(MediaContentDescription::kNo, video_desc.extmap_allow_mixed_enum());
  22. video_desc.set_extmap_allow_mixed_enum(MediaContentDescription::kMedia);
  23. EXPECT_EQ(MediaContentDescription::kMedia,
  24. video_desc.extmap_allow_mixed_enum());
  25. video_desc.set_extmap_allow_mixed_enum(MediaContentDescription::kSession);
  26. EXPECT_EQ(MediaContentDescription::kSession,
  27. video_desc.extmap_allow_mixed_enum());
  28. // Not allowed to downgrade from kSession to kMedia.
  29. video_desc.set_extmap_allow_mixed_enum(MediaContentDescription::kMedia);
  30. EXPECT_EQ(MediaContentDescription::kSession,
  31. video_desc.extmap_allow_mixed_enum());
  32. // Always okay to set not supported.
  33. video_desc.set_extmap_allow_mixed_enum(MediaContentDescription::kNo);
  34. EXPECT_EQ(MediaContentDescription::kNo, video_desc.extmap_allow_mixed_enum());
  35. video_desc.set_extmap_allow_mixed_enum(MediaContentDescription::kMedia);
  36. EXPECT_EQ(MediaContentDescription::kMedia,
  37. video_desc.extmap_allow_mixed_enum());
  38. video_desc.set_extmap_allow_mixed_enum(MediaContentDescription::kNo);
  39. EXPECT_EQ(MediaContentDescription::kNo, video_desc.extmap_allow_mixed_enum());
  40. }
  41. TEST(MediaContentDescriptionTest, MixedOneTwoByteHeaderSupported) {
  42. VideoContentDescription video_desc;
  43. video_desc.set_extmap_allow_mixed_enum(MediaContentDescription::kNo);
  44. EXPECT_FALSE(video_desc.extmap_allow_mixed());
  45. video_desc.set_extmap_allow_mixed_enum(MediaContentDescription::kMedia);
  46. EXPECT_TRUE(video_desc.extmap_allow_mixed());
  47. video_desc.set_extmap_allow_mixed_enum(MediaContentDescription::kSession);
  48. EXPECT_TRUE(video_desc.extmap_allow_mixed());
  49. }
  50. TEST(SessionDescriptionTest, SetExtmapAllowMixed) {
  51. SessionDescription session_desc;
  52. session_desc.set_extmap_allow_mixed(true);
  53. EXPECT_TRUE(session_desc.extmap_allow_mixed());
  54. session_desc.set_extmap_allow_mixed(false);
  55. EXPECT_FALSE(session_desc.extmap_allow_mixed());
  56. }
  57. TEST(SessionDescriptionTest, SetExtmapAllowMixedPropagatesToMediaLevel) {
  58. SessionDescription session_desc;
  59. session_desc.AddContent("video", MediaProtocolType::kRtp,
  60. std::make_unique<VideoContentDescription>());
  61. MediaContentDescription* video_desc =
  62. session_desc.GetContentDescriptionByName("video");
  63. // Setting true on session level propagates to media level.
  64. session_desc.set_extmap_allow_mixed(true);
  65. EXPECT_EQ(MediaContentDescription::kSession,
  66. video_desc->extmap_allow_mixed_enum());
  67. // Don't downgrade from session level to media level
  68. video_desc->set_extmap_allow_mixed_enum(MediaContentDescription::kMedia);
  69. EXPECT_EQ(MediaContentDescription::kSession,
  70. video_desc->extmap_allow_mixed_enum());
  71. // Setting false on session level propagates to media level if the current
  72. // state is kSession.
  73. session_desc.set_extmap_allow_mixed(false);
  74. EXPECT_EQ(MediaContentDescription::kNo,
  75. video_desc->extmap_allow_mixed_enum());
  76. // Now possible to set at media level.
  77. video_desc->set_extmap_allow_mixed_enum(MediaContentDescription::kMedia);
  78. EXPECT_EQ(MediaContentDescription::kMedia,
  79. video_desc->extmap_allow_mixed_enum());
  80. // Setting false on session level does not override on media level if current
  81. // state is kMedia.
  82. session_desc.set_extmap_allow_mixed(false);
  83. EXPECT_EQ(MediaContentDescription::kMedia,
  84. video_desc->extmap_allow_mixed_enum());
  85. // Setting true on session level overrides setting on media level.
  86. session_desc.set_extmap_allow_mixed(true);
  87. EXPECT_EQ(MediaContentDescription::kSession,
  88. video_desc->extmap_allow_mixed_enum());
  89. }
  90. TEST(SessionDescriptionTest, AddContentTransfersExtmapAllowMixedSetting) {
  91. SessionDescription session_desc;
  92. session_desc.set_extmap_allow_mixed(false);
  93. std::unique_ptr<MediaContentDescription> audio_desc =
  94. std::make_unique<AudioContentDescription>();
  95. audio_desc->set_extmap_allow_mixed_enum(MediaContentDescription::kMedia);
  96. // If session setting is false, media level setting is preserved when new
  97. // content is added.
  98. session_desc.AddContent("audio", MediaProtocolType::kRtp,
  99. std::move(audio_desc));
  100. EXPECT_EQ(MediaContentDescription::kMedia,
  101. session_desc.GetContentDescriptionByName("audio")
  102. ->extmap_allow_mixed_enum());
  103. // If session setting is true, it's transferred to media level when new
  104. // content is added.
  105. session_desc.set_extmap_allow_mixed(true);
  106. std::unique_ptr<MediaContentDescription> video_desc =
  107. std::make_unique<VideoContentDescription>();
  108. session_desc.AddContent("video", MediaProtocolType::kRtp,
  109. std::move(video_desc));
  110. EXPECT_EQ(MediaContentDescription::kSession,
  111. session_desc.GetContentDescriptionByName("video")
  112. ->extmap_allow_mixed_enum());
  113. // Session level setting overrides media level when new content is added.
  114. std::unique_ptr<MediaContentDescription> data_desc =
  115. std::make_unique<RtpDataContentDescription>();
  116. data_desc->set_extmap_allow_mixed_enum(MediaContentDescription::kMedia);
  117. session_desc.AddContent("data", MediaProtocolType::kRtp,
  118. std::move(data_desc));
  119. EXPECT_EQ(MediaContentDescription::kSession,
  120. session_desc.GetContentDescriptionByName("data")
  121. ->extmap_allow_mixed_enum());
  122. }
  123. } // namespace cricket