Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: webrtc/media/base/codec_unittest.cc

Issue 1845673002: Removing `preference` field from `cricket::Codec`. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing sort order (got reversed when optimizations were made) Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/media/base/codec.cc ('k') | webrtc/media/base/fakemediaengine.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 class CodecTest : public testing::Test {
24 public: 24 public:
25 CodecTest() {} 25 CodecTest() {}
26 }; 26 };
27 27
28 TEST_F(CodecTest, TestCodecOperators) { 28 TEST_F(CodecTest, TestCodecOperators) {
29 Codec c0(96, "D", 1000, 0); 29 Codec c0(96, "D", 1000);
30 c0.SetParam("a", 1); 30 c0.SetParam("a", 1);
31 31
32 Codec c1 = c0; 32 Codec c1 = c0;
33 EXPECT_TRUE(c1 == c0); 33 EXPECT_TRUE(c1 == c0);
34 34
35 int param_value0; 35 int param_value0;
36 int param_value1; 36 int param_value1;
37 EXPECT_TRUE(c0.GetParam("a", &param_value0)); 37 EXPECT_TRUE(c0.GetParam("a", &param_value0));
38 EXPECT_TRUE(c1.GetParam("a", &param_value1)); 38 EXPECT_TRUE(c1.GetParam("a", &param_value1));
39 EXPECT_EQ(param_value0, param_value1); 39 EXPECT_EQ(param_value0, param_value1);
40 40
41 c1.id = 86; 41 c1.id = 86;
42 EXPECT_TRUE(c0 != c1); 42 EXPECT_TRUE(c0 != c1);
43 43
44 c1 = c0; 44 c1 = c0;
45 c1.name = "x"; 45 c1.name = "x";
46 EXPECT_TRUE(c0 != c1); 46 EXPECT_TRUE(c0 != c1);
47 47
48 c1 = c0; 48 c1 = c0;
49 c1.clockrate = 2000; 49 c1.clockrate = 2000;
50 EXPECT_TRUE(c0 != c1); 50 EXPECT_TRUE(c0 != c1);
51 51
52 c1 = c0; 52 c1 = c0;
53 c1.preference = 1;
54 EXPECT_TRUE(c0 != c1);
55
56 c1 = c0;
57 c1.SetParam("a", 2); 53 c1.SetParam("a", 2);
58 EXPECT_TRUE(c0 != c1); 54 EXPECT_TRUE(c0 != c1);
59 55
60 Codec c5; 56 Codec c5;
61 Codec c6(0, "", 0, 0); 57 Codec c6(0, "", 0);
62 EXPECT_TRUE(c5 == c6); 58 EXPECT_TRUE(c5 == c6);
63 } 59 }
64 60
65 TEST_F(CodecTest, TestAudioCodecOperators) { 61 TEST_F(CodecTest, TestAudioCodecOperators) {
66 AudioCodec c0(96, "A", 44100, 20000, 2, 3); 62 AudioCodec c0(96, "A", 44100, 20000, 2);
67 AudioCodec c1(95, "A", 44100, 20000, 2, 3); 63 AudioCodec c1(95, "A", 44100, 20000, 2);
68 AudioCodec c2(96, "x", 44100, 20000, 2, 3); 64 AudioCodec c2(96, "x", 44100, 20000, 2);
69 AudioCodec c3(96, "A", 48000, 20000, 2, 3); 65 AudioCodec c3(96, "A", 48000, 20000, 2);
70 AudioCodec c4(96, "A", 44100, 10000, 2, 3); 66 AudioCodec c4(96, "A", 44100, 10000, 2);
71 AudioCodec c5(96, "A", 44100, 20000, 1, 3); 67 AudioCodec c5(96, "A", 44100, 20000, 1);
72 AudioCodec c6(96, "A", 44100, 20000, 2, 1);
73 EXPECT_TRUE(c0 != c1); 68 EXPECT_TRUE(c0 != c1);
74 EXPECT_TRUE(c0 != c2); 69 EXPECT_TRUE(c0 != c2);
75 EXPECT_TRUE(c0 != c3); 70 EXPECT_TRUE(c0 != c3);
76 EXPECT_TRUE(c0 != c4); 71 EXPECT_TRUE(c0 != c4);
77 EXPECT_TRUE(c0 != c5); 72 EXPECT_TRUE(c0 != c5);
78 EXPECT_TRUE(c0 != c6);
79 73
80 AudioCodec c7; 74 AudioCodec c7;
81 AudioCodec c8(0, "", 0, 0, 0, 0); 75 AudioCodec c8(0, "", 0, 0, 0);
82 AudioCodec c9 = c0; 76 AudioCodec c9 = c0;
83 EXPECT_TRUE(c8 == c7); 77 EXPECT_TRUE(c8 == c7);
84 EXPECT_TRUE(c9 != c7); 78 EXPECT_TRUE(c9 != c7);
85 EXPECT_TRUE(c9 == c0); 79 EXPECT_TRUE(c9 == c0);
86 80
87 AudioCodec c10(c0); 81 AudioCodec c10(c0);
88 AudioCodec c11(c0); 82 AudioCodec c11(c0);
89 AudioCodec c12(c0); 83 AudioCodec c12(c0);
90 AudioCodec c13(c0); 84 AudioCodec c13(c0);
91 c10.params["x"] = "abc"; 85 c10.params["x"] = "abc";
92 c11.params["x"] = "def"; 86 c11.params["x"] = "def";
93 c12.params["y"] = "abc"; 87 c12.params["y"] = "abc";
94 c13.params["x"] = "abc"; 88 c13.params["x"] = "abc";
95 EXPECT_TRUE(c10 != c0); 89 EXPECT_TRUE(c10 != c0);
96 EXPECT_TRUE(c11 != c0); 90 EXPECT_TRUE(c11 != c0);
97 EXPECT_TRUE(c11 != c10); 91 EXPECT_TRUE(c11 != c10);
98 EXPECT_TRUE(c12 != c0); 92 EXPECT_TRUE(c12 != c0);
99 EXPECT_TRUE(c12 != c10); 93 EXPECT_TRUE(c12 != c10);
100 EXPECT_TRUE(c12 != c11); 94 EXPECT_TRUE(c12 != c11);
101 EXPECT_TRUE(c13 == c10); 95 EXPECT_TRUE(c13 == c10);
102 } 96 }
103 97
104 TEST_F(CodecTest, TestAudioCodecMatches) { 98 TEST_F(CodecTest, TestAudioCodecMatches) {
105 // Test a codec with a static payload type. 99 // Test a codec with a static payload type.
106 AudioCodec c0(95, "A", 44100, 20000, 1, 3); 100 AudioCodec c0(95, "A", 44100, 20000, 1);
107 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 44100, 20000, 1, 0))); 101 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 44100, 20000, 1)));
108 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 44100, 20000, 0, 0))); 102 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 44100, 20000, 0)));
109 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 44100, 0, 0, 0))); 103 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 44100, 0, 0)));
110 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 0, 0, 0, 0))); 104 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 0, 0, 0)));
111 EXPECT_FALSE(c0.Matches(AudioCodec(96, "", 44100, 20000, 1, 0))); 105 EXPECT_FALSE(c0.Matches(AudioCodec(96, "", 44100, 20000, 1)));
112 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 55100, 20000, 1, 0))); 106 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 55100, 20000, 1)));
113 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 44100, 30000, 1, 0))); 107 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 44100, 30000, 1)));
114 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 44100, 20000, 2, 0))); 108 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 44100, 20000, 2)));
115 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 55100, 30000, 2, 0))); 109 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 55100, 30000, 2)));
116 110
117 // Test a codec with a dynamic payload type. 111 // Test a codec with a dynamic payload type.
118 AudioCodec c1(96, "A", 44100, 20000, 1, 3); 112 AudioCodec c1(96, "A", 44100, 20000, 1);
119 EXPECT_TRUE(c1.Matches(AudioCodec(96, "A", 0, 0, 0, 0))); 113 EXPECT_TRUE(c1.Matches(AudioCodec(96, "A", 0, 0, 0)));
120 EXPECT_TRUE(c1.Matches(AudioCodec(97, "A", 0, 0, 0, 0))); 114 EXPECT_TRUE(c1.Matches(AudioCodec(97, "A", 0, 0, 0)));
121 EXPECT_TRUE(c1.Matches(AudioCodec(96, "a", 0, 0, 0, 0))); 115 EXPECT_TRUE(c1.Matches(AudioCodec(96, "a", 0, 0, 0)));
122 EXPECT_TRUE(c1.Matches(AudioCodec(97, "a", 0, 0, 0, 0))); 116 EXPECT_TRUE(c1.Matches(AudioCodec(97, "a", 0, 0, 0)));
123 EXPECT_FALSE(c1.Matches(AudioCodec(95, "A", 0, 0, 0, 0))); 117 EXPECT_FALSE(c1.Matches(AudioCodec(95, "A", 0, 0, 0)));
124 EXPECT_FALSE(c1.Matches(AudioCodec(96, "", 44100, 20000, 2, 0))); 118 EXPECT_FALSE(c1.Matches(AudioCodec(96, "", 44100, 20000, 2)));
125 EXPECT_FALSE(c1.Matches(AudioCodec(96, "A", 55100, 30000, 1, 0))); 119 EXPECT_FALSE(c1.Matches(AudioCodec(96, "A", 55100, 30000, 1)));
126 120
127 // Test a codec with a dynamic payload type, and auto bitrate. 121 // Test a codec with a dynamic payload type, and auto bitrate.
128 AudioCodec c2(97, "A", 16000, 0, 1, 3); 122 AudioCodec c2(97, "A", 16000, 0, 1);
129 // Use default bitrate. 123 // Use default bitrate.
130 EXPECT_TRUE(c2.Matches(AudioCodec(97, "A", 16000, 0, 1, 0))); 124 EXPECT_TRUE(c2.Matches(AudioCodec(97, "A", 16000, 0, 1)));
131 EXPECT_TRUE(c2.Matches(AudioCodec(97, "A", 16000, 0, 0, 0))); 125 EXPECT_TRUE(c2.Matches(AudioCodec(97, "A", 16000, 0, 0)));
132 // Use explicit bitrate. 126 // Use explicit bitrate.
133 EXPECT_TRUE(c2.Matches(AudioCodec(97, "A", 16000, 32000, 1, 0))); 127 EXPECT_TRUE(c2.Matches(AudioCodec(97, "A", 16000, 32000, 1)));
134 // Backward compatibility with clients that might send "-1" (for default). 128 // Backward compatibility with clients that might send "-1" (for default).
135 EXPECT_TRUE(c2.Matches(AudioCodec(97, "A", 16000, -1, 1, 0))); 129 EXPECT_TRUE(c2.Matches(AudioCodec(97, "A", 16000, -1, 1)));
136 130
137 // Stereo doesn't match channels = 0. 131 // Stereo doesn't match channels = 0.
138 AudioCodec c3(96, "A", 44100, 20000, 2, 3); 132 AudioCodec c3(96, "A", 44100, 20000, 2);
139 EXPECT_TRUE(c3.Matches(AudioCodec(96, "A", 44100, 20000, 2, 3))); 133 EXPECT_TRUE(c3.Matches(AudioCodec(96, "A", 44100, 20000, 2)));
140 EXPECT_FALSE(c3.Matches(AudioCodec(96, "A", 44100, 20000, 1, 3))); 134 EXPECT_FALSE(c3.Matches(AudioCodec(96, "A", 44100, 20000, 1)));
141 EXPECT_FALSE(c3.Matches(AudioCodec(96, "A", 44100, 20000, 0, 3))); 135 EXPECT_FALSE(c3.Matches(AudioCodec(96, "A", 44100, 20000, 0)));
142 } 136 }
143 137
144 TEST_F(CodecTest, TestVideoCodecOperators) { 138 TEST_F(CodecTest, TestVideoCodecOperators) {
145 VideoCodec c0(96, "V", 320, 200, 30, 3); 139 VideoCodec c0(96, "V", 320, 200, 30);
146 VideoCodec c1(95, "V", 320, 200, 30, 3); 140 VideoCodec c1(95, "V", 320, 200, 30);
147 VideoCodec c2(96, "x", 320, 200, 30, 3); 141 VideoCodec c2(96, "x", 320, 200, 30);
148 VideoCodec c3(96, "V", 120, 200, 30, 3); 142 VideoCodec c3(96, "V", 120, 200, 30);
149 VideoCodec c4(96, "V", 320, 100, 30, 3); 143 VideoCodec c4(96, "V", 320, 100, 30);
150 VideoCodec c5(96, "V", 320, 200, 10, 3); 144 VideoCodec c5(96, "V", 320, 200, 10);
151 VideoCodec c6(96, "V", 320, 200, 30, 1);
152 EXPECT_TRUE(c0 != c1); 145 EXPECT_TRUE(c0 != c1);
153 EXPECT_TRUE(c0 != c2); 146 EXPECT_TRUE(c0 != c2);
154 EXPECT_TRUE(c0 != c3); 147 EXPECT_TRUE(c0 != c3);
155 EXPECT_TRUE(c0 != c4); 148 EXPECT_TRUE(c0 != c4);
156 EXPECT_TRUE(c0 != c5); 149 EXPECT_TRUE(c0 != c5);
157 EXPECT_TRUE(c0 != c6);
158 150
159 VideoCodec c7; 151 VideoCodec c7;
160 VideoCodec c8(0, "", 0, 0, 0, 0); 152 VideoCodec c8(0, "", 0, 0, 0);
161 VideoCodec c9 = c0; 153 VideoCodec c9 = c0;
162 EXPECT_TRUE(c8 == c7); 154 EXPECT_TRUE(c8 == c7);
163 EXPECT_TRUE(c9 != c7); 155 EXPECT_TRUE(c9 != c7);
164 EXPECT_TRUE(c9 == c0); 156 EXPECT_TRUE(c9 == c0);
165 157
166 VideoCodec c10(c0); 158 VideoCodec c10(c0);
167 VideoCodec c11(c0); 159 VideoCodec c11(c0);
168 VideoCodec c12(c0); 160 VideoCodec c12(c0);
169 VideoCodec c13(c0); 161 VideoCodec c13(c0);
170 c10.params["x"] = "abc"; 162 c10.params["x"] = "abc";
171 c11.params["x"] = "def"; 163 c11.params["x"] = "def";
172 c12.params["y"] = "abc"; 164 c12.params["y"] = "abc";
173 c13.params["x"] = "abc"; 165 c13.params["x"] = "abc";
174 EXPECT_TRUE(c10 != c0); 166 EXPECT_TRUE(c10 != c0);
175 EXPECT_TRUE(c11 != c0); 167 EXPECT_TRUE(c11 != c0);
176 EXPECT_TRUE(c11 != c10); 168 EXPECT_TRUE(c11 != c10);
177 EXPECT_TRUE(c12 != c0); 169 EXPECT_TRUE(c12 != c0);
178 EXPECT_TRUE(c12 != c10); 170 EXPECT_TRUE(c12 != c10);
179 EXPECT_TRUE(c12 != c11); 171 EXPECT_TRUE(c12 != c11);
180 EXPECT_TRUE(c13 == c10); 172 EXPECT_TRUE(c13 == c10);
181 } 173 }
182 174
183 TEST_F(CodecTest, TestVideoCodecMatches) { 175 TEST_F(CodecTest, TestVideoCodecMatches) {
184 // Test a codec with a static payload type. 176 // Test a codec with a static payload type.
185 VideoCodec c0(95, "V", 320, 200, 30, 3); 177 VideoCodec c0(95, "V", 320, 200, 30);
186 EXPECT_TRUE(c0.Matches(VideoCodec(95, "", 640, 400, 15, 0))); 178 EXPECT_TRUE(c0.Matches(VideoCodec(95, "", 640, 400, 15)));
187 EXPECT_FALSE(c0.Matches(VideoCodec(96, "", 320, 200, 30, 0))); 179 EXPECT_FALSE(c0.Matches(VideoCodec(96, "", 320, 200, 30)));
188 180
189 // Test a codec with a dynamic payload type. 181 // Test a codec with a dynamic payload type.
190 VideoCodec c1(96, "V", 320, 200, 30, 3); 182 VideoCodec c1(96, "V", 320, 200, 30);
191 EXPECT_TRUE(c1.Matches(VideoCodec(96, "V", 640, 400, 15, 0))); 183 EXPECT_TRUE(c1.Matches(VideoCodec(96, "V", 640, 400, 15)));
192 EXPECT_TRUE(c1.Matches(VideoCodec(97, "V", 640, 400, 15, 0))); 184 EXPECT_TRUE(c1.Matches(VideoCodec(97, "V", 640, 400, 15)));
193 EXPECT_TRUE(c1.Matches(VideoCodec(96, "v", 640, 400, 15, 0))); 185 EXPECT_TRUE(c1.Matches(VideoCodec(96, "v", 640, 400, 15)));
194 EXPECT_TRUE(c1.Matches(VideoCodec(97, "v", 640, 400, 15, 0))); 186 EXPECT_TRUE(c1.Matches(VideoCodec(97, "v", 640, 400, 15)));
195 EXPECT_FALSE(c1.Matches(VideoCodec(96, "", 320, 200, 30, 0))); 187 EXPECT_FALSE(c1.Matches(VideoCodec(96, "", 320, 200, 30)));
196 EXPECT_FALSE(c1.Matches(VideoCodec(95, "V", 640, 400, 15, 0))); 188 EXPECT_FALSE(c1.Matches(VideoCodec(95, "V", 640, 400, 15)));
197 } 189 }
198 190
199 TEST_F(CodecTest, TestDataCodecMatches) { 191 TEST_F(CodecTest, TestDataCodecMatches) {
200 // Test a codec with a static payload type. 192 // Test a codec with a static payload type.
201 DataCodec c0(95, "D", 0); 193 DataCodec c0(95, "D");
202 EXPECT_TRUE(c0.Matches(DataCodec(95, "", 0))); 194 EXPECT_TRUE(c0.Matches(DataCodec(95, "")));
203 EXPECT_FALSE(c0.Matches(DataCodec(96, "", 0))); 195 EXPECT_FALSE(c0.Matches(DataCodec(96, "")));
204 196
205 // Test a codec with a dynamic payload type. 197 // Test a codec with a dynamic payload type.
206 DataCodec c1(96, "D", 3); 198 DataCodec c1(96, "D");
207 EXPECT_TRUE(c1.Matches(DataCodec(96, "D", 0))); 199 EXPECT_TRUE(c1.Matches(DataCodec(96, "D")));
208 EXPECT_TRUE(c1.Matches(DataCodec(97, "D", 0))); 200 EXPECT_TRUE(c1.Matches(DataCodec(97, "D")));
209 EXPECT_TRUE(c1.Matches(DataCodec(96, "d", 0))); 201 EXPECT_TRUE(c1.Matches(DataCodec(96, "d")));
210 EXPECT_TRUE(c1.Matches(DataCodec(97, "d", 0))); 202 EXPECT_TRUE(c1.Matches(DataCodec(97, "d")));
211 EXPECT_FALSE(c1.Matches(DataCodec(96, "", 0))); 203 EXPECT_FALSE(c1.Matches(DataCodec(96, "")));
212 EXPECT_FALSE(c1.Matches(DataCodec(95, "D", 0))); 204 EXPECT_FALSE(c1.Matches(DataCodec(95, "D")));
213 } 205 }
214 206
215 TEST_F(CodecTest, TestSetParamGetParamAndRemoveParam) { 207 TEST_F(CodecTest, TestSetParamGetParamAndRemoveParam) {
216 AudioCodec codec; 208 AudioCodec codec;
217 codec.SetParam("a", "1"); 209 codec.SetParam("a", "1");
218 codec.SetParam("b", "x"); 210 codec.SetParam("b", "x");
219 211
220 int int_value = 0; 212 int int_value = 0;
221 EXPECT_TRUE(codec.GetParam("a", &int_value)); 213 EXPECT_TRUE(codec.GetParam("a", &int_value));
222 EXPECT_EQ(1, int_value); 214 EXPECT_EQ(1, int_value);
(...skipping 24 matching lines...) Expand all
247 c2.AddFeedbackParam(b3); 239 c2.AddFeedbackParam(b3);
248 240
249 c1.IntersectFeedbackParams(c2); 241 c1.IntersectFeedbackParams(c2);
250 EXPECT_TRUE(c1.HasFeedbackParam(a1)); 242 EXPECT_TRUE(c1.HasFeedbackParam(a1));
251 EXPECT_FALSE(c1.HasFeedbackParam(b2)); 243 EXPECT_FALSE(c1.HasFeedbackParam(b2));
252 EXPECT_FALSE(c1.HasFeedbackParam(c3)); 244 EXPECT_FALSE(c1.HasFeedbackParam(c3));
253 } 245 }
254 246
255 TEST_F(CodecTest, TestGetCodecType) { 247 TEST_F(CodecTest, TestGetCodecType) {
256 // Codec type comparison should be case insenstive on names. 248 // Codec type comparison should be case insenstive on names.
257 const VideoCodec codec(96, "V", 320, 200, 30, 3); 249 const VideoCodec codec(96, "V", 320, 200, 30);
258 const VideoCodec rtx_codec(96, "rTx", 320, 200, 30, 3); 250 const VideoCodec rtx_codec(96, "rTx", 320, 200, 30);
259 const VideoCodec ulpfec_codec(96, "ulpFeC", 320, 200, 30, 3); 251 const VideoCodec ulpfec_codec(96, "ulpFeC", 320, 200, 30);
260 const VideoCodec red_codec(96, "ReD", 320, 200, 30, 3); 252 const VideoCodec red_codec(96, "ReD", 320, 200, 30);
261 EXPECT_EQ(VideoCodec::CODEC_VIDEO, codec.GetCodecType()); 253 EXPECT_EQ(VideoCodec::CODEC_VIDEO, codec.GetCodecType());
262 EXPECT_EQ(VideoCodec::CODEC_RTX, rtx_codec.GetCodecType()); 254 EXPECT_EQ(VideoCodec::CODEC_RTX, rtx_codec.GetCodecType());
263 EXPECT_EQ(VideoCodec::CODEC_ULPFEC, ulpfec_codec.GetCodecType()); 255 EXPECT_EQ(VideoCodec::CODEC_ULPFEC, ulpfec_codec.GetCodecType());
264 EXPECT_EQ(VideoCodec::CODEC_RED, red_codec.GetCodecType()); 256 EXPECT_EQ(VideoCodec::CODEC_RED, red_codec.GetCodecType());
265 } 257 }
266 258
267 TEST_F(CodecTest, TestCreateRtxCodec) { 259 TEST_F(CodecTest, TestCreateRtxCodec) {
268 VideoCodec rtx_codec = VideoCodec::CreateRtxCodec(96, 120); 260 VideoCodec rtx_codec = VideoCodec::CreateRtxCodec(96, 120);
269 EXPECT_EQ(96, rtx_codec.id); 261 EXPECT_EQ(96, rtx_codec.id);
270 EXPECT_EQ(VideoCodec::CODEC_RTX, rtx_codec.GetCodecType()); 262 EXPECT_EQ(VideoCodec::CODEC_RTX, rtx_codec.GetCodecType());
271 int associated_payload_type; 263 int associated_payload_type;
272 ASSERT_TRUE(rtx_codec.GetParam(kCodecParamAssociatedPayloadType, 264 ASSERT_TRUE(rtx_codec.GetParam(kCodecParamAssociatedPayloadType,
273 &associated_payload_type)); 265 &associated_payload_type));
274 EXPECT_EQ(120, associated_payload_type); 266 EXPECT_EQ(120, associated_payload_type);
275 } 267 }
276 268
277 TEST_F(CodecTest, TestValidateCodecFormat) { 269 TEST_F(CodecTest, TestValidateCodecFormat) {
278 const VideoCodec codec(96, "V", 320, 200, 30, 3); 270 const VideoCodec codec(96, "V", 320, 200, 30);
279 ASSERT_TRUE(codec.ValidateCodecFormat()); 271 ASSERT_TRUE(codec.ValidateCodecFormat());
280 272
281 // Accept 0-127 as payload types. 273 // Accept 0-127 as payload types.
282 VideoCodec low_payload_type = codec; 274 VideoCodec low_payload_type = codec;
283 low_payload_type.id = 0; 275 low_payload_type.id = 0;
284 VideoCodec high_payload_type = codec; 276 VideoCodec high_payload_type = codec;
285 high_payload_type.id = 127; 277 high_payload_type.id = 127;
286 ASSERT_TRUE(low_payload_type.ValidateCodecFormat()); 278 ASSERT_TRUE(low_payload_type.ValidateCodecFormat());
287 EXPECT_TRUE(high_payload_type.ValidateCodecFormat()); 279 EXPECT_TRUE(high_payload_type.ValidateCodecFormat());
288 280
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 equal_bitrates.params[kCodecParamMinBitrate] = "100"; 314 equal_bitrates.params[kCodecParamMinBitrate] = "100";
323 equal_bitrates.params[kCodecParamMaxBitrate] = "100"; 315 equal_bitrates.params[kCodecParamMaxBitrate] = "100";
324 EXPECT_TRUE(equal_bitrates.ValidateCodecFormat()); 316 EXPECT_TRUE(equal_bitrates.ValidateCodecFormat());
325 317
326 // Accept min bitrate < max bitrate. 318 // Accept min bitrate < max bitrate.
327 VideoCodec different_bitrates = codec; 319 VideoCodec different_bitrates = codec;
328 different_bitrates.params[kCodecParamMinBitrate] = "99"; 320 different_bitrates.params[kCodecParamMinBitrate] = "99";
329 different_bitrates.params[kCodecParamMaxBitrate] = "100"; 321 different_bitrates.params[kCodecParamMaxBitrate] = "100";
330 EXPECT_TRUE(different_bitrates.ValidateCodecFormat()); 322 EXPECT_TRUE(different_bitrates.ValidateCodecFormat());
331 } 323 }
OLDNEW
« no previous file with comments | « webrtc/media/base/codec.cc ('k') | webrtc/media/base/fakemediaengine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698