reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
RTPPortManager.hxx
Go to the documentation of this file.
1#if !defined(RTPPortManager_hxx)
2#define RTPPortManager_hxx
3
4#include <deque>
5
6#include "rutil/Data.hxx"
7
8namespace resip
9{
10
11// FIXME - consider making this a singleton or detect and warn if the
12// application attempts to create overlapping instances
13
15{
16public:
17 RTPPortManager(int portRangeMin = 17000, int portRangeMax = 18000);
19 unsigned int allocateRTPPort();
23 unsigned int allocateRTPPort(const resip::Data& address);
24 void freeRTPPort(unsigned int port);
25 unsigned int getNumAllocatedPortPairs() { return mTotalPortPairs - (unsigned int)mRTPPortFreeList.size(); }
26 unsigned int getNumFreePortPairs() { return (unsigned int)mRTPPortFreeList.size(); }
27
28private:
29 unsigned int mPortRangeMin;
30 unsigned int mPortRangeMax;
31 std::deque<unsigned int> mRTPPortFreeList;
32 unsigned int mTotalPortPairs;
33};
34
35}
36
37#endif
38
39/* ====================================================================
40
41 Copyright (c) 2010-2026, SIP Spectrum, Inc. http://www.sipspectrum.com
42 Copyright (c) 2014 Daniel Pocock http://danielpocock.com
43 Copyright (c) 2007-2008, Plantronics, Inc.
44 All rights reserved.
45
46 Redistribution and use in source and binary forms, with or without
47 modification, are permitted provided that the following conditions are
48 met:
49
50 1. Redistributions of source code must retain the above copyright
51 notice, this list of conditions and the following disclaimer.
52
53 2. Redistributions in binary form must reproduce the above copyright
54 notice, this list of conditions and the following disclaimer in the
55 documentation and/or other materials provided with the distribution.
56
57 3. Neither the name of Plantronics nor the names of its contributors
58 may be used to endorse or promote products derived from this
59 software without specific prior written permission.
60
61 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
62 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
63 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
64 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
65 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
66 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
67 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
68 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
69 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
70 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
71 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
72
73 ==================================================================== */
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
unsigned int getNumFreePortPairs()
unsigned int allocateRTPPort()
Allocates an RTP port (even - the RTCP port is the one after it). Returns 0 if none is free.
void freeRTPPort(unsigned int port)
unsigned int getNumAllocatedPortPairs()
dcm! – add UnusedChecking(_enum) below;