henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
kjellander | 1afca73 | 2016-02-07 20:46:45 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3 | * |
kjellander | 1afca73 | 2016-02-07 20:46:45 -0800 | [diff] [blame] | 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. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #include "media/base/streamparams.h" |
| 12 | #include "media/base/testutils.h" |
| 13 | #include "rtc_base/arraysize.h" |
| 14 | #include "rtc_base/gunit.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 15 | |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 16 | static const uint32_t kSsrcs1[] = {1}; |
| 17 | static const uint32_t kSsrcs2[] = {1, 2}; |
| 18 | static const uint32_t kSsrcs3[] = {1, 2, 3}; |
| 19 | static const uint32_t kRtxSsrcs3[] = {4, 5, 6}; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 20 | |
| 21 | static cricket::StreamParams CreateStreamParamsWithSsrcGroup( |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 22 | const std::string& semantics, |
| 23 | const uint32_t ssrcs_in[], |
| 24 | size_t len) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 25 | cricket::StreamParams stream; |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 26 | std::vector<uint32_t> ssrcs(ssrcs_in, ssrcs_in + len); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 27 | cricket::SsrcGroup sg(semantics, ssrcs); |
| 28 | stream.ssrcs = ssrcs; |
| 29 | stream.ssrc_groups.push_back(sg); |
| 30 | return stream; |
| 31 | } |
| 32 | |
| 33 | TEST(SsrcGroup, EqualNotEqual) { |
| 34 | cricket::SsrcGroup ssrc_groups[] = { |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 35 | cricket::SsrcGroup("ABC", MAKE_VECTOR(kSsrcs1)), |
| 36 | cricket::SsrcGroup("ABC", MAKE_VECTOR(kSsrcs2)), |
| 37 | cricket::SsrcGroup("Abc", MAKE_VECTOR(kSsrcs2)), |
| 38 | cricket::SsrcGroup("abc", MAKE_VECTOR(kSsrcs2)), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 39 | }; |
| 40 | |
tfarina | 5237aaf | 2015-11-10 23:44:30 -0800 | [diff] [blame] | 41 | for (size_t i = 0; i < arraysize(ssrc_groups); ++i) { |
| 42 | for (size_t j = 0; j < arraysize(ssrc_groups); ++j) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 43 | EXPECT_EQ((ssrc_groups[i] == ssrc_groups[j]), (i == j)); |
| 44 | EXPECT_EQ((ssrc_groups[i] != ssrc_groups[j]), (i != j)); |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | TEST(SsrcGroup, HasSemantics) { |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 50 | cricket::SsrcGroup sg1("ABC", MAKE_VECTOR(kSsrcs1)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 51 | EXPECT_TRUE(sg1.has_semantics("ABC")); |
| 52 | |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 53 | cricket::SsrcGroup sg2("Abc", MAKE_VECTOR(kSsrcs1)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 54 | EXPECT_FALSE(sg2.has_semantics("ABC")); |
| 55 | |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 56 | cricket::SsrcGroup sg3("abc", MAKE_VECTOR(kSsrcs1)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 57 | EXPECT_FALSE(sg3.has_semantics("ABC")); |
| 58 | } |
| 59 | |
| 60 | TEST(SsrcGroup, ToString) { |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 61 | cricket::SsrcGroup sg1("ABC", MAKE_VECTOR(kSsrcs1)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 62 | EXPECT_STREQ("{semantics:ABC;ssrcs:[1]}", sg1.ToString().c_str()); |
| 63 | } |
| 64 | |
| 65 | TEST(StreamParams, CreateLegacy) { |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 66 | const uint32_t ssrc = 7; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 67 | cricket::StreamParams one_sp = cricket::StreamParams::CreateLegacy(ssrc); |
| 68 | EXPECT_EQ(1U, one_sp.ssrcs.size()); |
| 69 | EXPECT_EQ(ssrc, one_sp.first_ssrc()); |
| 70 | EXPECT_TRUE(one_sp.has_ssrcs()); |
| 71 | EXPECT_TRUE(one_sp.has_ssrc(ssrc)); |
| 72 | EXPECT_FALSE(one_sp.has_ssrc(ssrc+1)); |
| 73 | EXPECT_FALSE(one_sp.has_ssrc_groups()); |
| 74 | EXPECT_EQ(0U, one_sp.ssrc_groups.size()); |
| 75 | } |
| 76 | |
| 77 | TEST(StreamParams, HasSsrcGroup) { |
| 78 | cricket::StreamParams sp = |
tfarina | 5237aaf | 2015-11-10 23:44:30 -0800 | [diff] [blame] | 79 | CreateStreamParamsWithSsrcGroup("XYZ", kSsrcs2, arraysize(kSsrcs2)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 80 | EXPECT_EQ(2U, sp.ssrcs.size()); |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 81 | EXPECT_EQ(kSsrcs2[0], sp.first_ssrc()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 82 | EXPECT_TRUE(sp.has_ssrcs()); |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 83 | EXPECT_TRUE(sp.has_ssrc(kSsrcs2[0])); |
| 84 | EXPECT_TRUE(sp.has_ssrc(kSsrcs2[1])); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 85 | EXPECT_TRUE(sp.has_ssrc_group("XYZ")); |
| 86 | EXPECT_EQ(1U, sp.ssrc_groups.size()); |
| 87 | EXPECT_EQ(2U, sp.ssrc_groups[0].ssrcs.size()); |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 88 | EXPECT_EQ(kSsrcs2[0], sp.ssrc_groups[0].ssrcs[0]); |
| 89 | EXPECT_EQ(kSsrcs2[1], sp.ssrc_groups[0].ssrcs[1]); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | TEST(StreamParams, GetSsrcGroup) { |
| 93 | cricket::StreamParams sp = |
tfarina | 5237aaf | 2015-11-10 23:44:30 -0800 | [diff] [blame] | 94 | CreateStreamParamsWithSsrcGroup("XYZ", kSsrcs2, arraysize(kSsrcs2)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 95 | EXPECT_EQ(NULL, sp.get_ssrc_group("xyz")); |
| 96 | EXPECT_EQ(&sp.ssrc_groups[0], sp.get_ssrc_group("XYZ")); |
| 97 | } |
| 98 | |
| 99 | TEST(StreamParams, EqualNotEqual) { |
| 100 | cricket::StreamParams l1 = cricket::StreamParams::CreateLegacy(1); |
| 101 | cricket::StreamParams l2 = cricket::StreamParams::CreateLegacy(2); |
| 102 | cricket::StreamParams sg1 = |
tfarina | 5237aaf | 2015-11-10 23:44:30 -0800 | [diff] [blame] | 103 | CreateStreamParamsWithSsrcGroup("ABC", kSsrcs1, arraysize(kSsrcs1)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 104 | cricket::StreamParams sg2 = |
tfarina | 5237aaf | 2015-11-10 23:44:30 -0800 | [diff] [blame] | 105 | CreateStreamParamsWithSsrcGroup("ABC", kSsrcs2, arraysize(kSsrcs2)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 106 | cricket::StreamParams sg3 = |
tfarina | 5237aaf | 2015-11-10 23:44:30 -0800 | [diff] [blame] | 107 | CreateStreamParamsWithSsrcGroup("Abc", kSsrcs2, arraysize(kSsrcs2)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 108 | cricket::StreamParams sg4 = |
tfarina | 5237aaf | 2015-11-10 23:44:30 -0800 | [diff] [blame] | 109 | CreateStreamParamsWithSsrcGroup("abc", kSsrcs2, arraysize(kSsrcs2)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 110 | cricket::StreamParams sps[] = {l1, l2, sg1, sg2, sg3, sg4}; |
| 111 | |
tfarina | 5237aaf | 2015-11-10 23:44:30 -0800 | [diff] [blame] | 112 | for (size_t i = 0; i < arraysize(sps); ++i) { |
| 113 | for (size_t j = 0; j < arraysize(sps); ++j) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 114 | EXPECT_EQ((sps[i] == sps[j]), (i == j)); |
| 115 | EXPECT_EQ((sps[i] != sps[j]), (i != j)); |
| 116 | } |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | TEST(StreamParams, FidFunctions) { |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 121 | uint32_t fid_ssrc; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 122 | |
| 123 | cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(1); |
| 124 | EXPECT_FALSE(sp.AddFidSsrc(10, 20)); |
| 125 | EXPECT_TRUE(sp.AddFidSsrc(1, 2)); |
| 126 | EXPECT_TRUE(sp.GetFidSsrc(1, &fid_ssrc)); |
| 127 | EXPECT_EQ(2u, fid_ssrc); |
| 128 | EXPECT_FALSE(sp.GetFidSsrc(15, &fid_ssrc)); |
| 129 | |
| 130 | sp.add_ssrc(20); |
brandtr | 9688e38 | 2016-11-22 00:59:48 -0800 | [diff] [blame] | 131 | EXPECT_TRUE(sp.AddFidSsrc(20, 30)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 132 | EXPECT_TRUE(sp.GetFidSsrc(20, &fid_ssrc)); |
| 133 | EXPECT_EQ(30u, fid_ssrc); |
| 134 | |
| 135 | // Manually create SsrcGroup to test bounds-checking |
| 136 | // in GetSecondarySsrc. We construct an invalid StreamParams |
| 137 | // for this. |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 138 | std::vector<uint32_t> fid_vector; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 139 | fid_vector.push_back(13); |
| 140 | cricket::SsrcGroup invalid_fid_group(cricket::kFidSsrcGroupSemantics, |
| 141 | fid_vector); |
| 142 | cricket::StreamParams sp_invalid; |
| 143 | sp_invalid.add_ssrc(13); |
| 144 | sp_invalid.ssrc_groups.push_back(invalid_fid_group); |
| 145 | EXPECT_FALSE(sp_invalid.GetFidSsrc(13, &fid_ssrc)); |
| 146 | } |
| 147 | |
pbos@webrtc.org | 5301b0f | 2014-07-17 08:51:46 +0000 | [diff] [blame] | 148 | TEST(StreamParams, GetPrimaryAndFidSsrcs) { |
| 149 | cricket::StreamParams sp; |
| 150 | sp.ssrcs.push_back(1); |
| 151 | sp.ssrcs.push_back(2); |
| 152 | sp.ssrcs.push_back(3); |
| 153 | |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 154 | std::vector<uint32_t> primary_ssrcs; |
pbos@webrtc.org | 5301b0f | 2014-07-17 08:51:46 +0000 | [diff] [blame] | 155 | sp.GetPrimarySsrcs(&primary_ssrcs); |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 156 | std::vector<uint32_t> fid_ssrcs; |
pbos@webrtc.org | 5301b0f | 2014-07-17 08:51:46 +0000 | [diff] [blame] | 157 | sp.GetFidSsrcs(primary_ssrcs, &fid_ssrcs); |
| 158 | ASSERT_EQ(1u, primary_ssrcs.size()); |
| 159 | EXPECT_EQ(1u, primary_ssrcs[0]); |
| 160 | ASSERT_EQ(0u, fid_ssrcs.size()); |
| 161 | |
| 162 | sp.ssrc_groups.push_back( |
| 163 | cricket::SsrcGroup(cricket::kSimSsrcGroupSemantics, sp.ssrcs)); |
| 164 | sp.AddFidSsrc(1, 10); |
| 165 | sp.AddFidSsrc(2, 20); |
| 166 | |
| 167 | primary_ssrcs.clear(); |
| 168 | sp.GetPrimarySsrcs(&primary_ssrcs); |
| 169 | fid_ssrcs.clear(); |
| 170 | sp.GetFidSsrcs(primary_ssrcs, &fid_ssrcs); |
| 171 | ASSERT_EQ(3u, primary_ssrcs.size()); |
| 172 | EXPECT_EQ(1u, primary_ssrcs[0]); |
| 173 | EXPECT_EQ(2u, primary_ssrcs[1]); |
| 174 | EXPECT_EQ(3u, primary_ssrcs[2]); |
| 175 | ASSERT_EQ(2u, fid_ssrcs.size()); |
| 176 | EXPECT_EQ(10u, fid_ssrcs[0]); |
| 177 | EXPECT_EQ(20u, fid_ssrcs[1]); |
| 178 | } |
| 179 | |
brandtr | 9688e38 | 2016-11-22 00:59:48 -0800 | [diff] [blame] | 180 | TEST(StreamParams, FecFrFunctions) { |
| 181 | uint32_t fecfr_ssrc; |
| 182 | |
| 183 | cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(1); |
| 184 | EXPECT_FALSE(sp.AddFecFrSsrc(10, 20)); |
| 185 | EXPECT_TRUE(sp.AddFecFrSsrc(1, 2)); |
| 186 | EXPECT_TRUE(sp.GetFecFrSsrc(1, &fecfr_ssrc)); |
| 187 | EXPECT_EQ(2u, fecfr_ssrc); |
| 188 | EXPECT_FALSE(sp.GetFecFrSsrc(15, &fecfr_ssrc)); |
| 189 | |
| 190 | sp.add_ssrc(20); |
| 191 | EXPECT_TRUE(sp.AddFecFrSsrc(20, 30)); |
| 192 | EXPECT_TRUE(sp.GetFecFrSsrc(20, &fecfr_ssrc)); |
| 193 | EXPECT_EQ(30u, fecfr_ssrc); |
| 194 | |
| 195 | // Manually create SsrcGroup to test bounds-checking |
| 196 | // in GetSecondarySsrc. We construct an invalid StreamParams |
| 197 | // for this. |
| 198 | std::vector<uint32_t> fecfr_vector; |
| 199 | fecfr_vector.push_back(13); |
| 200 | cricket::SsrcGroup invalid_fecfr_group(cricket::kFecFrSsrcGroupSemantics, |
| 201 | fecfr_vector); |
| 202 | cricket::StreamParams sp_invalid; |
| 203 | sp_invalid.add_ssrc(13); |
| 204 | sp_invalid.ssrc_groups.push_back(invalid_fecfr_group); |
| 205 | EXPECT_FALSE(sp_invalid.GetFecFrSsrc(13, &fecfr_ssrc)); |
| 206 | } |
| 207 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 208 | TEST(StreamParams, ToString) { |
| 209 | cricket::StreamParams sp = |
tfarina | 5237aaf | 2015-11-10 23:44:30 -0800 | [diff] [blame] | 210 | CreateStreamParamsWithSsrcGroup("XYZ", kSsrcs2, arraysize(kSsrcs2)); |
Seth Hampson | 5b4f075 | 2018-04-02 16:31:36 -0700 | [diff] [blame^] | 211 | sp.set_stream_ids({"stream_id"}); |
| 212 | EXPECT_STREQ( |
| 213 | "{ssrcs:[1,2];ssrc_groups:{semantics:XYZ;ssrcs:[1,2]};stream_ids:stream_" |
| 214 | "id;}", |
| 215 | sp.ToString().c_str()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 216 | } |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 217 | |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 218 | TEST(StreamParams, TestIsOneSsrcStream_LegacyStream) { |
| 219 | EXPECT_TRUE( |
| 220 | cricket::IsOneSsrcStream(cricket::StreamParams::CreateLegacy(13))); |
| 221 | } |
| 222 | |
| 223 | TEST(StreamParams, TestIsOneSsrcStream_SingleRtxStream) { |
| 224 | cricket::StreamParams stream; |
| 225 | stream.add_ssrc(13); |
| 226 | EXPECT_TRUE(stream.AddFidSsrc(13, 14)); |
| 227 | EXPECT_TRUE(cricket::IsOneSsrcStream(stream)); |
| 228 | } |
| 229 | |
brandtr | 9688e38 | 2016-11-22 00:59:48 -0800 | [diff] [blame] | 230 | TEST(StreamParams, TestIsOneSsrcStream_SingleFlexfecStream) { |
| 231 | cricket::StreamParams stream; |
| 232 | stream.add_ssrc(13); |
| 233 | EXPECT_TRUE(stream.AddFecFrSsrc(13, 14)); |
| 234 | EXPECT_TRUE(cricket::IsOneSsrcStream(stream)); |
| 235 | } |
| 236 | |
| 237 | TEST(StreamParams, TestIsOneSsrcStream_SingleFlexfecAndRtxStream) { |
| 238 | cricket::StreamParams stream; |
| 239 | stream.add_ssrc(13); |
| 240 | EXPECT_TRUE(stream.AddFecFrSsrc(13, 14)); |
| 241 | EXPECT_TRUE(stream.AddFidSsrc(13, 15)); |
| 242 | EXPECT_TRUE(cricket::IsOneSsrcStream(stream)); |
| 243 | } |
| 244 | |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 245 | TEST(StreamParams, TestIsOneSsrcStream_SimulcastStream) { |
| 246 | EXPECT_FALSE(cricket::IsOneSsrcStream( |
| 247 | cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs2)))); |
| 248 | EXPECT_FALSE(cricket::IsOneSsrcStream( |
| 249 | cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs3)))); |
| 250 | } |
| 251 | |
| 252 | TEST(StreamParams, TestIsOneSsrcStream_SimRtxStream) { |
| 253 | cricket::StreamParams stream = |
| 254 | cricket::CreateSimWithRtxStreamParams("cname", |
| 255 | MAKE_VECTOR(kSsrcs3), |
| 256 | MAKE_VECTOR(kRtxSsrcs3)); |
| 257 | EXPECT_FALSE(cricket::IsOneSsrcStream(stream)); |
| 258 | } |
| 259 | |
| 260 | TEST(StreamParams, TestIsSimulcastStream_LegacyStream) { |
| 261 | EXPECT_FALSE( |
| 262 | cricket::IsSimulcastStream(cricket::StreamParams::CreateLegacy(13))); |
| 263 | } |
| 264 | |
| 265 | TEST(StreamParams, TestIsSimulcastStream_SingleRtxStream) { |
| 266 | cricket::StreamParams stream; |
| 267 | stream.add_ssrc(13); |
| 268 | EXPECT_TRUE(stream.AddFidSsrc(13, 14)); |
| 269 | EXPECT_FALSE(cricket::IsSimulcastStream(stream)); |
| 270 | } |
| 271 | |
| 272 | TEST(StreamParams, TestIsSimulcastStream_SimulcastStream) { |
| 273 | EXPECT_TRUE(cricket::IsSimulcastStream( |
| 274 | cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs2)))); |
| 275 | EXPECT_TRUE(cricket::IsSimulcastStream( |
| 276 | cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs3)))); |
| 277 | } |
| 278 | |
| 279 | TEST(StreamParams, TestIsSimulcastStream_SimRtxStream) { |
| 280 | cricket::StreamParams stream = |
| 281 | cricket::CreateSimWithRtxStreamParams("cname", |
| 282 | MAKE_VECTOR(kSsrcs3), |
| 283 | MAKE_VECTOR(kRtxSsrcs3)); |
| 284 | EXPECT_TRUE(cricket::IsSimulcastStream(stream)); |
| 285 | } |
| 286 | |
| 287 | TEST(StreamParams, TestIsSimulcastStream_InvalidStreams) { |
| 288 | // stream1 has extra non-sim, non-fid ssrc. |
| 289 | cricket::StreamParams stream1 = |
| 290 | cricket::CreateSimWithRtxStreamParams("cname", |
| 291 | MAKE_VECTOR(kSsrcs3), |
| 292 | MAKE_VECTOR(kRtxSsrcs3)); |
| 293 | stream1.add_ssrc(25); |
| 294 | EXPECT_FALSE(cricket::IsSimulcastStream(stream1)); |
| 295 | |
| 296 | // stream2 has invalid fid-group (no primary). |
| 297 | cricket::StreamParams stream2; |
| 298 | stream2.add_ssrc(13); |
| 299 | EXPECT_TRUE(stream2.AddFidSsrc(13, 14)); |
kjellander | a96e2d7 | 2016-02-04 23:52:28 -0800 | [diff] [blame] | 300 | std::remove(stream2.ssrcs.begin(), stream2.ssrcs.end(), 13u); |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 301 | EXPECT_FALSE(cricket::IsSimulcastStream(stream2)); |
| 302 | |
| 303 | // stream3 has two SIM groups. |
| 304 | cricket::StreamParams stream3 = |
| 305 | cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs2)); |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 306 | std::vector<uint32_t> sim_ssrcs = MAKE_VECTOR(kRtxSsrcs3); |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 307 | cricket::SsrcGroup sg(cricket::kSimSsrcGroupSemantics, sim_ssrcs); |
| 308 | for (size_t i = 0; i < sim_ssrcs.size(); i++) { |
| 309 | stream3.add_ssrc(sim_ssrcs[i]); |
| 310 | } |
| 311 | stream3.ssrc_groups.push_back(sg); |
| 312 | EXPECT_FALSE(cricket::IsSimulcastStream(stream3)); |
| 313 | } |