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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/ssrc_database.cc

Issue 2644303002: Delete class SSRCDatabase, and its global ssrc registry. (Closed)
Patch Set: Rebase. 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "webrtc/modules/rtp_rtcp/source/ssrc_database.h"
12 #include "webrtc/base/timeutils.h"
13 #include "webrtc/base/checks.h"
14
15 namespace webrtc {
16
17 SSRCDatabase* SSRCDatabase::GetSSRCDatabase() {
18 return GetStaticInstance<SSRCDatabase>(kAddRef);
19 }
20
21 void SSRCDatabase::ReturnSSRCDatabase() {
22 GetStaticInstance<SSRCDatabase>(kRelease);
23 }
24
25 uint32_t SSRCDatabase::CreateSSRC() {
26 rtc::CritScope lock(&crit_);
27
28 while (true) { // Try until get a new ssrc.
29 // 0 and 0xffffffff are invalid values for SSRC.
30 uint32_t ssrc = random_.Rand(1u, 0xfffffffe);
31 if (ssrcs_.insert(ssrc).second) {
32 return ssrc;
33 }
34 }
35 }
36
37 void SSRCDatabase::RegisterSSRC(uint32_t ssrc) {
38 rtc::CritScope lock(&crit_);
39 ssrcs_.insert(ssrc);
40 }
41
42 void SSRCDatabase::ReturnSSRC(uint32_t ssrc) {
43 rtc::CritScope lock(&crit_);
44 ssrcs_.erase(ssrc);
45 }
46
47 SSRCDatabase::SSRCDatabase() : random_(rtc::TimeMicros()) {}
48
49 SSRCDatabase::~SSRCDatabase() {}
50
51 } // namespace webrtc
OLDNEW
« 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