Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Compiled Object files
*.slo
*.lo
*.o
*.obj
3 changes: 2 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ ${TINYMSRP_LIBS} \
${TINYRTP_LIBS} \
${TINYIPSEC_LIBS} \
-lxml2 \
-lpthread
-lpthread \
-ldl


webrtc2sip_SOURCES = \
Expand Down
22 changes: 20 additions & 2 deletions config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@
<!-- Please check the technical guide (http://webrtc2sip.org/technical-guide-1.0.pdf) for more information on how to adjust this file -->
<config>

<debug-level>ERROR</debug-level>
<debug-level>INFO</debug-level>
<log-path>/tmp/</log-path>
<log-filename>webrtc2sip.log</log-filename>

<app-log-level>INFO</app-log-level>
<app-log-path>/tmp/</app-log-path>
<app-log-filename>app.log</app-log-filename>


<stat-path>/tmp/</stat-path>
<stat-filename>webrtc2sip.stat</stat-filename>
<stat-interval>5</stat-interval>
<reset-enable>yes</reset-enable>

<transport>udp;*;10060</transport>
<transport>ws;*;10060</transport>
Expand Down Expand Up @@ -30,6 +42,12 @@
<max-fds>-1</max-fds>

<!--nameserver>66.66.66.6</nameserver-->
<ssl-certificates>
/root/build/webrtc2sip/siampiwat-pem/private.pem;
/root/build/webrtc2sip/siampiwat-pem/cert.pem;
/root/build/webrtc2sip/siampiwat-pem/fullchain.pem;
no
</ssl-certificates>

<!--ssl-certificates>
C:/Projects/ssl/priv.pem;
Expand All @@ -48,4 +66,4 @@
<!--account-http-domain>click2dial.org</account-http-domain-->
<!--account-recaptcha>https://www.google.com/recaptcha/api/siteverify;your-secret-here</account-recaptcha-->

</config>
</config>
8 changes: 8 additions & 0 deletions doubango/tinySAK.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,14 @@
RelativePath="..\..\doubango\tinySAK\src\tsk_debug.h"
>
</File>
<File
RelativePath="..\..\doubango\tinySAK\src\my_debug.h"
>
</File>
<File
RelativePath="..\..\doubango\tinySAK\src\tsk_stat.h"
>
</File>
<File
RelativePath="..\..\doubango\tinySAK\src\tsk_errno.h"
>
Expand Down
2 changes: 1 addition & 1 deletion mp_c2c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include "tsk_string.h"
#include "tsk_memory.h"

#include "tsk_debug.h"
#include "tinyhttp.h"

#include <assert.h>
Expand Down
1 change: 1 addition & 0 deletions mp_c2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "mp_config.h"
#include "mp_net_transport.h"
#include "tsk_debug.h"
#include "db/mp_db.h"
#include "mp_mail.h"
#include "mp_recaptcha.h"
Expand Down
124 changes: 91 additions & 33 deletions mp_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* along with 'webrtc2sip'.
*/
#include "mp_engine.h"
#include "app_log.h"
#include "mp_proxyplugin_mgr.h"
#include "db/sqlite/mp_db_sqlite.h"

Expand Down Expand Up @@ -126,6 +127,27 @@ bool MPEngine::setDebugLevel(const char* pcLevel)
return false;
}

bool MPEngine::setAppLogLevel(const char* pcLevel)
{
struct debug_level { const char* name; int level; };
static const debug_level debug_levels[] =
{
{"INFO", DEBUG_LEVEL_INFO},
{"WARN", DEBUG_LEVEL_WARN},
{"ERROR", DEBUG_LEVEL_ERROR},
{"FATAL", DEBUG_LEVEL_FATAL},
};
static const int debug_levels_count = sizeof(debug_levels)/sizeof(debug_levels[0]);
int i;
for(i = 0; i < debug_levels_count; ++i){
if(tsk_striequals(debug_levels[i].name, pcLevel)){
tsk_debug_set_level(debug_levels[i].level);
return true;
}
}
return false;
}

