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

Side by Side Diff: webrtc/pc/mediasession_unittest.cc

Issue 2761143002: Support encrypted RTP extensions (RFC 6904) (Closed)
Patch Set: Fix compile error on win_x64 bots. Created 3 years, 5 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/pc/mediasession.cc ('k') | webrtc/pc/srtpfilter.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 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2004 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
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 DataCodec(127, "utf8-text")}; 105 DataCodec(127, "utf8-text")};
106 106
107 static const DataCodec kDataCodecsAnswer[] = {DataCodec(98, "binary-data"), 107 static const DataCodec kDataCodecsAnswer[] = {DataCodec(98, "binary-data"),
108 DataCodec(99, "utf8-text")}; 108 DataCodec(99, "utf8-text")};
109 109
110 static const RtpExtension kAudioRtpExtension1[] = { 110 static const RtpExtension kAudioRtpExtension1[] = {
111 RtpExtension("urn:ietf:params:rtp-hdrext:ssrc-audio-level", 8), 111 RtpExtension("urn:ietf:params:rtp-hdrext:ssrc-audio-level", 8),
112 RtpExtension("http://google.com/testing/audio_something", 10), 112 RtpExtension("http://google.com/testing/audio_something", 10),
113 }; 113 };
114 114
115 static const RtpExtension kAudioRtpExtensionEncrypted1[] = {
116 RtpExtension("urn:ietf:params:rtp-hdrext:ssrc-audio-level", 8),
117 RtpExtension("http://google.com/testing/audio_something", 10),
118 RtpExtension("urn:ietf:params:rtp-hdrext:ssrc-audio-level", 12, true),
119 };
120
115 static const RtpExtension kAudioRtpExtension2[] = { 121 static const RtpExtension kAudioRtpExtension2[] = {
116 RtpExtension("urn:ietf:params:rtp-hdrext:ssrc-audio-level", 2), 122 RtpExtension("urn:ietf:params:rtp-hdrext:ssrc-audio-level", 2),
117 RtpExtension("http://google.com/testing/audio_something_else", 8), 123 RtpExtension("http://google.com/testing/audio_something_else", 8),
118 RtpExtension("http://google.com/testing/both_audio_and_video", 7), 124 RtpExtension("http://google.com/testing/both_audio_and_video", 7),
119 }; 125 };
120 126
121 static const RtpExtension kAudioRtpExtension3[] = { 127 static const RtpExtension kAudioRtpExtension3[] = {
122 RtpExtension("http://google.com/testing/audio_something", 2), 128 RtpExtension("http://google.com/testing/audio_something", 2),
123 RtpExtension("http://google.com/testing/both_audio_and_video", 3), 129 RtpExtension("http://google.com/testing/both_audio_and_video", 3),
124 }; 130 };
125 131
132 static const RtpExtension kAudioRtpExtension3ForEncryption[] = {
133 RtpExtension("http://google.com/testing/audio_something", 2),
134 // Use RTP extension that supports encryption.
135 RtpExtension("urn:ietf:params:rtp-hdrext:toffset", 3),
136 };
137
138 static const RtpExtension kAudioRtpExtension3ForEncryptionOffer[] = {
139 RtpExtension("http://google.com/testing/audio_something", 2),
140 RtpExtension("urn:ietf:params:rtp-hdrext:toffset", 3),
141 RtpExtension("urn:ietf:params:rtp-hdrext:toffset", 14, true),
142 };
143
126 static const RtpExtension kAudioRtpExtensionAnswer[] = { 144 static const RtpExtension kAudioRtpExtensionAnswer[] = {
127 RtpExtension("urn:ietf:params:rtp-hdrext:ssrc-audio-level", 8), 145 RtpExtension("urn:ietf:params:rtp-hdrext:ssrc-audio-level", 8),
128 }; 146 };
129 147
148 static const RtpExtension kAudioRtpExtensionEncryptedAnswer[] = {
149 RtpExtension("urn:ietf:params:rtp-hdrext:ssrc-audio-level", 12, true),
150 };
151
130 static const RtpExtension kVideoRtpExtension1[] = { 152 static const RtpExtension kVideoRtpExtension1[] = {
131 RtpExtension("urn:ietf:params:rtp-hdrext:toffset", 14), 153 RtpExtension("urn:ietf:params:rtp-hdrext:toffset", 14),
132 RtpExtension("http://google.com/testing/video_something", 13), 154 RtpExtension("http://google.com/testing/video_something", 13),
133 }; 155 };
134 156
157 static const RtpExtension kVideoRtpExtensionEncrypted1[] = {
158 RtpExtension("urn:ietf:params:rtp-hdrext:toffset", 14),
159 RtpExtension("http://google.com/testing/video_something", 13),
160 RtpExtension("urn:ietf:params:rtp-hdrext:toffset", 11, true),
161 };
162
135 static const RtpExtension kVideoRtpExtension2[] = { 163 static const RtpExtension kVideoRtpExtension2[] = {
136 RtpExtension("urn:ietf:params:rtp-hdrext:toffset", 2), 164 RtpExtension("urn:ietf:params:rtp-hdrext:toffset", 2),
137 RtpExtension("http://google.com/testing/video_something_else", 14), 165 RtpExtension("http://google.com/testing/video_something_else", 14),
138 RtpExtension("http://google.com/testing/both_audio_and_video", 7), 166 RtpExtension("http://google.com/testing/both_audio_and_video", 7),
139 }; 167 };
140 168
141 static const RtpExtension kVideoRtpExtension3[] = { 169 static const RtpExtension kVideoRtpExtension3[] = {
142 RtpExtension("http://google.com/testing/video_something", 4), 170 RtpExtension("http://google.com/testing/video_something", 4),
143 RtpExtension("http://google.com/testing/both_audio_and_video", 5), 171 RtpExtension("http://google.com/testing/both_audio_and_video", 5),
144 }; 172 };
145 173
174 static const RtpExtension kVideoRtpExtension3ForEncryption[] = {
175 RtpExtension("http://google.com/testing/video_something", 4),
176 // Use RTP extension that supports encryption.
177 RtpExtension("urn:ietf:params:rtp-hdrext:toffset", 5),
178 };
179
146 static const RtpExtension kVideoRtpExtensionAnswer[] = { 180 static const RtpExtension kVideoRtpExtensionAnswer[] = {
147 RtpExtension("urn:ietf:params:rtp-hdrext:toffset", 14), 181 RtpExtension("urn:ietf:params:rtp-hdrext:toffset", 14),
148 }; 182 };
149 183
184 static const RtpExtension kVideoRtpExtensionEncryptedAnswer[] = {
185 RtpExtension("urn:ietf:params:rtp-hdrext:toffset", 11, true),
186 };
187
150 static const uint32_t kSimulcastParamsSsrc[] = {10, 11, 20, 21, 30, 31}; 188 static const uint32_t kSimulcastParamsSsrc[] = {10, 11, 20, 21, 30, 31};
151 static const uint32_t kSimSsrc[] = {10, 20, 30}; 189 static const uint32_t kSimSsrc[] = {10, 20, 30};
152 static const uint32_t kFec1Ssrc[] = {10, 11}; 190 static const uint32_t kFec1Ssrc[] = {10, 11};
153 static const uint32_t kFec2Ssrc[] = {20, 21}; 191 static const uint32_t kFec2Ssrc[] = {20, 21};
154 static const uint32_t kFec3Ssrc[] = {30, 31}; 192 static const uint32_t kFec3Ssrc[] = {30, 31};
155 193
156 static const char kMediaStream1[] = "stream_1"; 194 static const char kMediaStream1[] = "stream_1";
157 static const char kMediaStream2[] = "stream_2"; 195 static const char kMediaStream2[] = "stream_2";
158 static const char kVideoTrack1[] = "video_1"; 196 static const char kVideoTrack1[] = "video_1";
159 static const char kVideoTrack2[] = "video_2"; 197 static const char kVideoTrack2[] = "video_2";
(...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 GetFirstVideoContentDescription( 1219 GetFirstVideoContentDescription(
1182 offer.get())->rtp_header_extensions()); 1220 offer.get())->rtp_header_extensions());
1183 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionAnswer), 1221 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionAnswer),
1184 GetFirstAudioContentDescription( 1222 GetFirstAudioContentDescription(
1185 answer.get())->rtp_header_extensions()); 1223 answer.get())->rtp_header_extensions());
1186 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer), 1224 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer),
1187 GetFirstVideoContentDescription( 1225 GetFirstVideoContentDescription(
1188 answer.get())->rtp_header_extensions()); 1226 answer.get())->rtp_header_extensions());
1189 } 1227 }
1190 1228
1229 TEST_F(MediaSessionDescriptionFactoryTest,
1230 TestOfferAnswerWithEncryptedRtpExtensionsBoth) {
1231 MediaSessionOptions opts;
1232 opts.recv_video = true;
1233
1234 f1_.set_enable_encrypted_rtp_header_extensions(true);
1235 f2_.set_enable_encrypted_rtp_header_extensions(true);
1236
1237 f1_.set_audio_rtp_header_extensions(
1238 MAKE_VECTOR(kAudioRtpExtension1));
1239 f1_.set_video_rtp_header_extensions(
1240 MAKE_VECTOR(kVideoRtpExtension1));
1241 f2_.set_audio_rtp_header_extensions(
1242 MAKE_VECTOR(kAudioRtpExtension2));
1243 f2_.set_video_rtp_header_extensions(
1244 MAKE_VECTOR(kVideoRtpExtension2));
1245
1246 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
1247 ASSERT_TRUE(offer.get() != NULL);
1248 std::unique_ptr<SessionDescription> answer(
1249 f2_.CreateAnswer(offer.get(), opts, NULL));
1250
1251 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionEncrypted1),
1252 GetFirstAudioContentDescription(
1253 offer.get())->rtp_header_extensions());
1254 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionEncrypted1),
1255 GetFirstVideoContentDescription(
1256 offer.get())->rtp_header_extensions());
1257 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionEncryptedAnswer),
1258 GetFirstAudioContentDescription(
1259 answer.get())->rtp_header_extensions());
1260 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionEncryptedAnswer),
1261 GetFirstVideoContentDescription(
1262 answer.get())->rtp_header_extensions());
1263 }
1264
1265 TEST_F(MediaSessionDescriptionFactoryTest,
1266 TestOfferAnswerWithEncryptedRtpExtensionsOffer) {
1267 MediaSessionOptions opts;
1268 opts.recv_video = true;
1269
1270 f1_.set_enable_encrypted_rtp_header_extensions(true);
1271
1272 f1_.set_audio_rtp_header_extensions(
1273 MAKE_VECTOR(kAudioRtpExtension1));
1274 f1_.set_video_rtp_header_extensions(
1275 MAKE_VECTOR(kVideoRtpExtension1));
1276 f2_.set_audio_rtp_header_extensions(
1277 MAKE_VECTOR(kAudioRtpExtension2));
1278 f2_.set_video_rtp_header_extensions(
1279 MAKE_VECTOR(kVideoRtpExtension2));
1280
1281 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
1282 ASSERT_TRUE(offer.get() != NULL);
1283 std::unique_ptr<SessionDescription> answer(
1284 f2_.CreateAnswer(offer.get(), opts, NULL));
1285
1286 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionEncrypted1),
1287 GetFirstAudioContentDescription(
1288 offer.get())->rtp_header_extensions());
1289 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionEncrypted1),
1290 GetFirstVideoContentDescription(
1291 offer.get())->rtp_header_extensions());
1292 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionAnswer),
1293 GetFirstAudioContentDescription(
1294 answer.get())->rtp_header_extensions());
1295 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer),
1296 GetFirstVideoContentDescription(
1297 answer.get())->rtp_header_extensions());
1298 }
1299
1300 TEST_F(MediaSessionDescriptionFactoryTest,
1301 TestOfferAnswerWithEncryptedRtpExtensionsAnswer) {
1302 MediaSessionOptions opts;
1303 opts.recv_video = true;
1304
1305 f2_.set_enable_encrypted_rtp_header_extensions(true);
1306
1307 f1_.set_audio_rtp_header_extensions(
1308 MAKE_VECTOR(kAudioRtpExtension1));
1309 f1_.set_video_rtp_header_extensions(
1310 MAKE_VECTOR(kVideoRtpExtension1));
1311 f2_.set_audio_rtp_header_extensions(
1312 MAKE_VECTOR(kAudioRtpExtension2));
1313 f2_.set_video_rtp_header_extensions(
1314 MAKE_VECTOR(kVideoRtpExtension2));
1315
1316 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
1317 ASSERT_TRUE(offer.get() != NULL);
1318 std::unique_ptr<SessionDescription> answer(
1319 f2_.CreateAnswer(offer.get(), opts, NULL));
1320
1321 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension1),
1322 GetFirstAudioContentDescription(
1323 offer.get())->rtp_header_extensions());
1324 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtension1),
1325 GetFirstVideoContentDescription(
1326 offer.get())->rtp_header_extensions());
1327 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionAnswer),
1328 GetFirstAudioContentDescription(
1329 answer.get())->rtp_header_extensions());
1330 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer),
1331 GetFirstVideoContentDescription(
1332 answer.get())->rtp_header_extensions());
1333 }
1334
1191 // Create an audio, video, data answer without legacy StreamParams. 1335 // Create an audio, video, data answer without legacy StreamParams.
1192 TEST_F(MediaSessionDescriptionFactoryTest, 1336 TEST_F(MediaSessionDescriptionFactoryTest,
1193 TestCreateAnswerWithoutLegacyStreams) { 1337 TestCreateAnswerWithoutLegacyStreams) {
1194 MediaSessionOptions opts; 1338 MediaSessionOptions opts;
1195 opts.recv_video = true; 1339 opts.recv_video = true;
1196 opts.data_channel_type = cricket::DCT_RTP; 1340 opts.data_channel_type = cricket::DCT_RTP;
1197 f1_.set_add_legacy_streams(false); 1341 f1_.set_add_legacy_streams(false);
1198 f2_.set_add_legacy_streams(false); 1342 f2_.set_add_legacy_streams(false);
1199 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); 1343 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
1200 ASSERT_TRUE(offer.get() != NULL); 1344 ASSERT_TRUE(offer.get() != NULL);
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
2255 f1_.CreateOffer(opts, offer.get())); 2399 f1_.CreateOffer(opts, offer.get()));
2256 2400
2257 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension3), 2401 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension3),
2258 GetFirstAudioContentDescription( 2402 GetFirstAudioContentDescription(
2259 updated_offer.get())->rtp_header_extensions()); 2403 updated_offer.get())->rtp_header_extensions());
2260 EXPECT_EQ(MAKE_VECTOR(kExpectedVideoRtpExtension), 2404 EXPECT_EQ(MAKE_VECTOR(kExpectedVideoRtpExtension),
2261 GetFirstVideoContentDescription( 2405 GetFirstVideoContentDescription(
2262 updated_offer.get())->rtp_header_extensions()); 2406 updated_offer.get())->rtp_header_extensions());
2263 } 2407 }
2264 2408
2409 // Same as "RtpExtensionIdReused" above for encrypted RTP extensions.
2410 TEST_F(MediaSessionDescriptionFactoryTest, RtpExtensionIdReusedEncrypted) {
2411 MediaSessionOptions opts;
2412 opts.recv_audio = true;
2413 opts.recv_video = true;
2414
2415 f1_.set_enable_encrypted_rtp_header_extensions(true);
2416 f2_.set_enable_encrypted_rtp_header_extensions(true);
2417
2418 f1_.set_audio_rtp_header_extensions(
2419 MAKE_VECTOR(kAudioRtpExtension3ForEncryption));
2420 f1_.set_video_rtp_header_extensions(
2421 MAKE_VECTOR(kVideoRtpExtension3ForEncryption));
2422
2423 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
2424
2425 // The extensions that are shared between audio and video should use the same
2426 // id.
2427 const RtpExtension kExpectedVideoRtpExtension[] = {
2428 kVideoRtpExtension3ForEncryption[0],
2429 kAudioRtpExtension3ForEncryptionOffer[1],
2430 kAudioRtpExtension3ForEncryptionOffer[2],
2431 };
2432
2433 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension3ForEncryptionOffer),
2434 GetFirstAudioContentDescription(
2435 offer.get())->rtp_header_extensions());
2436 EXPECT_EQ(MAKE_VECTOR(kExpectedVideoRtpExtension),
2437 GetFirstVideoContentDescription(
2438 offer.get())->rtp_header_extensions());
2439
2440 // Nothing should change when creating a new offer
2441 std::unique_ptr<SessionDescription> updated_offer(
2442 f1_.CreateOffer(opts, offer.get()));
2443
2444 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension3ForEncryptionOffer),
2445 GetFirstAudioContentDescription(
2446 updated_offer.get())->rtp_header_extensions());
2447 EXPECT_EQ(MAKE_VECTOR(kExpectedVideoRtpExtension),
2448 GetFirstVideoContentDescription(
2449 updated_offer.get())->rtp_header_extensions());
2450 }
2451
2265 TEST(MediaSessionDescription, CopySessionDescription) { 2452 TEST(MediaSessionDescription, CopySessionDescription) {
2266 SessionDescription source; 2453 SessionDescription source;
2267 cricket::ContentGroup group(cricket::CN_AUDIO); 2454 cricket::ContentGroup group(cricket::CN_AUDIO);
2268 source.AddGroup(group); 2455 source.AddGroup(group);
2269 AudioContentDescription* acd(new AudioContentDescription()); 2456 AudioContentDescription* acd(new AudioContentDescription());
2270 acd->set_codecs(MAKE_VECTOR(kAudioCodecs1)); 2457 acd->set_codecs(MAKE_VECTOR(kAudioCodecs1));
2271 acd->AddLegacyStream(1); 2458 acd->AddLegacyStream(1);
2272 source.AddContent(cricket::CN_AUDIO, cricket::NS_JINGLE_RTP, acd); 2459 source.AddContent(cricket::CN_AUDIO, cricket::NS_JINGLE_RTP, acd);
2273 VideoContentDescription* vcd(new VideoContentDescription()); 2460 VideoContentDescription* vcd(new VideoContentDescription());
2274 vcd->set_codecs(MAKE_VECTOR(kVideoCodecs1)); 2461 vcd->set_codecs(MAKE_VECTOR(kVideoCodecs1));
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
3054 ::testing::Combine( 3241 ::testing::Combine(
3055 ::testing::Values(cricket::MD_SENDONLY, 3242 ::testing::Values(cricket::MD_SENDONLY,
3056 cricket::MD_RECVONLY, 3243 cricket::MD_RECVONLY,
3057 cricket::MD_SENDRECV, 3244 cricket::MD_SENDRECV,
3058 cricket::MD_INACTIVE), 3245 cricket::MD_INACTIVE),
3059 ::testing::Values(cricket::MD_SENDONLY, 3246 ::testing::Values(cricket::MD_SENDONLY,
3060 cricket::MD_RECVONLY, 3247 cricket::MD_RECVONLY,
3061 cricket::MD_SENDRECV, 3248 cricket::MD_SENDRECV,
3062 cricket::MD_INACTIVE), 3249 cricket::MD_INACTIVE),
3063 ::testing::Bool())); 3250 ::testing::Bool()));
OLDNEW
« no previous file with comments | « webrtc/pc/mediasession.cc ('k') | webrtc/pc/srtpfilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698