mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1212908 - Update a=simulcast to match new grammar in 03 draft. r=mt
--HG-- extra : transplant_source : %16%0B8%F7%12%C4%E18j%BF%C4%F6%8A%F3%96p_%90Q%96
This commit is contained in:
parent
380290f5b6
commit
2a66036623
@ -485,7 +485,6 @@ static std::string ParseToken(std::istream& is,
|
||||
const std::string& delims,
|
||||
std::string* error)
|
||||
{
|
||||
is >> std::ws;
|
||||
std::string token;
|
||||
while (is) {
|
||||
unsigned char c = PeekChar(is, error);
|
||||
@ -846,6 +845,7 @@ SdpRidAttributeList::Constraints::Parse(std::istream& is, std::string* error)
|
||||
}
|
||||
|
||||
do {
|
||||
is >> std::ws;
|
||||
std::string key = ParseKey(is, error);
|
||||
if (key.empty()) {
|
||||
return false; // Illegal trailing cruft
|
||||
@ -984,6 +984,7 @@ SdpRidAttributeList::Rid::Parse(std::istream& is, std::string* error)
|
||||
return false;
|
||||
}
|
||||
|
||||
is >> std::ws;
|
||||
std::string directionToken = ParseToken(is, " ", error);
|
||||
if (directionToken == "send") {
|
||||
direction = sdp::kSend;
|
||||
@ -1119,8 +1120,8 @@ void
|
||||
SdpSimulcastAttribute::Version::Serialize(std::ostream& os) const
|
||||
{
|
||||
SkipFirstDelimiter comma(",");
|
||||
for (uint16_t format : choices) {
|
||||
os << comma << format;
|
||||
for (const std::string& choice : choices) {
|
||||
os << comma << choice;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1128,8 +1129,8 @@ bool
|
||||
SdpSimulcastAttribute::Version::Parse(std::istream& is, std::string* error)
|
||||
{
|
||||
do {
|
||||
uint16_t value;
|
||||
if (!GetUnsigned<uint16_t>(is, 0, UINT16_MAX, &value, error)) {
|
||||
std::string value = ParseToken(is, ",; ", error);
|
||||
if (value.empty()) {
|
||||
return false;
|
||||
}
|
||||
choices.push_back(value);
|
||||
@ -1138,32 +1139,33 @@ SdpSimulcastAttribute::Version::Parse(std::istream& is, std::string* error)
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
SdpSimulcastAttribute::Version::AppendAsStrings(
|
||||
std::vector<std::string>* formats) const
|
||||
bool
|
||||
SdpSimulcastAttribute::Version::GetChoicesAsFormats(
|
||||
std::vector<uint16_t>* formats) const
|
||||
{
|
||||
for (uint16_t pt : choices) {
|
||||
std::ostringstream os;
|
||||
os << pt;
|
||||
formats->push_back(os.str());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SdpSimulcastAttribute::Version::AddChoice(const std::string& pt)
|
||||
{
|
||||
uint16_t ptAsInt;
|
||||
if (!SdpHelper::GetPtAsInt(pt, &ptAsInt)) {
|
||||
MOZ_ASSERT(false);
|
||||
return;
|
||||
for (const std::string& choice : choices) {
|
||||
uint16_t format;
|
||||
if (!SdpHelper::GetPtAsInt(choice, &format) || (format > 127)) {
|
||||
return false;
|
||||
}
|
||||
formats->push_back(format);
|
||||
}
|
||||
|
||||
choices.push_back(ptAsInt);
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
SdpSimulcastAttribute::Versions::Serialize(std::ostream& os) const
|
||||
{
|
||||
switch (type) {
|
||||
case kRid:
|
||||
os << "rid=";
|
||||
break;
|
||||
case kPt:
|
||||
os << "pt=";
|
||||
break;
|
||||
}
|
||||
|
||||
SkipFirstDelimiter semic(";");
|
||||
for (const Version& version : *this) {
|
||||
if (!version.IsSet()) {
|
||||
@ -1177,11 +1179,35 @@ SdpSimulcastAttribute::Versions::Serialize(std::ostream& os) const
|
||||
bool
|
||||
SdpSimulcastAttribute::Versions::Parse(std::istream& is, std::string* error)
|
||||
{
|
||||
std::string rawType = ParseKey(is, error);
|
||||
if (rawType.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rawType == "pt") {
|
||||
type = kPt;
|
||||
} else if (rawType == "rid") {
|
||||
type = kRid;
|
||||
} else {
|
||||
*error = "Unknown simulcast identification type ";
|
||||
error->append(rawType);
|
||||
return false;
|
||||
}
|
||||
|
||||
do {
|
||||
Version version;
|
||||
if (!version.Parse(is, error)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (type == kPt) {
|
||||
std::vector<uint16_t> formats;
|
||||
if (!version.GetChoicesAsFormats(&formats)) {
|
||||
*error = "Invalid payload type";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
push_back(version);
|
||||
} while(SkipChar(is, ';', error));
|
||||
|
||||
@ -1191,9 +1217,7 @@ SdpSimulcastAttribute::Versions::Parse(std::istream& is, std::string* error)
|
||||
void
|
||||
SdpSimulcastAttribute::Serialize(std::ostream& os) const
|
||||
{
|
||||
MOZ_ASSERT(sendVersions.IsSet() ||
|
||||
recvVersions.IsSet() ||
|
||||
sendrecvVersions.IsSet());
|
||||
MOZ_ASSERT(sendVersions.IsSet() || recvVersions.IsSet());
|
||||
|
||||
os << "a=" << mType << ":";
|
||||
|
||||
@ -1207,11 +1231,6 @@ SdpSimulcastAttribute::Serialize(std::ostream& os) const
|
||||
recvVersions.Serialize(os);
|
||||
}
|
||||
|
||||
if (sendrecvVersions.IsSet()) {
|
||||
os << " sendrecv ";
|
||||
sendrecvVersions.Serialize(os);
|
||||
}
|
||||
|
||||
os << CRLF;
|
||||
}
|
||||
|
||||
@ -1220,9 +1239,9 @@ SdpSimulcastAttribute::Parse(std::istream& is, std::string* error)
|
||||
{
|
||||
bool gotRecv = false;
|
||||
bool gotSend = false;
|
||||
bool gotSendrecv = false;
|
||||
|
||||
while (true) {
|
||||
is >> std::ws;
|
||||
std::string token = ParseToken(is, " \t", error);
|
||||
if (token.empty()) {
|
||||
break;
|
||||
@ -1250,24 +1269,13 @@ SdpSimulcastAttribute::Parse(std::istream& is, std::string* error)
|
||||
if (!recvVersions.Parse(is, error)) {
|
||||
return false;
|
||||
}
|
||||
} else if (token == "sendrecv") {
|
||||
if (gotSendrecv) {
|
||||
*error = "Already got a sendrecv list";
|
||||
return false;
|
||||
}
|
||||
gotSendrecv = true;
|
||||
|
||||
is >> std::ws;
|
||||
if (!sendrecvVersions.Parse(is, error)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
*error = "Type must be either 'send', 'recv', or 'sendrecv'";
|
||||
*error = "Type must be either 'send' or 'recv'";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!gotSend && !gotRecv && !gotSendrecv) {
|
||||
if (!gotSend && !gotRecv) {
|
||||
*error = "Empty simulcast attribute";
|
||||
return false;
|
||||
}
|
||||
|
@ -1410,16 +1410,16 @@ inline std::ostream& operator<<(std::ostream& os, SdpSetupAttribute::Role r)
|
||||
return os;
|
||||
}
|
||||
|
||||
// Note: This ABNF is buggy since it does not include a ':' after "a=simulcast"
|
||||
// The authors have said this will be fixed in a subsequent version.
|
||||
// TODO(bug 1191986): Update this ABNF once the new version is out.
|
||||
// simulcast-attribute = "a=simulcast" 1*3( WSP sc-dir-list )
|
||||
// sc-dir-list = sc-dir WSP sc-fmt-list *( ";" sc-fmt-list )
|
||||
// sc-dir = "send" / "recv" / "sendrecv"
|
||||
// sc-fmt-list = sc-fmt *( "," sc-fmt )
|
||||
// sc-fmt = fmt
|
||||
// sc-attr = "a=simulcast:" 1*2( WSP sc-str-list ) [WSP sc-pause-list]
|
||||
// sc-str-list = sc-dir WSP sc-id-type "=" sc-alt-list *( ";" sc-alt-list )
|
||||
// sc-pause-list = "paused=" sc-alt-list
|
||||
// sc-dir = "send" / "recv"
|
||||
// sc-id-type = "pt" / "rid" / token
|
||||
// sc-alt-list = sc-id *( "," sc-id )
|
||||
// sc-id = fmt / rid-identifier / token
|
||||
// ; WSP defined in [RFC5234]
|
||||
// ; fmt defined in [RFC4566]
|
||||
// ; fmt, token defined in [RFC4566]
|
||||
// ; rid-identifier defined in [I-D.pthatcher-mmusic-rid]
|
||||
class SdpSimulcastAttribute : public SdpAttribute
|
||||
{
|
||||
public:
|
||||
@ -1437,15 +1437,20 @@ public:
|
||||
return !choices.empty();
|
||||
}
|
||||
bool Parse(std::istream& is, std::string* error);
|
||||
void AppendAsStrings(std::vector<std::string>* formats) const;
|
||||
void AddChoice(const std::string& pt);
|
||||
bool GetChoicesAsFormats(std::vector<uint16_t>* formats) const;
|
||||
|
||||
std::vector<uint16_t> choices;
|
||||
std::vector<std::string> choices;
|
||||
};
|
||||
|
||||
class Versions : public std::vector<Version>
|
||||
{
|
||||
public:
|
||||
enum Type {
|
||||
kPt,
|
||||
kRid
|
||||
};
|
||||
|
||||
Versions() : type(kRid) {}
|
||||
void Serialize(std::ostream& os) const;
|
||||
bool IsSet() const
|
||||
{
|
||||
@ -1461,12 +1466,13 @@ public:
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Parse(std::istream& is, std::string* error);
|
||||
Type type;
|
||||
};
|
||||
|
||||
Versions sendVersions;
|
||||
Versions recvVersions;
|
||||
Versions sendrecvVersions;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1195,7 +1195,7 @@ const std::string kBasicAudioVideoOffer =
|
||||
"a=ssrc:1111 foo:bar" CRLF
|
||||
"a=imageattr:120 send * recv *" CRLF
|
||||
"a=imageattr:121 send [x=640,y=480] recv [x=640,y=480]" CRLF
|
||||
"a=simulcast:sendrecv 120;121" CRLF
|
||||
"a=simulcast:send pt=120;121" CRLF
|
||||
"a=rid:foo send" CRLF
|
||||
"a=rid:bar recv pt=96;max-width=800;max-height=600" CRLF
|
||||
"m=audio 9 RTP/SAVPF 0" CRLF
|
||||
@ -2099,13 +2099,14 @@ TEST_P(NewSdpTest, CheckSimulcast)
|
||||
const SdpSimulcastAttribute& simulcast =
|
||||
mSdp->GetMediaSection(1).GetAttributeList().GetSimulcast();
|
||||
|
||||
ASSERT_EQ(0U, simulcast.sendVersions.size());
|
||||
ASSERT_EQ(0U, simulcast.recvVersions.size());
|
||||
ASSERT_EQ(2U, simulcast.sendrecvVersions.size());
|
||||
ASSERT_EQ(1U, simulcast.sendrecvVersions[0].choices.size());
|
||||
ASSERT_EQ(120U, simulcast.sendrecvVersions[0].choices[0]);
|
||||
ASSERT_EQ(1U, simulcast.sendrecvVersions[1].choices.size());
|
||||
ASSERT_EQ(121U, simulcast.sendrecvVersions[1].choices[0]);
|
||||
ASSERT_EQ(2U, simulcast.sendVersions.size());
|
||||
ASSERT_EQ(1U, simulcast.sendVersions[0].choices.size());
|
||||
ASSERT_EQ("120", simulcast.sendVersions[0].choices[0]);
|
||||
ASSERT_EQ(1U, simulcast.sendVersions[1].choices.size());
|
||||
ASSERT_EQ("121", simulcast.sendVersions[1].choices[0]);
|
||||
ASSERT_EQ(SdpSimulcastAttribute::Versions::kPt,
|
||||
simulcast.sendVersions.type);
|
||||
}
|
||||
|
||||
TEST_P(NewSdpTest, CheckSctpmap) {
|
||||
@ -3418,17 +3419,17 @@ TEST(NewSdpTestNoFixture, CheckSimulcastVersionSerialize)
|
||||
std::ostringstream os;
|
||||
|
||||
SdpSimulcastAttribute::Version version;
|
||||
version.choices.push_back(8U);
|
||||
version.choices.push_back("8");
|
||||
version.Serialize(os);
|
||||
ASSERT_EQ("8", os.str());
|
||||
os.str("");
|
||||
|
||||
version.choices.push_back(9U);
|
||||
version.choices.push_back("9");
|
||||
version.Serialize(os);
|
||||
ASSERT_EQ("8,9", os.str());
|
||||
os.str("");
|
||||
|
||||
version.choices.push_back(0U);
|
||||
version.choices.push_back("0");
|
||||
version.Serialize(os);
|
||||
ASSERT_EQ("8,9,0", os.str());
|
||||
os.str("");
|
||||
@ -3452,30 +3453,28 @@ TEST(NewSdpTestNoFixture, CheckSimulcastVersionValidParse)
|
||||
SdpSimulcastAttribute::Version version(
|
||||
ParseSimulcastVersion("1"));
|
||||
ASSERT_EQ(1U, version.choices.size());
|
||||
ASSERT_EQ(1U, version.choices[0]);
|
||||
ASSERT_EQ("1", version.choices[0]);
|
||||
}
|
||||
|
||||
{
|
||||
SdpSimulcastAttribute::Version version(
|
||||
ParseSimulcastVersion("1,2"));
|
||||
ASSERT_EQ(2U, version.choices.size());
|
||||
ASSERT_EQ(1U, version.choices[0]);
|
||||
ASSERT_EQ(2U, version.choices[1]);
|
||||
ASSERT_EQ("1", version.choices[0]);
|
||||
ASSERT_EQ("2", version.choices[1]);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(NewSdpTestNoFixture, CheckSimulcastVersionInvalidParse)
|
||||
{
|
||||
ParseInvalid<SdpSimulcastAttribute::Version>("", 0);
|
||||
ParseInvalid<SdpSimulcastAttribute::Version>("x", 0);
|
||||
ParseInvalid<SdpSimulcastAttribute::Version>("*", 0);
|
||||
ParseInvalid<SdpSimulcastAttribute::Version>(",", 0);
|
||||
ParseInvalid<SdpSimulcastAttribute::Version>(";", 0);
|
||||
ParseInvalid<SdpSimulcastAttribute::Version>(" ", 0);
|
||||
ParseInvalid<SdpSimulcastAttribute::Version>("8,", 2);
|
||||
ParseInvalid<SdpSimulcastAttribute::Version>("8,x", 2);
|
||||
ParseInvalid<SdpSimulcastAttribute::Version>("8,*", 2);
|
||||
ParseInvalid<SdpSimulcastAttribute::Version>("-1", 0);
|
||||
ParseInvalid<SdpSimulcastAttribute::Version>("8,-1", 2);
|
||||
ParseInvalid<SdpSimulcastAttribute::Version>("99999", 5);
|
||||
ParseInvalid<SdpSimulcastAttribute::Version>("8,99999", 7);
|
||||
ParseInvalid<SdpSimulcastAttribute::Version>("8, ", 2);
|
||||
ParseInvalid<SdpSimulcastAttribute::Version>("8,,", 2);
|
||||
ParseInvalid<SdpSimulcastAttribute::Version>("8,;", 2);
|
||||
}
|
||||
|
||||
TEST(NewSdpTestNoFixture, CheckSimulcastVersionsSerialize)
|
||||
@ -3483,26 +3482,32 @@ TEST(NewSdpTestNoFixture, CheckSimulcastVersionsSerialize)
|
||||
std::ostringstream os;
|
||||
|
||||
SdpSimulcastAttribute::Versions versions;
|
||||
versions.type = SdpSimulcastAttribute::Versions::kPt;
|
||||
versions.push_back(SdpSimulcastAttribute::Version());
|
||||
versions.back().choices.push_back(8U);
|
||||
versions.back().choices.push_back("8");
|
||||
versions.Serialize(os);
|
||||
ASSERT_EQ("8", os.str());
|
||||
ASSERT_EQ("pt=8", os.str());
|
||||
os.str("");
|
||||
|
||||
versions.type = SdpSimulcastAttribute::Versions::kRid;
|
||||
versions.Serialize(os);
|
||||
ASSERT_EQ("rid=8", os.str());
|
||||
os.str("");
|
||||
|
||||
versions.push_back(SdpSimulcastAttribute::Version());
|
||||
versions.Serialize(os);
|
||||
ASSERT_EQ("8", os.str());
|
||||
ASSERT_EQ("rid=8", os.str());
|
||||
os.str("");
|
||||
|
||||
versions.back().choices.push_back(9U);
|
||||
versions.back().choices.push_back("9");
|
||||
versions.Serialize(os);
|
||||
ASSERT_EQ("8;9", os.str());
|
||||
ASSERT_EQ("rid=8;9", os.str());
|
||||
os.str("");
|
||||
|
||||
versions.push_back(SdpSimulcastAttribute::Version());
|
||||
versions.back().choices.push_back(0U);
|
||||
versions.back().choices.push_back("0");
|
||||
versions.Serialize(os);
|
||||
ASSERT_EQ("8;9;0", os.str());
|
||||
ASSERT_EQ("rid=8;9;0", os.str());
|
||||
os.str("");
|
||||
}
|
||||
|
||||
@ -3522,41 +3527,57 @@ TEST(NewSdpTestNoFixture, CheckSimulcastVersionsValidParse)
|
||||
{
|
||||
{
|
||||
SdpSimulcastAttribute::Versions versions(
|
||||
ParseSimulcastVersions("8"));
|
||||
ParseSimulcastVersions("pt=8"));
|
||||
ASSERT_EQ(1U, versions.size());
|
||||
ASSERT_EQ(SdpSimulcastAttribute::Versions::kPt, versions.type);
|
||||
ASSERT_EQ(1U, versions[0].choices.size());
|
||||
ASSERT_EQ(8U, versions[0].choices[0]);
|
||||
ASSERT_EQ("8", versions[0].choices[0]);
|
||||
}
|
||||
|
||||
{
|
||||
SdpSimulcastAttribute::Versions versions(
|
||||
ParseSimulcastVersions("8,9"));
|
||||
ParseSimulcastVersions("rid=8"));
|
||||
ASSERT_EQ(1U, versions.size());
|
||||
ASSERT_EQ(SdpSimulcastAttribute::Versions::kRid, versions.type);
|
||||
ASSERT_EQ(1U, versions[0].choices.size());
|
||||
ASSERT_EQ("8", versions[0].choices[0]);
|
||||
}
|
||||
|
||||
{
|
||||
SdpSimulcastAttribute::Versions versions(
|
||||
ParseSimulcastVersions("pt=8,9"));
|
||||
ASSERT_EQ(1U, versions.size());
|
||||
ASSERT_EQ(2U, versions[0].choices.size());
|
||||
ASSERT_EQ(8U, versions[0].choices[0]);
|
||||
ASSERT_EQ(9U, versions[0].choices[1]);
|
||||
ASSERT_EQ("8", versions[0].choices[0]);
|
||||
ASSERT_EQ("9", versions[0].choices[1]);
|
||||
}
|
||||
|
||||
{
|
||||
SdpSimulcastAttribute::Versions versions(
|
||||
ParseSimulcastVersions("8,9;10"));
|
||||
ParseSimulcastVersions("pt=8,9;10"));
|
||||
ASSERT_EQ(2U, versions.size());
|
||||
ASSERT_EQ(2U, versions[0].choices.size());
|
||||
ASSERT_EQ(8U, versions[0].choices[0]);
|
||||
ASSERT_EQ(9U, versions[0].choices[1]);
|
||||
ASSERT_EQ("8", versions[0].choices[0]);
|
||||
ASSERT_EQ("9", versions[0].choices[1]);
|
||||
ASSERT_EQ(1U, versions[1].choices.size());
|
||||
ASSERT_EQ(10U, versions[1].choices[0]);
|
||||
ASSERT_EQ("10", versions[1].choices[0]);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(NewSdpTestNoFixture, CheckSimulcastVersionsInvalidParse)
|
||||
{
|
||||
ParseInvalid<SdpSimulcastAttribute::Versions>("", 0);
|
||||
ParseInvalid<SdpSimulcastAttribute::Versions>("x", 0);
|
||||
ParseInvalid<SdpSimulcastAttribute::Versions>(";", 0);
|
||||
ParseInvalid<SdpSimulcastAttribute::Versions>("8;", 2);
|
||||
ParseInvalid<SdpSimulcastAttribute::Versions>("8;x", 2);
|
||||
ParseInvalid<SdpSimulcastAttribute::Versions>("8;;", 2);
|
||||
ParseInvalid<SdpSimulcastAttribute::Versions>("x", 1);
|
||||
ParseInvalid<SdpSimulcastAttribute::Versions>(";", 1);
|
||||
ParseInvalid<SdpSimulcastAttribute::Versions>("8", 1);
|
||||
ParseInvalid<SdpSimulcastAttribute::Versions>("foo=", 4);
|
||||
ParseInvalid<SdpSimulcastAttribute::Versions>("foo=8", 4);
|
||||
ParseInvalid<SdpSimulcastAttribute::Versions>("pt=9999", 7);
|
||||
ParseInvalid<SdpSimulcastAttribute::Versions>("pt=-1", 5);
|
||||
ParseInvalid<SdpSimulcastAttribute::Versions>("pt=x", 4);
|
||||
ParseInvalid<SdpSimulcastAttribute::Versions>("pt=8;", 5);
|
||||
ParseInvalid<SdpSimulcastAttribute::Versions>("pt=8;x", 6);
|
||||
ParseInvalid<SdpSimulcastAttribute::Versions>("pt=8;;", 5);
|
||||
}
|
||||
|
||||
TEST(NewSdpTestNoFixture, CheckSimulcastSerialize)
|
||||
@ -3564,22 +3585,17 @@ TEST(NewSdpTestNoFixture, CheckSimulcastSerialize)
|
||||
std::ostringstream os;
|
||||
|
||||
SdpSimulcastAttribute simulcast;
|
||||
simulcast.recvVersions.type = SdpSimulcastAttribute::Versions::kPt;
|
||||
simulcast.recvVersions.push_back(SdpSimulcastAttribute::Version());
|
||||
simulcast.recvVersions.back().choices.push_back(8U);
|
||||
simulcast.recvVersions.back().choices.push_back("8");
|
||||
simulcast.Serialize(os);
|
||||
ASSERT_EQ("a=simulcast: recv 8" CRLF, os.str());
|
||||
ASSERT_EQ("a=simulcast: recv pt=8" CRLF, os.str());
|
||||
os.str("");
|
||||
|
||||
simulcast.sendVersions.push_back(SdpSimulcastAttribute::Version());
|
||||
simulcast.sendVersions.back().choices.push_back(9U);
|
||||
simulcast.sendVersions.back().choices.push_back("9");
|
||||
simulcast.Serialize(os);
|
||||
ASSERT_EQ("a=simulcast: send 9 recv 8" CRLF, os.str());
|
||||
os.str("");
|
||||
|
||||
simulcast.sendrecvVersions.push_back(SdpSimulcastAttribute::Version());
|
||||
simulcast.sendrecvVersions.back().choices.push_back(0U);
|
||||
simulcast.Serialize(os);
|
||||
ASSERT_EQ("a=simulcast: send 9 recv 8 sendrecv 0" CRLF, os.str());
|
||||
ASSERT_EQ("a=simulcast: send rid=9 recv pt=8" CRLF, os.str());
|
||||
os.str("");
|
||||
}
|
||||
|
||||
@ -3597,66 +3613,59 @@ ParseSimulcast(const std::string& input)
|
||||
TEST(NewSdpTestNoFixture, CheckSimulcastValidParse)
|
||||
{
|
||||
{
|
||||
SdpSimulcastAttribute simulcast(ParseSimulcast(" send 8"));
|
||||
SdpSimulcastAttribute simulcast(ParseSimulcast(" send pt=8"));
|
||||
ASSERT_EQ(1U, simulcast.sendVersions.size());
|
||||
ASSERT_EQ(SdpSimulcastAttribute::Versions::kPt,
|
||||
simulcast.sendVersions.type);
|
||||
ASSERT_EQ(1U, simulcast.sendVersions[0].choices.size());
|
||||
ASSERT_EQ(8U, simulcast.sendVersions[0].choices[0]);
|
||||
ASSERT_EQ("8", simulcast.sendVersions[0].choices[0]);
|
||||
ASSERT_EQ(0U, simulcast.recvVersions.size());
|
||||
ASSERT_EQ(0U, simulcast.sendrecvVersions.size());
|
||||
}
|
||||
|
||||
{
|
||||
SdpSimulcastAttribute simulcast(ParseSimulcast(" SEND 8"));
|
||||
SdpSimulcastAttribute simulcast(ParseSimulcast(" SEND pt=8"));
|
||||
ASSERT_EQ(1U, simulcast.sendVersions.size());
|
||||
ASSERT_EQ(SdpSimulcastAttribute::Versions::kPt,
|
||||
simulcast.sendVersions.type);
|
||||
ASSERT_EQ(1U, simulcast.sendVersions[0].choices.size());
|
||||
ASSERT_EQ(8U, simulcast.sendVersions[0].choices[0]);
|
||||
ASSERT_EQ("8", simulcast.sendVersions[0].choices[0]);
|
||||
ASSERT_EQ(0U, simulcast.recvVersions.size());
|
||||
ASSERT_EQ(0U, simulcast.sendrecvVersions.size());
|
||||
}
|
||||
|
||||
{
|
||||
SdpSimulcastAttribute simulcast(ParseSimulcast(" recv 8"));
|
||||
SdpSimulcastAttribute simulcast(ParseSimulcast(" recv pt=8"));
|
||||
ASSERT_EQ(1U, simulcast.recvVersions.size());
|
||||
ASSERT_EQ(SdpSimulcastAttribute::Versions::kPt,
|
||||
simulcast.recvVersions.type);
|
||||
ASSERT_EQ(1U, simulcast.recvVersions[0].choices.size());
|
||||
ASSERT_EQ(8U, simulcast.recvVersions[0].choices[0]);
|
||||
ASSERT_EQ("8", simulcast.recvVersions[0].choices[0]);
|
||||
ASSERT_EQ(0U, simulcast.sendVersions.size());
|
||||
ASSERT_EQ(0U, simulcast.sendrecvVersions.size());
|
||||
}
|
||||
|
||||
{
|
||||
SdpSimulcastAttribute simulcast(ParseSimulcast(" sendrecv 8"));
|
||||
ASSERT_EQ(1U, simulcast.sendrecvVersions.size());
|
||||
ASSERT_EQ(1U, simulcast.sendrecvVersions[0].choices.size());
|
||||
ASSERT_EQ(8U, simulcast.sendrecvVersions[0].choices[0]);
|
||||
ASSERT_EQ(0U, simulcast.sendVersions.size());
|
||||
ASSERT_EQ(0U, simulcast.recvVersions.size());
|
||||
}
|
||||
|
||||
{
|
||||
SdpSimulcastAttribute simulcast(
|
||||
ParseSimulcast(" send 8,9;101;97,98 recv 101,120;97 sendrecv 101;97"));
|
||||
ParseSimulcast(
|
||||
" send pt=8,9;101;97,98 recv pt=101,120;97"));
|
||||
ASSERT_EQ(3U, simulcast.sendVersions.size());
|
||||
ASSERT_EQ(SdpSimulcastAttribute::Versions::kPt,
|
||||
simulcast.sendVersions.type);
|
||||
ASSERT_EQ(2U, simulcast.sendVersions[0].choices.size());
|
||||
ASSERT_EQ(8U, simulcast.sendVersions[0].choices[0]);
|
||||
ASSERT_EQ(9U, simulcast.sendVersions[0].choices[1]);
|
||||
ASSERT_EQ("8", simulcast.sendVersions[0].choices[0]);
|
||||
ASSERT_EQ("9", simulcast.sendVersions[0].choices[1]);
|
||||
ASSERT_EQ(1U, simulcast.sendVersions[1].choices.size());
|
||||
ASSERT_EQ(101U, simulcast.sendVersions[1].choices[0]);
|
||||
ASSERT_EQ("101", simulcast.sendVersions[1].choices[0]);
|
||||
ASSERT_EQ(2U, simulcast.sendVersions[2].choices.size());
|
||||
ASSERT_EQ(97U, simulcast.sendVersions[2].choices[0]);
|
||||
ASSERT_EQ(98U, simulcast.sendVersions[2].choices[1]);
|
||||
ASSERT_EQ("97", simulcast.sendVersions[2].choices[0]);
|
||||
ASSERT_EQ("98", simulcast.sendVersions[2].choices[1]);
|
||||
|
||||
ASSERT_EQ(2U, simulcast.recvVersions.size());
|
||||
ASSERT_EQ(SdpSimulcastAttribute::Versions::kPt,
|
||||
simulcast.recvVersions.type);
|
||||
ASSERT_EQ(2U, simulcast.recvVersions[0].choices.size());
|
||||
ASSERT_EQ(101U, simulcast.recvVersions[0].choices[0]);
|
||||
ASSERT_EQ(120U, simulcast.recvVersions[0].choices[1]);
|
||||
ASSERT_EQ("101", simulcast.recvVersions[0].choices[0]);
|
||||
ASSERT_EQ("120", simulcast.recvVersions[0].choices[1]);
|
||||
ASSERT_EQ(1U, simulcast.recvVersions[1].choices.size());
|
||||
ASSERT_EQ(97U, simulcast.recvVersions[1].choices[0]);
|
||||
|
||||
ASSERT_EQ(2U, simulcast.sendrecvVersions.size());
|
||||
ASSERT_EQ(1U, simulcast.sendrecvVersions[0].choices.size());
|
||||
ASSERT_EQ(101U, simulcast.sendrecvVersions[0].choices[0]);
|
||||
ASSERT_EQ(1U, simulcast.sendrecvVersions[1].choices.size());
|
||||
ASSERT_EQ(97U, simulcast.sendrecvVersions[1].choices[0]);
|
||||
ASSERT_EQ("97", simulcast.recvVersions[1].choices[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3665,12 +3674,10 @@ TEST(NewSdpTestNoFixture, CheckSimulcastInvalidParse)
|
||||
ParseInvalid<SdpSimulcastAttribute>("", 0);
|
||||
ParseInvalid<SdpSimulcastAttribute>(" ", 1);
|
||||
ParseInvalid<SdpSimulcastAttribute>("vcer ", 4);
|
||||
ParseInvalid<SdpSimulcastAttribute>(" send x", 6);
|
||||
ParseInvalid<SdpSimulcastAttribute>(" recv x", 6);
|
||||
ParseInvalid<SdpSimulcastAttribute>(" sendrecv x", 10);
|
||||
ParseInvalid<SdpSimulcastAttribute>(" send 8 send ", 12);
|
||||
ParseInvalid<SdpSimulcastAttribute>(" recv 8 recv ", 12);
|
||||
ParseInvalid<SdpSimulcastAttribute>(" sendrecv 8 sendrecv ", 20);
|
||||
ParseInvalid<SdpSimulcastAttribute>(" send x", 7);
|
||||
ParseInvalid<SdpSimulcastAttribute>(" recv x", 7);
|
||||
ParseInvalid<SdpSimulcastAttribute>(" send pt=8 send ", 15);
|
||||
ParseInvalid<SdpSimulcastAttribute>(" recv pt=8 recv ", 15);
|
||||
}
|
||||
|
||||
static SdpRidAttributeList::Constraints
|
||||
@ -4124,7 +4131,7 @@ TEST(NewSdpTestNoFixture, CheckRidValidParse)
|
||||
TEST(NewSdpTestNoFixture, CheckRidInvalidParse)
|
||||
{
|
||||
ParseInvalid<SdpRidAttributeList::Rid>("", 0);
|
||||
ParseInvalid<SdpRidAttributeList::Rid>(" ", 1);
|
||||
ParseInvalid<SdpRidAttributeList::Rid>(" ", 0);
|
||||
ParseInvalid<SdpRidAttributeList::Rid>("foo", 3);
|
||||
ParseInvalid<SdpRidAttributeList::Rid>("foo ", 4);
|
||||
ParseInvalid<SdpRidAttributeList::Rid>("foo ", 5);
|
||||
|
Loading…
Reference in New Issue
Block a user