blob: 7129d0de766e52303ecd739937e58d20b3cc3251 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
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#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_SSRC_DATABASE_H_
12#define WEBRTC_MODULES_RTP_RTCP_SOURCE_SSRC_DATABASE_H_
13
pbos@webrtc.orga048d7c2013-05-29 14:27:38 +000014#include <map>
niklase@google.com470e71d2011-07-07 08:21:25 +000015
Henrik Kjellander98f53512015-10-28 18:17:40 +010016#include "webrtc/system_wrappers/include/static_instance.h"
pbos@webrtc.orga048d7c2013-05-29 14:27:38 +000017#include "webrtc/typedefs.h"
henrike@webrtc.org315282c2011-12-09 17:46:20 +000018
niklase@google.com470e71d2011-07-07 08:21:25 +000019namespace webrtc {
20class CriticalSectionWrapper;
21
22class SSRCDatabase
23{
niklase@google.com470e71d2011-07-07 08:21:25 +000024public:
25 static SSRCDatabase* GetSSRCDatabase();
26 static void ReturnSSRCDatabase();
27
pbos@webrtc.org2f446732013-04-08 11:08:41 +000028 uint32_t CreateSSRC();
29 int32_t RegisterSSRC(const uint32_t ssrc);
30 int32_t ReturnSSRC(const uint32_t ssrc);
niklase@google.com470e71d2011-07-07 08:21:25 +000031
henrike@webrtc.org315282c2011-12-09 17:46:20 +000032protected:
niklase@google.com470e71d2011-07-07 08:21:25 +000033 SSRCDatabase();
34 virtual ~SSRCDatabase();
35
henrike@webrtc.org315282c2011-12-09 17:46:20 +000036 static SSRCDatabase* CreateInstance() { return new SSRCDatabase(); }
37
38private:
39 // Friend function to allow the SSRC destructor to be accessed from the
40 // template class.
41 friend SSRCDatabase* GetStaticInstance<SSRCDatabase>(
42 CountOperation count_operation);
43 static SSRCDatabase* StaticInstance(CountOperation count_operation);
44
pbos@webrtc.org2f446732013-04-08 11:08:41 +000045 uint32_t GenerateRandom();
niklase@google.com470e71d2011-07-07 08:21:25 +000046
pbos@webrtc.org2f446732013-04-08 11:08:41 +000047 std::map<uint32_t, uint32_t> _ssrcMap;
niklase@google.com470e71d2011-07-07 08:21:25 +000048
49 CriticalSectionWrapper* _critSect;
50};
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000051} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000052
53#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_SSRC_DATABASE_H_