Skip to content

Commit 6bae9a8

Browse files
shushantsharanshushant.sharankingster
authored
Realtime Audio Streaming (#45)
Support for realtime streaming of PCMA, PCMU, G711 calls. --------- Co-authored-by: shushant.sharan <[email protected]> Co-authored-by: Kinshuk Bairagi <[email protected]>
1 parent 85a8cb2 commit 6bae9a8

21 files changed

+982
-7
lines changed

.devcontainer/Dockerfile.orkaudio.build

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,25 @@ RUN mkdir -p /opt/bcg729 && chmod 777 /opt/bcg729`
4646
RUN mkdir -p /opt/backward-cpp && chmod 777 /opt/backward-cpp`
4747
&& git clone --depth 1 https://github.com/bombela/backward-cpp.git /opt/backward-cpp `
4848
&& ln -s /opt/backward-cpp/backward.hpp /usr/local/include/backward.hpp
49-
49+
50+
#httplib
51+
RUN mkdir -p /opt/httplib && chmod 777 /opt/httplib`
52+
&& git clone --depth 1 --branch v0.12.3 https://github.com/yhirose/cpp-httplib.git /opt/httplib `
53+
&& ln -s /opt/httplib/httplib.h /usr/local/include/httplib.h
54+
55+
#json
56+
RUN mkdir -p /opt/json && chmod 777 /opt/json`
57+
&& git clone --depth 1 https://github.com/nlohmann/json.git /opt/json/ `
58+
&& cd /opt/json `
59+
&& cmake . -DCMAKE_INSTALL_PREFIX=/usr`
60+
&& make && make install
61+
62+
#srs-librtmp
63+
RUN git clone --depth 1 --branch 3.0release https://github.com/ossrs/srs.git /opt/srs `
64+
&& cd /opt/srs/trunk && CXXFLAGS="-fPIC" ./configure --with-librtmp --without-ssl --export-librtmp-project=/opt/srs-librtmp `
65+
&& cd /opt/srs-librtmp && sed -i '/Building the srs-librtmp example/,+1d' Makefile`
66+
&& make && ln -s /opt/srs-librtmp/objs/lib/srs_librtmp.a /opt/srs-librtmp/objs/lib/libsrs_librtmp.a
67+
5068
COPY .devcontainer/build.sh /entrypoint.sh
5169

5270
#INSERT_HERE

.devcontainer/build-pjsua.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
set -e
3+
4+
apt-get update -qq && apt-get install -y --no-install-recommends ca-certificates curl libgsm1-dev \
5+
libspeex-dev libspeexdsp-dev libssl-dev portaudio19-dev libsrtp0-dev \
6+
&& apt-get purge -y --auto-remove && rm -rf /var/lib/apt/lists/*
7+
8+
git clone --depth 1 --branch 2.5.5 https://github.com/pjsip/pjproject /opt/pjproject \
9+
&& cd /opt/pjproject && ./configure && touch pjlib/include/pj/config_site.h && make dep && make \
10+
&& cp pjsip-apps/bin/pjsua* /usr/local/bin/pjsua

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ Based on [OrecX](http://www.orecx.com/open-source/) [Oreka](https://github.com/O
1818
**OrkAudio**
1919

2020
- Support for G729 Codec
21-
- CallID Tracking
21+
- SIP-CallID Tracking
2222
- Upgrade to latest version of libraries.
23+
- [Realtime Streaming](https://github.com/voiceip/oreka/wiki/Live-Streaming) of Live Calls.
2324

2425
**OrkTrack**
2526

distribution/docker/Dockerfile.orkaudio

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,24 @@ RUN mkdir -p /opt/backward-cpp && chmod 777 /opt/backward-cpp`
4545
&& git clone --depth 1 https://github.com/bombela/backward-cpp.git /opt/backward-cpp `
4646
&& ln -s /opt/backward-cpp/backward.hpp /usr/local/include/backward.hpp
4747

48+
#httplib
49+
RUN mkdir -p /opt/httplib && chmod 777 /opt/httplib`
50+
&& git clone --depth 1 --branch v0.12.3 https://github.com/yhirose/cpp-httplib.git /opt/httplib `
51+
&& ln -s /opt/httplib/httplib.h /usr/local/include/httplib.h
52+
53+
#json
54+
RUN mkdir -p /opt/json && chmod 777 /opt/json`
55+
&& git clone --depth 1 https://github.com/nlohmann/json.git /opt/json/ `
56+
&& cd /opt/json `
57+
&& cmake . -DCMAKE_INSTALL_PREFIX=/usr`
58+
&& make && make install
59+
60+
#srs-librtmp
61+
RUN git clone --depth 1 --branch 3.0release https://github.com/ossrs/srs.git /opt/srs `
62+
&& cd /opt/srs/trunk && CXXFLAGS="-fPIC" ./configure --with-librtmp --without-ssl --export-librtmp-project=/opt/srs-librtmp `
63+
&& cd /opt/srs-librtmp && sed -i '/Building the srs-librtmp example/,+1d' Makefile`
64+
&& make && ln -s /opt/srs-librtmp/objs/lib/srs_librtmp.a /opt/srs-librtmp/objs/lib/libsrs_librtmp.a
65+
4866
RUN mkdir -p /opt/oreka && chmod 777 /opt/oreka`
4967
&& git clone --depth 1 https://github.com/voiceip/oreka.git /opt/oreka `
5068
&& cd /opt/oreka/orkbasecxx `

orkaudio/audiocaptureplugins/voip/VoIpSession.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4337,6 +4337,10 @@ void VoIpSessions::ClearLocalPartyMap()
43374337
m_localPartyMap.clear();
43384338
}
43394339

4340+
const std::map<unsigned long long, VoIpSessionRef> & VoIpSessions::getByIpAndPort() const {
4341+
return m_byIpAndPort;
4342+
}
4343+
43404344
void VoIpSessions::StopAll()
43414345
{
43424346
time_t forceExpiryTime = time(NULL) + 2*DLLCONFIG.m_rtpSessionOnHoldTimeOutSec;

orkaudio/audiocaptureplugins/voip/VoIpSession.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ class VoIpSessions: public OrkSingleton<VoIpSessions>
247247
void TaggingSipTransferCalls(VoIpSessionRef& session);
248248
void CopyMetadataToNewSession(VoIpSessionRef& oldSession, VoIpSessionRef& newSession);
249249
void ClearLocalPartyMap();
250+
const std::map<unsigned long long, VoIpSessionRef> & getByIpAndPort() const;
250251

251252
private:
252253
void CraftMediaAddress(CStdString& mediaAddress, struct in_addr ipAddress, unsigned short udpPort);

orkaudio/config-linux-template.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<!-- TlsClientCACertCheckIgnoreExpiry value to false -->
4545
<!-- <TlsClientCACertCheckIgnoreExpiry>true</TlsClientCACertCheckIgnoreExpiry> -->
4646

47-
<CapturePortFilters>LiveMonitoring</CapturePortFilters>
47+
<!-- <CapturePortFilters>LiveMonitoring</CapturePortFilters> -->
4848
<TapeProcessors>BatchProcessing, Reporting</TapeProcessors>
4949

5050
<!-- <ImmediateProcessingQueueSize>50000</ImmediateProcessingQueueSize> -->
@@ -144,4 +144,14 @@
144144
<!-- End of Available Configurations for Mitel Communications Platform -->
145145

146146
</VoIpPlugin>
147+
148+
<!-- LiveStreamFilter Configuration -->
149+
<!-- To Enable this plugin add `LiveStreamFilter` in CapturePortFilters -->
150+
<!-- <CapturePortFilters>LiveStreamFilter</CapturePortFilters> -->
151+
<RTMPServerEndPoint>127.0.0.1:1935/live</RTMPServerEndPoint>
152+
<LiveStreamAllCalls>true</LiveStreamAllCalls>
153+
<!-- <LiveStreamingServerPort>59160</LiveStreamingServerPort> -->
154+
<!-- <LiveStreamingQueueFlushThreshold>500</LiveStreamingQueueFlushThreshold> -->
155+
<!-- End of LiveStreamFilter Configuration -->
156+
147157
</config>

orkaudio/configure.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ AC_ARG_ENABLE( [tsan],
1313
)
1414

1515
AC_LANG_CPLUSPLUS
16-
AC_PROG_CXX([g++])
16+
AC_PROG_CXX
1717
AM_PROG_LIBTOOL
1818

1919
AS_IF([test "x$enable_tsan" = "xyes"], [
@@ -56,7 +56,7 @@ AC_PREFIX_DEFAULT(/usr)
5656

5757
AC_SUBST(speex_lib,$speex_lib)
5858

59-
AC_OUTPUT(Makefile audiocaptureplugins/Makefile audiocaptureplugins/generator/Makefile audiocaptureplugins/voip/Makefile filters/Makefile filters/rtpmixer/Makefile filters/silkcodec/Makefile filters/g729codec/Makefile)
59+
AC_OUTPUT(Makefile audiocaptureplugins/Makefile audiocaptureplugins/generator/Makefile audiocaptureplugins/voip/Makefile filters/Makefile filters/rtpmixer/Makefile filters/silkcodec/Makefile filters/g729codec/Makefile filters/LiveStream/Makefile)
6060

6161
echo ""
6262
echo "========= Configuration ==========="
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
#include "LiveStreamConfig.h"
3+
#include <log4cxx/logger.h>
4+
5+
static log4cxx::LoggerPtr s_log = log4cxx::Logger::getLogger("plugin.livestream");
6+
7+
LiveStreamConfig g_LiveStreamConfigObjectRef;
8+
9+
LiveStreamConfig::LiveStreamConfig() {
10+
m_serverPort = LIVE_STREAMING_SERVER_PORT_DEFAULT;
11+
m_queueFlushThresholdMillis = DEFAULT_LIVE_STREAMING_QUEUE_FLUSH_THRESHOLD;
12+
m_shouldStreamAllCalls = false;
13+
}
14+
15+
void LiveStreamConfig::Reset() {
16+
m_rtmpServerEndpoint = "";
17+
m_shouldStreamAllCalls = false;
18+
m_serverPort = LIVE_STREAMING_SERVER_PORT_DEFAULT;
19+
m_queueFlushThresholdMillis = DEFAULT_LIVE_STREAMING_QUEUE_FLUSH_THRESHOLD;
20+
}
21+
22+
void LiveStreamConfig::Define(Serializer* s) {
23+
s->StringValue(RTMP_SERVER_ENDPOINT, m_rtmpServerEndpoint);
24+
s->IntValue(LIVE_STREAMING_SERVER_PORT_PARAM, m_serverPort);
25+
s->IntValue(LIVE_STREAMING_QUEUE_FLUSH_THRESHOLD, m_queueFlushThresholdMillis);
26+
s->BoolValue(LIVE_STREAM_ALL_CALLS, m_shouldStreamAllCalls);
27+
LOG4CXX_INFO(s_log, "LiveStreamConfig Endpoint " + m_rtmpServerEndpoint);
28+
}
29+
30+
void LiveStreamConfig::Validate() {
31+
}
32+
33+
CStdString LiveStreamConfig::GetClassName() {
34+
return CStdString("LiveStreamConfig");
35+
}
36+
37+
ObjectRef LiveStreamConfig::NewInstance() {
38+
return ObjectRef(new LiveStreamConfig);
39+
}
40+
41+
void LiveStreamConfig::Configure(DOMNode* node) {
42+
if (node){
43+
try {
44+
g_LiveStreamConfigObjectRef.DeSerializeDom(node);
45+
LOG4CXX_INFO(s_log, "LiveStreamConfig Configured");
46+
} catch (CStdString& e) {
47+
LOG4CXX_ERROR(s_log, e + " - check your config.xml");
48+
}
49+
} else {
50+
LOG4CXX_ERROR(s_log, "Got empty DOM tree");
51+
}
52+
}
53+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#ifndef __LIVESTREAMCONFIG_H__
2+
#define __LIVESTREAMCONFIG_H__
3+
4+
#include "Object.h"
5+
#include "serializers/Serializer.h"
6+
#include "StdString.h"
7+
#include "Utils.h"
8+
9+
#define RTMP_SERVER_ENDPOINT "RTMPServerEndPoint"
10+
#define LIVE_STREAMING_SERVER_PORT_PARAM "LiveStreamingServerPort"
11+
#define LIVE_STREAMING_QUEUE_FLUSH_THRESHOLD "LiveStreamingQueueFlushThreshold"
12+
#define LIVE_STREAMING_SERVER_PORT_DEFAULT 59160
13+
#define DEFAULT_LIVE_STREAMING_QUEUE_FLUSH_THRESHOLD 500
14+
#define LIVE_STREAM_ALL_CALLS "LiveStreamAllCalls"
15+
16+
class LiveStreamConfig : public Object {
17+
public:
18+
LiveStreamConfig();
19+
void Define(Serializer* s);
20+
void Validate();
21+
void Reset();
22+
ObjectRef NewInstance();
23+
CStdString GetClassName();
24+
inline ObjectRef Process() {return ObjectRef();};
25+
26+
static void Configure(DOMNode* node);
27+
28+
CStdString m_rtmpServerEndpoint;
29+
int m_serverPort;
30+
int m_queueFlushThresholdMillis;
31+
bool m_shouldStreamAllCalls;
32+
};
33+
34+
extern LiveStreamConfig g_LiveStreamConfigObjectRef;
35+
36+
#define LIVESTREAMCONFIG g_LiveStreamConfigObjectRef
37+
38+
#endif

0 commit comments

Comments
 (0)