o SEMS-7: RTP extension headers may be ignored if ignore_rtpxheaders=yes set in config file
 o if changing payload type fails, packet will not be processed
 o minor code beautification and comments added/corrected



git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@418 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Stefan Sayer 19 years ago
parent 0d9ddae975
commit 019791dd09

@ -59,7 +59,7 @@ AmAudioRtpFormat::AmAudioRtpFormat(const vector<SdpPayload *>& payloads)
setCurrentPayload(m_payloads[0]->payload_type);
}
void AmAudioRtpFormat::setCurrentPayload(int payload)
int AmAudioRtpFormat::setCurrentPayload(int payload)
{
if (m_currentPayload != payload)
{
@ -67,7 +67,7 @@ void AmAudioRtpFormat::setCurrentPayload(int payload)
if (p == m_sdpPayloadByPayload.end())
{
ERROR("Could not find payload <%i>\n", payload);
return;
return -1;
}
map<int, amci_payload_t *>::iterator pp = m_payloadPByPayload.find(payload);
if (pp == m_payloadPByPayload.end())
@ -76,7 +76,7 @@ void AmAudioRtpFormat::setCurrentPayload(int payload)
if (m_currentPayloadP == NULL)
{
ERROR("Could not find payload <%i>\n", payload);
return;
return -1;
}
m_payloadPByPayload[payload] = m_currentPayloadP;
}
@ -114,8 +114,10 @@ void AmAudioRtpFormat::setCurrentPayload(int payload)
rate = m_currentPayloadP->sample_rate;
} else {
ERROR("Could not find payload <%i>\n", payload);
return -1;
}
}
return 0;
}
AmAudioRtpFormat::~AmAudioRtpFormat()

@ -230,7 +230,10 @@ public:
AmAudioRtpFormat(const vector<SdpPayload *>& payloads);
~AmAudioRtpFormat();
void setCurrentPayload(int payload);
/**
* changes payload. returns != 0 on error.
*/
int setCurrentPayload(int payload);
};
/**

@ -58,6 +58,8 @@ string AmConfig::LocalSIPIP = "";
string AmConfig::Signature = "";
bool AmConfig::SingleCodecInOK = false;
unsigned int AmConfig::DeadRtpTime = DEAD_RTP_TIME;
bool AmConfig::IgnoreRTPXHdrs = false;
vector <string> AmConfig::CodecOrder;
AmSessionTimerConfig AmConfig::defaultSessionTimerConfig;
@ -257,6 +259,11 @@ int AmConfig::readConfiguration()
SingleCodecInOK = (cfg.getParameter("single_codec_in_ok") == "yes");
}
// single codec in 200 OK
if(cfg.hasParameter("ignore_rtpxheaders")){
IgnoreRTPXHdrs = (cfg.getParameter("ignore_rtpxheaders") == "yes");
}
// codec_order
CodecOrder = explode(cfg.getParameter("codec_order"), ",");

@ -92,6 +92,9 @@ struct AmConfig
/** Time of no RTP after which Session is regarded as dead, 0 for no Timeout */
static unsigned int DeadRtpTime;
/** Ignore RTP Extension headers? */
static bool IgnoreRTPXHdrs;
/** Init function. Resolves SMTP server address. */
static int init();

