define a global null_frame object so when queueing a null frame, you don't

have to allocate one on the stack


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@9001 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.4
Russell Bryant 20 years ago
parent 18eac350af
commit e01861fafd

@ -206,7 +206,6 @@ enum volume_action {
}; };
static int admin_exec(struct ast_channel *chan, void *data); static int admin_exec(struct ast_channel *chan, void *data);
static struct ast_frame null_frame = { AST_FRAME_NULL, };
static void *recordthread(void *args); static void *recordthread(void *args);
@ -1574,7 +1573,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
if (conf->transpath[index]) { if (conf->transpath[index]) {
conf->transframe[index] = ast_translate(conf->transpath[index], conf->origframe, 0); conf->transframe[index] = ast_translate(conf->transpath[index], conf->origframe, 0);
if (!conf->transframe[index]) if (!conf->transframe[index])
conf->transframe[index] = &null_frame; conf->transframe[index] = &ast_null_frame;
} }
} }
} }

@ -1760,17 +1760,13 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
void *data; void *data;
int res; int res;
#endif #endif
static struct ast_frame null_frame = {
AST_FRAME_NULL,
};
ast_mutex_lock(&chan->lock); ast_mutex_lock(&chan->lock);
if (chan->masq) { if (chan->masq) {
if (ast_do_masquerade(chan)) { if (ast_do_masquerade(chan)) {
ast_log(LOG_WARNING, "Failed to perform masquerade\n"); ast_log(LOG_WARNING, "Failed to perform masquerade\n");
f = NULL; f = NULL;
} else } else
f = &null_frame; f = &ast_null_frame;
ast_mutex_unlock(&chan->lock); ast_mutex_unlock(&chan->lock);
return f; return f;
} }
@ -1838,8 +1834,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
chan->timingdata = NULL; chan->timingdata = NULL;
ast_mutex_unlock(&chan->lock); ast_mutex_unlock(&chan->lock);
} }
f = &null_frame; return &ast_null_frame;
return f;
} else } else
ast_log(LOG_NOTICE, "No/unknown event '%d' on timer for '%s'?\n", blah, chan->name); ast_log(LOG_NOTICE, "No/unknown event '%d' on timer for '%s'?\n", blah, chan->name);
} else } else
@ -1851,8 +1846,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
chan->generatordata = NULL; /* reset to let ast_write get through */ chan->generatordata = NULL; /* reset to let ast_write get through */
chan->generator->generate(chan, tmp, -1, -1); chan->generator->generate(chan, tmp, -1, -1);
chan->generatordata = tmp; chan->generatordata = tmp;
f = &null_frame; return &ast_null_frame;
return f;
} }
/* Check for pending read queue */ /* Check for pending read queue */
@ -1872,7 +1866,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
f = chan->tech->exception(chan); f = chan->tech->exception(chan);
else { else {
ast_log(LOG_WARNING, "Exception flag set on '%s', but no exception handler\n", chan->name); ast_log(LOG_WARNING, "Exception flag set on '%s', but no exception handler\n", chan->name);
f = &null_frame; f = &ast_null_frame;
} }
/* Clear the exception flag */ /* Clear the exception flag */
ast_clear_flag(chan, AST_FLAG_EXCEPTION); ast_clear_flag(chan, AST_FLAG_EXCEPTION);
@ -1898,7 +1892,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
if (f->subclass == AST_CONTROL_ANSWER) { if (f->subclass == AST_CONTROL_ANSWER) {
if (prestate == AST_STATE_UP) { if (prestate == AST_STATE_UP) {
ast_log(LOG_DEBUG, "Dropping duplicate answer!\n"); ast_log(LOG_DEBUG, "Dropping duplicate answer!\n");
f = &null_frame; f = &ast_null_frame;
} }
/* Answer the CDR */ /* Answer the CDR */
ast_setstate(chan, AST_STATE_UP); ast_setstate(chan, AST_STATE_UP);
@ -1912,7 +1906,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
chan->dtmfq[strlen(chan->dtmfq)] = f->subclass; chan->dtmfq[strlen(chan->dtmfq)] = f->subclass;
else else
ast_log(LOG_WARNING, "Dropping deferred DTMF digits on %s\n", chan->name); ast_log(LOG_WARNING, "Dropping deferred DTMF digits on %s\n", chan->name);
f = &null_frame; f = &ast_null_frame;
} }
break; break;
case AST_FRAME_DTMF_BEGIN: case AST_FRAME_DTMF_BEGIN:
@ -1924,14 +1918,14 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
case AST_FRAME_VOICE: case AST_FRAME_VOICE:
if (dropaudio) { if (dropaudio) {
ast_frfree(f); ast_frfree(f);
f = &null_frame; f = &ast_null_frame;
} else if (!(f->subclass & chan->nativeformats)) { } else if (!(f->subclass & chan->nativeformats)) {
/* This frame can't be from the current native formats -- drop it on the /* This frame can't be from the current native formats -- drop it on the
floor */ floor */
ast_log(LOG_NOTICE, "Dropping incompatible voice frame on %s of format %s since our native format has changed to %s\n", ast_log(LOG_NOTICE, "Dropping incompatible voice frame on %s of format %s since our native format has changed to %s\n",
chan->name, ast_getformatname(f->subclass), ast_getformatname(chan->nativeformats)); chan->name, ast_getformatname(f->subclass), ast_getformatname(chan->nativeformats));
ast_frfree(f); ast_frfree(f);
f = &null_frame; f = &ast_null_frame;
} else { } else {
if (chan->spies) if (chan->spies)
queue_frame_to_spies(chan, f, SPY_READ); queue_frame_to_spies(chan, f, SPY_READ);
@ -1962,7 +1956,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
if (chan->readtrans) { if (chan->readtrans) {
if (!(f = ast_translate(chan->readtrans, f, 1))) if (!(f = ast_translate(chan->readtrans, f, 1)))
f = &null_frame; f = &ast_null_frame;
} }
/* Run any generator sitting on the channel */ /* Run any generator sitting on the channel */
@ -3121,10 +3115,9 @@ int ast_do_masquerade(struct ast_channel *original)
); );
ast_channel_free(clone); ast_channel_free(clone);
} else { } else {
struct ast_frame null_frame = { AST_FRAME_NULL, };
ast_log(LOG_DEBUG, "Released clone lock on '%s'\n", clone->name); ast_log(LOG_DEBUG, "Released clone lock on '%s'\n", clone->name);
ast_set_flag(clone, AST_FLAG_ZOMBIE); ast_set_flag(clone, AST_FLAG_ZOMBIE);
ast_queue_frame(clone, &null_frame); ast_queue_frame(clone, &ast_null_frame);
ast_mutex_unlock(&clone->lock); ast_mutex_unlock(&clone->lock);
} }

