Let MediaSession generate a FlexFEC SSRC when FlexFEC is active.
This CL generates the SSRC that will be exposed in the FEC-FR group in the SDP. BUG=webrtc:5654 R=perkj@webrtc.org CC=stefan@webrtc.org, magjed@webrtc.org Review-Url: https://codereview.webrtc.org/2505003003 Cr-Commit-Position: refs/heads/master@{#15187}
This commit is contained in:
parent
0dbb6f57fc
commit
03d5fb1294
@ -446,6 +446,9 @@ static bool AddStreamParams(MediaType media_type,
|
||||
return true;
|
||||
}
|
||||
|
||||
const bool include_flexfec_stream =
|
||||
ContainsFlexfecCodec(content_description->codecs());
|
||||
|
||||
MediaSessionOptions::Streams::const_iterator stream_it;
|
||||
for (stream_it = streams.begin();
|
||||
stream_it != streams.end(); ++stream_it) {
|
||||
@ -481,6 +484,21 @@ static bool AddStreamParams(MediaType media_type,
|
||||
}
|
||||
content_description->set_multistream(true);
|
||||
}
|
||||
// Generate extra ssrc for include_flexfec_stream case.
|
||||
if (include_flexfec_stream) {
|
||||
// TODO(brandtr): Update when we support multistream protection.
|
||||
if (ssrcs.size() == 1) {
|
||||
std::vector<uint32_t> flexfec_ssrcs;
|
||||
GenerateSsrcs(*current_streams, 1, &flexfec_ssrcs);
|
||||
stream_param.AddFecFrSsrc(ssrcs[0], flexfec_ssrcs[0]);
|
||||
content_description->set_multistream(true);
|
||||
} else if (!ssrcs.empty()) {
|
||||
LOG(LS_WARNING)
|
||||
<< "Our FlexFEC implementation only supports protecting "
|
||||
<< "a single media streams. This session has multiple "
|
||||
<< "media streams however, so no FlexFEC SSRC will be generated.";
|
||||
}
|
||||
}
|
||||
stream_param.cname = options.rtcp_cname;
|
||||
stream_param.sync_label = stream_it->sync_label;
|
||||
content_description->AddStream(stream_param);
|
||||
@ -672,9 +690,8 @@ static bool UpdateCryptoParamsForBundle(const ContentGroup& bundle_group,
|
||||
|
||||
template <class C>
|
||||
static bool ContainsRtxCodec(const std::vector<C>& codecs) {
|
||||
typename std::vector<C>::const_iterator it;
|
||||
for (it = codecs.begin(); it != codecs.end(); ++it) {
|
||||
if (IsRtxCodec(*it)) {
|
||||
for (const auto& codec : codecs) {
|
||||
if (IsRtxCodec(codec)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -686,6 +703,21 @@ static bool IsRtxCodec(const C& codec) {
|
||||
return stricmp(codec.name.c_str(), kRtxCodecName) == 0;
|
||||
}
|
||||
|
||||
template <class C>
|
||||
static bool ContainsFlexfecCodec(const std::vector<C>& codecs) {
|
||||
for (const auto& codec : codecs) {
|
||||
if (IsFlexfecCodec(codec)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class C>
|
||||
static bool IsFlexfecCodec(const C& codec) {
|
||||
return stricmp(codec.name.c_str(), kFlexfecCodecName) == 0;
|
||||
}
|
||||
|
||||
static TransportOptions GetTransportOptions(const MediaSessionOptions& options,
|
||||
const std::string& content_name) {
|
||||
TransportOptions transport_options;
|
||||
|
||||
@ -1631,7 +1631,6 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoAnswer) {
|
||||
EXPECT_TRUE(data_streams[0] == updated_data_streams[0]);
|
||||
}
|
||||
|
||||
|
||||
// Create an updated offer after creating an answer to the original offer and
|
||||
// verify that the codecs that were part of the original answer are not changed
|
||||
// in the updated offer.
|
||||
@ -2015,6 +2014,88 @@ TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateMultipleRtxSsrcs) {
|
||||
EXPECT_EQ(3u, fid_ssrcs.size());
|
||||
}
|
||||
|
||||
// Test that, when the FlexFEC codec is added, a FlexFEC ssrc is created
|
||||
// together with a FEC-FR grouping.
|
||||
TEST_F(MediaSessionDescriptionFactoryTest, GenerateFlexfecSsrc) {
|
||||
MediaSessionOptions opts;
|
||||
opts.recv_video = true;
|
||||
opts.recv_audio = false;
|
||||
|
||||
// Add single stream.
|
||||
opts.AddSendVideoStream("stream1", "stream1label", 1);
|
||||
|
||||
// Use a single real codec, and then add FlexFEC for it.
|
||||
std::vector<VideoCodec> f1_codecs;
|
||||
f1_codecs.push_back(VideoCodec(97, "H264"));
|
||||
f1_codecs.push_back(VideoCodec(118, "flexfec-03"));
|
||||
f1_.set_video_codecs(f1_codecs);
|
||||
|
||||
// Ensure that the offer has a single FlexFEC ssrc and that
|
||||
// there is no FEC-FR ssrc + grouping for each.
|
||||
std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr));
|
||||
ASSERT_TRUE(offer.get() != nullptr);
|
||||
VideoContentDescription* desc = static_cast<VideoContentDescription*>(
|
||||
offer->GetContentDescriptionByName(cricket::CN_VIDEO));
|
||||
ASSERT_TRUE(desc != nullptr);
|
||||
EXPECT_TRUE(desc->multistream());
|
||||
const StreamParamsVec& streams = desc->streams();
|
||||
// Single stream.
|
||||
ASSERT_EQ(1u, streams.size());
|
||||
// Stream should have 2 ssrcs: 1 for video, 1 for FlexFEC.
|
||||
EXPECT_EQ(2u, streams[0].ssrcs.size());
|
||||
// And should have a FEC-FR group for FlexFEC.
|
||||
EXPECT_TRUE(streams[0].has_ssrc_group("FEC-FR"));
|
||||
std::vector<uint32_t> primary_ssrcs;
|
||||
streams[0].GetPrimarySsrcs(&primary_ssrcs);
|
||||
ASSERT_EQ(1u, primary_ssrcs.size());
|
||||
uint32_t flexfec_ssrc;
|
||||
EXPECT_TRUE(streams[0].GetFecFrSsrc(primary_ssrcs[0], &flexfec_ssrc));
|
||||
EXPECT_NE(flexfec_ssrc, 0u);
|
||||
}
|
||||
|
||||
// Test that FlexFEC is disabled for simulcast.
|
||||
// TODO(brandtr): Remove this test when we support simulcast, either through
|
||||
// multiple FlexfecSenders, or through multistream protection.
|
||||
TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateNoFlexfecSsrcs) {
|
||||
MediaSessionOptions opts;
|
||||
opts.recv_video = true;
|
||||
opts.recv_audio = false;
|
||||
|
||||
// Add simulcast streams.
|
||||
opts.AddSendVideoStream("stream1", "stream1label", 3);
|
||||
|
||||
// Use a single real codec, and then add FlexFEC for it.
|
||||
std::vector<VideoCodec> f1_codecs;
|
||||
f1_codecs.push_back(VideoCodec(97, "H264"));
|
||||
f1_codecs.push_back(VideoCodec(118, "flexfec-03"));
|
||||
f1_.set_video_codecs(f1_codecs);
|
||||
|
||||
// Ensure that the offer has no FlexFEC ssrcs for each regular ssrc, and that
|
||||
// there is no FEC-FR ssrc + grouping for each.
|
||||
std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr));
|
||||
ASSERT_TRUE(offer.get() != nullptr);
|
||||
VideoContentDescription* desc = static_cast<VideoContentDescription*>(
|
||||
offer->GetContentDescriptionByName(cricket::CN_VIDEO));
|
||||
ASSERT_TRUE(desc != nullptr);
|
||||
EXPECT_FALSE(desc->multistream());
|
||||
const StreamParamsVec& streams = desc->streams();
|
||||
// Single stream.
|
||||
ASSERT_EQ(1u, streams.size());
|
||||
// Stream should have 3 ssrcs: 3 for video, 0 for FlexFEC.
|
||||
EXPECT_EQ(3u, streams[0].ssrcs.size());
|
||||
// And should have a SIM group for the simulcast.
|
||||
EXPECT_TRUE(streams[0].has_ssrc_group("SIM"));
|
||||
// And not a FEC-FR group for FlexFEC.
|
||||
EXPECT_FALSE(streams[0].has_ssrc_group("FEC-FR"));
|
||||
std::vector<uint32_t> primary_ssrcs;
|
||||
streams[0].GetPrimarySsrcs(&primary_ssrcs);
|
||||
EXPECT_EQ(3u, primary_ssrcs.size());
|
||||
for (uint32_t primary_ssrc : primary_ssrcs) {
|
||||
uint32_t flexfec_ssrc;
|
||||
EXPECT_FALSE(streams[0].GetFecFrSsrc(primary_ssrc, &flexfec_ssrc));
|
||||
}
|
||||
}
|
||||
|
||||
// Create an updated offer after creating an answer to the original offer and
|
||||
// verify that the RTP header extensions that were part of the original answer
|
||||
// are not changed in the updated offer.
|
||||
@ -2862,7 +2943,8 @@ void TestAudioCodecsAnswer(MediaContentDirection offer_direction,
|
||||
<< "Only inactive offers are allowed to not generate any audio content";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
class AudioCodecsOfferTest
|
||||
: public ::testing::TestWithParam<std::tr1::tuple<MediaContentDirection,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user