| Index: webrtc/modules/rtp_rtcp/source/ssrc_database.cc
|
| diff --git a/webrtc/modules/rtp_rtcp/source/ssrc_database.cc b/webrtc/modules/rtp_rtcp/source/ssrc_database.cc
|
| index fb02b7ef12cd12f785fd18ed331e1407d3fd38c4..7c06dccab97a8df6d8d764b299815824e21bbe07 100644
|
| --- a/webrtc/modules/rtp_rtcp/source/ssrc_database.cc
|
| +++ b/webrtc/modules/rtp_rtcp/source/ssrc_database.cc
|
| @@ -11,15 +11,9 @@
|
| #include "webrtc/modules/rtp_rtcp/source/ssrc_database.h"
|
|
|
| #include "webrtc/base/checks.h"
|
| -#include "webrtc/system_wrappers/include/clock.h"
|
| -#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
| +#include "webrtc/system_wrappers/include/tick_util.h"
|
|
|
| namespace webrtc {
|
| -namespace {
|
| -uint64_t Seed() {
|
| - return Clock::GetRealTimeClock()->TimeInMicroseconds();
|
| -}
|
| -} // namespace
|
|
|
| SSRCDatabase* SSRCDatabase::GetSSRCDatabase() {
|
| return GetStaticInstance<SSRCDatabase>(kAddRef);
|
| @@ -30,7 +24,7 @@ void SSRCDatabase::ReturnSSRCDatabase() {
|
| }
|
|
|
| uint32_t SSRCDatabase::CreateSSRC() {
|
| - CriticalSectionScoped lock(crit_.get());
|
| + rtc::CritScope lock(&crit_);
|
|
|
| while (true) { // Try until get a new ssrc.
|
| // 0 and 0xffffffff are invalid values for SSRC.
|
| @@ -42,19 +36,27 @@ uint32_t SSRCDatabase::CreateSSRC() {
|
| }
|
|
|
| void SSRCDatabase::RegisterSSRC(uint32_t ssrc) {
|
| - CriticalSectionScoped lock(crit_.get());
|
| + rtc::CritScope lock(&crit_);
|
| ssrcs_.insert(ssrc);
|
| }
|
|
|
| void SSRCDatabase::ReturnSSRC(uint32_t ssrc) {
|
| - CriticalSectionScoped lock(crit_.get());
|
| + rtc::CritScope lock(&crit_);
|
| ssrcs_.erase(ssrc);
|
| }
|
|
|
| -SSRCDatabase::SSRCDatabase()
|
| - : crit_(CriticalSectionWrapper::CreateCriticalSection()), random_(Seed()) {}
|
| -
|
| -SSRCDatabase::~SSRCDatabase() {
|
| -}
|
| +// For initializing the random seed, we don't use TimeInMicroseconds() since it
|
| +// can return 0 on Mac if we're called early on during process startup (e.g.
|
| +// in tests). This is because when the tick count gets converted into
|
| +// microseconds, we can end up multiplying with 0 and end up with a seed of 0.
|
| +// TODO(tommi): Make initialization of Random possible without having to provide
|
| +// a seed. Random could use functionality in webrtc/base* to generate a seed
|
| +// and we should probably have a special function who's purpose
|
| +// is clear and not just a generic tick count since the implementation varies
|
| +// from platform to platform.
|
| +// * Can't be TickTime since it is in system_wrappers.
|
| +SSRCDatabase::SSRCDatabase() : random_(TickTime::Now().Ticks()) {}
|
| +
|
| +SSRCDatabase::~SSRCDatabase() {}
|
|
|
| } // namespace webrtc
|
|
|