@ -438,7 +438,6 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
{ {
struct agent_pvt *p = ast->tech_pvt; struct agent_pvt *p = ast->tech_pvt;
struct ast_frame *f = NULL; struct ast_frame *f = NULL;
static struct ast_frame null_frame = { AST_FRAME_NULL, };
static struct ast_frame answer_frame = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER }; static struct ast_frame answer_frame = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER };
const char *status; const char *status;
ast_mutex_lock(&p->lock); ast_mutex_lock(&p->lock);
@ -448,7 +447,7 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
p->chan->fdno = (ast->fdno == AST_AGENT_FD) ? AST_TIMING_FD : ast->fdno; p->chan->fdno = (ast->fdno == AST_AGENT_FD) ? AST_TIMING_FD : ast->fdno;
f = ast_read(p->chan); f = ast_read(p->chan);
} else } else
f = &null_frame; f = &ast_null_frame;
if (!f) { if (!f) {
/* If there's a channel, hang it up (if it's on a callback) make it NULL */ /* If there's a channel, hang it up (if it's on a callback) make it NULL */
if (p->chan) { if (p->chan) {
@ -486,7 +485,7 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
ast_verbose(VERBOSE_PREFIX_3 "%s answered, waiting for '#' to acknowledge\n", p->chan->name); ast_verbose(VERBOSE_PREFIX_3 "%s answered, waiting for '#' to acknowledge\n", p->chan->name);
/* Don't pass answer along */ /* Don't pass answer along */
ast_frfree(f); ast_frfree(f);
f = &null_frame; f = &ast_null_frame;
} else { } else {
p->acknowledged = 1; p->acknowledged = 1;
/* Use the builtin answer frame for the /* Use the builtin answer frame for the
@ -513,7 +512,7 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
/* don't pass voice until the call is acknowledged */ /* don't pass voice until the call is acknowledged */
if (!p->acknowledged) { if (!p->acknowledged) {
ast_frfree(f); ast_frfree(f);
f = &null_frame; f = &ast_null_frame;
} }
break; break;
} }
@ -899,7 +898,6 @@ static struct ast_channel *agent_bridgedchannel(struct ast_channel *chan, struct
static struct ast_channel *agent_new(struct agent_pvt *p, int state) static struct ast_channel *agent_new(struct agent_pvt *p, int state)
{ {
struct ast_channel *tmp; struct ast_channel *tmp;
struct ast_frame null_frame = { AST_FRAME_NULL };
#if 0 #if 0
if (!p->chan) { if (!p->chan) {
ast_log(LOG_WARNING, "No channel? :(\n"); ast_log(LOG_WARNING, "No channel? :(\n");
@ -950,7 +948,7 @@ static struct ast_channel *agent_new(struct agent_pvt *p, int state)
if( ast_mutex_trylock(&p->app_lock) ) if( ast_mutex_trylock(&p->app_lock) )
{ {
if (p->chan) { if (p->chan) {
ast_queue_frame(p->chan, &null_frame); ast_queue_frame(p->chan, &ast_null_frame);
ast_mutex_unlock(&p->lock); /* For other thread to read the condition. */ ast_mutex_unlock(&p->lock); /* For other thread to read the condition. */
ast_mutex_lock(&p->app_lock); ast_mutex_lock(&p->app_lock);
ast_mutex_lock(&p->lock); ast_mutex_lock(&p->lock);

@ -241,12 +241,11 @@ static int features_answer(struct ast_channel *ast)
static struct ast_frame *features_read(struct ast_channel *ast) static struct ast_frame *features_read(struct ast_channel *ast)
{ {
static struct ast_frame null_frame = { AST_FRAME_NULL, };
struct feature_pvt *p = ast->tech_pvt; struct feature_pvt *p = ast->tech_pvt;
struct ast_frame *f; struct ast_frame *f;
int x; int x;
f = &null_frame; f = &ast_null_frame;
ast_mutex_lock(&p->lock); ast_mutex_lock(&p->lock);
x = indexof(p, ast, 0); x = indexof(p, ast, 0);
if (!x && p->subchan) { if (!x && p->subchan) {

@ -543,7 +543,6 @@ static struct ast_frame *oh323_rtp_read(struct oh323_pvt *pvt)
{ {
/* Retrieve audio/etc from channel. Assumes pvt->lock is already held. */ /* Retrieve audio/etc from channel. Assumes pvt->lock is already held. */
struct ast_frame *f; struct ast_frame *f;
static struct ast_frame null_frame = { AST_FRAME_NULL, };
/* Only apply it for the first packet, we just need the correct ip/port */ /* Only apply it for the first packet, we just need the correct ip/port */
if (pvt->options.nat) { if (pvt->options.nat) {
@ -554,7 +553,7 @@ static struct ast_frame *oh323_rtp_read(struct oh323_pvt *pvt)
f = ast_rtp_read(pvt->rtp); f = ast_rtp_read(pvt->rtp);
/* Don't send RFC2833 if we're not supposed to */ /* Don't send RFC2833 if we're not supposed to */
if (f && (f->frametype == AST_FRAME_DTMF) && !(pvt->options.dtmfmode & H323_DTMF_RFC2833)) { if (f && (f->frametype == AST_FRAME_DTMF) && !(pvt->options.dtmfmode & H323_DTMF_RFC2833)) {
return &null_frame; return &ast_null_frame;
} }
if (pvt->owner) { if (pvt->owner) {
/* We already hold the channel lock */ /* We already hold the channel lock */
@ -563,7 +562,7 @@ static struct ast_frame *oh323_rtp_read(struct oh323_pvt *pvt)
/* Try to avoid deadlock */ /* Try to avoid deadlock */
if (ast_mutex_trylock(&pvt->owner->lock)) { if (ast_mutex_trylock(&pvt->owner->lock)) {
ast_log(LOG_NOTICE, "Format changed but channel is locked. Ignoring frame...\n"); ast_log(LOG_NOTICE, "Format changed but channel is locked. Ignoring frame...\n");
return &null_frame; return &ast_null_frame;
} }
ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass); ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
pvt->owner->nativeformats = f->subclass; pvt->owner->nativeformats = f->subclass;

@ -1219,12 +1219,11 @@ static struct ast_frame *mgcp_rtp_read(struct mgcp_subchannel *sub)
{ {
/* Retrieve audio/etc from channel. Assumes sub->lock is already held. */ /* Retrieve audio/etc from channel. Assumes sub->lock is already held. */
struct ast_frame *f; struct ast_frame *f;
static struct ast_frame null_frame = { AST_FRAME_NULL, };
f = ast_rtp_read(sub->rtp); f = ast_rtp_read(sub->rtp);
/* Don't send RFC2833 if we're not supposed to */ /* Don't send RFC2833 if we're not supposed to */
if (f && (f->frametype == AST_FRAME_DTMF) && !(sub->parent->dtmfmode & MGCP_DTMF_RFC2833)) if (f && (f->frametype == AST_FRAME_DTMF) && !(sub->parent->dtmfmode & MGCP_DTMF_RFC2833))
return &null_frame; return &ast_null_frame;
if (sub->owner) { if (sub->owner) {
/* We already hold the channel lock */ /* We already hold the channel lock */
if (f->frametype == AST_FRAME_VOICE) { if (f->frametype == AST_FRAME_VOICE) {

@ -3051,11 +3051,10 @@ static struct ast_frame *sip_rtp_read(struct ast_channel *ast, struct sip_pvt *p
{ {
/* Retrieve audio/etc from channel. Assumes p->lock is already held. */ /* Retrieve audio/etc from channel. Assumes p->lock is already held. */
struct ast_frame *f; struct ast_frame *f;
static struct ast_frame null_frame = { AST_FRAME_NULL, };
if (!p->rtp) { if (!p->rtp) {
/* We have no RTP allocated for this channel */ /* We have no RTP allocated for this channel */
return &null_frame; return &ast_null_frame;
} }
switch(ast->fdno) { switch(ast->fdno) {
@ -3072,11 +3071,11 @@ static struct ast_frame *sip_rtp_read(struct ast_channel *ast, struct sip_pvt *p
f = ast_rtcp_read(p->vrtp); /* RTCP Control Channel for video */ f = ast_rtcp_read(p->vrtp); /* RTCP Control Channel for video */
break; break;
default: default:
f = &null_frame; f = &ast_null_frame;
} }
/* Don't forward RFC2833 if we're not supposed to */ /* Don't forward RFC2833 if we're not supposed to */
if (f && (f->frametype == AST_FRAME_DTMF) && (ast_test_flag(p, SIP_DTMF) != SIP_DTMF_RFC2833)) if (f && (f->frametype == AST_FRAME_DTMF) && (ast_test_flag(p, SIP_DTMF) != SIP_DTMF_RFC2833))
return &null_frame; return &ast_null_frame;
if (p->owner) { if (p->owner) {
/* We already hold the channel lock */ /* We already hold the channel lock */

@ -56,13 +56,6 @@ AST_MUTEX_DEFINE_STATIC(framelock);
#define TYPE_DONTSEND 0x3 #define TYPE_DONTSEND 0x3
#define TYPE_MASK 0x3 #define TYPE_MASK 0x3
struct ast_format_list {
int visible; /*!< Can we see this entry */
int bits; /*!< bitmask value */
char *name; /*!< short name */
char *desc; /*!< Description */
};
struct ast_smoother { struct ast_smoother {
int size; int size;
int format; int format;
@ -79,7 +72,12 @@ struct ast_smoother {
}; };
/*! \brief Definition of supported media formats (codecs) */ /*! \brief Definition of supported media formats (codecs) */
static struct ast_format_list AST_FORMAT_LIST[] = { static struct ast_format_list {
int visible; /*!< Can we see this entry */
int bits; /*!< bitmask value */
char *name; /*!< short name */
char *desc; /*!< Description */
} AST_FORMAT_LIST[] = {
{ 1, AST_FORMAT_G723_1 , "g723" , "G.723.1"}, /*!< codec_g723_1.c */ { 1, AST_FORMAT_G723_1 , "g723" , "G.723.1"}, /*!< codec_g723_1.c */
{ 1, AST_FORMAT_GSM, "gsm" , "GSM"}, /*!< codec_gsm.c */ { 1, AST_FORMAT_GSM, "gsm" , "GSM"}, /*!< codec_gsm.c */
{ 1, AST_FORMAT_ULAW, "ulaw", "G.711 u-law" }, /*!< codec_ulaw.c */ { 1, AST_FORMAT_ULAW, "ulaw", "G.711 u-law" }, /*!< codec_ulaw.c */
@ -108,6 +106,8 @@ static struct ast_format_list AST_FORMAT_LIST[] = {
{ 0, AST_FORMAT_MAX_VIDEO, "maxvideo", "Maximum video format" }, { 0, AST_FORMAT_MAX_VIDEO, "maxvideo", "Maximum video format" },
}; };
struct ast_frame ast_null_frame = { AST_FRAME_NULL, };
void ast_smoother_reset(struct ast_smoother *s, int size) void ast_smoother_reset(struct ast_smoother *s, int size)
{ {
memset(s, 0, sizeof(struct ast_smoother)); memset(s, 0, sizeof(struct ast_smoother));

@ -111,6 +111,10 @@ struct ast_frame {
struct ast_frame *next; struct ast_frame *next;
}; };
/*! Queueing a null frame is fairly common, so we declare a global null frame object
for this purpose instead of having to declare one on the stack */
extern struct ast_frame ast_null_frame;
#define AST_FRIENDLY_OFFSET 64 /*! It's polite for a a new frame to #define AST_FRIENDLY_OFFSET 64 /*! It's polite for a a new frame to
have this number of bytes for additional have this number of bytes for additional
headers. */ headers. */

32
rtp.c

@ -174,7 +174,6 @@ void ast_rtp_setnat(struct ast_rtp *rtp, int nat)
static struct ast_frame *send_dtmf(struct ast_rtp *rtp) static struct ast_frame *send_dtmf(struct ast_rtp *rtp)
{ {
static struct ast_frame null_frame = { AST_FRAME_NULL, };
char iabuf[INET_ADDRSTRLEN]; char iabuf[INET_ADDRSTRLEN];
if (ast_tvcmp(ast_tvnow(), rtp->dtmfmute) < 0) { if (ast_tvcmp(ast_tvnow(), rtp->dtmfmute) < 0) {
@ -182,7 +181,7 @@ static struct ast_frame *send_dtmf(struct ast_rtp *rtp)
ast_log(LOG_DEBUG, "Ignore potential DTMF echo from '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr)); ast_log(LOG_DEBUG, "Ignore potential DTMF echo from '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr));
rtp->resp = 0; rtp->resp = 0;
rtp->dtmfduration = 0; rtp->dtmfduration = 0;
return &null_frame; return &ast_null_frame;
} }
if (option_debug) if (option_debug)
ast_log(LOG_DEBUG, "Sending dtmf: %d (%c), at %s\n", rtp->resp, rtp->resp, ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr)); ast_log(LOG_DEBUG, "Sending dtmf: %d (%c), at %s\n", rtp->resp, rtp->resp, ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr));
@ -364,7 +363,6 @@ static int rtpread(int *id, int fd, short events, void *cbdata)
struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp) struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
{ {
static struct ast_frame null_frame = { AST_FRAME_NULL, };
socklen_t len; socklen_t len;
int hdrlen = 8; int hdrlen = 8;
int res; int res;
@ -373,7 +371,7 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
char iabuf[INET_ADDRSTRLEN]; char iabuf[INET_ADDRSTRLEN];
if (!rtp || !rtp->rtcp) if (!rtp || !rtp->rtcp)
return &null_frame; return &ast_null_frame;
len = sizeof(sin); len = sizeof(sin);
@ -385,12 +383,12 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
ast_log(LOG_WARNING, "RTP Read error: %s\n", strerror(errno)); ast_log(LOG_WARNING, "RTP Read error: %s\n", strerror(errno));
if (errno == EBADF) if (errno == EBADF)
CRASH; CRASH;
return &null_frame; return &ast_null_frame;
} }
if (res < hdrlen) { if (res < hdrlen) {
ast_log(LOG_WARNING, "RTP Read too short\n"); ast_log(LOG_WARNING, "RTP Read too short\n");
return &null_frame; return &ast_null_frame;
} }
if (rtp->nat) { if (rtp->nat) {
@ -404,7 +402,7 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
} }
if (option_debug) if (option_debug)
ast_log(LOG_DEBUG, "Got RTCP report of %d bytes\n", res); ast_log(LOG_DEBUG, "Got RTCP report of %d bytes\n", res);
return &null_frame; return &ast_null_frame;
} }
static void calc_rxstamp(struct timeval *tv, struct ast_rtp *rtp, unsigned int timestamp, int mark) static void calc_rxstamp(struct timeval *tv, struct ast_rtp *rtp, unsigned int timestamp, int mark)
@ -434,7 +432,7 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
char iabuf[INET_ADDRSTRLEN]; char iabuf[INET_ADDRSTRLEN];
unsigned int timestamp; unsigned int timestamp;
unsigned int *rtpheader; unsigned int *rtpheader;
static struct ast_frame *f, null_frame = { AST_FRAME_NULL, }; static struct ast_frame *f;
struct rtpPayloadType rtpPT; struct rtpPayloadType rtpPT;
len = sizeof(sin); len = sizeof(sin);
@ -450,17 +448,17 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
ast_log(LOG_WARNING, "RTP Read error: %s\n", strerror(errno)); ast_log(LOG_WARNING, "RTP Read error: %s\n", strerror(errno));
if (errno == EBADF) if (errno == EBADF)
CRASH; CRASH;
return &null_frame; return &ast_null_frame;
} }
if (res < hdrlen) { if (res < hdrlen) {
ast_log(LOG_WARNING, "RTP Read too short\n"); ast_log(LOG_WARNING, "RTP Read too short\n");
return &null_frame; return &ast_null_frame;
} }
/* Ignore if the other side hasn't been given an address /* Ignore if the other side hasn't been given an address
yet. */ yet. */
if (!rtp->them.sin_addr.s_addr || !rtp->them.sin_port) if (!rtp->them.sin_addr.s_addr || !rtp->them.sin_port)
return &null_frame; return &ast_null_frame;
if (rtp->nat) { if (rtp->nat) {
/* Send to whoever sent to us */ /* Send to whoever sent to us */
@ -480,7 +478,7 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
/* Check RTP version */ /* Check RTP version */
version = (seqno & 0xC0000000) >> 30; version = (seqno & 0xC0000000) >> 30;
if (version != 2) if (version != 2)
return &null_frame; return &ast_null_frame;
payloadtype = (seqno & 0x7f0000) >> 16; payloadtype = (seqno & 0x7f0000) >> 16;
padding = seqno & (1 << 29); padding = seqno & (1 << 29);
@ -502,7 +500,7 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
if (res < hdrlen) { if (res < hdrlen) {
ast_log(LOG_WARNING, "RTP Read too short (%d, expecting %d)\n", res, hdrlen); ast_log(LOG_WARNING, "RTP Read too short (%d, expecting %d)\n", res, hdrlen);
return &null_frame; return &ast_null_frame;
} }
if(rtp_debug_test_addr(&sin)) if(rtp_debug_test_addr(&sin))
@ -537,7 +535,7 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
if (f) if (f)
return f; return f;
else else
return &null_frame; return &ast_null_frame;
} else if (rtpPT.code == AST_RTP_CISCO_DTMF) { } else if (rtpPT.code == AST_RTP_CISCO_DTMF) {
/* It's really special -- process it the Cisco way */ /* It's really special -- process it the Cisco way */
if (rtp->lasteventseqn <= seqno || rtp->resp == 0 || (rtp->lasteventseqn >= 65530 && seqno <= 6)) { if (rtp->lasteventseqn <= seqno || rtp->resp == 0 || (rtp->lasteventseqn >= 65530 && seqno <= 6)) {
@ -548,17 +546,17 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
if (f) if (f)
return f; return f;
else else
return &null_frame; return &ast_null_frame;
} else if (rtpPT.code == AST_RTP_CN) { } else if (rtpPT.code == AST_RTP_CN) {
/* Comfort Noise */ /* Comfort Noise */
f = process_rfc3389(rtp, rtp->rawdata + AST_FRIENDLY_OFFSET + hdrlen, res - hdrlen); f = process_rfc3389(rtp, rtp->rawdata + AST_FRIENDLY_OFFSET + hdrlen, res - hdrlen);
if (f) if (f)
return f; return f;
else else
return &null_frame; return &ast_null_frame;
} else { } else {
ast_log(LOG_NOTICE, "Unknown RTP codec %d received\n", payloadtype); ast_log(LOG_NOTICE, "Unknown RTP codec %d received\n", payloadtype);
return &null_frame; return &ast_null_frame;
} }
} }
rtp->f.subclass = rtpPT.code; rtp->f.subclass = rtpPT.code;

@ -645,7 +645,6 @@ struct ast_frame *ast_udptl_read(struct ast_udptl *udptl)
uint16_t seqno = 0; uint16_t seqno = 0;
char iabuf[INET_ADDRSTRLEN]; char iabuf[INET_ADDRSTRLEN];
uint16_t *udptlheader; uint16_t *udptlheader;
static struct ast_frame null_frame = { AST_FRAME_NULL, };
len = sizeof(sin); len = sizeof(sin);
@ -662,12 +661,12 @@ struct ast_frame *ast_udptl_read(struct ast_udptl *udptl)
ast_log(LOG_WARNING, "UDPTL read error: %s\n", strerror(errno)); ast_log(LOG_WARNING, "UDPTL read error: %s\n", strerror(errno));
if (errno == EBADF) if (errno == EBADF)
CRASH; CRASH;
return &null_frame; return &ast_null_frame;
} }
/* Ignore if the other side hasn't been given an address yet. */ /* Ignore if the other side hasn't been given an address yet. */
if (!udptl->them.sin_addr.s_addr || !udptl->them.sin_port) if (!udptl->them.sin_addr.s_addr || !udptl->them.sin_port)
return &null_frame; return &ast_null_frame;
if (udptl->nat) { if (udptl->nat) {
/* Send to whoever sent to us */ /* Send to whoever sent to us */

Loading…
Cancel
Save