@ -31,6 +31,7 @@
#include "AmApi.h"
#include "AmInterfaceHandler.h"
#include "AmUtils.h"
#include "AmSdp.h"
#include "amci/amci.h"
#include "amci/codecs.h"
@ -96,7 +97,7 @@ amci_payload_t _payload_tevent = {
AmPlugIn* AmPlugIn::_instance=0;
AmPlugIn::AmPlugIn()
: dynamic_pl(96) // range: 96->127, see RFC 1890
: dynamic_pl(DYNAMIC_PAYLOAD_TYPE_START)
{
DBG("adding built-in codecs...\n");
addCodec(&_codec_pcm16);

@ -84,9 +84,13 @@ int AmRtpAudio::receive(unsigned int wallclock_ts)
if(size <= 0)
break;
setCurrentPayload(payload);
if(send_only){
if (// don't process if we don't need to
send_only ||
// ignore CN
COMFORT_NOISE_PAYLOAD_TYPE == payload ||
// ignore packet if payload not found
setCurrentPayload(payload)
){
playout_buffer->clearLastTs();
continue;
}
@ -133,11 +137,15 @@ void AmRtpAudio::init(const vector<SdpPayload*>& sdp_payloads)
fmt.reset(new AmAudioRtpFormat(sdp_payloads));
}
void AmRtpAudio::setCurrentPayload(int payload)
int AmRtpAudio::setCurrentPayload(int payload)
{
((AmAudioRtpFormat *) fmt.get())->setCurrentPayload(payload);
amci_codec_t* codec = fmt->getCodec();
use_default_plc = !(codec && codec->plc);
int res =
((AmAudioRtpFormat *) fmt.get())->setCurrentPayload(payload);
if (!res) {
amci_codec_t* codec = fmt->getCodec();
use_default_plc = !(codec && codec->plc);
}
return res;
}
unsigned int AmRtpAudio::conceal_loss(unsigned int ts_diff, unsigned char *buffer)

@ -88,7 +88,7 @@ public:
bool checkInterval(unsigned int ts);
bool sendIntReached();
void setCurrentPayload(int payload);
int setCurrentPayload(int payload);
int receive(unsigned int wallclock_ts);

@ -28,6 +28,7 @@
#include "AmRtpPacket.h"
#include "rtp/rtp.h"
#include "log.h"
#include "AmConfig.h"
#include <assert.h>
#include <string.h>
@ -88,9 +89,19 @@ int AmRtpPacket::parse()
return -1;
}
data_offset = sizeof(rtp_hdr_t) + (hdr->cc*4);
if(hdr->x != 0){
DBG("RTP extension headers not supported.\n");
return -1;
if (AmConfig::IgnoreRTPXHdrs) {
// skip the extension header
if (b_size >= data_offset + 4) {
data_offset +=
ntohs(((rtp_xhdr_t*) (buffer + data_offset))->len)*4;
}
} else {
DBG("RTP extension headers not supported.\n");
return -1;
}
}
payload = hdr->pt;
@ -99,7 +110,6 @@ int AmRtpPacket::parse()
timestamp = ntohl(hdr->ts);
ssrc = ntohl(hdr->ssrc);
data_offset = sizeof(rtp_hdr_t) + (hdr->cc*4);
if (data_offset >= b_size) {
ERROR("bad rtp packet (header size too big) !\n");
return -1;

@ -308,7 +308,7 @@ const vector<SdpPayload *>& AmSdp::getCompatiblePayloads(int media_type, string&
for(; it != m_it->payloads.end(); ++it ) {
amci_payload_t* a_pl = NULL;
if(it->payload_type < 96){
if(it->payload_type < DYNAMIC_PAYLOAD_TYPE_START){
// try static payloads
a_pl = pi->payload(it->payload_type);
}

@ -36,6 +36,8 @@ using std::map;
using std::vector;
#define COMFORT_NOISE_PAYLOAD_TYPE 13 // RFC 3389
#define DYNAMIC_PAYLOAD_TYPE_START 96 // range: 96->127, see RFC 1890
/**
* @file AmSdp.h
* Definitions for the SDP parser.

@ -70,4 +70,9 @@ typedef struct {
u_int32 ssrc; /* synchronization source */
} rtp_hdr_t;
typedef struct {
u_int16 profile; /* xhdr type */
u_int16 len; /* xhdr length */
} rtp_xhdr_t;
#endif

@ -81,12 +81,12 @@ smtp_port=25
# optional parameter: rtp_low_port=<port>
#
# - sets port of rtp lowest server
# - sets lowest for RTP used port
rtp_low_port=10000
# optional parameter: rtp_high_port=<port>
#
# - sets port of rtp highest server
# - sets highest for RTP used port
rtp_high_port=60000
# optional parameter: media_processor_threads=<num_value>
@ -174,4 +174,16 @@ media_processor_threads=1
#
# default=empty
#
# codec_order=iLBC,GSM
# codec_order=iLBC,GSM
# optional parameter: ignore_rtpxheaders={yes|no}
#
# - if this is set to yes, RTP extension headers (e.g. when using ZRTP)
# are ignored. If set to no, the whole RTP packets with extension
# headers will be ignored and a debug message is printed on every
# received packet.
#
# default=no
#
# ignore_rtpxheaders=yes

Loading…
Cancel
Save