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 1636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1647 ASSERT_EQ("H264", updated_vcd->codecs()[0].name); | 1647 ASSERT_EQ("H264", updated_vcd->codecs()[0].name); |
1648 ASSERT_EQ(std::string(cricket::kRtxCodecName), updated_vcd->codecs()[1].name); | 1648 ASSERT_EQ(std::string(cricket::kRtxCodecName), updated_vcd->codecs()[1].name); |
1649 int new_h264_pl_type = updated_vcd->codecs()[0].id; | 1649 int new_h264_pl_type = updated_vcd->codecs()[0].id; |
1650 EXPECT_NE(used_pl_type, new_h264_pl_type); | 1650 EXPECT_NE(used_pl_type, new_h264_pl_type); |
1651 VideoCodec rtx = updated_vcd->codecs()[1]; | 1651 VideoCodec rtx = updated_vcd->codecs()[1]; |
1652 int pt_referenced_by_rtx = rtc::FromString<int>( | 1652 int pt_referenced_by_rtx = rtc::FromString<int>( |
1653 rtx.params[cricket::kCodecParamAssociatedPayloadType]); | 1653 rtx.params[cricket::kCodecParamAssociatedPayloadType]); |
1654 EXPECT_EQ(new_h264_pl_type, pt_referenced_by_rtx); | 1654 EXPECT_EQ(new_h264_pl_type, pt_referenced_by_rtx); |
1655 } | 1655 } |
1656 | 1656 |
| 1657 // Create an updated offer with RTX after creating an answer to an offer |
| 1658 // without RTX, and with different default payload types. |
| 1659 // Verify that the added RTX codec references the correct payload type. |
| 1660 TEST_F(MediaSessionDescriptionFactoryTest, |
| 1661 RespondentCreatesOfferWithRtxAfterCreatingAnswerWithoutRtx) { |
| 1662 MediaSessionOptions opts; |
| 1663 opts.recv_video = true; |
| 1664 opts.recv_audio = true; |
| 1665 |
| 1666 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); |
| 1667 // This creates rtx for H264 with the payload type |f2_| uses. |
| 1668 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs); |
| 1669 f2_.set_video_codecs(f2_codecs); |
| 1670 |
| 1671 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
| 1672 ASSERT_TRUE(offer.get() != nullptr); |
| 1673 rtc::scoped_ptr<SessionDescription> answer( |
| 1674 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
| 1675 |
| 1676 const VideoContentDescription* vcd = |
| 1677 GetFirstVideoContentDescription(answer.get()); |
| 1678 |
| 1679 std::vector<VideoCodec> expected_codecs = MAKE_VECTOR(kVideoCodecsAnswer); |
| 1680 EXPECT_EQ(expected_codecs, vcd->codecs()); |
| 1681 |
| 1682 // Now, ensure that the RTX codec is created correctly when |f2_| creates an |
| 1683 // updated offer, even though the default payload types are different from |
| 1684 // those of |f1_|. |
| 1685 rtc::scoped_ptr<SessionDescription> updated_offer( |
| 1686 f2_.CreateOffer(opts, answer.get())); |
| 1687 ASSERT_TRUE(updated_offer); |
| 1688 |
| 1689 const VideoContentDescription* updated_vcd = |
| 1690 GetFirstVideoContentDescription(updated_offer.get()); |
| 1691 |
| 1692 // New offer should attempt to add H263, and RTX for H264. |
| 1693 expected_codecs.push_back(kVideoCodecs2[1]); |
| 1694 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs1[1].id), |
| 1695 &expected_codecs); |
| 1696 EXPECT_EQ(expected_codecs, updated_vcd->codecs()); |
| 1697 } |
| 1698 |
1657 // Test that RTX is ignored when there is no associated payload type parameter. | 1699 // Test that RTX is ignored when there is no associated payload type parameter. |
1658 TEST_F(MediaSessionDescriptionFactoryTest, RtxWithoutApt) { | 1700 TEST_F(MediaSessionDescriptionFactoryTest, RtxWithoutApt) { |
1659 MediaSessionOptions opts; | 1701 MediaSessionOptions opts; |
1660 opts.recv_video = true; | 1702 opts.recv_video = true; |
1661 opts.recv_audio = false; | 1703 opts.recv_audio = false; |
1662 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); | 1704 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); |
1663 // This creates RTX without associated payload type parameter. | 1705 // This creates RTX without associated payload type parameter. |
1664 AddRtxCodec(VideoCodec(126, cricket::kRtxCodecName, 0, 0, 0, 0), &f1_codecs); | 1706 AddRtxCodec(VideoCodec(126, cricket::kRtxCodecName, 0, 0, 0, 0), &f1_codecs); |
1665 f1_.set_video_codecs(f1_codecs); | 1707 f1_.set_video_codecs(f1_codecs); |
1666 | 1708 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1755 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1797 f2_.CreateAnswer(offer.get(), opts, NULL)); |
1756 const VideoContentDescription* vcd = | 1798 const VideoContentDescription* vcd = |
1757 GetFirstVideoContentDescription(answer.get()); | 1799 GetFirstVideoContentDescription(answer.get()); |
1758 std::vector<VideoCodec> expected_codecs = MAKE_VECTOR(kVideoCodecsAnswer); | 1800 std::vector<VideoCodec> expected_codecs = MAKE_VECTOR(kVideoCodecsAnswer); |
1759 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), | 1801 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), |
1760 &expected_codecs); | 1802 &expected_codecs); |
1761 | 1803 |
1762 EXPECT_EQ(expected_codecs, vcd->codecs()); | 1804 EXPECT_EQ(expected_codecs, vcd->codecs()); |
1763 } | 1805 } |
1764 | 1806 |
| 1807 // Test that after one RTX codec has been negotiated, a new offer can attempt |
| 1808 // to add another. |
| 1809 TEST_F(MediaSessionDescriptionFactoryTest, AddSecondRtxInNewOffer) { |
| 1810 MediaSessionOptions opts; |
| 1811 opts.recv_video = true; |
| 1812 opts.recv_audio = false; |
| 1813 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); |
| 1814 // This creates RTX for H264 for the offerer. |
| 1815 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); |
| 1816 f1_.set_video_codecs(f1_codecs); |
| 1817 |
| 1818 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
| 1819 ASSERT_TRUE(offer); |
| 1820 const VideoContentDescription* vcd = |
| 1821 GetFirstVideoContentDescription(offer.get()); |
| 1822 |
| 1823 std::vector<VideoCodec> expected_codecs = MAKE_VECTOR(kVideoCodecs1); |
| 1824 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), |
| 1825 &expected_codecs); |
| 1826 EXPECT_EQ(expected_codecs, vcd->codecs()); |
| 1827 |
| 1828 // Now, attempt to add RTX for H264-SVC. |
| 1829 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs1[0].id), &f1_codecs); |
| 1830 f1_.set_video_codecs(f1_codecs); |
| 1831 |
| 1832 rtc::scoped_ptr<SessionDescription> updated_offer( |
| 1833 f1_.CreateOffer(opts, offer.get())); |
| 1834 ASSERT_TRUE(updated_offer); |
| 1835 vcd = GetFirstVideoContentDescription(updated_offer.get()); |
| 1836 |
| 1837 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs1[0].id), |
| 1838 &expected_codecs); |
| 1839 EXPECT_EQ(expected_codecs, vcd->codecs()); |
| 1840 } |
| 1841 |
1765 // Test that when RTX is used in conjunction with simulcast, an RTX ssrc is | 1842 // Test that when RTX is used in conjunction with simulcast, an RTX ssrc is |
1766 // generated for each simulcast ssrc and correctly grouped. | 1843 // generated for each simulcast ssrc and correctly grouped. |
1767 TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateMultipleRtxSsrcs) { | 1844 TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateMultipleRtxSsrcs) { |
1768 MediaSessionOptions opts; | 1845 MediaSessionOptions opts; |
1769 opts.recv_video = true; | 1846 opts.recv_video = true; |
1770 opts.recv_audio = false; | 1847 opts.recv_audio = false; |
1771 | 1848 |
1772 // Add simulcast streams. | 1849 // Add simulcast streams. |
1773 opts.AddSendVideoStream("stream1", "stream1label", 3); | 1850 opts.AddSendVideoStream("stream1", "stream1label", 3); |
1774 | 1851 |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2318 const ContentInfo* audio_content = GetFirstAudioContent(updated_offer.get()); | 2395 const ContentInfo* audio_content = GetFirstAudioContent(updated_offer.get()); |
2319 const ContentInfo* video_content = GetFirstVideoContent(updated_offer.get()); | 2396 const ContentInfo* video_content = GetFirstVideoContent(updated_offer.get()); |
2320 const ContentInfo* data_content = GetFirstDataContent(updated_offer.get()); | 2397 const ContentInfo* data_content = GetFirstDataContent(updated_offer.get()); |
2321 ASSERT_TRUE(audio_content != nullptr); | 2398 ASSERT_TRUE(audio_content != nullptr); |
2322 ASSERT_TRUE(video_content != nullptr); | 2399 ASSERT_TRUE(video_content != nullptr); |
2323 ASSERT_TRUE(data_content != nullptr); | 2400 ASSERT_TRUE(data_content != nullptr); |
2324 EXPECT_EQ("audio_modified", audio_content->name); | 2401 EXPECT_EQ("audio_modified", audio_content->name); |
2325 EXPECT_EQ("video_modified", video_content->name); | 2402 EXPECT_EQ("video_modified", video_content->name); |
2326 EXPECT_EQ("data_modified", data_content->name); | 2403 EXPECT_EQ("data_modified", data_content->name); |
2327 } | 2404 } |
OLD | NEW |