OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_SSRC_DATABASE_H_ | 11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_SSRC_DATABASE_H_ |
12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_SSRC_DATABASE_H_ | 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_SSRC_DATABASE_H_ |
13 | 13 |
14 #include <map> | 14 #include <set> |
15 | 15 |
| 16 #include "webrtc/base/random.h" |
| 17 #include "webrtc/base/scoped_ptr.h" |
16 #include "webrtc/system_wrappers/include/static_instance.h" | 18 #include "webrtc/system_wrappers/include/static_instance.h" |
17 #include "webrtc/typedefs.h" | 19 #include "webrtc/typedefs.h" |
18 | 20 |
19 namespace webrtc { | 21 namespace webrtc { |
20 class CriticalSectionWrapper; | 22 class CriticalSectionWrapper; |
21 | 23 |
22 class SSRCDatabase { | 24 class SSRCDatabase { |
23 public: | 25 public: |
24 static SSRCDatabase* GetSSRCDatabase(); | 26 static SSRCDatabase* GetSSRCDatabase(); |
25 static void ReturnSSRCDatabase(); | 27 static void ReturnSSRCDatabase(); |
26 | 28 |
27 uint32_t CreateSSRC(); | 29 uint32_t CreateSSRC(); |
28 int32_t RegisterSSRC(const uint32_t ssrc); | 30 void RegisterSSRC(uint32_t ssrc); |
29 int32_t ReturnSSRC(const uint32_t ssrc); | 31 void ReturnSSRC(uint32_t ssrc); |
30 | 32 |
31 protected: | 33 protected: |
32 SSRCDatabase(); | 34 SSRCDatabase(); |
33 virtual ~SSRCDatabase(); | 35 virtual ~SSRCDatabase(); |
34 | 36 |
35 static SSRCDatabase* CreateInstance() { return new SSRCDatabase(); } | 37 static SSRCDatabase* CreateInstance() { return new SSRCDatabase(); } |
36 | 38 |
37 private: | 39 private: |
38 // Friend function to allow the SSRC destructor to be accessed from the | 40 // Friend function to allow the SSRC destructor to be accessed from the |
39 // template class. | 41 // template class. |
40 friend SSRCDatabase* GetStaticInstance<SSRCDatabase>( | 42 friend SSRCDatabase* GetStaticInstance<SSRCDatabase>( |
41 CountOperation count_operation); | 43 CountOperation count_operation); |
42 static SSRCDatabase* StaticInstance(CountOperation count_operation); | |
43 | 44 |
44 uint32_t GenerateRandom(); | 45 rtc::scoped_ptr<CriticalSectionWrapper> crit_; |
45 | 46 Random random_ GUARDED_BY(crit_); |
46 std::map<uint32_t, uint32_t> _ssrcMap; | 47 std::set<uint32_t> ssrcs_ GUARDED_BY(crit_); |
47 | |
48 CriticalSectionWrapper* _critSect; | |
49 }; | 48 }; |
50 } // namespace webrtc | 49 } // namespace webrtc |
51 | 50 |
52 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_SSRC_DATABASE_H_ | 51 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_SSRC_DATABASE_H_ |
OLD | NEW |