OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2004 Google Inc. | 3 * Copyright 2004 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 1653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1664 ASSERT_EQ("H264", updated_vcd->codecs()[0].name); | 1664 ASSERT_EQ("H264", updated_vcd->codecs()[0].name); |
1665 ASSERT_EQ(std::string(cricket::kRtxCodecName), updated_vcd->codecs()[1].name); | 1665 ASSERT_EQ(std::string(cricket::kRtxCodecName), updated_vcd->codecs()[1].name); |
1666 int new_h264_pl_type = updated_vcd->codecs()[0].id; | 1666 int new_h264_pl_type = updated_vcd->codecs()[0].id; |
1667 EXPECT_NE(used_pl_type, new_h264_pl_type); | 1667 EXPECT_NE(used_pl_type, new_h264_pl_type); |
1668 VideoCodec rtx = updated_vcd->codecs()[1]; | 1668 VideoCodec rtx = updated_vcd->codecs()[1]; |
1669 int pt_referenced_by_rtx = rtc::FromString<int>( | 1669 int pt_referenced_by_rtx = rtc::FromString<int>( |
1670 rtx.params[cricket::kCodecParamAssociatedPayloadType]); | 1670 rtx.params[cricket::kCodecParamAssociatedPayloadType]); |
1671 EXPECT_EQ(new_h264_pl_type, pt_referenced_by_rtx); | 1671 EXPECT_EQ(new_h264_pl_type, pt_referenced_by_rtx); |
1672 } | 1672 } |
1673 | 1673 |
| 1674 // Create an updated offer with RTX after creating an answer to an offer |
| 1675 // without RTX, and with different default payload types. |
| 1676 // Verify that the added RTX codec references the correct payload type. |
| 1677 TEST_F(MediaSessionDescriptionFactoryTest, |
| 1678 RespondentCreatesOfferWithRtxAfterCreatingAnswerWithoutRtx) { |
| 1679 MediaSessionOptions opts; |
| 1680 opts.recv_video = true; |
| 1681 opts.recv_audio = true; |
| 1682 |
| 1683 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); |
| 1684 // This creates rtx for H264 with the payload type |f2_| uses. |
| 1685 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs); |
| 1686 f2_.set_video_codecs(f2_codecs); |
| 1687 |
| 1688 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
| 1689 ASSERT_TRUE(offer.get() != nullptr); |
| 1690 rtc::scoped_ptr<SessionDescription> answer( |
| 1691 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
| 1692 |
| 1693 const VideoContentDescription* vcd = |
| 1694 GetFirstVideoContentDescription(answer.get()); |
| 1695 |
| 1696 std::vector<VideoCodec> expected_codecs = MAKE_VECTOR(kVideoCodecsAnswer); |
| 1697 EXPECT_EQ(expected_codecs, vcd->codecs()); |
| 1698 |
| 1699 // Now, ensure that the RTX codec is created correctly when |f2_| creates an |
| 1700 // updated offer, even though the default payload types are different from |
| 1701 // those of |f1_|. |
| 1702 rtc::scoped_ptr<SessionDescription> updated_offer( |
| 1703 f2_.CreateOffer(opts, answer.get())); |
| 1704 ASSERT_TRUE(updated_offer); |
| 1705 |
| 1706 const VideoContentDescription* updated_vcd = |
| 1707 GetFirstVideoContentDescription(updated_offer.get()); |
| 1708 |
| 1709 // New offer should attempt to add H263, and RTX for H264. |
| 1710 expected_codecs.push_back(kVideoCodecs2[1]); |
| 1711 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs1[1].id), |
| 1712 &expected_codecs); |
| 1713 EXPECT_EQ(expected_codecs, updated_vcd->codecs()); |
| 1714 } |
| 1715 |
1674 // Test that RTX is ignored when there is no associated payload type parameter. | 1716 // Test that RTX is ignored when there is no associated payload type parameter. |
1675 TEST_F(MediaSessionDescriptionFactoryTest, RtxWithoutApt) { | 1717 TEST_F(MediaSessionDescriptionFactoryTest, RtxWithoutApt) { |
1676 MediaSessionOptions opts; | 1718 MediaSessionOptions opts; |
1677 opts.recv_video = true; | 1719 opts.recv_video = true; |
1678 opts.recv_audio = false; | 1720 opts.recv_audio = false; |
1679 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); | 1721 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); |
1680 // This creates RTX without associated payload type parameter. | 1722 // This creates RTX without associated payload type parameter. |
1681 AddRtxCodec(VideoCodec(126, cricket::kRtxCodecName, 0, 0, 0, 0), &f1_codecs); | 1723 AddRtxCodec(VideoCodec(126, cricket::kRtxCodecName, 0, 0, 0, 0), &f1_codecs); |
1682 f1_.set_video_codecs(f1_codecs); | 1724 f1_.set_video_codecs(f1_codecs); |
1683 | 1725 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1772 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1814 f2_.CreateAnswer(offer.get(), opts, NULL)); |
1773 const VideoContentDescription* vcd = | 1815 const VideoContentDescription* vcd = |
1774 GetFirstVideoContentDescription(answer.get()); | 1816 GetFirstVideoContentDescription(answer.get()); |
1775 std::vector<VideoCodec> expected_codecs = MAKE_VECTOR(kVideoCodecsAnswer); | 1817 std::vector<VideoCodec> expected_codecs = MAKE_VECTOR(kVideoCodecsAnswer); |
1776 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), | 1818 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), |
1777 &expected_codecs); | 1819 &expected_codecs); |
1778 | 1820 |
1779 EXPECT_EQ(expected_codecs, vcd->codecs()); | 1821 EXPECT_EQ(expected_codecs, vcd->codecs()); |
1780 } | 1822 } |
1781 | 1823 |
| 1824 // Test that after one RTX codec has been negotiated, a new offer can attempt |
| 1825 // to add another. |
| 1826 TEST_F(MediaSessionDescriptionFactoryTest, AddSecondRtxInNewOffer) { |
| 1827 MediaSessionOptions opts; |
| 1828 opts.recv_video = true; |
| 1829 opts.recv_audio = false; |
| 1830 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); |
| 1831 // This creates RTX for H264 for the offerer. |
| 1832 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); |
| 1833 f1_.set_video_codecs(f1_codecs); |
| 1834 |
| 1835 rtc::scoped_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
| 1836 ASSERT_TRUE(offer); |
| 1837 const VideoContentDescription* vcd = |
| 1838 GetFirstVideoContentDescription(offer.get()); |
| 1839 |
| 1840 std::vector<VideoCodec> expected_codecs = MAKE_VECTOR(kVideoCodecs1); |
| 1841 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), |
| 1842 &expected_codecs); |
| 1843 EXPECT_EQ(expected_codecs, vcd->codecs()); |
| 1844 |
| 1845 // Now, attempt to add RTX for H264-SVC. |
| 1846 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs1[0].id), &f1_codecs); |
| 1847 f1_.set_video_codecs(f1_codecs); |
| 1848 |
| 1849 rtc::scoped_ptr<SessionDescription> updated_offer( |
| 1850 f1_.CreateOffer(opts, offer.get())); |
| 1851 ASSERT_TRUE(updated_offer); |
| 1852 vcd = GetFirstVideoContentDescription(updated_offer.get()); |
| 1853 |
| 1854 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs1[0].id), |
| 1855 &expected_codecs); |
| 1856 EXPECT_EQ(expected_codecs, vcd->codecs()); |
| 1857 } |
| 1858 |
1782 // Test that when RTX is used in conjunction with simulcast, an RTX ssrc is | 1859 // Test that when RTX is used in conjunction with simulcast, an RTX ssrc is |
1783 // generated for each simulcast ssrc and correctly grouped. | 1860 // generated for each simulcast ssrc and correctly grouped. |
1784 TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateMultipleRtxSsrcs) { | 1861 TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateMultipleRtxSsrcs) { |
1785 MediaSessionOptions opts; | 1862 MediaSessionOptions opts; |
1786 opts.recv_video = true; | 1863 opts.recv_video = true; |
1787 opts.recv_audio = false; | 1864 opts.recv_audio = false; |
1788 | 1865 |
1789 // Add simulcast streams. | 1866 // Add simulcast streams. |
1790 opts.AddSendVideoStream("stream1", "stream1label", 3); | 1867 opts.AddSendVideoStream("stream1", "stream1label", 3); |
1791 | 1868 |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2335 const ContentInfo* audio_content = GetFirstAudioContent(updated_offer.get()); | 2412 const ContentInfo* audio_content = GetFirstAudioContent(updated_offer.get()); |
2336 const ContentInfo* video_content = GetFirstVideoContent(updated_offer.get()); | 2413 const ContentInfo* video_content = GetFirstVideoContent(updated_offer.get()); |
2337 const ContentInfo* data_content = GetFirstDataContent(updated_offer.get()); | 2414 const ContentInfo* data_content = GetFirstDataContent(updated_offer.get()); |
2338 ASSERT_TRUE(audio_content != nullptr); | 2415 ASSERT_TRUE(audio_content != nullptr); |
2339 ASSERT_TRUE(video_content != nullptr); | 2416 ASSERT_TRUE(video_content != nullptr); |
2340 ASSERT_TRUE(data_content != nullptr); | 2417 ASSERT_TRUE(data_content != nullptr); |
2341 EXPECT_EQ("audio_modified", audio_content->name); | 2418 EXPECT_EQ("audio_modified", audio_content->name); |
2342 EXPECT_EQ("video_modified", video_content->name); | 2419 EXPECT_EQ("video_modified", video_content->name); |
2343 EXPECT_EQ("data_modified", data_content->name); | 2420 EXPECT_EQ("data_modified", data_content->name); |
2344 } | 2421 } |
OLD | NEW |