author Randell Jesup <>
Tue, 27 Dec 2016 19:41:02 -0500
changeset 327347 126348e718d03dec640b30b5def70fce8aa71527
parent 327346 e10e9f0e5ca20b500efb59dc5e4c25f248692b96
child 363568 fda2b2655b267852bfd29fe60a3ca0664c8de18b
permissions -rw-r--r--
Bug 1250356: rollup of changes for webrtc after applying v49 update r=pkerr,ng,pehrsons,etc See ssh:// for the patch development history.

 *  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 <set>

#include "webrtc/base/random.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/system_wrappers/include/static_instance.h"
#include "webrtc/typedefs.h"

namespace webrtc {
class CriticalSectionWrapper;

class SSRCDatabase {
  static SSRCDatabase* GetSSRCDatabase();
  static void ReturnSSRCDatabase();

  uint32_t CreateSSRC();
  void RegisterSSRC(uint32_t ssrc);
  void ReturnSSRC(uint32_t ssrc);

  virtual ~SSRCDatabase();

  static SSRCDatabase* CreateInstance() { return new SSRCDatabase(); }

  // Friend function to allow the SSRC destructor to be accessed from the
  // template class.
  friend SSRCDatabase* GetStaticInstance<SSRCDatabase>(
      CountOperation count_operation);

  rtc::scoped_ptr<CriticalSectionWrapper> crit_;
  Random random_ GUARDED_BY(crit_);
  std::set<uint32_t> ssrcs_ GUARDED_BY(crit_);
}  // namespace webrtc