OLD | NEW |
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 using cricket::MEDIA_TYPE_VIDEO; | 68 using cricket::MEDIA_TYPE_VIDEO; |
69 using cricket::MEDIA_TYPE_DATA; | 69 using cricket::MEDIA_TYPE_DATA; |
70 using cricket::RtpHeaderExtension; | 70 using cricket::RtpHeaderExtension; |
71 using cricket::SEC_DISABLED; | 71 using cricket::SEC_DISABLED; |
72 using cricket::SEC_ENABLED; | 72 using cricket::SEC_ENABLED; |
73 using cricket::SEC_REQUIRED; | 73 using cricket::SEC_REQUIRED; |
74 using rtc::CS_AES_CM_128_HMAC_SHA1_32; | 74 using rtc::CS_AES_CM_128_HMAC_SHA1_32; |
75 using rtc::CS_AES_CM_128_HMAC_SHA1_80; | 75 using rtc::CS_AES_CM_128_HMAC_SHA1_80; |
76 | 76 |
77 static const AudioCodec kAudioCodecs1[] = { | 77 static const AudioCodec kAudioCodecs1[] = { |
78 AudioCodec(103, "ISAC", 16000, -1, 1, 6), | 78 AudioCodec(103, "ISAC", 16000, -1, 1), |
79 AudioCodec(102, "iLBC", 8000, 13300, 1, 5), | 79 AudioCodec(102, "iLBC", 8000, 13300, 1), |
80 AudioCodec(0, "PCMU", 8000, 64000, 1, 4), | 80 AudioCodec(0, "PCMU", 8000, 64000, 1), |
81 AudioCodec(8, "PCMA", 8000, 64000, 1, 3), | 81 AudioCodec(8, "PCMA", 8000, 64000, 1), |
82 AudioCodec(117, "red", 8000, 0, 1, 2), | 82 AudioCodec(117, "red", 8000, 0, 1), |
83 AudioCodec(107, "CN", 48000, 0, 1, 1) | 83 AudioCodec(107, "CN", 48000, 0, 1)}; |
84 }; | |
85 | 84 |
86 static const AudioCodec kAudioCodecs2[] = { | 85 static const AudioCodec kAudioCodecs2[] = { |
87 AudioCodec(126, "speex", 16000, 22000, 1, 3), | 86 AudioCodec(126, "speex", 16000, 22000, 1), |
88 AudioCodec(0, "PCMU", 8000, 64000, 1, 2), | 87 AudioCodec(0, "PCMU", 8000, 64000, 1), |
89 AudioCodec(127, "iLBC", 8000, 13300, 1, 1), | 88 AudioCodec(127, "iLBC", 8000, 13300, 1), |
90 }; | 89 }; |
91 | 90 |
92 static const AudioCodec kAudioCodecsAnswer[] = { | 91 static const AudioCodec kAudioCodecsAnswer[] = { |
93 AudioCodec(102, "iLBC", 8000, 13300, 1, 5), | 92 AudioCodec(102, "iLBC", 8000, 13300, 1), |
94 AudioCodec(0, "PCMU", 8000, 64000, 1, 4), | 93 AudioCodec(0, "PCMU", 8000, 64000, 1), |
95 }; | 94 }; |
96 | 95 |
97 static const VideoCodec kVideoCodecs1[] = { | 96 static const VideoCodec kVideoCodecs1[] = { |
98 VideoCodec(96, "H264-SVC", 320, 200, 30, 2), | 97 VideoCodec(96, "H264-SVC", 320, 200, 30), |
99 VideoCodec(97, "H264", 320, 200, 30, 1) | 98 VideoCodec(97, "H264", 320, 200, 30)}; |
100 }; | |
101 | 99 |
102 static const VideoCodec kVideoCodecs2[] = { | 100 static const VideoCodec kVideoCodecs2[] = { |
103 VideoCodec(126, "H264", 320, 200, 30, 2), | 101 VideoCodec(126, "H264", 320, 200, 30), |
104 VideoCodec(127, "H263", 320, 200, 30, 1) | 102 VideoCodec(127, "H263", 320, 200, 30)}; |
105 }; | |
106 | 103 |
107 static const VideoCodec kVideoCodecsAnswer[] = { | 104 static const VideoCodec kVideoCodecsAnswer[] = { |
108 VideoCodec(97, "H264", 320, 200, 30, 1) | 105 VideoCodec(97, "H264", 320, 200, 30)}; |
109 }; | |
110 | 106 |
111 static const DataCodec kDataCodecs1[] = { | 107 static const DataCodec kDataCodecs1[] = {DataCodec(98, "binary-data"), |
112 DataCodec(98, "binary-data", 2), | 108 DataCodec(99, "utf8-text")}; |
113 DataCodec(99, "utf8-text", 1) | |
114 }; | |
115 | 109 |
116 static const DataCodec kDataCodecs2[] = { | 110 static const DataCodec kDataCodecs2[] = {DataCodec(126, "binary-data"), |
117 DataCodec(126, "binary-data", 2), | 111 DataCodec(127, "utf8-text")}; |
118 DataCodec(127, "utf8-text", 1) | |
119 }; | |
120 | 112 |
121 static const DataCodec kDataCodecsAnswer[] = { | 113 static const DataCodec kDataCodecsAnswer[] = {DataCodec(98, "binary-data"), |
122 DataCodec(98, "binary-data", 2), | 114 DataCodec(99, "utf8-text")}; |
123 DataCodec(99, "utf8-text", 1) | |
124 }; | |
125 | 115 |
126 static const RtpHeaderExtension kAudioRtpExtension1[] = { | 116 static const RtpHeaderExtension kAudioRtpExtension1[] = { |
127 RtpHeaderExtension("urn:ietf:params:rtp-hdrext:ssrc-audio-level", 8), | 117 RtpHeaderExtension("urn:ietf:params:rtp-hdrext:ssrc-audio-level", 8), |
128 RtpHeaderExtension("http://google.com/testing/audio_something", 10), | 118 RtpHeaderExtension("http://google.com/testing/audio_something", 10), |
129 }; | 119 }; |
130 | 120 |
131 static const RtpHeaderExtension kAudioRtpExtension2[] = { | 121 static const RtpHeaderExtension kAudioRtpExtension2[] = { |
132 RtpHeaderExtension("urn:ietf:params:rtp-hdrext:ssrc-audio-level", 2), | 122 RtpHeaderExtension("urn:ietf:params:rtp-hdrext:ssrc-audio-level", 2), |
133 RtpHeaderExtension("http://google.com/testing/audio_something_else", 8), | 123 RtpHeaderExtension("http://google.com/testing/audio_something_else", 8), |
134 RtpHeaderExtension("http://google.com/testing/both_audio_and_video", 7), | 124 RtpHeaderExtension("http://google.com/testing/both_audio_and_video", 7), |
(...skipping 1428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1563 | 1553 |
1564 const VideoContentDescription* vcd = | 1554 const VideoContentDescription* vcd = |
1565 GetFirstVideoContentDescription(answer.get()); | 1555 GetFirstVideoContentDescription(answer.get()); |
1566 | 1556 |
1567 std::vector<VideoCodec> expected_codecs = MAKE_VECTOR(kVideoCodecsAnswer); | 1557 std::vector<VideoCodec> expected_codecs = MAKE_VECTOR(kVideoCodecsAnswer); |
1568 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), | 1558 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), |
1569 &expected_codecs); | 1559 &expected_codecs); |
1570 | 1560 |
1571 EXPECT_EQ(expected_codecs, vcd->codecs()); | 1561 EXPECT_EQ(expected_codecs, vcd->codecs()); |
1572 | 1562 |
1573 // Now, make sure we get same result, except for the preference order, | 1563 // Now, make sure we get same result (except for the order) if |f2_| creates |
1574 // if |f2_| creates an updated offer even though the default payload types | 1564 // an updated offer even though the default payload types between |f1_| and |
1575 // are different from |f1_|. | 1565 // |f2_| are different. |
1576 expected_codecs[0].preference = f1_codecs[1].preference; | |
1577 | |
1578 std::unique_ptr<SessionDescription> updated_offer( | 1566 std::unique_ptr<SessionDescription> updated_offer( |
1579 f2_.CreateOffer(opts, answer.get())); | 1567 f2_.CreateOffer(opts, answer.get())); |
1580 ASSERT_TRUE(updated_offer); | 1568 ASSERT_TRUE(updated_offer); |
1581 std::unique_ptr<SessionDescription> updated_answer( | 1569 std::unique_ptr<SessionDescription> updated_answer( |
1582 f1_.CreateAnswer(updated_offer.get(), opts, answer.get())); | 1570 f1_.CreateAnswer(updated_offer.get(), opts, answer.get())); |
1583 | 1571 |
1584 const VideoContentDescription* updated_vcd = | 1572 const VideoContentDescription* updated_vcd = |
1585 GetFirstVideoContentDescription(updated_answer.get()); | 1573 GetFirstVideoContentDescription(updated_answer.get()); |
1586 | 1574 |
1587 EXPECT_EQ(expected_codecs, updated_vcd->codecs()); | 1575 EXPECT_EQ(expected_codecs, updated_vcd->codecs()); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1687 EXPECT_EQ(expected_codecs, updated_vcd->codecs()); | 1675 EXPECT_EQ(expected_codecs, updated_vcd->codecs()); |
1688 } | 1676 } |
1689 | 1677 |
1690 // Test that RTX is ignored when there is no associated payload type parameter. | 1678 // Test that RTX is ignored when there is no associated payload type parameter. |
1691 TEST_F(MediaSessionDescriptionFactoryTest, RtxWithoutApt) { | 1679 TEST_F(MediaSessionDescriptionFactoryTest, RtxWithoutApt) { |
1692 MediaSessionOptions opts; | 1680 MediaSessionOptions opts; |
1693 opts.recv_video = true; | 1681 opts.recv_video = true; |
1694 opts.recv_audio = false; | 1682 opts.recv_audio = false; |
1695 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); | 1683 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); |
1696 // This creates RTX without associated payload type parameter. | 1684 // This creates RTX without associated payload type parameter. |
1697 AddRtxCodec(VideoCodec(126, cricket::kRtxCodecName, 0, 0, 0, 0), &f1_codecs); | 1685 AddRtxCodec(VideoCodec(126, cricket::kRtxCodecName, 0, 0, 0), &f1_codecs); |
1698 f1_.set_video_codecs(f1_codecs); | 1686 f1_.set_video_codecs(f1_codecs); |
1699 | 1687 |
1700 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); | 1688 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); |
1701 // This creates RTX for H264 with the payload type |f2_| uses. | 1689 // This creates RTX for H264 with the payload type |f2_| uses. |
1702 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs); | 1690 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs); |
1703 f2_.set_video_codecs(f2_codecs); | 1691 f2_.set_video_codecs(f2_codecs); |
1704 | 1692 |
1705 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1693 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
1706 ASSERT_TRUE(offer.get() != NULL); | 1694 ASSERT_TRUE(offer.get() != NULL); |
1707 // kCodecParamAssociatedPayloadType will always be added to the offer when RTX | 1695 // kCodecParamAssociatedPayloadType will always be added to the offer when RTX |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1835 TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateMultipleRtxSsrcs) { | 1823 TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateMultipleRtxSsrcs) { |
1836 MediaSessionOptions opts; | 1824 MediaSessionOptions opts; |
1837 opts.recv_video = true; | 1825 opts.recv_video = true; |
1838 opts.recv_audio = false; | 1826 opts.recv_audio = false; |
1839 | 1827 |
1840 // Add simulcast streams. | 1828 // Add simulcast streams. |
1841 opts.AddSendVideoStream("stream1", "stream1label", 3); | 1829 opts.AddSendVideoStream("stream1", "stream1label", 3); |
1842 | 1830 |
1843 // Use a single real codec, and then add RTX for it. | 1831 // Use a single real codec, and then add RTX for it. |
1844 std::vector<VideoCodec> f1_codecs; | 1832 std::vector<VideoCodec> f1_codecs; |
1845 f1_codecs.push_back(VideoCodec(97, "H264", 320, 200, 30, 1)); | 1833 f1_codecs.push_back(VideoCodec(97, "H264", 320, 200, 30)); |
1846 AddRtxCodec(VideoCodec::CreateRtxCodec(125, 97), &f1_codecs); | 1834 AddRtxCodec(VideoCodec::CreateRtxCodec(125, 97), &f1_codecs); |
1847 f1_.set_video_codecs(f1_codecs); | 1835 f1_.set_video_codecs(f1_codecs); |
1848 | 1836 |
1849 // Ensure that the offer has an RTX ssrc for each regular ssrc, and that there | 1837 // Ensure that the offer has an RTX ssrc for each regular ssrc, and that there |
1850 // is a FID ssrc + grouping for each. | 1838 // is a FID ssrc + grouping for each. |
1851 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1839 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
1852 ASSERT_TRUE(offer.get() != NULL); | 1840 ASSERT_TRUE(offer.get() != NULL); |
1853 VideoContentDescription* desc = static_cast<VideoContentDescription*>( | 1841 VideoContentDescription* desc = static_cast<VideoContentDescription*>( |
1854 offer->GetContentDescriptionByName(cricket::CN_VIDEO)); | 1842 offer->GetContentDescriptionByName(cricket::CN_VIDEO)); |
1855 ASSERT_TRUE(desc != NULL); | 1843 ASSERT_TRUE(desc != NULL); |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2384 const ContentInfo* audio_content = GetFirstAudioContent(updated_offer.get()); | 2372 const ContentInfo* audio_content = GetFirstAudioContent(updated_offer.get()); |
2385 const ContentInfo* video_content = GetFirstVideoContent(updated_offer.get()); | 2373 const ContentInfo* video_content = GetFirstVideoContent(updated_offer.get()); |
2386 const ContentInfo* data_content = GetFirstDataContent(updated_offer.get()); | 2374 const ContentInfo* data_content = GetFirstDataContent(updated_offer.get()); |
2387 ASSERT_TRUE(audio_content != nullptr); | 2375 ASSERT_TRUE(audio_content != nullptr); |
2388 ASSERT_TRUE(video_content != nullptr); | 2376 ASSERT_TRUE(video_content != nullptr); |
2389 ASSERT_TRUE(data_content != nullptr); | 2377 ASSERT_TRUE(data_content != nullptr); |
2390 EXPECT_EQ("audio_modified", audio_content->name); | 2378 EXPECT_EQ("audio_modified", audio_content->name); |
2391 EXPECT_EQ("video_modified", video_content->name); | 2379 EXPECT_EQ("video_modified", video_content->name); |
2392 EXPECT_EQ("data_modified", data_content->name); | 2380 EXPECT_EQ("data_modified", data_content->name); |
2393 } | 2381 } |
OLD | NEW |