bool MPEngine::addTransport(const char* pTransport, uint16_t nLocalPort, const char* pcLocalIP /*= tsk_null*/)
{
if(!isValid())
Expand Down Expand Up @@ -163,6 +185,15 @@ bool MPEngine::setRtpSymetricEnabled(bool bEnabled)
return MediaSessionMgr::defaultsSetRtpSymetricEnabled(bEnabled);
}

bool MPEngine::setRtpPortRange(uint16_t start, uint16_t stop)
{
if(start < 1024 || stop < 1024 || start >= stop) {
TSK_DEBUG_ERROR("Invalid parameter: (%u < 1024 || %u < 1024 || %u >= %u)", start, stop, start, stop);
return false;
}
return MediaSessionMgr::defaultsSetRtpPortRange(start, stop);
}

bool MPEngine::set100relEnabled(bool bEnabled)
{
return MediaSessionMgr::defaultsSet100relEnabled(bEnabled);
Expand Down Expand Up @@ -259,8 +290,8 @@ bool MPEngine::setCodecs(const char* pcCodecs)
return false;
}

int i;
struct codec{ const char* name; tmedia_codec_id_t id; };
int i;
struct codec{ const char* name; tmedia_codec_id_t id; };
static const codec aCodecNames[] = {
{"pcma", tmedia_codec_id_pcma},
{"pcmu", tmedia_codec_id_pcmu},
Expand All @@ -274,41 +305,41 @@ bool MPEngine::setCodecs(const char* pcCodecs)
{"gsm", tmedia_codec_id_gsm},
{"g722", tmedia_codec_id_g722},
{"ilbc", tmedia_codec_id_ilbc},
{"h264-bp", tmedia_codec_id_h264_bp},
{"h264-mp", tmedia_codec_id_h264_mp},
{"vp8", tmedia_codec_id_vp8},
{"h263", tmedia_codec_id_h263},
{"h263+", tmedia_codec_id_h263p},
{"theora", tmedia_codec_id_theora},
{"mp4v-es", tmedia_codec_id_mp4ves_es}
};
static const int nCodecsCount = sizeof(aCodecNames) / sizeof(aCodecNames[0]);

{"h264-bp", tmedia_codec_id_h264_bp},
{"h264-mp", tmedia_codec_id_h264_mp},
{"vp8", tmedia_codec_id_vp8},
{"h263", tmedia_codec_id_h263},
{"h263+", tmedia_codec_id_h263p},
{"theora", tmedia_codec_id_theora},
{"mp4v-es", tmedia_codec_id_mp4ves_es}
};
static const int nCodecsCount = sizeof(aCodecNames) / sizeof(aCodecNames[0]);
int64_t nCodecs = (int64_t)tmedia_codec_id_none;
tsk_params_L_t* pParams;
int nPriority = 0;

