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

Unified Diff: webrtc/pc/webrtcsdp_unittest.cc

Issue 2761143002: Support encrypted RTP extensions (RFC 6904) (Closed)
Patch Set: Fix compile error on win_x64 bots. Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/pc/webrtcsdp.cc ('k') | webrtc/pc/webrtcsession.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/pc/webrtcsdp_unittest.cc
diff --git a/webrtc/pc/webrtcsdp_unittest.cc b/webrtc/pc/webrtcsdp_unittest.cc
index 57a7bdb0c05117a3cece735704172c3a49641456..af6f2c91e615dadbd6926186d8bb9e9401db7355 100644
--- a/webrtc/pc/webrtcsdp_unittest.cc
+++ b/webrtc/pc/webrtcsdp_unittest.cc
@@ -94,6 +94,9 @@ static const char kExtmap[] =
"a=extmap:1 http://example.com/082005/ext.htm#ttime\r\n";
static const char kExtmapWithDirectionAndAttribute[] =
"a=extmap:1/sendrecv http://example.com/082005/ext.htm#ttime a1 a2\r\n";
+static const char kExtmapWithDirectionAndAttributeEncrypted[] =
+ "a=extmap:1/sendrecv urn:ietf:params:rtp-hdrext:encrypt "
+ "http://example.com/082005/ext.htm#ttime a1 a2\r\n";
static const uint8_t kIdentityDigest[] = {
0x4A, 0xAD, 0xB9, 0xB1, 0x3F, 0x82, 0x18, 0x3B, 0x54, 0x02,
@@ -1213,6 +1216,7 @@ class WebRtcSdpTest : public testing::Test {
const RtpExtension ext2 = cd2->rtp_header_extensions().at(i);
EXPECT_EQ(ext1.uri, ext2.uri);
EXPECT_EQ(ext1.id, ext2.id);
+ EXPECT_EQ(ext1.encrypt, ext2.encrypt);
}
}
@@ -1434,13 +1438,15 @@ class WebRtcSdpTest : public testing::Test {
cricket::CONNECTIONROLE_NONE, &fingerprint))));
}
- void AddExtmap() {
+ void AddExtmap(bool encrypted) {
audio_desc_ = static_cast<AudioContentDescription*>(
audio_desc_->Copy());
video_desc_ = static_cast<VideoContentDescription*>(
video_desc_->Copy());
- audio_desc_->AddRtpHeaderExtension(RtpExtension(kExtmapUri, kExtmapId));
- video_desc_->AddRtpHeaderExtension(RtpExtension(kExtmapUri, kExtmapId));
+ audio_desc_->AddRtpHeaderExtension(
+ RtpExtension(kExtmapUri, kExtmapId, encrypted));
+ video_desc_->AddRtpHeaderExtension(
+ RtpExtension(kExtmapUri, kExtmapId, encrypted));
desc_.RemoveContentByName(kAudioContentName);
desc_.RemoveContentByName(kVideoContentName);
desc_.AddContent(kAudioContentName, NS_JINGLE_RTP, audio_desc_);
@@ -1576,8 +1582,9 @@ class WebRtcSdpTest : public testing::Test {
return true;
}
- void TestDeserializeExtmap(bool session_level, bool media_level) {
- AddExtmap();
+ void TestDeserializeExtmap(bool session_level, bool media_level,
+ bool encrypted) {
+ AddExtmap(encrypted);
JsepSessionDescription new_jdesc("dummy");
ASSERT_TRUE(new_jdesc.Initialize(desc_.Copy(),
jdesc_.session_id(),
@@ -1585,13 +1592,19 @@ class WebRtcSdpTest : public testing::Test {
JsepSessionDescription jdesc_with_extmap("dummy");
std::string sdp_with_extmap = kSdpString;
if (session_level) {
- InjectAfter(kSessionTime, kExtmapWithDirectionAndAttribute,
+ InjectAfter(kSessionTime,
+ encrypted ? kExtmapWithDirectionAndAttributeEncrypted
+ : kExtmapWithDirectionAndAttribute,
&sdp_with_extmap);
}
if (media_level) {
- InjectAfter(kAttributeIcePwdVoice, kExtmapWithDirectionAndAttribute,
+ InjectAfter(kAttributeIcePwdVoice,
+ encrypted ? kExtmapWithDirectionAndAttributeEncrypted
+ : kExtmapWithDirectionAndAttribute,
&sdp_with_extmap);
- InjectAfter(kAttributeIcePwdVideo, kExtmapWithDirectionAndAttribute,
+ InjectAfter(kAttributeIcePwdVideo,
+ encrypted ? kExtmapWithDirectionAndAttributeEncrypted
+ : kExtmapWithDirectionAndAttribute,
&sdp_with_extmap);
}
// The extmap can't be present at the same time in both session level and
@@ -2016,7 +2029,8 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithDataChannelAndBandwidth) {
}
TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithExtmap) {
- AddExtmap();
+ bool encrypted = false;
+ AddExtmap(encrypted);
JsepSessionDescription desc_with_extmap("dummy");
MakeDescriptionWithoutCandidates(&desc_with_extmap);
std::string message = webrtc::SdpSerialize(desc_with_extmap, false);
@@ -2030,6 +2044,15 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithExtmap) {
EXPECT_EQ(sdp_with_extmap, message);
}
+TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithExtmapEncrypted) {
+ bool encrypted = true;
+ AddExtmap(encrypted);
+ JsepSessionDescription desc_with_extmap("dummy");
+ ASSERT_TRUE(desc_with_extmap.Initialize(desc_.Copy(),
+ kSessionId, kSessionVersion));
+ TestSerialize(desc_with_extmap, false);
+}
+
TEST_F(WebRtcSdpTest, SerializeCandidates) {
std::string message = webrtc::SdpSerializeCandidate(*jcandidate_);
EXPECT_EQ(std::string(kRawCandidate), message);
@@ -2675,18 +2698,32 @@ TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannelsAndBandwidth) {
EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_with_bandwidth));
}
-TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithSessionLevelExtmap) {
- TestDeserializeExtmap(true, false);
+class WebRtcSdpExtmapTest
+ : public WebRtcSdpTest, public testing::WithParamInterface<bool> {
+};
+
+TEST_P(WebRtcSdpExtmapTest,
+ DeserializeSessionDescriptionWithSessionLevelExtmap) {
+ bool encrypted = GetParam();
+ TestDeserializeExtmap(true, false, encrypted);
}
-TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithMediaLevelExtmap) {
- TestDeserializeExtmap(false, true);
+TEST_P(WebRtcSdpExtmapTest,
+ DeserializeSessionDescriptionWithMediaLevelExtmap) {
+ bool encrypted = GetParam();
+ TestDeserializeExtmap(false, true, encrypted);
}
-TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithInvalidExtmap) {
- TestDeserializeExtmap(true, true);
+TEST_P(WebRtcSdpExtmapTest,
+ DeserializeSessionDescriptionWithInvalidExtmap) {
+ bool encrypted = GetParam();
+ TestDeserializeExtmap(true, true, encrypted);
}
+INSTANTIATE_TEST_CASE_P(Encrypted,
+ WebRtcSdpExtmapTest,
+ ::testing::Values(false, true));
+
TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithoutEndLineBreak) {
JsepSessionDescription jdesc(kDummyString);
std::string sdp = kSdpFullString;
« no previous file with comments | « webrtc/pc/webrtcsdp.cc ('k') | webrtc/pc/webrtcsession.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698