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

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

Issue 1623543002: Refactor RtpSender and SSRCDatabase a bit. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Update comment and remove the one from ssrc_database.cc Created 4 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
OLDNEW
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 <set> 14 #include <set>
15 15
16 #include "webrtc/base/criticalsection.h"
16 #include "webrtc/base/random.h" 17 #include "webrtc/base/random.h"
17 #include "webrtc/base/scoped_ptr.h" 18 #include "webrtc/base/thread_annotations.h"
18 #include "webrtc/system_wrappers/include/static_instance.h" 19 #include "webrtc/system_wrappers/include/static_instance.h"
19 #include "webrtc/typedefs.h" 20 #include "webrtc/typedefs.h"
20 21
21 namespace webrtc { 22 namespace webrtc {
22 class CriticalSectionWrapper;
23 23
24 // TODO(tommi, holmer): Look into whether we can eliminate locking in this
25 // class or the class itself completely once voice engine doesn't rely on it.
26 // At the moment voe_auto_test requires locking, but it's not clear if that's
27 // an issue with the test code or if it reflects real world usage or if that's
28 // the best design performance wise.
29 // If we do decide to keep the class, we should at least get rid of using
30 // StaticInstance.
24 class SSRCDatabase { 31 class SSRCDatabase {
25 public: 32 public:
26 static SSRCDatabase* GetSSRCDatabase(); 33 static SSRCDatabase* GetSSRCDatabase();
27 static void ReturnSSRCDatabase(); 34 static void ReturnSSRCDatabase();
28 35
29 uint32_t CreateSSRC(); 36 uint32_t CreateSSRC();
30 void RegisterSSRC(uint32_t ssrc); 37 void RegisterSSRC(uint32_t ssrc);
31 void ReturnSSRC(uint32_t ssrc); 38 void ReturnSSRC(uint32_t ssrc);
32 39
33 protected: 40 protected:
34 SSRCDatabase(); 41 SSRCDatabase();
35 virtual ~SSRCDatabase(); 42 ~SSRCDatabase();
36 43
37 static SSRCDatabase* CreateInstance() { return new SSRCDatabase(); } 44 static SSRCDatabase* CreateInstance() { return new SSRCDatabase(); }
38 45
39 private:
40 // Friend function to allow the SSRC destructor to be accessed from the 46 // Friend function to allow the SSRC destructor to be accessed from the
41 // template class. 47 // template class.
42 friend SSRCDatabase* GetStaticInstance<SSRCDatabase>( 48 friend SSRCDatabase* GetStaticInstance<SSRCDatabase>(
43 CountOperation count_operation); 49 CountOperation count_operation);
44 50
45 rtc::scoped_ptr<CriticalSectionWrapper> crit_; 51 private:
52 rtc::CriticalSection crit_;
46 Random random_ GUARDED_BY(crit_); 53 Random random_ GUARDED_BY(crit_);
47 std::set<uint32_t> ssrcs_ GUARDED_BY(crit_); 54 std::set<uint32_t> ssrcs_ GUARDED_BY(crit_);
55 // TODO(tommi): Use a thread checker to ensure the object is created and
56 // deleted on the same thread. At the moment this isn't possible due to
57 // voe::ChannelOwner in voice engine. To reproduce, run:
58 // voe_auto_test --automated --gtest_filter=*MixManyChannelsForStressOpus
48 }; 59 };
49 } // namespace webrtc 60 } // namespace webrtc
50 61
51 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_SSRC_DATABASE_H_ 62 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_SSRC_DATABASE_H_
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_sender.cc ('k') | webrtc/modules/rtp_rtcp/source/ssrc_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698