OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2009 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2009 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/base/gunit.h" | 11 #include "webrtc/base/gunit.h" |
12 #include "webrtc/media/base/codec.h" | 12 #include "webrtc/media/base/codec.h" |
13 | 13 |
14 using cricket::AudioCodec; | 14 using cricket::AudioCodec; |
15 using cricket::Codec; | 15 using cricket::Codec; |
16 using cricket::DataCodec; | 16 using cricket::DataCodec; |
17 using cricket::FeedbackParam; | 17 using cricket::FeedbackParam; |
18 using cricket::VideoCodec; | 18 using cricket::VideoCodec; |
19 using cricket::kCodecParamAssociatedPayloadType; | 19 using cricket::kCodecParamAssociatedPayloadType; |
20 using cricket::kCodecParamMaxBitrate; | 20 using cricket::kCodecParamMaxBitrate; |
21 using cricket::kCodecParamMinBitrate; | 21 using cricket::kCodecParamMinBitrate; |
22 | 22 |
23 class CodecTest : public testing::Test { | 23 TEST(CodecTest, TestCodecOperators) { |
24 public: | |
25 CodecTest() {} | |
26 }; | |
27 | |
28 TEST_F(CodecTest, TestCodecOperators) { | |
29 Codec c0(96, "D", 1000); | 24 Codec c0(96, "D", 1000); |
30 c0.SetParam("a", 1); | 25 c0.SetParam("a", 1); |
31 | 26 |
32 Codec c1 = c0; | 27 Codec c1 = c0; |
33 EXPECT_TRUE(c1 == c0); | 28 EXPECT_TRUE(c1 == c0); |
34 | 29 |
35 int param_value0; | 30 int param_value0; |
36 int param_value1; | 31 int param_value1; |
37 EXPECT_TRUE(c0.GetParam("a", ¶m_value0)); | 32 EXPECT_TRUE(c0.GetParam("a", ¶m_value0)); |
38 EXPECT_TRUE(c1.GetParam("a", ¶m_value1)); | 33 EXPECT_TRUE(c1.GetParam("a", ¶m_value1)); |
(...skipping 12 matching lines...) Expand all Loading... |
51 | 46 |
52 c1 = c0; | 47 c1 = c0; |
53 c1.SetParam("a", 2); | 48 c1.SetParam("a", 2); |
54 EXPECT_TRUE(c0 != c1); | 49 EXPECT_TRUE(c0 != c1); |
55 | 50 |
56 Codec c5; | 51 Codec c5; |
57 Codec c6(0, "", 0); | 52 Codec c6(0, "", 0); |
58 EXPECT_TRUE(c5 == c6); | 53 EXPECT_TRUE(c5 == c6); |
59 } | 54 } |
60 | 55 |
61 TEST_F(CodecTest, TestAudioCodecOperators) { | 56 TEST(CodecTest, TestAudioCodecOperators) { |
62 AudioCodec c0(96, "A", 44100, 20000, 2); | 57 AudioCodec c0(96, "A", 44100, 20000, 2); |
63 AudioCodec c1(95, "A", 44100, 20000, 2); | 58 AudioCodec c1(95, "A", 44100, 20000, 2); |
64 AudioCodec c2(96, "x", 44100, 20000, 2); | 59 AudioCodec c2(96, "x", 44100, 20000, 2); |
65 AudioCodec c3(96, "A", 48000, 20000, 2); | 60 AudioCodec c3(96, "A", 48000, 20000, 2); |
66 AudioCodec c4(96, "A", 44100, 10000, 2); | 61 AudioCodec c4(96, "A", 44100, 10000, 2); |
67 AudioCodec c5(96, "A", 44100, 20000, 1); | 62 AudioCodec c5(96, "A", 44100, 20000, 1); |
68 EXPECT_TRUE(c0 != c1); | 63 EXPECT_TRUE(c0 != c1); |
69 EXPECT_TRUE(c0 != c2); | 64 EXPECT_TRUE(c0 != c2); |
70 EXPECT_TRUE(c0 != c3); | 65 EXPECT_TRUE(c0 != c3); |
71 EXPECT_TRUE(c0 != c4); | 66 EXPECT_TRUE(c0 != c4); |
(...skipping 16 matching lines...) Expand all Loading... |
88 c13.params["x"] = "abc"; | 83 c13.params["x"] = "abc"; |
89 EXPECT_TRUE(c10 != c0); | 84 EXPECT_TRUE(c10 != c0); |
90 EXPECT_TRUE(c11 != c0); | 85 EXPECT_TRUE(c11 != c0); |
91 EXPECT_TRUE(c11 != c10); | 86 EXPECT_TRUE(c11 != c10); |
92 EXPECT_TRUE(c12 != c0); | 87 EXPECT_TRUE(c12 != c0); |
93 EXPECT_TRUE(c12 != c10); | 88 EXPECT_TRUE(c12 != c10); |
94 EXPECT_TRUE(c12 != c11); | 89 EXPECT_TRUE(c12 != c11); |
95 EXPECT_TRUE(c13 == c10); | 90 EXPECT_TRUE(c13 == c10); |
96 } | 91 } |
97 | 92 |
98 TEST_F(CodecTest, TestAudioCodecMatches) { | 93 TEST(CodecTest, TestAudioCodecMatches) { |
99 // Test a codec with a static payload type. | 94 // Test a codec with a static payload type. |
100 AudioCodec c0(95, "A", 44100, 20000, 1); | 95 AudioCodec c0(95, "A", 44100, 20000, 1); |
101 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 44100, 20000, 1))); | 96 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 44100, 20000, 1))); |
102 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 44100, 20000, 0))); | 97 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 44100, 20000, 0))); |
103 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 44100, 0, 0))); | 98 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 44100, 0, 0))); |
104 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 0, 0, 0))); | 99 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 0, 0, 0))); |
105 EXPECT_FALSE(c0.Matches(AudioCodec(96, "", 44100, 20000, 1))); | 100 EXPECT_FALSE(c0.Matches(AudioCodec(96, "", 44100, 20000, 1))); |
106 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 55100, 20000, 1))); | 101 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 55100, 20000, 1))); |
107 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 44100, 30000, 1))); | 102 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 44100, 30000, 1))); |
108 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 44100, 20000, 2))); | 103 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 44100, 20000, 2))); |
(...skipping 19 matching lines...) Expand all Loading... |
128 // Backward compatibility with clients that might send "-1" (for default). | 123 // Backward compatibility with clients that might send "-1" (for default). |
129 EXPECT_TRUE(c2.Matches(AudioCodec(97, "A", 16000, -1, 1))); | 124 EXPECT_TRUE(c2.Matches(AudioCodec(97, "A", 16000, -1, 1))); |
130 | 125 |
131 // Stereo doesn't match channels = 0. | 126 // Stereo doesn't match channels = 0. |
132 AudioCodec c3(96, "A", 44100, 20000, 2); | 127 AudioCodec c3(96, "A", 44100, 20000, 2); |
133 EXPECT_TRUE(c3.Matches(AudioCodec(96, "A", 44100, 20000, 2))); | 128 EXPECT_TRUE(c3.Matches(AudioCodec(96, "A", 44100, 20000, 2))); |
134 EXPECT_FALSE(c3.Matches(AudioCodec(96, "A", 44100, 20000, 1))); | 129 EXPECT_FALSE(c3.Matches(AudioCodec(96, "A", 44100, 20000, 1))); |
135 EXPECT_FALSE(c3.Matches(AudioCodec(96, "A", 44100, 20000, 0))); | 130 EXPECT_FALSE(c3.Matches(AudioCodec(96, "A", 44100, 20000, 0))); |
136 } | 131 } |
137 | 132 |
138 TEST_F(CodecTest, TestVideoCodecOperators) { | 133 TEST(CodecTest, TestVideoCodecOperators) { |
139 VideoCodec c0(96, "V", 320, 200, 30); | 134 VideoCodec c0(96, "V", 320, 200, 30); |
140 VideoCodec c1(95, "V", 320, 200, 30); | 135 VideoCodec c1(95, "V", 320, 200, 30); |
141 VideoCodec c2(96, "x", 320, 200, 30); | 136 VideoCodec c2(96, "x", 320, 200, 30); |
142 VideoCodec c3(96, "V", 120, 200, 30); | 137 VideoCodec c3(96, "V", 120, 200, 30); |
143 VideoCodec c4(96, "V", 320, 100, 30); | 138 VideoCodec c4(96, "V", 320, 100, 30); |
144 VideoCodec c5(96, "V", 320, 200, 10); | 139 VideoCodec c5(96, "V", 320, 200, 10); |
145 EXPECT_TRUE(c0 != c1); | 140 EXPECT_TRUE(c0 != c1); |
146 EXPECT_TRUE(c0 != c2); | 141 EXPECT_TRUE(c0 != c2); |
147 EXPECT_TRUE(c0 != c3); | 142 EXPECT_TRUE(c0 != c3); |
148 EXPECT_TRUE(c0 != c4); | 143 EXPECT_TRUE(c0 != c4); |
(...skipping 16 matching lines...) Expand all Loading... |
165 c13.params["x"] = "abc"; | 160 c13.params["x"] = "abc"; |
166 EXPECT_TRUE(c10 != c0); | 161 EXPECT_TRUE(c10 != c0); |
167 EXPECT_TRUE(c11 != c0); | 162 EXPECT_TRUE(c11 != c0); |
168 EXPECT_TRUE(c11 != c10); | 163 EXPECT_TRUE(c11 != c10); |
169 EXPECT_TRUE(c12 != c0); | 164 EXPECT_TRUE(c12 != c0); |
170 EXPECT_TRUE(c12 != c10); | 165 EXPECT_TRUE(c12 != c10); |
171 EXPECT_TRUE(c12 != c11); | 166 EXPECT_TRUE(c12 != c11); |
172 EXPECT_TRUE(c13 == c10); | 167 EXPECT_TRUE(c13 == c10); |
173 } | 168 } |
174 | 169 |
175 TEST_F(CodecTest, TestVideoCodecMatches) { | 170 TEST(CodecTest, TestVideoCodecMatches) { |
176 // Test a codec with a static payload type. | 171 // Test a codec with a static payload type. |
177 VideoCodec c0(95, "V", 320, 200, 30); | 172 VideoCodec c0(95, "V", 320, 200, 30); |
178 EXPECT_TRUE(c0.Matches(VideoCodec(95, "", 640, 400, 15))); | 173 EXPECT_TRUE(c0.Matches(VideoCodec(95, "", 640, 400, 15))); |
179 EXPECT_FALSE(c0.Matches(VideoCodec(96, "", 320, 200, 30))); | 174 EXPECT_FALSE(c0.Matches(VideoCodec(96, "", 320, 200, 30))); |
180 | 175 |
181 // Test a codec with a dynamic payload type. | 176 // Test a codec with a dynamic payload type. |
182 VideoCodec c1(96, "V", 320, 200, 30); | 177 VideoCodec c1(96, "V", 320, 200, 30); |
183 EXPECT_TRUE(c1.Matches(VideoCodec(96, "V", 640, 400, 15))); | 178 EXPECT_TRUE(c1.Matches(VideoCodec(96, "V", 640, 400, 15))); |
184 EXPECT_TRUE(c1.Matches(VideoCodec(97, "V", 640, 400, 15))); | 179 EXPECT_TRUE(c1.Matches(VideoCodec(97, "V", 640, 400, 15))); |
185 EXPECT_TRUE(c1.Matches(VideoCodec(96, "v", 640, 400, 15))); | 180 EXPECT_TRUE(c1.Matches(VideoCodec(96, "v", 640, 400, 15))); |
186 EXPECT_TRUE(c1.Matches(VideoCodec(97, "v", 640, 400, 15))); | 181 EXPECT_TRUE(c1.Matches(VideoCodec(97, "v", 640, 400, 15))); |
187 EXPECT_FALSE(c1.Matches(VideoCodec(96, "", 320, 200, 30))); | 182 EXPECT_FALSE(c1.Matches(VideoCodec(96, "", 320, 200, 30))); |
188 EXPECT_FALSE(c1.Matches(VideoCodec(95, "V", 640, 400, 15))); | 183 EXPECT_FALSE(c1.Matches(VideoCodec(95, "V", 640, 400, 15))); |
189 } | 184 } |
190 | 185 |
191 TEST_F(CodecTest, TestDataCodecMatches) { | 186 TEST(CodecTest, TestVideoCodecMatchesH264Baseline) { |
| 187 const VideoCodec no_params(96, cricket::kH264CodecName, 640, 480, 30); |
| 188 |
| 189 VideoCodec baseline(96, cricket::kH264CodecName, 640, 480, 30); |
| 190 baseline.SetParam(cricket::kH264FmtpProfileLevelId, |
| 191 cricket::kH264FmtpDefaultProfileLevelId); |
| 192 |
| 193 EXPECT_TRUE(baseline.Matches(baseline)); |
| 194 EXPECT_TRUE(baseline.Matches(no_params)); |
| 195 EXPECT_TRUE(no_params.Matches(baseline)); |
| 196 EXPECT_TRUE(no_params.Matches(no_params)); |
| 197 } |
| 198 |
| 199 TEST(CodecTest, TestVideoCodecMatchesH264Profiles) { |
| 200 VideoCodec baseline(96, cricket::kH264CodecName, 640, 480, 30); |
| 201 baseline.SetParam(cricket::kH264FmtpProfileLevelId, |
| 202 cricket::kH264FmtpDefaultProfileLevelId); |
| 203 baseline.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed, "1"); |
| 204 |
| 205 VideoCodec constrained_baseline(96, cricket::kH264CodecName, 640, 480, 30); |
| 206 constrained_baseline.SetParam(cricket::kH264FmtpProfileLevelId, |
| 207 cricket::kH264ProfileLevelConstrainedBaseline); |
| 208 constrained_baseline.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed, "1"); |
| 209 |
| 210 EXPECT_TRUE(baseline.Matches(baseline)); |
| 211 EXPECT_FALSE(baseline.Matches(constrained_baseline)); |
| 212 EXPECT_FALSE(constrained_baseline.Matches(baseline)); |
| 213 EXPECT_TRUE(constrained_baseline.Matches(constrained_baseline)); |
| 214 } |
| 215 |
| 216 TEST(CodecTest, TestVideoCodecMatchesH264LevelAsymmetry) { |
| 217 // Constrained Baseline Profile Level 1.0. |
| 218 VideoCodec cbp_1_0(96, cricket::kH264CodecName, 640, 480, 30); |
| 219 cbp_1_0.SetParam(cricket::kH264FmtpProfileLevelId, |
| 220 "42e00a"); |
| 221 |
| 222 VideoCodec cbp_1_0_asymmetry_allowed = cbp_1_0; |
| 223 cbp_1_0_asymmetry_allowed.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed, |
| 224 "1"); |
| 225 |
| 226 // Constrained Baseline Profile Level 3.1. |
| 227 VideoCodec cbp_3_1(96, cricket::kH264CodecName, 640, 480, 30); |
| 228 cbp_3_1.SetParam(cricket::kH264FmtpProfileLevelId, "42e01f"); |
| 229 |
| 230 VideoCodec cbp_3_1_asymmetry_allowed = cbp_3_1; |
| 231 cbp_3_1_asymmetry_allowed.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed, |
| 232 "1"); |
| 233 |
| 234 // It's ok to differ in level-asymmetry-allowed param as long as the level is |
| 235 // the same. |
| 236 EXPECT_TRUE(cbp_1_0.Matches(cbp_1_0_asymmetry_allowed)); |
| 237 EXPECT_TRUE(cbp_3_1.Matches(cbp_3_1_asymmetry_allowed)); |
| 238 |
| 239 // Both codecs need to accept level asymmetry if levels differ. |
| 240 EXPECT_FALSE(cbp_1_0.Matches(cbp_3_1_asymmetry_allowed)); |
| 241 EXPECT_FALSE(cbp_1_0_asymmetry_allowed.Matches(cbp_3_1)); |
| 242 EXPECT_TRUE(cbp_1_0_asymmetry_allowed.Matches(cbp_3_1_asymmetry_allowed)); |
| 243 |
| 244 // Test explicitly disabling level asymmetry. It should have the same behavior |
| 245 // as missing the param. |
| 246 cbp_1_0.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed, "0"); |
| 247 EXPECT_TRUE(cbp_1_0.Matches(cbp_1_0_asymmetry_allowed)); |
| 248 EXPECT_FALSE(cbp_1_0.Matches(cbp_3_1_asymmetry_allowed)); |
| 249 } |
| 250 |
| 251 TEST(CodecTest, TestDataCodecMatches) { |
192 // Test a codec with a static payload type. | 252 // Test a codec with a static payload type. |
193 DataCodec c0(95, "D"); | 253 DataCodec c0(95, "D"); |
194 EXPECT_TRUE(c0.Matches(DataCodec(95, ""))); | 254 EXPECT_TRUE(c0.Matches(DataCodec(95, ""))); |
195 EXPECT_FALSE(c0.Matches(DataCodec(96, ""))); | 255 EXPECT_FALSE(c0.Matches(DataCodec(96, ""))); |
196 | 256 |
197 // Test a codec with a dynamic payload type. | 257 // Test a codec with a dynamic payload type. |
198 DataCodec c1(96, "D"); | 258 DataCodec c1(96, "D"); |
199 EXPECT_TRUE(c1.Matches(DataCodec(96, "D"))); | 259 EXPECT_TRUE(c1.Matches(DataCodec(96, "D"))); |
200 EXPECT_TRUE(c1.Matches(DataCodec(97, "D"))); | 260 EXPECT_TRUE(c1.Matches(DataCodec(97, "D"))); |
201 EXPECT_TRUE(c1.Matches(DataCodec(96, "d"))); | 261 EXPECT_TRUE(c1.Matches(DataCodec(96, "d"))); |
202 EXPECT_TRUE(c1.Matches(DataCodec(97, "d"))); | 262 EXPECT_TRUE(c1.Matches(DataCodec(97, "d"))); |
203 EXPECT_FALSE(c1.Matches(DataCodec(96, ""))); | 263 EXPECT_FALSE(c1.Matches(DataCodec(96, ""))); |
204 EXPECT_FALSE(c1.Matches(DataCodec(95, "D"))); | 264 EXPECT_FALSE(c1.Matches(DataCodec(95, "D"))); |
205 } | 265 } |
206 | 266 |
207 TEST_F(CodecTest, TestSetParamGetParamAndRemoveParam) { | 267 TEST(CodecTest, TestSetParamGetParamAndRemoveParam) { |
208 AudioCodec codec; | 268 AudioCodec codec; |
209 codec.SetParam("a", "1"); | 269 codec.SetParam("a", "1"); |
210 codec.SetParam("b", "x"); | 270 codec.SetParam("b", "x"); |
211 | 271 |
212 int int_value = 0; | 272 int int_value = 0; |
213 EXPECT_TRUE(codec.GetParam("a", &int_value)); | 273 EXPECT_TRUE(codec.GetParam("a", &int_value)); |
214 EXPECT_EQ(1, int_value); | 274 EXPECT_EQ(1, int_value); |
215 EXPECT_FALSE(codec.GetParam("b", &int_value)); | 275 EXPECT_FALSE(codec.GetParam("b", &int_value)); |
216 EXPECT_FALSE(codec.GetParam("c", &int_value)); | 276 EXPECT_FALSE(codec.GetParam("c", &int_value)); |
217 | 277 |
218 std::string str_value; | 278 std::string str_value; |
219 EXPECT_TRUE(codec.GetParam("a", &str_value)); | 279 EXPECT_TRUE(codec.GetParam("a", &str_value)); |
220 EXPECT_EQ("1", str_value); | 280 EXPECT_EQ("1", str_value); |
221 EXPECT_TRUE(codec.GetParam("b", &str_value)); | 281 EXPECT_TRUE(codec.GetParam("b", &str_value)); |
222 EXPECT_EQ("x", str_value); | 282 EXPECT_EQ("x", str_value); |
223 EXPECT_FALSE(codec.GetParam("c", &str_value)); | 283 EXPECT_FALSE(codec.GetParam("c", &str_value)); |
224 EXPECT_TRUE(codec.RemoveParam("a")); | 284 EXPECT_TRUE(codec.RemoveParam("a")); |
225 EXPECT_FALSE(codec.RemoveParam("c")); | 285 EXPECT_FALSE(codec.RemoveParam("c")); |
226 } | 286 } |
227 | 287 |
228 TEST_F(CodecTest, TestIntersectFeedbackParams) { | 288 TEST(CodecTest, TestIntersectFeedbackParams) { |
229 const FeedbackParam a1("a", "1"); | 289 const FeedbackParam a1("a", "1"); |
230 const FeedbackParam b2("b", "2"); | 290 const FeedbackParam b2("b", "2"); |
231 const FeedbackParam b3("b", "3"); | 291 const FeedbackParam b3("b", "3"); |
232 const FeedbackParam c3("c", "3"); | 292 const FeedbackParam c3("c", "3"); |
233 Codec c1; | 293 Codec c1; |
234 c1.AddFeedbackParam(a1); // Only match with c2. | 294 c1.AddFeedbackParam(a1); // Only match with c2. |
235 c1.AddFeedbackParam(b2); // Same param different values. | 295 c1.AddFeedbackParam(b2); // Same param different values. |
236 c1.AddFeedbackParam(c3); // Not in c2. | 296 c1.AddFeedbackParam(c3); // Not in c2. |
237 Codec c2; | 297 Codec c2; |
238 c2.AddFeedbackParam(a1); | 298 c2.AddFeedbackParam(a1); |
239 c2.AddFeedbackParam(b3); | 299 c2.AddFeedbackParam(b3); |
240 | 300 |
241 c1.IntersectFeedbackParams(c2); | 301 c1.IntersectFeedbackParams(c2); |
242 EXPECT_TRUE(c1.HasFeedbackParam(a1)); | 302 EXPECT_TRUE(c1.HasFeedbackParam(a1)); |
243 EXPECT_FALSE(c1.HasFeedbackParam(b2)); | 303 EXPECT_FALSE(c1.HasFeedbackParam(b2)); |
244 EXPECT_FALSE(c1.HasFeedbackParam(c3)); | 304 EXPECT_FALSE(c1.HasFeedbackParam(c3)); |
245 } | 305 } |
246 | 306 |
247 TEST_F(CodecTest, TestGetCodecType) { | 307 TEST(CodecTest, TestGetCodecType) { |
248 // Codec type comparison should be case insenstive on names. | 308 // Codec type comparison should be case insenstive on names. |
249 const VideoCodec codec(96, "V", 320, 200, 30); | 309 const VideoCodec codec(96, "V", 320, 200, 30); |
250 const VideoCodec rtx_codec(96, "rTx", 320, 200, 30); | 310 const VideoCodec rtx_codec(96, "rTx", 320, 200, 30); |
251 const VideoCodec ulpfec_codec(96, "ulpFeC", 320, 200, 30); | 311 const VideoCodec ulpfec_codec(96, "ulpFeC", 320, 200, 30); |
252 const VideoCodec red_codec(96, "ReD", 320, 200, 30); | 312 const VideoCodec red_codec(96, "ReD", 320, 200, 30); |
253 EXPECT_EQ(VideoCodec::CODEC_VIDEO, codec.GetCodecType()); | 313 EXPECT_EQ(VideoCodec::CODEC_VIDEO, codec.GetCodecType()); |
254 EXPECT_EQ(VideoCodec::CODEC_RTX, rtx_codec.GetCodecType()); | 314 EXPECT_EQ(VideoCodec::CODEC_RTX, rtx_codec.GetCodecType()); |
255 EXPECT_EQ(VideoCodec::CODEC_ULPFEC, ulpfec_codec.GetCodecType()); | 315 EXPECT_EQ(VideoCodec::CODEC_ULPFEC, ulpfec_codec.GetCodecType()); |
256 EXPECT_EQ(VideoCodec::CODEC_RED, red_codec.GetCodecType()); | 316 EXPECT_EQ(VideoCodec::CODEC_RED, red_codec.GetCodecType()); |
257 } | 317 } |
258 | 318 |
259 TEST_F(CodecTest, TestCreateRtxCodec) { | 319 TEST(CodecTest, TestCreateRtxCodec) { |
260 VideoCodec rtx_codec = VideoCodec::CreateRtxCodec(96, 120); | 320 VideoCodec rtx_codec = VideoCodec::CreateRtxCodec(96, 120); |
261 EXPECT_EQ(96, rtx_codec.id); | 321 EXPECT_EQ(96, rtx_codec.id); |
262 EXPECT_EQ(VideoCodec::CODEC_RTX, rtx_codec.GetCodecType()); | 322 EXPECT_EQ(VideoCodec::CODEC_RTX, rtx_codec.GetCodecType()); |
263 int associated_payload_type; | 323 int associated_payload_type; |
264 ASSERT_TRUE(rtx_codec.GetParam(kCodecParamAssociatedPayloadType, | 324 ASSERT_TRUE(rtx_codec.GetParam(kCodecParamAssociatedPayloadType, |
265 &associated_payload_type)); | 325 &associated_payload_type)); |
266 EXPECT_EQ(120, associated_payload_type); | 326 EXPECT_EQ(120, associated_payload_type); |
267 } | 327 } |
268 | 328 |
269 TEST_F(CodecTest, TestValidateCodecFormat) { | 329 TEST(CodecTest, TestValidateCodecFormat) { |
270 const VideoCodec codec(96, "V", 320, 200, 30); | 330 const VideoCodec codec(96, "V", 320, 200, 30); |
271 ASSERT_TRUE(codec.ValidateCodecFormat()); | 331 ASSERT_TRUE(codec.ValidateCodecFormat()); |
272 | 332 |
273 // Accept 0-127 as payload types. | 333 // Accept 0-127 as payload types. |
274 VideoCodec low_payload_type = codec; | 334 VideoCodec low_payload_type = codec; |
275 low_payload_type.id = 0; | 335 low_payload_type.id = 0; |
276 VideoCodec high_payload_type = codec; | 336 VideoCodec high_payload_type = codec; |
277 high_payload_type.id = 127; | 337 high_payload_type.id = 127; |
278 ASSERT_TRUE(low_payload_type.ValidateCodecFormat()); | 338 ASSERT_TRUE(low_payload_type.ValidateCodecFormat()); |
279 EXPECT_TRUE(high_payload_type.ValidateCodecFormat()); | 339 EXPECT_TRUE(high_payload_type.ValidateCodecFormat()); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 equal_bitrates.params[kCodecParamMaxBitrate] = "100"; | 375 equal_bitrates.params[kCodecParamMaxBitrate] = "100"; |
316 EXPECT_TRUE(equal_bitrates.ValidateCodecFormat()); | 376 EXPECT_TRUE(equal_bitrates.ValidateCodecFormat()); |
317 | 377 |
318 // Accept min bitrate < max bitrate. | 378 // Accept min bitrate < max bitrate. |
319 VideoCodec different_bitrates = codec; | 379 VideoCodec different_bitrates = codec; |
320 different_bitrates.params[kCodecParamMinBitrate] = "99"; | 380 different_bitrates.params[kCodecParamMinBitrate] = "99"; |
321 different_bitrates.params[kCodecParamMaxBitrate] = "100"; | 381 different_bitrates.params[kCodecParamMaxBitrate] = "100"; |
322 EXPECT_TRUE(different_bitrates.ValidateCodecFormat()); | 382 EXPECT_TRUE(different_bitrates.ValidateCodecFormat()); |
323 } | 383 } |
324 | 384 |
325 TEST_F(CodecTest, TestToCodecParameters) { | 385 TEST(CodecTest, TestToCodecParameters) { |
326 const VideoCodec v(96, "V", 320, 200, 30); | 386 const VideoCodec v(96, "V", 320, 200, 30); |
327 webrtc::RtpCodecParameters codec_params_1 = v.ToCodecParameters(); | 387 webrtc::RtpCodecParameters codec_params_1 = v.ToCodecParameters(); |
328 EXPECT_EQ(96, codec_params_1.payload_type); | 388 EXPECT_EQ(96, codec_params_1.payload_type); |
329 EXPECT_EQ("V", codec_params_1.mime_type); | 389 EXPECT_EQ("V", codec_params_1.mime_type); |
330 EXPECT_EQ(cricket::kVideoCodecClockrate, codec_params_1.clock_rate); | 390 EXPECT_EQ(cricket::kVideoCodecClockrate, codec_params_1.clock_rate); |
331 EXPECT_EQ(1, codec_params_1.channels); | 391 EXPECT_EQ(1, codec_params_1.channels); |
332 | 392 |
333 const AudioCodec a(97, "A", 44100, 20000, 2); | 393 const AudioCodec a(97, "A", 44100, 20000, 2); |
334 webrtc::RtpCodecParameters codec_params_2 = a.ToCodecParameters(); | 394 webrtc::RtpCodecParameters codec_params_2 = a.ToCodecParameters(); |
335 EXPECT_EQ(97, codec_params_2.payload_type); | 395 EXPECT_EQ(97, codec_params_2.payload_type); |
336 EXPECT_EQ("A", codec_params_2.mime_type); | 396 EXPECT_EQ("A", codec_params_2.mime_type); |
337 EXPECT_EQ(44100, codec_params_2.clock_rate); | 397 EXPECT_EQ(44100, codec_params_2.clock_rate); |
338 EXPECT_EQ(2, codec_params_2.channels); | 398 EXPECT_EQ(2, codec_params_2.channels); |
339 } | 399 } |
OLD | NEW |