Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: webrtc/modules/rtp_rtcp/source/ssrc_database.cc

Issue 2700413002: Revert of Delete class SSRCDatabase, and its global ssrc registry. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/ssrc_database.h ('k') | webrtc/voice_engine/channel.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
new file mode 100644
index 0000000000000000000000000000000000000000..a96d05db468f0309740b8dca2cdc617ffd310daf
--- /dev/null
+++ b/webrtc/modules/rtp_rtcp/source/ssrc_database.cc
@@ -0,0 +1,51 @@
+/*
+ * 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
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/ssrc_database.h ('k') | webrtc/voice_engine/channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698