Bug 1147919 - Part 1: Make sure content gets an error callback when it does not use a fingerprint algorithm we support. r=drno

This commit is contained in:
Byron Campen [:bwc] 2015-03-26 10:39:07 -07:00
parent 75d2653edb
commit 0484bd79e4
2 changed files with 31 additions and 0 deletions

View File

@ -1936,6 +1936,14 @@ JsepSessionImpl::ParseSdp(const std::string& sdp, UniquePtr<Sdp>* parsedp)
return NS_ERROR_INVALID_ARG;
}
const SdpFingerprintAttributeList& fingerprints(
mediaAttrs.GetFingerprint());
if (fingerprints.mFingerprints.empty()) {
JSEP_SET_ERROR("Invalid description, no supported fingerprint algorithms "
"present");
return NS_ERROR_INVALID_ARG;
}
if (mediaAttrs.HasAttribute(SdpAttribute::kSetupAttribute) &&
mediaAttrs.GetSetup().mRole == SdpSetupAttribute::kHoldconn) {
JSEP_SET_ERROR("Description has illegal setup attribute "

View File

@ -2460,6 +2460,15 @@ Replace(const std::string& toReplace,
in->replace(pos, toReplace.size(), with);
}
static void ReplaceAll(const std::string& toReplace,
const std::string& with,
std::string* in)
{
while (in->find(toReplace) != std::string::npos) {
Replace(toReplace, with, in);
}
}
static void
GetCodec(JsepSession& session,
size_t pairIndex,
@ -3034,6 +3043,20 @@ TEST_F(JsepSessionTest, TestUniquePayloadTypes)
GetUniquePayloadTypes().size());
}
TEST_F(JsepSessionTest, UnknownFingerprintAlgorithm)
{
types.push_back(SdpMediaSection::kAudio);
AddTracks(mSessionOff, "audio");
AddTracks(mSessionAns, "audio");
std::string offer(CreateOffer());
SetLocalOffer(offer);
ReplaceAll("fingerprint:sha", "fingerprint:foo", &offer);
nsresult rv = mSessionAns.SetRemoteDescription(kJsepSdpOffer, offer);
ASSERT_NE(NS_OK, rv);
ASSERT_NE("", mSessionAns.GetLastError());
}
TEST(H264ProfileLevelIdTest, TestLevelComparisons)
{
ASSERT_LT(JsepVideoCodecDescription::GetSaneH264Level(0x421D0B), // 1b