Bug 1141749: Prevent collisions in local SSRCs. r=mt

--HG--
extra : rebase_source : f28488aa956b8eb33a6b812e1f88ec9623132f93
This commit is contained in:
Byron Campen [:bwc] 2015-03-10 13:54:34 -07:00
Родитель 320d5f8bf7
Коммит d799e4b5c3
2 изменённых файлов: 13 добавлений и 6 удалений

Просмотреть файл

@ -117,12 +117,16 @@ JsepSessionImpl::AddTrack(const RefPtr<JsepTrack>& track)
if (track->GetSsrcs().empty()) {
uint32_t ssrc;
SECStatus rv = PK11_GenerateRandom(
reinterpret_cast<unsigned char*>(&ssrc), sizeof(ssrc));
if (rv != SECSuccess) {
JSEP_SET_ERROR("Failed to generate SSRC, error=" << rv);
return NS_ERROR_FAILURE;
}
do {
SECStatus rv = PK11_GenerateRandom(
reinterpret_cast<unsigned char*>(&ssrc), sizeof(ssrc));
if (rv != SECSuccess) {
JSEP_SET_ERROR("Failed to generate SSRC, error=" << rv);
return NS_ERROR_FAILURE;
}
} while (mSsrcs.count(ssrc));
mSsrcs.insert(ssrc);
track->AddSsrc(ssrc);
}
}

Просмотреть файл

@ -336,6 +336,9 @@ private:
std::string mDefaultRemoteStreamId;
std::map<size_t, std::string> mDefaultRemoteTrackIdsByLevel;
std::string mCNAME;
// Used to prevent duplicate local SSRCs. Not used to prevent local/remote or
// remote-only duplication, which will be important for EKT but not now.
std::set<uint32_t> mSsrcs;
UniquePtr<Sdp> mGeneratedLocalDescription; // Created but not set.
UniquePtr<Sdp> mCurrentLocalDescription;
UniquePtr<Sdp> mCurrentRemoteDescription;