Skip to content

Commit ef5d1e1

Browse files
committed
Added local rtp proxy
1 parent 7abd468 commit ef5d1e1

File tree

6 files changed

+79
-43
lines changed

6 files changed

+79
-43
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
nbproject
12
Makefile.in
23
aclocal.m4
34
autom4te.cache/

include/OSS/SIP/SBC/SBCMediaProxy.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727

2828
#include "OSS/SIP/SBC/SBCMediaProxyClient.h"
29+
#include "OSS/RTP/RTPProxyManager.h"
2930

3031

3132
namespace OSS {
@@ -55,7 +56,7 @@ class SBCMediaProxy
5556

5657
bool getSDP(const std::string& sessionId, std::string& lastOffer, std::string& lastAnswer);
5758

58-
bool initialize();
59+
bool initialize(bool remoteRtpEnabled = false);
5960

6061
bool removeSession(const std::string& sessionId);
6162

@@ -73,6 +74,8 @@ class SBCMediaProxy
7374
SBCMediaProxyClient _node3;
7475
SBCMediaProxyClient _node4;
7576
SBCManager* _pManager;
77+
OSS::RTP::RTPProxyManager _rtp;
78+
bool _remoteRtpEnabled;
7679
};
7780

7881
//

src/js/oss_js.cpp src/js/oss_core.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ int main(int argc, char** argv)
3939
{
4040
if (argc < 2)
4141
{
42-
std::cerr << "Usage: ossjs [script] [script_options]" << std::endl;
42+
std::cerr << "Usage: " << argv[0] << " [script] [script_options]" << std::endl;
4343
_exit(1);
4444
}
4545

src/js/src.am

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ liboss_core_la_SOURCES += \
1717
js/JSInterIsolateCallManager.cpp \
1818
js/JSFileDescriptorManager.cpp
1919

20-
bin_PROGRAMS += ossjs
21-
ossjs_SOURCES = js/oss_js.cpp
20+
bin_PROGRAMS += oss_core
21+
oss_core_SOURCES = js/oss_core.cpp
2222
endif
2323

2424

src/rtp/RTPProxyManager.cpp

-10
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,7 @@ RTPProxyManager::~RTPProxyManager()
5151

5252
void RTPProxyManager::run(int threadCount, int readTimeout)
5353
{
54-
if (_rtpProxyThreadCount > 0)
55-
return;
56-
57-
58-
59-
#if RTP_THREADED
6054
_rtpProxyThreadCount = threadCount;
61-
#else
62-
(void)threadCount;
63-
_rtpProxyThreadCount = 1;
64-
#endif
6555
_readTimeout = readTimeout;
6656
//
6757
// start the houseKeepingTimer to keep the io_service busy

src/sbc/SBCMediaProxy.cpp

+71-29
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ namespace OSS {
3030
namespace SIP {
3131
namespace SBC {
3232

33+
#define RTP_PROXY_THREAD_COUNT 30
3334

3435
static int get_node(const std::string& sessionId, bool& spillOver)
3536
{
@@ -77,43 +78,55 @@ SBCMediaProxy::SBCMediaProxy(SBCManager* pManager) :
7778
_node2(2),
7879
_node3(3),
7980
_node4(4),
80-
_pManager(pManager)
81+
_pManager(pManager),
82+
_remoteRtpEnabled(false)
8183
{
8284
}
8385

8486
SBCMediaProxy::~SBCMediaProxy()
8587
{
8688
}
8789

88-
bool SBCMediaProxy::initialize()
90+
bool SBCMediaProxy::initialize(bool remoteRtpEnabled)
8991
{
90-
if (!_node0.initialize())
91-
return false;
92-
if (!_node1.initialize())
93-
return false;
94-
if (!_node2.initialize())
95-
return false;
96-
if (!_node3.initialize())
97-
return false;
98-
if (!_node4.initialize())
99-
return false;
100-
92+
_remoteRtpEnabled = remoteRtpEnabled;
93+
94+
if (_remoteRtpEnabled)
95+
{
96+
if (!_node0.initialize())
97+
return false;
98+
if (!_node1.initialize())
99+
return false;
100+
if (!_node2.initialize())
101+
return false;
102+
if (!_node3.initialize())
103+
return false;
104+
if (!_node4.initialize())
105+
return false;
106+
}
107+
else
108+
{
109+
_rtp.run(RTP_PROXY_THREAD_COUNT);
110+
}
101111
return true;
102112
}
103113

104114
SBCMediaProxyClient* SBCMediaProxy::getNode(const std::string& sessionId, bool& spillOver)
105115
{
106-
int node = get_node(sessionId, spillOver);
107-
if (node == 0)
108-
return &_node0;
109-
else if (node == 1)
110-
return &_node1;
111-
else if (node == 2)
112-
return &_node2;
113-
else if (node == 3)
114-
return &_node3;
115-
else if (node == 4)
116-
return &_node4;
116+
if (_remoteRtpEnabled)
117+
{
118+
int node = get_node(sessionId, spillOver);
119+
if (node == 0)
120+
return &_node0;
121+
else if (node == 1)
122+
return &_node1;
123+
else if (node == 2)
124+
return &_node2;
125+
else if (node == 3)
126+
return &_node3;
127+
else if (node == 4)
128+
return &_node4;
129+
}
117130
return 0;
118131
}
119132

@@ -136,6 +149,18 @@ bool SBCMediaProxy::handleSDP(
136149
{
137150
return pNode->handleSDP(logId, sessionId, sentBy, packetSourceIP, packetLocalInterface, route, routeLocalInterface, requestType, sdp, rtpAttribute);
138151
}
152+
else
153+
{
154+
try
155+
{
156+
_rtp.handleSDP(logId, sessionId, sentBy, packetSourceIP, packetLocalInterface, route, routeLocalInterface, requestType, sdp, rtpAttribute);
157+
return true;
158+
}
159+
catch (...)
160+
{
161+
return false;
162+
}
163+
}
139164
return false;
140165
}
141166

@@ -147,6 +172,11 @@ bool SBCMediaProxy::getSDP(const std::string& sessionId, std::string& lastOffer,
147172
{
148173
return pNode->getSDP( sessionId, lastOffer, lastAnswer);
149174
}
175+
else
176+
{
177+
_rtp.getSDP(sessionId, lastOffer, lastAnswer);
178+
return true;
179+
}
150180
return false;
151181
}
152182

@@ -159,6 +189,11 @@ bool SBCMediaProxy::removeSession(const std::string& sessionId)
159189
{
160190
return pNode->removeSession(sessionId);
161191
}
192+
else
193+
{
194+
_rtp.removeSession(sessionId);
195+
return true;
196+
}
162197
return false;
163198
}
164199

@@ -179,11 +214,18 @@ unsigned int SBCMediaProxy::getMaxSession() const
179214

180215
unsigned int SBCMediaProxy::getSessionCount() const
181216
{
182-
return _node0.getSessionCount() +
183-
_node1.getSessionCount() +
184-
_node2.getSessionCount() +
185-
_node3.getSessionCount() +
186-
_node4.getSessionCount();
217+
if (_remoteRtpEnabled)
218+
{
219+
return _node0.getSessionCount() +
220+
_node1.getSessionCount() +
221+
_node2.getSessionCount() +
222+
_node3.getSessionCount() +
223+
_node4.getSessionCount();
224+
}
225+
else
226+
{
227+
return _rtp.getSessionCount();
228+
}
187229
}
188230

189231
} } } //OSS::SIP::SBC

0 commit comments

Comments
 (0)