Bug 1481548: Added additonal comparison for fmtp r=bwc

Added additional fmtp comparison for the parsing resutl comparer by
implementing the C++ == operator for SdpFmtpAttributeList.

Differential Revision: https://phabricator.services.mozilla.com/D3228

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nils Ohlmeier [:drno] 2018-08-14 00:36:23 +00:00
parent ef2703b39a
commit e6eaea8889
4 changed files with 152 additions and 0 deletions

View File

@ -4147,6 +4147,73 @@ TEST(NewSdpTestNoFixture, CheckParsingResultComparer) {
ASSERT_TRUE(check_comparison(kBasicAudioVideoOffer));
ASSERT_TRUE(check_comparison(kH264AudioVideoOffer));
// Check the Fmtp comprison
const std::string kBasicOpusFmtp1 =
"v=0" CRLF
"o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0" CRLF
"s=SIP Call" CRLF
"c=IN IP4 224.0.0.1/100/12" CRLF
"t=0 0" CRLF
"m=video 9 RTP/SAVPF 120" CRLF
"a=rtpmap:120 opus/48000" CRLF
"a=fmtp:120 stereo=1;useinbandfec=1" CRLF;
ASSERT_TRUE(check_comparison(kBasicOpusFmtp1));
const std::string kBasicOpusFmtp2 =
"v=0" CRLF
"o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0" CRLF
"s=SIP Call" CRLF
"c=IN IP4 224.0.0.1/100/12" CRLF
"t=0 0" CRLF
"m=video 9 RTP/SAVPF 120" CRLF
"a=rtpmap:120 opus/48000" CRLF
"a=fmtp:120 useinbandfec=1;stereo=1;maxplaybackrate=32000" CRLF;
ASSERT_TRUE(check_comparison(kBasicOpusFmtp2));
const std::string kBasicVP8Fmtp1 =
"v=0" CRLF
"o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0" CRLF
"s=SIP Call" CRLF
"c=IN IP4 224.0.0.1/100/12" CRLF
"t=0 0" CRLF
"m=video 9 RTP/SAVPF 120" CRLF
"a=rtpmap:120 VP8/90000" CRLF
"a=fmtp:120 max-fs=3600;max-fr=60" CRLF;
ASSERT_TRUE(check_comparison(kBasicVP8Fmtp1));
//
const std::string kBasicVP8Fmtp2 =
"v=0" CRLF
"o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0" CRLF
"s=SIP Call" CRLF
"c=IN IP4 224.0.0.1/100/12" CRLF
"t=0 0" CRLF
"m=video 9 RTP/SAVPF 120" CRLF
"a=rtpmap:120 VP8/90000" CRLF
"a=fmtp:120 max-fr=60;max-fs=3600" CRLF;
ASSERT_TRUE(check_comparison(kBasicVP8Fmtp2));
const std::string kBasicH264Fmtp1 =
"v=0" CRLF
"o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0" CRLF
"s=SIP Call" CRLF
"c=IN IP4 224.0.0.1/100/12" CRLF
"t=0 0" CRLF
"m=video 9 RTP/SAVPF 120" CRLF
"a=rtpmap:120 H264/90000" CRLF
"a=fmtp:120 profile-level-id=42a01e;level_asymmetry_allowed=1" CRLF;
ASSERT_TRUE(check_comparison(kBasicH264Fmtp1));
const std::string kBasicH264Fmtp2 =
"v=0" CRLF
"o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0" CRLF
"s=SIP Call" CRLF
"c=IN IP4 224.0.0.1/100/12" CRLF
"t=0 0" CRLF
"m=video 9 RTP/SAVPF 120" CRLF
"a=rtpmap:120 H264/90000" CRLF
"a=fmtp:120 level_asymmetry_allowed=1;profile-level-id=42a01e;max_fs=3600" CRLF;
ASSERT_TRUE(check_comparison(kBasicH264Fmtp2));
}
TEST(NewSdpTestNoFixture, CheckAttributeTypeSerialize) {

View File

@ -212,6 +212,13 @@ ParsingResultComparer::CompareAttrLists(const SdpAttributeList& rustAttrlist,
auto rustAttrStr = ToString(*rustAttrlist.GetAttribute(type, false));
if (rustAttrStr != sipccAttrStr) {
if (type == AttributeType::kFmtpAttribute) {
if (rustAttrlist.GetFmtp() == sipccAttrlist.GetFmtp()) {
continue;
}
}
std::string originalAttrStr = GetAttributeLines(attrStr, level);
if (rustAttrStr != originalAttrStr) {
nsString typeStr;

View File

@ -177,6 +177,12 @@ SdpFingerprintAttributeList::ParseFingerprint(const std::string& str)
return fp;
}
bool
SdpFmtpAttributeList::operator==(const SdpFmtpAttributeList& other) const
{
return mFmtps == other.mFmtps;
}
void
SdpFmtpAttributeList::Serialize(std::ostream& os) const
{

View File

@ -1283,6 +1283,13 @@ public:
virtual ~Parameters() {}
virtual Parameters* Clone() const = 0;
virtual void Serialize(std::ostream& os) const = 0;
virtual bool CompareEq(const Parameters& other) const = 0;
bool operator==(const Parameters& other) const
{
return codec_type == other.codec_type &&
CompareEq(other);
}
SdpRtpmapAttributeList::CodecType codec_type;
};
@ -1310,6 +1317,12 @@ public:
}
}
virtual bool
CompareEq(const Parameters& other) const override
{
return encodings == static_cast<const RedParameters&>(other).encodings;
}
std::vector<uint8_t> encodings;
};
@ -1377,6 +1390,22 @@ public:
}
}
virtual bool
CompareEq(const Parameters& other) const override
{
const auto& otherH264 = static_cast<const H264Parameters&>(other);
// sprop is not comapred here as it does not get parsed in the rsdparsa
return packetization_mode == otherH264.packetization_mode &&
level_asymmetry_allowed == otherH264.level_asymmetry_allowed &&
profile_level_id == otherH264.profile_level_id &&
max_mbps == otherH264.max_mbps &&
max_fs == otherH264.max_fs &&
max_cpb == otherH264.max_cpb &&
max_dpb == otherH264.max_dpb &&
max_br == otherH264.max_br;
}
static const size_t max_sprop_len = 128;
char sprop_parameter_sets[max_sprop_len];
unsigned int packetization_mode;
@ -1413,6 +1442,15 @@ public:
os << ";max-fr=" << max_fr;
}
virtual bool
CompareEq(const Parameters& other) const override
{
const auto& otherVP8 = static_cast<const VP8Parameters&>(other);
return max_fs == otherVP8.max_fs &&
max_fr == otherVP8.max_fr;
}
unsigned int max_fs;
unsigned int max_fr;
};
@ -1444,6 +1482,25 @@ public:
<< ";useinbandfec=" << useInBandFec;
}
virtual bool
CompareEq(const Parameters& other) const override
{
const auto& otherOpus = static_cast<const OpusParameters&>(other);
bool maxplaybackrateIsEq = (maxplaybackrate == otherOpus.maxplaybackrate);
// This is due to a bug in sipcc that causes maxplaybackrate to
// always be 0 if it appears in the fmtp
if (((maxplaybackrate == 0) && (otherOpus.maxplaybackrate != 0)) ||
((maxplaybackrate != 0) && (otherOpus.maxplaybackrate == 0))) {
maxplaybackrateIsEq = true;
}
return maxplaybackrateIsEq &&
stereo == otherOpus.stereo &&
useInBandFec == otherOpus.useInBandFec;
}
unsigned int maxplaybackrate;
unsigned int stereo;
unsigned int useInBandFec;
@ -1469,6 +1526,13 @@ public:
os << dtmfTones;
}
virtual bool
CompareEq(const Parameters& other) const override
{
return dtmfTones == static_cast<const TelephoneEventParameters&>(other)
.dtmfTones;
}
std::string dtmfTones;
};
@ -1499,6 +1563,12 @@ public:
return *this;
}
bool operator==(const Fmtp& other) const
{
return format == other.format &&
*parameters == *other.parameters;
}
// The contract around these is as follows:
// * |parameters| is only set if we recognized the media type and had
// a subclass of Parameters to represent that type of parameters
@ -1510,6 +1580,8 @@ public:
UniquePtr<Parameters> parameters;
};
bool operator==(const SdpFmtpAttributeList& other) const;
virtual void Serialize(std::ostream& os) const override;
void