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

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

Issue 2761143002: Support encrypted RTP extensions (RFC 6904) (Closed)
Patch Set: More feedback from Taylor. Created 3 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
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 986 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 GetFirstVideoContentDescription( 1184 GetFirstVideoContentDescription(
1147 offer.get())->rtp_header_extensions()); 1185 offer.get())->rtp_header_extensions());
1148 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionAnswer), 1186 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionAnswer),
1149 GetFirstAudioContentDescription( 1187 GetFirstAudioContentDescription(
1150 answer.get())->rtp_header_extensions()); 1188 answer.get())->rtp_header_extensions());
1151 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer), 1189 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer),
1152 GetFirstVideoContentDescription( 1190 GetFirstVideoContentDescription(
1153 answer.get())->rtp_header_extensions()); 1191 answer.get())->rtp_header_extensions());
1154 } 1192 }
1155 1193
1194 TEST_F(MediaSessionDescriptionFactoryTest,
1195 TestOfferAnswerWithEncryptedRtpExtensionsBoth) {
1196 MediaSessionOptions opts;
1197 opts.recv_video = true;
1198
1199 f1_.set_enable_encrypted_rtp_header_extensions(true);
1200 f2_.set_enable_encrypted_rtp_header_extensions(true);
1201
1202 f1_.set_audio_rtp_header_extensions(
1203 MAKE_VECTOR(kAudioRtpExtension1));
1204 f1_.set_video_rtp_header_extensions(
1205 MAKE_VECTOR(kVideoRtpExtension1));
1206 f2_.set_audio_rtp_header_extensions(
1207 MAKE_VECTOR(kAudioRtpExtension2));
1208 f2_.set_video_rtp_header_extensions(
1209 MAKE_VECTOR(kVideoRtpExtension2));
1210
1211 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
1212 ASSERT_TRUE(offer.get() != NULL);
1213 std::unique_ptr<SessionDescription> answer(
1214 f2_.CreateAnswer(offer.get(), opts, NULL));
1215
1216 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionEncrypted1),
1217 GetFirstAudioContentDescription(
1218 offer.get())->rtp_header_extensions());
1219 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionEncrypted1),
1220 GetFirstVideoContentDescription(
1221 offer.get())->rtp_header_extensions());
1222 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionEncryptedAnswer),
1223 GetFirstAudioContentDescription(
1224 answer.get())->rtp_header_extensions());
1225 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionEncryptedAnswer),
1226 GetFirstVideoContentDescription(
1227 answer.get())->rtp_header_extensions());
1228 }
1229
1230 TEST_F(MediaSessionDescriptionFactoryTest,
1231 TestOfferAnswerWithEncryptedRtpExtensionsOffer) {
1232 MediaSessionOptions opts;
1233 opts.recv_video = true;
1234
1235 f1_.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(kAudioRtpExtensionAnswer),
1258 GetFirstAudioContentDescription(
1259 answer.get())->rtp_header_extensions());
1260 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer),
1261 GetFirstVideoContentDescription(
1262 answer.get())->rtp_header_extensions());
1263 }
1264
1265 TEST_F(MediaSessionDescriptionFactoryTest,
1266 TestOfferAnswerWithEncryptedRtpExtensionsAnswer) {
1267 MediaSessionOptions opts;
1268 opts.recv_video = true;
1269
1270 f2_.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(kAudioRtpExtension1),
1287 GetFirstAudioContentDescription(
1288 offer.get())->rtp_header_extensions());
1289 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtension1),
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
1156 // Create an audio, video, data answer without legacy StreamParams. 1300 // Create an audio, video, data answer without legacy StreamParams.
1157 TEST_F(MediaSessionDescriptionFactoryTest, 1301 TEST_F(MediaSessionDescriptionFactoryTest,
1158 TestCreateAnswerWithoutLegacyStreams) { 1302 TestCreateAnswerWithoutLegacyStreams) {
1159 MediaSessionOptions opts; 1303 MediaSessionOptions opts;
1160 opts.recv_video = true; 1304 opts.recv_video = true;
1161 opts.data_channel_type = cricket::DCT_RTP; 1305 opts.data_channel_type = cricket::DCT_RTP;
1162 f1_.set_add_legacy_streams(false); 1306 f1_.set_add_legacy_streams(false);
1163 f2_.set_add_legacy_streams(false); 1307 f2_.set_add_legacy_streams(false);
1164 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); 1308 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
1165 ASSERT_TRUE(offer.get() != NULL); 1309 ASSERT_TRUE(offer.get() != NULL);
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
2220 f1_.CreateOffer(opts, offer.get())); 2364 f1_.CreateOffer(opts, offer.get()));
2221 2365
2222 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension3), 2366 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension3),
2223 GetFirstAudioContentDescription( 2367 GetFirstAudioContentDescription(
2224 updated_offer.get())->rtp_header_extensions()); 2368 updated_offer.get())->rtp_header_extensions());
2225 EXPECT_EQ(MAKE_VECTOR(kExpectedVideoRtpExtension), 2369 EXPECT_EQ(MAKE_VECTOR(kExpectedVideoRtpExtension),
2226 GetFirstVideoContentDescription( 2370 GetFirstVideoContentDescription(
2227 updated_offer.get())->rtp_header_extensions()); 2371 updated_offer.get())->rtp_header_extensions());
2228 } 2372 }
2229 2373
2374 // Same as "RtpExtensionIdReused" above for encrypted RTP extensions.
2375 TEST_F(MediaSessionDescriptionFactoryTest, RtpExtensionIdReusedEncrypted) {
2376 MediaSessionOptions opts;
2377 opts.recv_audio = true;
2378 opts.recv_video = true;
2379
2380 f1_.set_enable_encrypted_rtp_header_extensions(true);
2381 f2_.set_enable_encrypted_rtp_header_extensions(true);
2382
2383 f1_.set_audio_rtp_header_extensions(
2384 MAKE_VECTOR(kAudioRtpExtension3ForEncryption));
2385 f1_.set_video_rtp_header_extensions(
2386 MAKE_VECTOR(kVideoRtpExtension3ForEncryption));
2387
2388 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL));
2389
2390 // The extensions that are shared between audio and video should use the same
2391 // id.
2392 const RtpExtension kExpectedVideoRtpExtension[] = {
2393 kVideoRtpExtension3ForEncryption[0],
2394 kAudioRtpExtension3ForEncryptionOffer[1],
2395 kAudioRtpExtension3ForEncryptionOffer[2],
2396 };
2397
2398 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension3ForEncryptionOffer),
2399 GetFirstAudioContentDescription(
2400 offer.get())->rtp_header_extensions());
2401 EXPECT_EQ(MAKE_VECTOR(kExpectedVideoRtpExtension),
2402 GetFirstVideoContentDescription(
2403 offer.get())->rtp_header_extensions());
2404
2405 // Nothing should change when creating a new offer
2406 std::unique_ptr<SessionDescription> updated_offer(
2407 f1_.CreateOffer(opts, offer.get()));
2408
2409 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension3ForEncryptionOffer),
2410 GetFirstAudioContentDescription(
2411 updated_offer.get())->rtp_header_extensions());
2412 EXPECT_EQ(MAKE_VECTOR(kExpectedVideoRtpExtension),
2413 GetFirstVideoContentDescription(
2414 updated_offer.get())->rtp_header_extensions());
2415 }
2416
2230 TEST(MediaSessionDescription, CopySessionDescription) { 2417 TEST(MediaSessionDescription, CopySessionDescription) {
2231 SessionDescription source; 2418 SessionDescription source;
2232 cricket::ContentGroup group(cricket::CN_AUDIO); 2419 cricket::ContentGroup group(cricket::CN_AUDIO);
2233 source.AddGroup(group); 2420 source.AddGroup(group);
2234 AudioContentDescription* acd(new AudioContentDescription()); 2421 AudioContentDescription* acd(new AudioContentDescription());
2235 acd->set_codecs(MAKE_VECTOR(kAudioCodecs1)); 2422 acd->set_codecs(MAKE_VECTOR(kAudioCodecs1));
2236 acd->AddLegacyStream(1); 2423 acd->AddLegacyStream(1);
2237 source.AddContent(cricket::CN_AUDIO, cricket::NS_JINGLE_RTP, acd); 2424 source.AddContent(cricket::CN_AUDIO, cricket::NS_JINGLE_RTP, acd);
2238 VideoContentDescription* vcd(new VideoContentDescription()); 2425 VideoContentDescription* vcd(new VideoContentDescription());
2239 vcd->set_codecs(MAKE_VECTOR(kVideoCodecs1)); 2426 vcd->set_codecs(MAKE_VECTOR(kVideoCodecs1));
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
3019 ::testing::Combine( 3206 ::testing::Combine(
3020 ::testing::Values(cricket::MD_SENDONLY, 3207 ::testing::Values(cricket::MD_SENDONLY,
3021 cricket::MD_RECVONLY, 3208 cricket::MD_RECVONLY,
3022 cricket::MD_SENDRECV, 3209 cricket::MD_SENDRECV,
3023 cricket::MD_INACTIVE), 3210 cricket::MD_INACTIVE),
3024 ::testing::Values(cricket::MD_SENDONLY, 3211 ::testing::Values(cricket::MD_SENDONLY,
3025 cricket::MD_RECVONLY, 3212 cricket::MD_RECVONLY,
3026 cricket::MD_SENDRECV, 3213 cricket::MD_SENDRECV,
3027 cricket::MD_INACTIVE), 3214 cricket::MD_INACTIVE),
3028 ::testing::Bool())); 3215 ::testing::Bool()));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698