Reason for revert:
Breaks webrtc_perf_tests reliably:
https://build.chromium.org/p/client.webrtc.perf/builders/Android32%20Tests%20%28L%20Nexus5%29/builds/1780
https://build.chromium.org/p/client.webrtc.perf/builders/Android32%20Tests%20%28L%20Nexus4%29/builds/178
We're actively working on getting a quick version of webrtc_perf_tests up on the trybots again to prevent breakages like this: https://bugs.chromium.org/p/webrtc/issues/detail?id=7101
Original issue's description:
> Delete class SSRCDatabase, and its global ssrc registry,
> and the method RTPSender::GenerateNewSSRC.
>
> It's now mandatory for higher layers to call SetSSRC, RTPSender
> no longer allocates any ssrc by default.
>
> BUG=webrtc:4306,webrtc:6887
>
> Review-Url: https://codereview.webrtc.org/2644303002
> Cr-Commit-Position: refs/heads/master@{#16670}
> Committed: b78d4d1383
TBR=solenberg@webrtc.org,stefan@webrtc.org,danilchap@webrtc.org,ivoc@webrtc.org,nisse@webrtc.org
NOTRY=True
BUG=webrtc:4306,webrtc:6887
Review-Url: https://codereview.webrtc.org/2700413002
Cr-Commit-Position: refs/heads/master@{#16693}
52 lines
1.3 KiB
C++
52 lines
1.3 KiB
C++
/*
|
|
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#include "webrtc/modules/rtp_rtcp/source/ssrc_database.h"
|
|
#include "webrtc/base/timeutils.h"
|
|
#include "webrtc/base/checks.h"
|
|
|
|
namespace webrtc {
|
|
|
|
SSRCDatabase* SSRCDatabase::GetSSRCDatabase() {
|
|
return GetStaticInstance<SSRCDatabase>(kAddRef);
|
|
}
|
|
|
|
void SSRCDatabase::ReturnSSRCDatabase() {
|
|
GetStaticInstance<SSRCDatabase>(kRelease);
|
|
}
|
|
|
|
uint32_t SSRCDatabase::CreateSSRC() {
|
|
rtc::CritScope lock(&crit_);
|
|
|
|
while (true) { // Try until get a new ssrc.
|
|
// 0 and 0xffffffff are invalid values for SSRC.
|
|
uint32_t ssrc = random_.Rand(1u, 0xfffffffe);
|
|
if (ssrcs_.insert(ssrc).second) {
|
|
return ssrc;
|
|
}
|
|
}
|
|
}
|
|
|
|
void SSRCDatabase::RegisterSSRC(uint32_t ssrc) {
|
|
rtc::CritScope lock(&crit_);
|
|
ssrcs_.insert(ssrc);
|
|
}
|
|
|
|
void SSRCDatabase::ReturnSSRC(uint32_t ssrc) {
|
|
rtc::CritScope lock(&crit_);
|
|
ssrcs_.erase(ssrc);
|
|
}
|
|
|
|
SSRCDatabase::SSRCDatabase() : random_(rtc::TimeMicros()) {}
|
|
|
|
SSRCDatabase::~SSRCDatabase() {}
|
|
|
|
} // namespace webrtc
|