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 1613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1624 EXPECT_EQ(video_streams[0], updated_video_streams[0]); | 1624 EXPECT_EQ(video_streams[0], updated_video_streams[0]); |
1625 EXPECT_EQ(kVideoTrack2, updated_video_streams[1].id); | 1625 EXPECT_EQ(kVideoTrack2, updated_video_streams[1].id); |
1626 // All media streams in one PeerConnection share one CNAME. | 1626 // All media streams in one PeerConnection share one CNAME. |
1627 EXPECT_EQ(updated_video_streams[1].cname, updated_video_streams[0].cname); | 1627 EXPECT_EQ(updated_video_streams[1].cname, updated_video_streams[0].cname); |
1628 | 1628 |
1629 const StreamParamsVec& updated_data_streams = updated_dcd->streams(); | 1629 const StreamParamsVec& updated_data_streams = updated_dcd->streams(); |
1630 ASSERT_EQ(1U, updated_data_streams.size()); | 1630 ASSERT_EQ(1U, updated_data_streams.size()); |
1631 EXPECT_TRUE(data_streams[0] == updated_data_streams[0]); | 1631 EXPECT_TRUE(data_streams[0] == updated_data_streams[0]); |
1632 } | 1632 } |
1633 | 1633 |
1634 | |
1635 // Create an updated offer after creating an answer to the original offer and | 1634 // Create an updated offer after creating an answer to the original offer and |
1636 // verify that the codecs that were part of the original answer are not changed | 1635 // verify that the codecs that were part of the original answer are not changed |
1637 // in the updated offer. | 1636 // in the updated offer. |
1638 TEST_F(MediaSessionDescriptionFactoryTest, | 1637 TEST_F(MediaSessionDescriptionFactoryTest, |
1639 RespondentCreatesOfferAfterCreatingAnswer) { | 1638 RespondentCreatesOfferAfterCreatingAnswer) { |
1640 MediaSessionOptions opts; | 1639 MediaSessionOptions opts; |
1641 opts.recv_audio = true; | 1640 opts.recv_audio = true; |
1642 opts.recv_video = true; | 1641 opts.recv_video = true; |
1643 | 1642 |
1644 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1643 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2008 // And a FID group for RTX. | 2007 // And a FID group for RTX. |
2009 EXPECT_TRUE(streams[0].has_ssrc_group("FID")); | 2008 EXPECT_TRUE(streams[0].has_ssrc_group("FID")); |
2010 std::vector<uint32_t> primary_ssrcs; | 2009 std::vector<uint32_t> primary_ssrcs; |
2011 streams[0].GetPrimarySsrcs(&primary_ssrcs); | 2010 streams[0].GetPrimarySsrcs(&primary_ssrcs); |
2012 EXPECT_EQ(3u, primary_ssrcs.size()); | 2011 EXPECT_EQ(3u, primary_ssrcs.size()); |
2013 std::vector<uint32_t> fid_ssrcs; | 2012 std::vector<uint32_t> fid_ssrcs; |
2014 streams[0].GetFidSsrcs(primary_ssrcs, &fid_ssrcs); | 2013 streams[0].GetFidSsrcs(primary_ssrcs, &fid_ssrcs); |
2015 EXPECT_EQ(3u, fid_ssrcs.size()); | 2014 EXPECT_EQ(3u, fid_ssrcs.size()); |
2016 } | 2015 } |
2017 | 2016 |
| 2017 // Test that, when the FlexFEC codec is added, a FlexFEC ssrc is created |
| 2018 // together with a FEC-FR grouping. |
| 2019 TEST_F(MediaSessionDescriptionFactoryTest, GenerateFlexfecSsrc) { |
| 2020 MediaSessionOptions opts; |
| 2021 opts.recv_video = true; |
| 2022 opts.recv_audio = false; |
| 2023 |
| 2024 // Add single stream. |
| 2025 opts.AddSendVideoStream("stream1", "stream1label", 1); |
| 2026 |
| 2027 // Use a single real codec, and then add FlexFEC for it. |
| 2028 std::vector<VideoCodec> f1_codecs; |
| 2029 f1_codecs.push_back(VideoCodec(97, "H264")); |
| 2030 f1_codecs.push_back(VideoCodec(118, "flexfec-03")); |
| 2031 f1_.set_video_codecs(f1_codecs); |
| 2032 |
| 2033 // Ensure that the offer has a single FlexFEC ssrc and that |
| 2034 // there is no FEC-FR ssrc + grouping for each. |
| 2035 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
| 2036 ASSERT_TRUE(offer.get() != nullptr); |
| 2037 VideoContentDescription* desc = static_cast<VideoContentDescription*>( |
| 2038 offer->GetContentDescriptionByName(cricket::CN_VIDEO)); |
| 2039 ASSERT_TRUE(desc != nullptr); |
| 2040 EXPECT_TRUE(desc->multistream()); |
| 2041 const StreamParamsVec& streams = desc->streams(); |
| 2042 // Single stream. |
| 2043 ASSERT_EQ(1u, streams.size()); |
| 2044 // Stream should have 2 ssrcs: 1 for video, 1 for FlexFEC. |
| 2045 EXPECT_EQ(2u, streams[0].ssrcs.size()); |
| 2046 // And should have a FEC-FR group for FlexFEC. |
| 2047 EXPECT_TRUE(streams[0].has_ssrc_group("FEC-FR")); |
| 2048 std::vector<uint32_t> primary_ssrcs; |
| 2049 streams[0].GetPrimarySsrcs(&primary_ssrcs); |
| 2050 ASSERT_EQ(1u, primary_ssrcs.size()); |
| 2051 uint32_t flexfec_ssrc; |
| 2052 EXPECT_TRUE(streams[0].GetFecFrSsrc(primary_ssrcs[0], &flexfec_ssrc)); |
| 2053 EXPECT_NE(flexfec_ssrc, 0u); |
| 2054 } |
| 2055 |
| 2056 // Test that FlexFEC is disabled for simulcast. |
| 2057 // TODO(brandtr): Remove this test when we support simulcast, either through |
| 2058 // multiple FlexfecSenders, or through multistream protection. |
| 2059 TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateNoFlexfecSsrcs) { |
| 2060 MediaSessionOptions opts; |
| 2061 opts.recv_video = true; |
| 2062 opts.recv_audio = false; |
| 2063 |
| 2064 // Add simulcast streams. |
| 2065 opts.AddSendVideoStream("stream1", "stream1label", 3); |
| 2066 |
| 2067 // Use a single real codec, and then add FlexFEC for it. |
| 2068 std::vector<VideoCodec> f1_codecs; |
| 2069 f1_codecs.push_back(VideoCodec(97, "H264")); |
| 2070 f1_codecs.push_back(VideoCodec(118, "flexfec-03")); |
| 2071 f1_.set_video_codecs(f1_codecs); |
| 2072 |
| 2073 // Ensure that the offer has no FlexFEC ssrcs for each regular ssrc, and that |
| 2074 // there is no FEC-FR ssrc + grouping for each. |
| 2075 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
| 2076 ASSERT_TRUE(offer.get() != nullptr); |
| 2077 VideoContentDescription* desc = static_cast<VideoContentDescription*>( |
| 2078 offer->GetContentDescriptionByName(cricket::CN_VIDEO)); |
| 2079 ASSERT_TRUE(desc != nullptr); |
| 2080 EXPECT_FALSE(desc->multistream()); |
| 2081 const StreamParamsVec& streams = desc->streams(); |
| 2082 // Single stream. |
| 2083 ASSERT_EQ(1u, streams.size()); |
| 2084 // Stream should have 3 ssrcs: 3 for video, 0 for FlexFEC. |
| 2085 EXPECT_EQ(3u, streams[0].ssrcs.size()); |
| 2086 // And should have a SIM group for the simulcast. |
| 2087 EXPECT_TRUE(streams[0].has_ssrc_group("SIM")); |
| 2088 // And not a FEC-FR group for FlexFEC. |
| 2089 EXPECT_FALSE(streams[0].has_ssrc_group("FEC-FR")); |
| 2090 std::vector<uint32_t> primary_ssrcs; |
| 2091 streams[0].GetPrimarySsrcs(&primary_ssrcs); |
| 2092 EXPECT_EQ(3u, primary_ssrcs.size()); |
| 2093 for (uint32_t primary_ssrc : primary_ssrcs) { |
| 2094 uint32_t flexfec_ssrc; |
| 2095 EXPECT_FALSE(streams[0].GetFecFrSsrc(primary_ssrc, &flexfec_ssrc)); |
| 2096 } |
| 2097 } |
| 2098 |
2018 // Create an updated offer after creating an answer to the original offer and | 2099 // Create an updated offer after creating an answer to the original offer and |
2019 // verify that the RTP header extensions that were part of the original answer | 2100 // verify that the RTP header extensions that were part of the original answer |
2020 // are not changed in the updated offer. | 2101 // are not changed in the updated offer. |
2021 TEST_F(MediaSessionDescriptionFactoryTest, | 2102 TEST_F(MediaSessionDescriptionFactoryTest, |
2022 RespondentCreatesOfferAfterCreatingAnswerWithRtpExtensions) { | 2103 RespondentCreatesOfferAfterCreatingAnswerWithRtpExtensions) { |
2023 MediaSessionOptions opts; | 2104 MediaSessionOptions opts; |
2024 opts.recv_audio = true; | 2105 opts.recv_audio = true; |
2025 opts.recv_video = true; | 2106 opts.recv_video = true; |
2026 | 2107 |
2027 f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension1)); | 2108 f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension1)); |
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2855 << ", got: " << format_codecs(acd->codecs()) | 2936 << ", got: " << format_codecs(acd->codecs()) |
2856 << "; Offered: " << MediaContentDirectionToString(offer_direction) | 2937 << "; Offered: " << MediaContentDirectionToString(offer_direction) |
2857 << ", answerer wants: " | 2938 << ", answerer wants: " |
2858 << MediaContentDirectionToString(answer_direction) | 2939 << MediaContentDirectionToString(answer_direction) |
2859 << "; got: " << MediaContentDirectionToString(acd->direction()); | 2940 << "; got: " << MediaContentDirectionToString(acd->direction()); |
2860 } else { | 2941 } else { |
2861 EXPECT_EQ(offer_direction, cricket::MD_INACTIVE) | 2942 EXPECT_EQ(offer_direction, cricket::MD_INACTIVE) |
2862 << "Only inactive offers are allowed to not generate any audio content"; | 2943 << "Only inactive offers are allowed to not generate any audio content"; |
2863 } | 2944 } |
2864 } | 2945 } |
2865 } | 2946 |
| 2947 } // namespace |
2866 | 2948 |
2867 class AudioCodecsOfferTest | 2949 class AudioCodecsOfferTest |
2868 : public ::testing::TestWithParam<std::tr1::tuple<MediaContentDirection, | 2950 : public ::testing::TestWithParam<std::tr1::tuple<MediaContentDirection, |
2869 bool>> { | 2951 bool>> { |
2870 }; | 2952 }; |
2871 | 2953 |
2872 TEST_P(AudioCodecsOfferTest, TestCodecsInOffer) { | 2954 TEST_P(AudioCodecsOfferTest, TestCodecsInOffer) { |
2873 TestAudioCodecsOffer(std::tr1::get<0>(GetParam()), | 2955 TestAudioCodecsOffer(std::tr1::get<0>(GetParam()), |
2874 std::tr1::get<1>(GetParam())); | 2956 std::tr1::get<1>(GetParam())); |
2875 } | 2957 } |
(...skipping 24 matching lines...) Expand all Loading... |
2900 ::testing::Combine( | 2982 ::testing::Combine( |
2901 ::testing::Values(cricket::MD_SENDONLY, | 2983 ::testing::Values(cricket::MD_SENDONLY, |
2902 cricket::MD_RECVONLY, | 2984 cricket::MD_RECVONLY, |
2903 cricket::MD_SENDRECV, | 2985 cricket::MD_SENDRECV, |
2904 cricket::MD_INACTIVE), | 2986 cricket::MD_INACTIVE), |
2905 ::testing::Values(cricket::MD_SENDONLY, | 2987 ::testing::Values(cricket::MD_SENDONLY, |
2906 cricket::MD_RECVONLY, | 2988 cricket::MD_RECVONLY, |
2907 cricket::MD_SENDRECV, | 2989 cricket::MD_SENDRECV, |
2908 cricket::MD_INACTIVE), | 2990 cricket::MD_INACTIVE), |
2909 ::testing::Bool())); | 2991 ::testing::Bool())); |
OLD | NEW |