Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2011 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 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 861 // WebRtcSdpTest | 861 // WebRtcSdpTest |
| 862 | 862 |
| 863 class WebRtcSdpTest : public testing::Test { | 863 class WebRtcSdpTest : public testing::Test { |
| 864 public: | 864 public: |
| 865 WebRtcSdpTest() | 865 WebRtcSdpTest() |
| 866 : jdesc_(kDummyString) { | 866 : jdesc_(kDummyString) { |
| 867 #ifdef WEBRTC_ANDROID | 867 #ifdef WEBRTC_ANDROID |
| 868 webrtc::InitializeAndroidObjects(); | 868 webrtc::InitializeAndroidObjects(); |
| 869 #endif | 869 #endif |
| 870 // AudioContentDescription | 870 // AudioContentDescription |
| 871 audio_desc_ = CreateAudioContentDescription(); | 871 audio_desc_ = CreateAudioContentDescription(); |
|
Taylor Brandstetter
2017/03/10 22:41:18
To be consistent with how most things in this file
Zhi Huang
2017/03/15 04:04:59
Done.
| |
| 872 StreamParams audio_stream; | 872 StreamParams audio_stream; |
| 873 audio_stream.id = kAudioTrackId1; | 873 audio_stream.id = kAudioTrackId1; |
| 874 audio_stream.cname = kStream1Cname; | 874 audio_stream.cname = kStream1Cname; |
| 875 audio_stream.sync_label = kStreamLabel1; | 875 audio_stream.sync_label = kStreamLabel1; |
| 876 audio_stream.ssrcs.push_back(kAudioTrack1Ssrc); | 876 audio_stream.ssrcs.push_back(kAudioTrack1Ssrc); |
| 877 audio_desc_->AddStream(audio_stream); | 877 audio_desc_->AddStream(audio_stream); |
| 878 desc_.AddContent(kAudioContentName, NS_JINGLE_RTP, audio_desc_); | 878 desc_.AddContent(kAudioContentName, NS_JINGLE_RTP, audio_desc_); |
| 879 | 879 |
| 880 // VideoContentDescription | 880 // VideoContentDescription |
| 881 video_desc_ = CreateVideoContentDescription(); | 881 video_desc_ = CreateVideoContentDescription(); |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1144 1, "AES_CM_128_HMAC_SHA1_80", | 1144 1, "AES_CM_128_HMAC_SHA1_80", |
| 1145 "inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj|2^20|1:32", "")); | 1145 "inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj|2^20|1:32", "")); |
| 1146 video->set_protocol(cricket::kMediaProtocolSavpf); | 1146 video->set_protocol(cricket::kMediaProtocolSavpf); |
| 1147 video->AddCodec( | 1147 video->AddCodec( |
| 1148 VideoCodec(120, JsepSessionDescription::kDefaultVideoCodecName)); | 1148 VideoCodec(120, JsepSessionDescription::kDefaultVideoCodecName)); |
| 1149 return video; | 1149 return video; |
| 1150 } | 1150 } |
| 1151 | 1151 |
| 1152 template <class MCD> | 1152 template <class MCD> |
| 1153 void CompareMediaContentDescription(const MCD* cd1, | 1153 void CompareMediaContentDescription(const MCD* cd1, |
| 1154 const MCD* cd2) { | 1154 const MCD* cd2) { |
|
Taylor Brandstetter
2017/03/10 22:41:18
... and add code to compare them in this method. T
Zhi Huang
2017/03/15 04:04:59
Done.
| |
| 1155 // type | 1155 // type |
| 1156 EXPECT_EQ(cd1->type(), cd1->type()); | 1156 EXPECT_EQ(cd1->type(), cd1->type()); |
| 1157 | 1157 |
| 1158 // content direction | 1158 // content direction |
| 1159 EXPECT_EQ(cd1->direction(), cd2->direction()); | 1159 EXPECT_EQ(cd1->direction(), cd2->direction()); |
| 1160 | 1160 |
| 1161 // rtcp_mux | 1161 // rtcp_mux |
| 1162 EXPECT_EQ(cd1->rtcp_mux(), cd2->rtcp_mux()); | 1162 EXPECT_EQ(cd1->rtcp_mux(), cd2->rtcp_mux()); |
| 1163 | 1163 |
| 1164 // rtcp_reduced_size | 1164 // rtcp_reduced_size |
| (...skipping 2332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3497 "s=-\r\n" | 3497 "s=-\r\n" |
| 3498 "t=0 0\r\n" | 3498 "t=0 0\r\n" |
| 3499 "m=audio 9 RTP/SAVPF 111\r\n" | 3499 "m=audio 9 RTP/SAVPF 111\r\n" |
| 3500 "c=IN IP4 0.0.0.0\r\n" | 3500 "c=IN IP4 0.0.0.0\r\n" |
| 3501 "a=rtpmap:111 opus/48000/2\r\n" | 3501 "a=rtpmap:111 opus/48000/2\r\n" |
| 3502 "a=msid: track_id\r\n"; | 3502 "a=msid: track_id\r\n"; |
| 3503 | 3503 |
| 3504 JsepSessionDescription jdesc_output(kDummyString); | 3504 JsepSessionDescription jdesc_output(kDummyString); |
| 3505 EXPECT_FALSE(SdpDeserialize(kSdpWithMissingStreamId, &jdesc_output)); | 3505 EXPECT_FALSE(SdpDeserialize(kSdpWithMissingStreamId, &jdesc_output)); |
| 3506 } | 3506 } |
| 3507 | |
| 3508 // Tests that the connection data on both the session level and media level can | |
| 3509 // be sucessfully parsed. | |
| 3510 TEST_F(WebRtcSdpTest, ParseConnectionData) { | |
| 3511 JsepSessionDescription jsep_desc(kDummyString); | |
| 3512 | |
| 3513 // IPv4 addresses. | |
| 3514 std::string sdp = kSdpFullString; | |
| 3515 InjectAfter("s=-\r\n", "c=IN IP4 192.168.0.1\r\n", &sdp); | |
| 3516 EXPECT_TRUE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3517 ASSERT_TRUE(jsep_desc.description()->session_connection_addr()); | |
| 3518 // The port is expected to be the default value 0. | |
| 3519 EXPECT_EQ("192.168.0.1:0", | |
| 3520 jsep_desc.description()->session_connection_addr()->ToString()); | |
| 3521 const auto& content1 = jsep_desc.description()->contents()[0]; | |
| 3522 EXPECT_EQ("74.125.127.126:0", | |
| 3523 static_cast<cricket::MediaContentDescription*>(content1.description) | |
| 3524 ->media_connection_addr() | |
| 3525 ->ToString()); | |
| 3526 const auto& content2 = jsep_desc.description()->contents()[1]; | |
| 3527 EXPECT_EQ("74.125.224.39:0", | |
| 3528 static_cast<cricket::MediaContentDescription*>(content2.description) | |
| 3529 ->media_connection_addr() | |
| 3530 ->ToString()); | |
| 3531 | |
| 3532 // IPv6 addresses/ | |
| 3533 sdp = kSdpFullString; | |
| 3534 InjectAfter("s=-\r\n", "c=IN IP6 2001:0db8:85a3:0000:0000:8a2e:0370:7334\r\n", | |
| 3535 &sdp); | |
| 3536 EXPECT_TRUE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3537 Replace("c=IN IP4 74.125.127.126\r\n", | |
| 3538 "c=IN IP6 2001:0db8:85a3:0000:0000:8a2e:0370:7335\r\n", &sdp); | |
| 3539 Replace("c=IN IP4 74.125.224.39\r\n", | |
| 3540 "c=IN IP6 2001:0db8:85a3:0000:0000:8a2e:0370:7336\r\n", &sdp); | |
| 3541 EXPECT_TRUE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3542 ASSERT_TRUE(jsep_desc.description()->session_connection_addr()); | |
| 3543 EXPECT_EQ("[2001:db8:85a3::8a2e:370:7334]:0", | |
| 3544 jsep_desc.description()->session_connection_addr()->ToString()); | |
| 3545 const auto& content3 = jsep_desc.description()->contents()[0]; | |
| 3546 EXPECT_EQ("[2001:db8:85a3::8a2e:370:7335]:0", | |
| 3547 static_cast<cricket::MediaContentDescription*>(content3.description) | |
| 3548 ->media_connection_addr() | |
| 3549 ->ToString()); | |
| 3550 const auto& content4 = jsep_desc.description()->contents()[1]; | |
| 3551 EXPECT_EQ("[2001:db8:85a3::8a2e:370:7336]:0", | |
| 3552 static_cast<cricket::MediaContentDescription*>(content4.description) | |
| 3553 ->media_connection_addr() | |
| 3554 ->ToString()); | |
| 3555 } | |
| 3556 | |
| 3557 // Test that the invalid connection data cannot be parsed. | |
|
Taylor Brandstetter
2017/03/10 22:41:18
I'd use the term "unsupported" rather than "invali
| |
| 3558 TEST_F(WebRtcSdpTest, ParseInvalidConnectionData) { | |
| 3559 JsepSessionDescription jsep_desc(kDummyString); | |
| 3560 std::string sdp = kSdpFullString; | |
| 3561 EXPECT_TRUE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3562 | |
| 3563 // Invalid session level IPv4 address. | |
| 3564 InjectAfter("s=-\r\n", "c=IN IP4 192.168.0.1/127\r\n", &sdp); | |
| 3565 EXPECT_FALSE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3566 | |
| 3567 // Invalid media level IPv4 address. | |
| 3568 sdp = kSdpFullString; | |
| 3569 Replace("c=IN IP4 74.125.224.39\r\n", "c=IN IP4 74.125.224.39/127\r\n", &sdp); | |
| 3570 EXPECT_FALSE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3571 | |
| 3572 // Invalid session level IPv6 address. | |
| 3573 sdp = kSdpFullString; | |
| 3574 EXPECT_TRUE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3575 InjectAfter("s=-\r\n", | |
| 3576 "c=IN IP6 2001:0db8:85a3:0000:0000:8a2e:0370:7334/3\r\n", &sdp); | |
| 3577 EXPECT_FALSE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3578 | |
| 3579 // Invalid media level IPv6 address. | |
| 3580 sdp = kSdpFullString; | |
| 3581 Replace("c=IN IP4 74.125.224.39\r\n", | |
| 3582 "c=IN IP6 2001:0db8:85a3:0000:0000:8a2e:0370:7334/3\r\n", &sdp); | |
| 3583 EXPECT_FALSE(SdpDeserialize(sdp, &jsep_desc)); | |
| 3584 } | |
| OLD | NEW |