2011-07-07 08:21:25 +00:00
|
|
|
/*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_SSRC_DATABASE_H_
|
|
|
|
|
#define WEBRTC_MODULES_RTP_RTCP_SOURCE_SSRC_DATABASE_H_
|
|
|
|
|
|
2013-05-29 14:27:38 +00:00
|
|
|
#include <map>
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-10-28 18:17:40 +01:00
|
|
|
#include "webrtc/system_wrappers/include/static_instance.h"
|
2013-05-29 14:27:38 +00:00
|
|
|
#include "webrtc/typedefs.h"
|
2011-12-09 17:46:20 +00:00
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
namespace webrtc {
|
|
|
|
|
class CriticalSectionWrapper;
|
|
|
|
|
|
2015-12-10 02:39:40 -08:00
|
|
|
class SSRCDatabase {
|
|
|
|
|
public:
|
|
|
|
|
static SSRCDatabase* GetSSRCDatabase();
|
|
|
|
|
static void ReturnSSRCDatabase();
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-12-10 02:39:40 -08:00
|
|
|
uint32_t CreateSSRC();
|
|
|
|
|
int32_t RegisterSSRC(const uint32_t ssrc);
|
|
|
|
|
int32_t ReturnSSRC(const uint32_t ssrc);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-12-10 02:39:40 -08:00
|
|
|
protected:
|
|
|
|
|
SSRCDatabase();
|
|
|
|
|
virtual ~SSRCDatabase();
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-12-10 02:39:40 -08:00
|
|
|
static SSRCDatabase* CreateInstance() { return new SSRCDatabase(); }
|
2011-12-09 17:46:20 +00:00
|
|
|
|
2015-12-10 02:39:40 -08:00
|
|
|
private:
|
|
|
|
|
// Friend function to allow the SSRC destructor to be accessed from the
|
|
|
|
|
// template class.
|
|
|
|
|
friend SSRCDatabase* GetStaticInstance<SSRCDatabase>(
|
|
|
|
|
CountOperation count_operation);
|
|
|
|
|
static SSRCDatabase* StaticInstance(CountOperation count_operation);
|
2011-12-09 17:46:20 +00:00
|
|
|
|
2015-12-10 02:39:40 -08:00
|
|
|
uint32_t GenerateRandom();
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-12-10 02:39:40 -08:00
|
|
|
std::map<uint32_t, uint32_t> _ssrcMap;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-12-10 02:39:40 -08:00
|
|
|
CriticalSectionWrapper* _critSect;
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
2013-07-03 15:12:26 +00:00
|
|
|
} // namespace webrtc
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-12-10 02:39:40 -08:00
|
|
|
#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_SSRC_DATABASE_H_
|