if((pParams = tsk_params_fromstring(pcCodecs, ";", tsk_true)))
{
const tsk_list_item_t* item;
tsk_list_foreach(item, pParams)
{
const char* pcCodecName = ((const tsk_param_t*)item->data)->name;
for(i = 0; i < nCodecsCount; ++i)
{
if(tsk_striequals(aCodecNames[i].name, pcCodecName))
{
nCodecs |= (int64_t)aCodecNames[i].id;
if(!tdav_codec_is_supported((tdav_codec_id_t)aCodecNames[i].id)){
TSK_DEBUG_INFO("'%s' codec enabled but not supported", aCodecNames[i].name);
}
else{
tdav_codec_set_priority((tdav_codec_id_t)aCodecNames[i].id, nPriority++);
}
break;
}
}
}
if((pParams = tsk_params_fromstring(pcCodecs, ";", tsk_true)))
{
const tsk_list_item_t* item;
tsk_list_foreach(item, pParams)
{
const char* pcCodecName = ((const tsk_param_t*)item->data)->name;
for(i = 0; i < nCodecsCount; ++i)
{
if(tsk_striequals(aCodecNames[i].name, pcCodecName))
{
nCodecs |= (int64_t)aCodecNames[i].id;
if(!tdav_codec_is_supported((tdav_codec_id_t)aCodecNames[i].id)){
TSK_DEBUG_INFO("'%s' codec enabled but not supported", aCodecNames[i].name);
}
else{
tdav_codec_set_priority((tdav_codec_id_t)aCodecNames[i].id, nPriority++);
}
break;
}
}
}
}

TSK_OBJECT_SAFE_FREE(pParams);
Expand Down Expand Up @@ -607,6 +638,7 @@ bool MPEngine::start()
// start SIP stack
if(const_cast<SipStack*>(m_oSipStack->getWrappedStack())->start())
{
//const_cast<SipStack*>(m_oSipStack->getWrappedStack())->setRtpPortRange(RtpPortStart(), RtpPortStop());
setStarted(true);
}
else
Expand Down Expand Up @@ -680,6 +712,32 @@ bool MPEngine::stop()
return (ret == 0);
}


bool MPEngine::setRtpPort(uint16_t start, uint16_t stop){

if(start < 1024 || stop < 1024 || start >= stop) {
TSK_DEBUG_ERROR("Invalid parameter: (%u < 1024 || %u < 1024 || %u >= %u)", start, stop, start, stop);
return false;
}

this->port_range_start = start;
this->port_range_stop = stop;

const_cast<SipStack*>(m_oSipStack->getWrappedStack())->setRtpPortRange(start, stop);

return true;
//return const_cast<SipStack*>(m_oSipStack->getWrappedStack())->setRtpPortRange(start, stop);
}


uint16_t MPEngine::RtpPortStart(){
return this->port_range_start;
}

uint16_t MPEngine::RtpPortStop(){
return this->port_range_stop;
}

MPObjectWrapper<MPPeer*> MPEngine::getPeerById(uint64_t nId)
{
MPObjectWrapper<MPPeer*> m_Peer = NULL;
Expand Down
8 changes: 8 additions & 0 deletions mp_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class MPEngine : public MPObject
virtual MP_INLINE bool isValid(){ return m_bValid; }
virtual MP_INLINE bool isStarted(){ return m_bStarted; }
virtual bool setDebugLevel(const char* pcLevel);
virtual bool setAppLogLevel(const char* pcLevel);
virtual bool addTransport(const char* pTransport, uint16_t nLocalPort, const char* pcLocalIP = tsk_null);
virtual bool setRtpSymetricEnabled(bool bEnabled);
virtual bool set100relEnabled(bool bEnabled);
Expand All @@ -61,6 +62,7 @@ class MPEngine : public MPObject
virtual bool setCodecs(const char* pcCodecs);
virtual bool setCodecOpusMaxRates(int32_t nPlaybackMaxRate, int32_t nCaptureMaxRate);
virtual bool setSRTPMode(const char* pcMode);
virtual bool setRtpPortRange(uint16_t, uint16_t);
virtual bool setSRTPType(const char* pcTypesCommaSep);
virtual bool setDtmfType(const char* pcDtmfType);
virtual bool setStunServer(const char* pcIP, unsigned short nPort, const char* pcUsrName, const char* pcUsrPwd);
Expand All @@ -80,6 +82,12 @@ class MPEngine : public MPObject

static MPObjectWrapper<MPEngine*> New();

virtual uint16_t RtpPortStart();
virtual uint16_t RtpPortStop();
virtual bool setRtpPort(uint16_t start, uint16_t stop);

uint16_t port_range_start;
uint16_t port_range_stop;

protected:
virtual MP_INLINE void setStarted(bool bStarted){ m_bStarted = bStarted; }
Expand Down
Loading