summaryrefslogtreecommitdiff
path: root/channels
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2009-04-02 17:20:52 +0000
committerJoshua Colp <jcolp@digium.com>2009-04-02 17:20:52 +0000
commit63de8343958b91c8836c5e6ddf1c0106b40e9fe6 (patch)
tree8a8042738e1c444e5988a648b795c4d2b02febd1 /channels
parent08971ce2056f4e035b4b37324c7f184370cd0ec6 (diff)
Merge in the RTP engine API.
This API provides a generic way for multiple RTP stacks to be integrated into Asterisk. Right now there is only one present, res_rtp_asterisk, which is the existing Asterisk RTP stack. Functionality wise this commit performs the same as previously. API documentation can be viewed in the rtp_engine.h header file. Review: http://reviewboard.digium.com/r/209/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@186078 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_agent.c1
-rw-r--r--channels/chan_bridge.c1
-rw-r--r--channels/chan_gtalk.c95
-rw-r--r--channels/chan_h323.c105
-rw-r--r--channels/chan_jingle.c79
-rw-r--r--channels/chan_local.c1
-rw-r--r--channels/chan_mgcp.c94
-rw-r--r--channels/chan_sip.c1070
-rw-r--r--channels/chan_skinny.c99
-rw-r--r--channels/chan_unistim.c93
10 files changed, 805 insertions, 833 deletions
diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index 4e1c28240..b15f7a04e 100644
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -52,7 +52,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/pbx.h"
#include "asterisk/sched.h"
#include "asterisk/io.h"
-#include "asterisk/rtp.h"
#include "asterisk/acl.h"
#include "asterisk/callerid.h"
#include "asterisk/file.h"
diff --git a/channels/chan_bridge.c b/channels/chan_bridge.c
index 84909e795..bd1d0fbee 100644
--- a/channels/chan_bridge.c
+++ b/channels/chan_bridge.c
@@ -39,7 +39,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/pbx.h"
#include "asterisk/sched.h"
#include "asterisk/io.h"
-#include "asterisk/rtp.h"
#include "asterisk/acl.h"
#include "asterisk/callerid.h"
#include "asterisk/file.h"
diff --git a/channels/chan_gtalk.c b/channels/chan_gtalk.c
index d608cc05c..f63cc2027 100644
--- a/channels/chan_gtalk.c
+++ b/channels/chan_gtalk.c
@@ -52,7 +52,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/pbx.h"
#include "asterisk/sched.h"
#include "asterisk/io.h"
-#include "asterisk/rtp.h"
+#include "asterisk/rtp_engine.h"
+#include "asterisk/stun.h"
#include "asterisk/acl.h"
#include "asterisk/callerid.h"
#include "asterisk/file.h"
@@ -112,8 +113,8 @@ struct gtalk_pvt {
char cid_name[80]; /*!< Caller ID name */
char exten[80]; /*!< Called extension */
struct ast_channel *owner; /*!< Master Channel */
- struct ast_rtp *rtp; /*!< RTP audio session */
- struct ast_rtp *vrtp; /*!< RTP video session */
+ struct ast_rtp_instance *rtp; /*!< RTP audio session */
+ struct ast_rtp_instance *vrtp; /*!< RTP video session */
int jointcapability; /*!< Supported capability at both ends (codecs ) */
int peercapability;
struct gtalk_pvt *next; /* Next entity */
@@ -183,11 +184,6 @@ static int gtalk_sendhtml(struct ast_channel *ast, int subclass, const char *dat
static struct gtalk_pvt *gtalk_alloc(struct gtalk *client, const char *us, const char *them, const char *sid);
static char *gtalk_do_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
static char *gtalk_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
-/*----- RTP interface functions */
-static int gtalk_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp,
- struct ast_rtp *vrtp, struct ast_rtp *trtp, int codecs, int nat_active);
-static enum ast_rtp_get_result gtalk_get_rtp_peer(struct ast_channel *chan, struct ast_rtp **rtp);
-static int gtalk_get_codec(struct ast_channel *chan);
/*! \brief PBX interface structure for channel registration */
static const struct ast_channel_tech gtalk_tech = {
@@ -197,7 +193,7 @@ static const struct ast_channel_tech gtalk_tech = {
.requester = gtalk_request,
.send_digit_begin = gtalk_digit_begin,
.send_digit_end = gtalk_digit_end,
- .bridge = ast_rtp_bridge,
+ .bridge = ast_rtp_instance_bridge,
.call = gtalk_call,
.hangup = gtalk_hangup,
.answer = gtalk_answer,
@@ -216,14 +212,6 @@ static struct sched_context *sched; /*!< The scheduling context */
static struct io_context *io; /*!< The IO context */
static struct in_addr __ourip;
-/*! \brief RTP driver interface */
-static struct ast_rtp_protocol gtalk_rtp = {
- type: "Gtalk",
- get_rtp_info: gtalk_get_rtp_peer,
- set_rtp_peer: gtalk_set_rtp_peer,
- get_codec: gtalk_get_codec,
-};
-
static struct ast_cli_entry gtalk_cli[] = {
AST_CLI_DEFINE(gtalk_do_reload, "Reload GoogleTalk configuration"),
AST_CLI_DEFINE(gtalk_show_channels, "Show GoogleTalk channels"),
@@ -371,7 +359,7 @@ static int add_codec_to_answer(const struct gtalk_pvt *p, int codec, iks *dcodec
iks_insert_node(dcodecs, payload_gsm);
res++;
}
- ast_rtp_lookup_code(p->rtp, 1, codec);
+
return res;
}
@@ -523,18 +511,19 @@ static int gtalk_answer(struct ast_channel *ast)
return res;
}
-static enum ast_rtp_get_result gtalk_get_rtp_peer(struct ast_channel *chan, struct ast_rtp **rtp)
+static enum ast_rtp_glue_result gtalk_get_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance **instance)
{
struct gtalk_pvt *p = chan->tech_pvt;
- enum ast_rtp_get_result res = AST_RTP_GET_FAILED;
+ enum ast_rtp_glue_result res = AST_RTP_GLUE_RESULT_FORBID;
if (!p)
return res;
ast_mutex_lock(&p->lock);
if (p->rtp){
- *rtp = p->rtp;
- res = AST_RTP_TRY_PARTIAL;
+ ao2_ref(p->rtp, +1);
+ *instance = p->rtp;
+ res = AST_RTP_GLUE_RESULT_LOCAL;
}
ast_mutex_unlock(&p->lock);
@@ -547,7 +536,7 @@ static int gtalk_get_codec(struct ast_channel *chan)
return p->peercapability;
}
-static int gtalk_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, struct ast_rtp *trtp, int codecs, int nat_active)
+static int gtalk_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *rtp, struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, int codecs, int nat_active)
{
struct gtalk_pvt *p;
@@ -567,6 +556,13 @@ static int gtalk_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, str
return 0;
}
+static struct ast_rtp_glue gtalk_rtp_glue = {
+ .type = "Gtalk",
+ .get_rtp_info = gtalk_get_rtp_peer,
+ .get_codec = gtalk_get_codec,
+ .update_peer = gtalk_set_rtp_peer,
+};
+
static int gtalk_response(struct gtalk *client, char *from, ikspak *pak, const char *reasonstr, const char *reasonstr2)
{
iks *response = NULL, *error = NULL, *reason = NULL;
@@ -617,13 +613,13 @@ static int gtalk_is_answered(struct gtalk *client, ikspak *pak)
/* codec points to the first <payload-type/> tag */
codec = iks_first_tag(iks_first_tag(iks_first_tag(pak->x)));
while (codec) {
- ast_rtp_set_m_type(tmp->rtp, atoi(iks_find_attrib(codec, "id")));
- ast_rtp_set_rtpmap_type(tmp->rtp, atoi(iks_find_attrib(codec, "id")), "audio", iks_find_attrib(codec, "name"), 0);
+ ast_rtp_codecs_payloads_set_m_type(ast_rtp_instance_get_codecs(tmp->rtp), tmp->rtp, atoi(iks_find_attrib(codec, "id")));
+ ast_rtp_codecs_payloads_set_rtpmap_type(ast_rtp_instance_get_codecs(tmp->rtp), tmp->rtp, atoi(iks_find_attrib(codec, "id")), "audio", iks_find_attrib(codec, "name"), 0);
codec = iks_next_tag(codec);
}
/* Now gather all of the codecs that we are asked for */
- ast_rtp_get_current_formats(tmp->rtp, &tmp->peercapability, &peernoncodeccapability);
+ ast_rtp_codecs_payload_formats(ast_rtp_instance_get_codecs(tmp->rtp), &tmp->peercapability, &peernoncodeccapability);
/* at this point, we received an awser from the remote Gtalk client,
which allows us to compare capabilities */
@@ -810,7 +806,7 @@ static int gtalk_create_candidates(struct gtalk *client, struct gtalk_pvt *p, ch
goto safeout;
}
- ast_rtp_get_us(p->rtp, &sin);
+ ast_rtp_instance_get_local_address(p->rtp, &sin);
ast_find_ourip(&us, bindaddr);
if (!strcmp(ast_inet_ntoa(us), "127.0.0.1")) {
ast_log(LOG_WARNING, "Found a loopback IP on the system, check your network configuration or set the bindaddr attribute.");
@@ -951,8 +947,9 @@ static struct gtalk_pvt *gtalk_alloc(struct gtalk *client, const char *us, const
tmp->initiator = 1;
}
/* clear codecs */
- tmp->rtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr);
- ast_rtp_pt_clear(tmp->rtp);
+ tmp->rtp = ast_rtp_instance_new(NULL, sched, &bindaddr, NULL);
+ ast_rtp_instance_set_prop(tmp->rtp, AST_RTP_PROPERTY_RTCP, 1);
+ ast_rtp_codecs_payloads_clear(ast_rtp_instance_get_codecs(tmp->rtp), tmp->rtp);
/* add user configured codec capabilites */
if (client->capability)
@@ -1014,20 +1011,20 @@ static struct ast_channel *gtalk_new(struct gtalk *client, struct gtalk_pvt *i,
/* Set Frame packetization */
if (i->rtp)
- ast_rtp_codec_setpref(i->rtp, &i->prefs);
+ ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(i->rtp), i->rtp, &i->prefs);
tmp->nativeformats = ast_codec_choose(&i->prefs, what, 1) | (i->jointcapability & AST_FORMAT_VIDEO_MASK);
fmt = ast_best_codec(tmp->nativeformats);
if (i->rtp) {
- ast_rtp_setstun(i->rtp, 1);
- ast_channel_set_fd(tmp, 0, ast_rtp_fd(i->rtp));
- ast_channel_set_fd(tmp, 1, ast_rtcp_fd(i->rtp));
+ ast_rtp_instance_set_prop(i->rtp, AST_RTP_PROPERTY_STUN, 1);
+ ast_channel_set_fd(tmp, 0, ast_rtp_instance_fd(i->rtp, 0));
+ ast_channel_set_fd(tmp, 1, ast_rtp_instance_fd(i->rtp, 1));
}
if (i->vrtp) {
- ast_rtp_setstun(i->rtp, 1);
- ast_channel_set_fd(tmp, 2, ast_rtp_fd(i->vrtp));
- ast_channel_set_fd(tmp, 3, ast_rtcp_fd(i->vrtp));
+ ast_rtp_instance_set_prop(i->vrtp, AST_RTP_PROPERTY_STUN, 1);
+ ast_channel_set_fd(tmp, 2, ast_rtp_instance_fd(i->vrtp, 0));
+ ast_channel_set_fd(tmp, 3, ast_rtp_instance_fd(i->vrtp, 1));
}
if (state == AST_STATE_RING)
tmp->rings = 1;
@@ -1142,9 +1139,9 @@ static void gtalk_free_pvt(struct gtalk *client, struct gtalk_pvt *p)
if (p->owner)
ast_log(LOG_WARNING, "Uh oh, there's an owner, this is going to be messy.\n");
if (p->rtp)
- ast_rtp_destroy(p->rtp);
+ ast_rtp_instance_destroy(p->rtp);
if (p->vrtp)
- ast_rtp_destroy(p->vrtp);
+ ast_rtp_instance_destroy(p->vrtp);
gtalk_free_candidates(p->theircandidates);
ast_free(p);
}
@@ -1207,13 +1204,13 @@ static int gtalk_newcall(struct gtalk *client, ikspak *pak)
codec = iks_first_tag(iks_first_tag(iks_first_tag(pak->x)));
while (codec) {
- ast_rtp_set_m_type(p->rtp, atoi(iks_find_attrib(codec, "id")));
- ast_rtp_set_rtpmap_type(p->rtp, atoi(iks_find_attrib(codec, "id")), "audio", iks_find_attrib(codec, "name"), 0);
+ ast_rtp_codecs_payloads_set_m_type(ast_rtp_instance_get_codecs(p->rtp), p->rtp, atoi(iks_find_attrib(codec, "id")));
+ ast_rtp_codecs_payloads_set_rtpmap_type(ast_rtp_instance_get_codecs(p->rtp), p->rtp, atoi(iks_find_attrib(codec, "id")), "audio", iks_find_attrib(codec, "name"), 0);
codec = iks_next_tag(codec);
}
/* Now gather all of the codecs that we are asked for */
- ast_rtp_get_current_formats(p->rtp, &p->peercapability, &peernoncodeccapability);
+ ast_rtp_codecs_payload_formats(ast_rtp_instance_get_codecs(p->rtp), &p->peercapability, &peernoncodeccapability);
p->jointcapability = p->capability & p->peercapability;
ast_mutex_unlock(&p->lock);
@@ -1277,16 +1274,16 @@ static int gtalk_update_stun(struct gtalk *client, struct gtalk_pvt *p)
p->ourcandidates->username);
/* Find out the result of the STUN */
- ast_rtp_get_peer(p->rtp, &aux);
+ ast_rtp_instance_get_remote_address(p->rtp, &aux);
/* If the STUN result is different from the IP of the hostname,
lock on the stun IP of the hostname advertised by the
remote client */
if (aux.sin_addr.s_addr &&
aux.sin_addr.s_addr != sin.sin_addr.s_addr)
- ast_rtp_stun_request(p->rtp, &aux, username);
+ ast_rtp_instance_stun_request(p->rtp, &aux, username);
else
- ast_rtp_stun_request(p->rtp, &sin, username);
+ ast_rtp_instance_stun_request(p->rtp, &sin, username);
if (aux.sin_addr.s_addr) {
ast_debug(4, "Receiving RTP traffic from IP %s, matches with remote candidate's IP %s\n", ast_inet_ntoa(aux.sin_addr), tmp->ip);
@@ -1387,7 +1384,7 @@ static struct ast_frame *gtalk_rtp_read(struct ast_channel *ast, struct gtalk_pv
if (!p->rtp)
return &ast_null_frame;
- f = ast_rtp_read(p->rtp);
+ f = ast_rtp_instance_read(p->rtp, 0);
gtalk_update_stun(p->parent, p);
if (p->owner) {
/* We already hold the channel lock */
@@ -1438,7 +1435,7 @@ static int gtalk_write(struct ast_channel *ast, struct ast_frame *frame)
if (p) {
ast_mutex_lock(&p->lock);
if (p->rtp) {
- res = ast_rtp_write(p->rtp, frame);
+ res = ast_rtp_instance_write(p->rtp, frame);
}
ast_mutex_unlock(&p->lock);
}
@@ -1447,7 +1444,7 @@ static int gtalk_write(struct ast_channel *ast, struct ast_frame *frame)
if (p) {
ast_mutex_lock(&p->lock);
if (p->vrtp) {
- res = ast_rtp_write(p->vrtp, frame);
+ res = ast_rtp_instance_write(p->vrtp, frame);
}
ast_mutex_unlock(&p->lock);
}
@@ -2062,7 +2059,7 @@ static int load_module(void)
return 0;
}
- ast_rtp_proto_register(&gtalk_rtp);
+ ast_rtp_glue_register(&gtalk_rtp_glue);
ast_cli_register_multiple(gtalk_cli, ARRAY_LEN(gtalk_cli));
/* Make sure we can register our channel type */
@@ -2086,7 +2083,7 @@ static int unload_module(void)
ast_cli_unregister_multiple(gtalk_cli, ARRAY_LEN(gtalk_cli));
/* First, take us out of the channel loop */
ast_channel_unregister(&gtalk_tech);
- ast_rtp_proto_unregister(&gtalk_rtp);
+ ast_rtp_glue_unregister(&gtalk_rtp_glue);
if (!ast_mutex_lock(&gtalklock)) {
/* Hangup all interfaces if they have an owner */
diff --git a/channels/chan_h323.c b/channels/chan_h323.c
index 2342ecfbb..c3e074d14 100644
--- a/channels/chan_h323.c
+++ b/channels/chan_h323.c
@@ -76,7 +76,7 @@ extern "C" {
#include "asterisk/utils.h"
#include "asterisk/sched.h"
#include "asterisk/io.h"
-#include "asterisk/rtp.h"
+#include "asterisk/rtp_engine.h"
#include "asterisk/acl.h"
#include "asterisk/callerid.h"
#include "asterisk/cli.h"
@@ -161,7 +161,7 @@ struct oh323_pvt {
char accountcode[256]; /*!< Account code */
char rdnis[80]; /*!< Referring DNIS, if available */
int amaflags; /*!< AMA Flags */
- struct ast_rtp *rtp; /*!< RTP Session */
+ struct ast_rtp_instance *rtp; /*!< RTP Session */
struct ast_dsp *vad; /*!< Used for in-band DTMF detection */
int nativeformats; /*!< Codec formats supported by a channel */
int needhangup; /*!< Send hangup when Asterisk is ready */
@@ -254,7 +254,7 @@ static const struct ast_channel_tech oh323_tech = {
.write = oh323_write,
.indicate = oh323_indicate,
.fixup = oh323_fixup,
- .bridge = ast_rtp_bridge,
+ .bridge = ast_rtp_instance_bridge,
};
static const char* redirectingreason2str(int redirectingreason)
@@ -381,8 +381,8 @@ static void __oh323_update_info(struct ast_channel *c, struct oh323_pvt *pvt)
if (pvt->update_rtp_info > 0) {
if (pvt->rtp) {
ast_jb_configure(c, &global_jbconf);
- ast_channel_set_fd(c, 0, ast_rtp_fd(pvt->rtp));
- ast_channel_set_fd(c, 1, ast_rtcp_fd(pvt->rtp));
+ ast_channel_set_fd(c, 0, ast_rtp_instance_fd(pvt->rtp, 0));
+ ast_channel_set_fd(c, 1, ast_rtp_instance_fd(pvt->rtp, 1));
ast_queue_frame(pvt->owner, &ast_null_frame); /* Tell Asterisk to apply changes */
}
pvt->update_rtp_info = -1;
@@ -444,7 +444,7 @@ static void __oh323_destroy(struct oh323_pvt *pvt)
AST_SCHED_DEL(sched, pvt->DTMFsched);
if (pvt->rtp) {
- ast_rtp_destroy(pvt->rtp);
+ ast_rtp_instance_destroy(pvt->rtp);
}
/* Free dsp used for in-band DTMF detection */
@@ -510,7 +510,7 @@ static int oh323_digit_begin(struct ast_channel *c, char digit)
if (h323debug) {
ast_log(LOG_DTMF, "Begin sending out-of-band digit %c on %s\n", digit, c->name);
}
- ast_rtp_senddigit_begin(pvt->rtp, digit);
+ ast_rtp_instance_dtmf_begin(pvt->rtp, digit);
ast_mutex_unlock(&pvt->lock);
} else if (pvt->txDtmfDigit != digit) {
/* in-band DTMF */
@@ -549,7 +549,7 @@ static int oh323_digit_end(struct ast_channel *c, char digit, unsigned int durat
if (h323debug) {
ast_log(LOG_DTMF, "End sending out-of-band digit %c on %s, duration %d\n", digit, c->name, duration);
}
- ast_rtp_senddigit_end(pvt->rtp, digit);
+ ast_rtp_instance_dtmf_end(pvt->rtp, digit);
ast_mutex_unlock(&pvt->lock);
} else {
/* in-band DTMF */
@@ -747,11 +747,11 @@ static struct ast_frame *oh323_rtp_read(struct oh323_pvt *pvt)
/* Only apply it for the first packet, we just need the correct ip/port */
if (pvt->options.nat) {
- ast_rtp_setnat(pvt->rtp, pvt->options.nat);
+ ast_rtp_instance_set_prop(pvt->rtp, AST_RTP_PROPERTY_NAT, pvt->options.nat);
pvt->options.nat = 0;
}
- f = ast_rtp_read(pvt->rtp);
+ f = ast_rtp_instance_read(pvt->rtp, 0);
/* Don't send RFC2833 if we're not supposed to */
if (f && (f->frametype == AST_FRAME_DTMF) && !(pvt->options.dtmfmode & (H323_DTMF_RFC2833 | H323_DTMF_CISCO))) {
return &ast_null_frame;
@@ -808,7 +808,7 @@ static struct ast_frame *oh323_read(struct ast_channel *c)
break;
case 1:
if (pvt->rtp)
- fr = ast_rtcp_read(pvt->rtp);
+ fr = ast_rtp_instance_read(pvt->rtp, 1);
else
fr = &ast_null_frame;
break;
@@ -842,7 +842,7 @@ static int oh323_write(struct ast_channel *c, struct ast_frame *frame)
if (pvt) {
ast_mutex_lock(&pvt->lock);
if (pvt->rtp && !pvt->recvonly)
- res = ast_rtp_write(pvt->rtp, frame);
+ res = ast_rtp_instance_write(pvt->rtp, frame);
__oh323_update_info(c, pvt);
ast_mutex_unlock(&pvt->lock);
}
@@ -910,7 +910,7 @@ static int oh323_indicate(struct ast_channel *c, int condition, const void *data
res = 0;
break;
case AST_CONTROL_SRCUPDATE:
- ast_rtp_new_source(pvt->rtp);
+ ast_rtp_instance_new_source(pvt->rtp);
res = 0;
break;
case AST_CONTROL_PROCEEDING:
@@ -946,17 +946,17 @@ static int oh323_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
static int __oh323_rtp_create(struct oh323_pvt *pvt)
{
- struct in_addr our_addr;
+ struct sockaddr_in our_addr;
if (pvt->rtp)
return 0;
- if (ast_find_ourip(&our_addr, bindaddr)) {
+ if (ast_find_ourip(&our_addr.sin_addr, bindaddr)) {
ast_mutex_unlock(&pvt->lock);
ast_log(LOG_ERROR, "Unable to locate local IP address for RTP stream\n");
return -1;
}
- pvt->rtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, our_addr);
+ pvt->rtp = ast_rtp_instance_new(NULL, sched, &our_addr, NULL);
if (!pvt->rtp) {
ast_mutex_unlock(&pvt->lock);
ast_log(LOG_WARNING, "Unable to create RTP session: %s\n", strerror(errno));
@@ -965,24 +965,24 @@ static int __oh323_rtp_create(struct oh323_pvt *pvt)
if (h323debug)
ast_debug(1, "Created RTP channel\n");
- ast_rtp_setqos(pvt->rtp, tos, cos, "H323 RTP");
+ ast_rtp_instance_set_qos(pvt->rtp, tos, cos, "H323 RTP");
if (h323debug)
ast_debug(1, "Setting NAT on RTP to %d\n", pvt->options.nat);
- ast_rtp_setnat(pvt->rtp, pvt->options.nat);
+ ast_rtp_instance_set_prop(pvt->rtp, AST_RTP_PROPERTY_NAT, pvt->options.nat);
if (pvt->dtmf_pt[0] > 0)
- ast_rtp_set_rtpmap_type(pvt->rtp, pvt->dtmf_pt[0], "audio", "telephone-event", 0);
+ ast_rtp_codecs_payloads_set_rtpmap_type(ast_rtp_instance_get_codecs(pvt->rtp), pvt->rtp, pvt->dtmf_pt[0], "audio", "telephone-event", 0);
if (pvt->dtmf_pt[1] > 0)
- ast_rtp_set_rtpmap_type(pvt->rtp, pvt->dtmf_pt[1], "audio", "cisco-telephone-event", 0);
+ ast_rtp_codecs_payloads_set_rtpmap_type(ast_rtp_instance_get_codecs(pvt->rtp), pvt->rtp, pvt->dtmf_pt[1], "audio", "cisco-telephone-event", 0);
if (pvt->peercapability)
- ast_rtp_codec_setpref(pvt->rtp, &pvt->peer_prefs);
+ ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(pvt->rtp), pvt->rtp, &pvt->peer_prefs);
if (pvt->owner && !ast_channel_trylock(pvt->owner)) {
ast_jb_configure(pvt->owner, &global_jbconf);
- ast_channel_set_fd(pvt->owner, 0, ast_rtp_fd(pvt->rtp));
- ast_channel_set_fd(pvt->owner, 1, ast_rtcp_fd(pvt->rtp));
+ ast_channel_set_fd(pvt->owner, 0, ast_rtp_instance_fd(pvt->rtp, 0));
+ ast_channel_set_fd(pvt->owner, 1, ast_rtp_instance_fd(pvt->rtp, 1));
ast_queue_frame(pvt->owner, &ast_null_frame); /* Tell Asterisk to apply changes */
ast_channel_unlock(pvt->owner);
} else
@@ -1028,13 +1028,13 @@ static struct ast_channel *__oh323_new(struct oh323_pvt *pvt, int state, const c
if (!pvt->rtp)
__oh323_rtp_create(pvt);
#if 0
- ast_channel_set_fd(ch, 0, ast_rtp_fd(pvt->rtp));
- ast_channel_set_fd(ch, 1, ast_rtcp_fd(pvt->rtp));
+ ast_channel_set_fd(ch, 0, ast_rtp_instance_fd(pvt->rtp, 0));
+ ast_channel_set_fd(ch, 1, ast_rtp_instance_fd(pvt->rtp, 1));
#endif
#ifdef VIDEO_SUPPORT
if (pvt->vrtp) {
- ast_channel_set_fd(ch, 2, ast_rtp_fd(pvt->vrtp));
- ast_channel_set_fd(ch, 3, ast_rtcp_fd(pvt->vrtp));
+ ast_channel_set_fd(ch, 2, ast_rtp_instance_fd(pvt->vrtp, 0));
+ ast_channel_set_fd(ch, 3, ast_rtp_instance_fd(pvt->vrtp, 1));
}
#endif
#ifdef T38_SUPPORT
@@ -1112,7 +1112,7 @@ static struct oh323_pvt *oh323_alloc(int callid)
}
if (!pvt->cd.call_token) {
ast_log(LOG_ERROR, "Not enough memory to alocate call token\n");
- ast_rtp_destroy(pvt->rtp);
+ ast_rtp_instance_destroy(pvt->rtp);
ast_free(pvt);
return NULL;
}
@@ -1912,7 +1912,7 @@ static struct rtp_info *external_rtp_create(unsigned call_reference, const char
return NULL;
}
/* figure out our local RTP port and tell the H.323 stack about it */
- ast_rtp_get_us(pvt->rtp, &us);
+ ast_rtp_instance_get_local_address(pvt->rtp, &us);
ast_mutex_unlock(&pvt->lock);
ast_copy_string(info->addr, ast_inet_ntoa(us.sin_addr), sizeof(info->addr));
@@ -1931,7 +1931,6 @@ static void setup_rtp_connection(unsigned call_reference, const char *remoteIp,
{
struct oh323_pvt *pvt;
struct sockaddr_in them;
- struct rtpPayloadType rtptype;
int nativeformats_changed;
enum { NEED_NONE, NEED_HOLD, NEED_UNHOLD } rtp_change = NEED_NONE;
@@ -1953,7 +1952,7 @@ static void setup_rtp_connection(unsigned call_reference, const char *remoteIp,
__oh323_rtp_create(pvt);
if ((pt == 2) && (pvt->jointcapability & AST_FORMAT_G726_AAL2)) {
- ast_rtp_set_rtpmap_type(pvt->rtp, pt, "audio", "G726-32", AST_RTP_OPT_G726_NONSTANDARD);
+ ast_rtp_codecs_payloads_set_rtpmap_type(ast_rtp_instance_get_codecs(pvt->rtp), pvt->rtp, pt, "audio", "G726-32", AST_RTP_OPT_G726_NONSTANDARD);
}
them.sin_family = AF_INET;
@@ -1962,13 +1961,13 @@ static void setup_rtp_connection(unsigned call_reference, const char *remoteIp,
them.sin_port = htons(remotePort);
if (them.sin_addr.s_addr) {
- ast_rtp_set_peer(pvt->rtp, &them);
+ ast_rtp_instance_set_remote_address(pvt->rtp, &them);
if (pvt->recvonly) {
pvt->recvonly = 0;
rtp_change = NEED_UNHOLD;
}
} else {
- ast_rtp_stop(pvt->rtp);
+ ast_rtp_instance_stop(pvt->rtp);
if (!pvt->recvonly) {
pvt->recvonly = 1;
rtp_change = NEED_HOLD;
@@ -1978,7 +1977,7 @@ static void setup_rtp_connection(unsigned call_reference, const char *remoteIp,
/* Change native format to reflect information taken from OLC/OLCAck */
nativeformats_changed = 0;
if (pt != 128 && pvt->rtp) { /* Payload type is invalid, so try to use previously decided */
- rtptype = ast_rtp_lookup_pt(pvt->rtp, pt);
+ struct ast_rtp_payload_type rtptype = ast_rtp_codecs_payload_lookup(ast_rtp_instance_get_codecs(pvt->rtp), pt);
if (h323debug)
ast_debug(1, "Native format is set to %d from %d by RTP payload type %d\n", rtptype.code, pvt->nativeformats, pt);
if (pvt->nativeformats != rtptype.code) {
@@ -2359,7 +2358,7 @@ static void cleanup_connection(unsigned call_reference, const char *call_token)
}
if (pvt->rtp) {
/* Immediately stop RTP */
- ast_rtp_destroy(pvt->rtp);
+ ast_rtp_instance_destroy(pvt->rtp);
pvt->rtp = NULL;
}
/* Free dsp used for in-band DTMF detection */
@@ -2421,7 +2420,7 @@ static void set_dtmf_payload(unsigned call_reference, const char *token, int pay
return;
}
if (pvt->rtp) {
- ast_rtp_set_rtpmap_type(pvt->rtp, payload, "audio", (is_cisco ? "cisco-telephone-event" : "telephone-event"), 0);
+ ast_rtp_codecs_payloads_set_rtpmap_type(ast_rtp_instance_get_codecs(pvt->rtp), pvt->rtp, payload, "audio", (is_cisco ? "cisco-telephone-event" : "telephone-event"), 0);
}
pvt->dtmf_pt[is_cisco ? 1 : 0] = payload;
ast_mutex_unlock(&pvt->lock);
@@ -2452,7 +2451,7 @@ static void set_peer_capabilities(unsigned call_reference, const char *token, in
}
}
if (pvt->rtp)
- ast_rtp_codec_setpref(pvt->rtp, &pvt->peer_prefs);
+ ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(pvt->rtp), pvt->rtp, &pvt->peer_prefs);
}
ast_mutex_unlock(&pvt->lock);
}
@@ -3113,19 +3112,19 @@ static int reload(void)
static struct ast_cli_entry cli_h323_reload =
AST_CLI_DEFINE(handle_cli_h323_reload, "Reload H.323 configuration");
-static enum ast_rtp_get_result oh323_get_rtp_peer(struct ast_channel *chan, struct ast_rtp **rtp)
+static enum ast_rtp_glue_result oh323_get_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance **instance)
{
struct oh323_pvt *pvt;
- enum ast_rtp_get_result res = AST_RTP_TRY_PARTIAL;
+ enum ast_rtp_glue_result res = AST_RTP_GLUE_RESULT_LOCAL;
if (!(pvt = (struct oh323_pvt *)chan->tech_pvt))
- return AST_RTP_GET_FAILED;
+ return AST_RTP_GLUE_RESULT_FORBID;
ast_mutex_lock(&pvt->lock);
- *rtp = pvt->rtp;
+ *instance = pvt->rtp ? ao2_ref(pvt->rtp, +1), pvt->rtp : NULL;
#if 0
if (pvt->options.bridge) {
- res = AST_RTP_TRY_NATIVE;
+ res = AST_RTP_GLUE_RESULT_REMOTE;
}
#endif
ast_mutex_unlock(&pvt->lock);
@@ -3133,11 +3132,6 @@ static enum ast_rtp_get_result oh323_get_rtp_peer(struct ast_channel *chan, stru
return res;
}
-static enum ast_rtp_get_result oh323_get_vrtp_peer(struct ast_channel *chan, struct ast_rtp **rtp)
-{
- return AST_RTP_GET_FAILED;
-}
-
static char *convertcap(int cap)
{
switch (cap) {
@@ -3165,7 +3159,7 @@ static char *convertcap(int cap)
}
}
-static int oh323_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, struct ast_rtp *trtp, int codecs, int nat_active)
+static int oh323_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *rtp, struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, int codecs, int nat_active)
{
/* XXX Deal with Video */
struct oh323_pvt *pvt;
@@ -3183,19 +3177,18 @@ static int oh323_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, str
ast_log(LOG_ERROR, "No Private Structure, this is bad\n");
return -1;
}
- ast_rtp_get_peer(rtp, &them);
- ast_rtp_get_us(rtp, &us);
+ ast_rtp_instance_get_remote_address(rtp, &them);
+ ast_rtp_instance_get_local_address(rtp, &us);
#if 0 /* Native bridge still isn't ready */
h323_native_bridge(pvt->cd.call_token, ast_inet_ntoa(them.sin_addr), mode);
#endif
return 0;
}
-static struct ast_rtp_protocol oh323_rtp = {
+static struct ast_rtp_glue oh323_rtp_glue = {
.type = "H323",
.get_rtp_info = oh323_get_rtp_peer,
- .get_vrtp_info = oh323_get_vrtp_peer,
- .set_rtp_peer = oh323_set_rtp_peer,
+ .update_peer = oh323_set_rtp_peer,
};
static enum ast_module_load_result load_module(void)
@@ -3250,7 +3243,7 @@ static enum ast_module_load_result load_module(void)
}
ast_cli_register_multiple(cli_h323, sizeof(cli_h323) / sizeof(struct ast_cli_entry));
- ast_rtp_proto_register(&oh323_rtp);
+ ast_rtp_glue_register(&oh323_rtp_glue);
/* Register our callback functions */
h323_callback_register(setup_incoming_call,
@@ -3271,7 +3264,7 @@ static enum ast_module_load_result load_module(void)
/* start the h.323 listener */
if (h323_start_listener(h323_signalling_port, bindaddr)) {
ast_log(LOG_ERROR, "Unable to create H323 listener.\n");
- ast_rtp_proto_unregister(&oh323_rtp);
+ ast_rtp_glue_unregister(&oh323_rtp_glue);
ast_cli_unregister_multiple(cli_h323, sizeof(cli_h323) / sizeof(struct ast_cli_entry));
ast_cli_unregister(&cli_h323_reload);
h323_end_process();
@@ -3310,7 +3303,7 @@ static int unload_module(void)
ast_cli_unregister(&cli_h323_reload);
ast_channel_unregister(&oh323_tech);
- ast_rtp_proto_unregister(&oh323_rtp);
+ ast_rtp_glue_unregister(&oh323_rtp_glue);
if (!ast_mutex_lock(&iflock)) {
/* hangup all interfaces if they have an owner */
diff --git a/channels/chan_jingle.c b/channels/chan_jingle.c
index d239fd717..e1a60ae7e 100644
--- a/channels/chan_jingle.c
+++ b/channels/chan_jingle.c
@@ -53,7 +53,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/pbx.h"
#include "asterisk/sched.h"
#include "asterisk/io.h"
-#include "asterisk/rtp.h"
+#include "asterisk/rtp_engine.h"
#include "asterisk/acl.h"
#include "asterisk/callerid.h"
#include "asterisk/file.h"
@@ -112,9 +112,9 @@ struct jingle_pvt {
char exten[80]; /*!< Called extension */
struct ast_channel *owner; /*!< Master Channel */
char audio_content_name[100]; /*!< name attribute of content tag */
- struct ast_rtp *rtp; /*!< RTP audio session */
+ struct ast_rtp_instance *rtp; /*!< RTP audio session */
char video_content_name[100]; /*!< name attribute of content tag */
- struct ast_rtp *vrtp; /*!< RTP video session */
+ struct ast_rtp_instance *vrtp; /*!< RTP video session */
int jointcapability; /*!< Supported capability at both ends (codecs ) */
int peercapability;
struct jingle_pvt *next; /* Next entity */
@@ -183,11 +183,6 @@ static int jingle_sendhtml(struct ast_channel *ast, int subclass, const char *da
static struct jingle_pvt *jingle_alloc(struct jingle *client, const char *from, const char *sid);
static char *jingle_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
static char *jingle_do_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
-/*----- RTP interface functions */
-static int jingle_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp,
- struct ast_rtp *vrtp, struct ast_rtp *tpeer, int codecs, int nat_active);
-static enum ast_rtp_get_result jingle_get_rtp_peer(struct ast_channel *chan, struct ast_rtp **rtp);
-static int jingle_get_codec(struct ast_channel *chan);
/*! \brief PBX interface structure for channel registration */
static const struct ast_channel_tech jingle_tech = {
@@ -197,7 +192,7 @@ static const struct ast_channel_tech jingle_tech = {
.requester = jingle_request,
.send_digit_begin = jingle_digit_begin,
.send_digit_end = jingle_digit_end,
- .bridge = ast_rtp_bridge,
+ .bridge = ast_rtp_instance_bridge,
.call = jingle_call,
.hangup = jingle_hangup,
.answer = jingle_answer,
@@ -216,15 +211,6 @@ static struct sched_context *sched; /*!< The scheduling context */
static struct io_context *io; /*!< The IO context */
static struct in_addr __ourip;
-
-/*! \brief RTP driver interface */
-static struct ast_rtp_protocol jingle_rtp = {
- type: "Jingle",
- get_rtp_info: jingle_get_rtp_peer,
- set_rtp_peer: jingle_set_rtp_peer,
- get_codec: jingle_get_codec,
-};
-
static struct ast_cli_entry jingle_cli[] = {
AST_CLI_DEFINE(jingle_do_reload, "Reload Jingle configuration"),
AST_CLI_DEFINE(jingle_show_channels, "Show Jingle channels"),
@@ -304,7 +290,6 @@ static void add_codec_to_answer(const struct jingle_pvt *p, int codec, iks *dcod
iks_insert_attrib(payload_g723, "name", "G723");
iks_insert_node(dcodecs, payload_g723);
}
- ast_rtp_lookup_code(p->rtp, 1, codec);
}
static int jingle_accept_call(struct jingle *client, struct jingle_pvt *p)
@@ -398,18 +383,19 @@ static int jingle_answer(struct ast_channel *ast)
return res;
}
-static enum ast_rtp_get_result jingle_get_rtp_peer(struct ast_channel *chan, struct ast_rtp **rtp)
+static enum ast_rtp_glue_result jingle_get_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance **instance)
{
struct jingle_pvt *p = chan->tech_pvt;
- enum ast_rtp_get_result res = AST_RTP_GET_FAILED;
+ enum ast_rtp_glue_result res = AST_RTP_GLUE_RESULT_FORBID;
if (!p)
return res;
ast_mutex_lock(&p->lock);
if (p->rtp) {
- *rtp = p->rtp;
- res = AST_RTP_TRY_PARTIAL;
+ ao2_ref(p->rtp, +1);
+ *instance = p->rtp;
+ res = AST_RTP_GLUE_RESULT_LOCAL;
}
ast_mutex_unlock(&p->lock);
@@ -422,7 +408,7 @@ static int jingle_get_codec(struct ast_channel *chan)
return p->peercapability;
}
-static int jingle_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, struct ast_rtp *tpeer, int codecs, int nat_active)
+static int jingle_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *rtp, struct ast_rtp_instance *vrtp, struct ast_rtp_instance *tpeer, int codecs, int nat_active)
{
struct jingle_pvt *p;
@@ -442,6 +428,13 @@ static int jingle_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, st
return 0;
}
+static struct ast_rtp_glue jingle_rtp_glue = {
+ .type = "Jingle",
+ .get_rtp_info = jingle_get_rtp_peer,
+ .get_codec = jingle_get_codec,
+ .update_peer = jingle_set_rtp_peer,
+};
+
static int jingle_response(struct jingle *client, ikspak *pak, const char *reasonstr, const char *reasonstr2)
{
iks *response = NULL, *error = NULL, *reason = NULL;
@@ -621,7 +614,7 @@ static int jingle_create_candidates(struct jingle *client, struct jingle_pvt *p,
goto safeout;
}
- ast_rtp_get_us(p->rtp, &sin);
+ ast_rtp_instance_get_local_address(p->rtp, &sin);
ast_find_ourip(&us, bindaddr);
/* Setup our first jingle candidate */
@@ -779,7 +772,7 @@ static struct jingle_pvt *jingle_alloc(struct jingle *client, const char *from,
ast_copy_string(tmp->them, idroster, sizeof(tmp->them));
tmp->initiator = 1;
}
- tmp->rtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr);
+ tmp->rtp = ast_rtp_instance_new(NULL, sched, &bindaddr, NULL);
tmp->parent = client;
if (!tmp->rtp) {
ast_log(LOG_WARNING, "Out of RTP sessions?\n");
@@ -825,18 +818,18 @@ static struct ast_channel *jingle_new(struct jingle *client, struct jingle_pvt *
/* Set Frame packetization */
if (i->rtp)
- ast_rtp_codec_setpref(i->rtp, &i->prefs);
+ ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(i->rtp), i->rtp, &i->prefs);
tmp->nativeformats = ast_codec_choose(&i->prefs, what, 1) | (i->jointcapability & AST_FORMAT_VIDEO_MASK);
fmt = ast_best_codec(tmp->nativeformats);
if (i->rtp) {
- ast_channel_set_fd(tmp, 0, ast_rtp_fd(i->rtp));
- ast_channel_set_fd(tmp, 1, ast_rtcp_fd(i->rtp));
+ ast_channel_set_fd(tmp, 0, ast_rtp_instance_fd(i->rtp, 0));
+ ast_channel_set_fd(tmp, 1, ast_rtp_instance_fd(i->rtp, 1));
}
if (i->vrtp) {
- ast_channel_set_fd(tmp, 2, ast_rtp_fd(i->vrtp));
- ast_channel_set_fd(tmp, 3, ast_rtcp_fd(i->vrtp));
+ ast_channel_set_fd(tmp, 2, ast_rtp_instance_fd(i->vrtp, 0));
+ ast_channel_set_fd(tmp, 3, ast_rtp_instance_fd(i->vrtp, 1));
}
if (state == AST_STATE_RING)
tmp->rings = 1;
@@ -942,9 +935,9 @@ static void jingle_free_pvt(struct jingle *client, struct jingle_pvt *p)
if (p->owner)
ast_log(LOG_WARNING, "Uh oh, there's an owner, this is going to be messy.\n");
if (p->rtp)
- ast_rtp_destroy(p->rtp);
+ ast_rtp_instance_destroy(p->rtp);
if (p->vrtp)
- ast_rtp_destroy(p->vrtp);
+ ast_rtp_instance_destroy(p->vrtp);
jingle_free_candidates(p->theircandidates);
ast_free(p);
}
@@ -1009,8 +1002,8 @@ static int jingle_newcall(struct jingle *client, ikspak *pak)
ast_copy_string(p->audio_content_name, iks_find_attrib(content, "name"), sizeof(p->audio_content_name));
while (codec) {
- ast_rtp_set_m_type(p->rtp, atoi(iks_find_attrib(codec, "id")));
- ast_rtp_set_rtpmap_type(p->rtp, atoi(iks_find_attrib(codec, "id")), "audio", iks_find_attrib(codec, "name"), 0);
+ ast_rtp_codecs_payloads_set_m_type(ast_rtp_instance_get_codecs(p->rtp), p->rtp, atoi(iks_find_attrib(codec, "id")));
+ ast_rtp_codecs_payloads_set_rtpmap_type(ast_rtp_instance_get_codecs(p->rtp), p->rtp, atoi(iks_find_attrib(codec, "id")), "audio", iks_find_attrib(codec, "name"), 0);
codec = iks_next(codec);
}
}
@@ -1025,8 +1018,8 @@ static int jingle_newcall(struct jingle *client, ikspak *pak)
ast_copy_string(p->video_content_name, iks_find_attrib(content, "name"), sizeof(p->video_content_name));
while (codec) {
- ast_rtp_set_m_type(p->rtp, atoi(iks_find_attrib(codec, "id")));
- ast_rtp_set_rtpmap_type(p->rtp, atoi(iks_find_attrib(codec, "id")), "audio", iks_find_attrib(codec, "name"), 0);
+ ast_rtp_codecs_payloads_set_m_type(ast_rtp_instance_get_codecs(p->rtp), p->rtp, atoi(iks_find_attrib(codec, "id")));
+ ast_rtp_codecs_payloads_set_rtpmap_type(ast_rtp_instance_get_codecs(p->rtp), p->rtp, atoi(iks_find_attrib(codec, "id")), "audio", iks_find_attrib(codec, "name"), 0);
codec = iks_next(codec);
}
}
@@ -1079,7 +1072,7 @@ static int jingle_update_stun(struct jingle *client, struct jingle_pvt *p)
sin.sin_port = htons(tmp->port);
snprintf(username, sizeof(username), "%s:%s", tmp->ufrag, p->ourcandidates->ufrag);
- ast_rtp_stun_request(p->rtp, &sin, username);
+ ast_rtp_instance_stun_request(p->rtp, &sin, username);
tmp = tmp->next;
}
return 1;
@@ -1169,7 +1162,7 @@ static struct ast_frame *jingle_rtp_read(struct ast_channel *ast, struct jingle_
if (!p->rtp)
return &ast_null_frame;
- f = ast_rtp_read(p->rtp);
+ f = ast_rtp_instance_read(p->rtp, 0);
jingle_update_stun(p->parent, p);
if (p->owner) {
/* We already hold the channel lock */
@@ -1220,7 +1213,7 @@ static int jingle_write(struct ast_channel *ast, struct ast_frame *frame)
if (p) {
ast_mutex_lock(&p->lock);
if (p->rtp) {
- res = ast_rtp_write(p->rtp, frame);
+ res = ast_rtp_instance_write(p->rtp, frame);
}
ast_mutex_unlock(&p->lock);
}
@@ -1229,7 +1222,7 @@ static int jingle_write(struct ast_channel *ast, struct ast_frame *frame)
if (p) {
ast_mutex_lock(&p->lock);
if (p->vrtp) {
- res = ast_rtp_write(p->vrtp, frame);
+ res = ast_rtp_instance_write(p->vrtp, frame);
}
ast_mutex_unlock(&p->lock);
}
@@ -1879,7 +1872,7 @@ static int load_module(void)
return 0;
}
- ast_rtp_proto_register(&jingle_rtp);
+ ast_rtp_glue_register(&jingle_rtp_glue);
ast_cli_register_multiple(jingle_cli, ARRAY_LEN(jingle_cli));
/* Make sure we can register our channel type */
if (ast_channel_register(&jingle_tech)) {
@@ -1902,7 +1895,7 @@ static int unload_module(void)
ast_cli_unregister_multiple(jingle_cli, ARRAY_LEN(jingle_cli));
/* First, take us out of the channel loop */
ast_channel_unregister(&jingle_tech);
- ast_rtp_proto_unregister(&jingle_rtp);
+ ast_rtp_glue_unregister(&jingle_rtp_glue);
if (!ast_mutex_lock(&jinglelock)) {
/* Hangup all interfaces if they have an owner */
diff --git a/channels/chan_local.c b/channels/chan_local.c
index de161d6af..e426e10fa 100644
--- a/channels/chan_local.c
+++ b/channels/chan_local.c
@@ -39,7 +39,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/pbx.h"
#include "asterisk/sched.h"
#include "asterisk/io.h"
-#include "asterisk/rtp.h"
#include "asterisk/acl.h"
#include "asterisk/callerid.h"
#include "asterisk/file.h"
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index 1c1482975..cad9d9497 100644
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -52,7 +52,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/pbx.h"
#include "asterisk/sched.h"
#include "asterisk/io.h"
-#include "asterisk/rtp.h"
+#include "asterisk/rtp_engine.h"
#include "asterisk/acl.h"
#include "asterisk/callerid.h"
#include "asterisk/cli.h"
@@ -282,7 +282,7 @@ struct mgcp_subchannel {
int id;
struct ast_channel *owner;
struct mgcp_endpoint *parent;
- struct ast_rtp *rtp;
+ struct ast_rtp_instance *rtp;
struct sockaddr_in tmpdest;
char txident[80]; /*! \todo FIXME txident is replaced by rqnt_ident in endpoint.
This should be obsoleted */
@@ -408,7 +408,7 @@ static int transmit_response(struct mgcp_subchannel *sub, char *msg, struct mgcp
static int transmit_notify_request(struct mgcp_subchannel *sub, char *tone);
static int transmit_modify_request(struct mgcp_subchannel *sub);
static int transmit_notify_request_with_callerid(struct mgcp_subchannel *sub, char *tone, char *callernum, char *callername);
-static int transmit_modify_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp *rtp, int codecs);
+static int transmit_modify_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp_instance *rtp, int codecs);
static int transmit_connection_del(struct mgcp_subchannel *sub);
static int transmit_audit_endpoint(struct mgcp_endpoint *p);
static void start_rtp(struct mgcp_subchannel *sub);
@@ -447,7 +447,7 @@ static const struct ast_channel_tech mgcp_tech = {
.fixup = mgcp_fixup,
.send_digit_begin = mgcp_senddigit_begin,
.send_digit_end = mgcp_senddigit_end,
- .bridge = ast_rtp_bridge,
+ .bridge = ast_rtp_instance_bridge,
};
static void mwi_event_cb(const struct ast_event *event, void *userdata)
@@ -503,7 +503,7 @@ static int unalloc_sub(struct mgcp_subchannel *sub)
sub->alreadygone = 0;
memset(&sub->tmpdest, 0, sizeof(sub->tmpdest));
if (sub->rtp) {
- ast_rtp_destroy(sub->rtp);
+ ast_rtp_instance_destroy(sub->rtp);
sub->rtp = NULL;
}
dump_cmd_queues(NULL, sub); /* SC */
@@ -1003,7 +1003,7 @@ static int mgcp_hangup(struct ast_channel *ast)
/* Reset temporary destination */
memset(&sub->tmpdest, 0, sizeof(sub->tmpdest));
if (sub->rtp) {
- ast_rtp_destroy(sub->rtp);
+ ast_rtp_instance_destroy(sub->rtp);
sub->rtp = NULL;
}
@@ -1203,7 +1203,7 @@ static struct ast_frame *mgcp_rtp_read(struct mgcp_subchannel *sub)
/* Retrieve audio/etc from channel. Assumes sub->lock is already held. */
struct ast_frame *f;
- f = ast_rtp_read(sub->rtp);
+ f = ast_rtp_instance_read(sub->rtp, 0);
/* Don't send RFC2833 if we're not supposed to */
if (f && (f->frametype == AST_FRAME_DTMF) && !(sub->parent->dtmfmode & MGCP_DTMF_RFC2833))
return &ast_null_frame;
@@ -1261,7 +1261,7 @@ static int mgcp_write(struct ast_channel *ast, struct ast_frame *frame)
ast_mutex_lock(&sub->lock);
if ((sub->parent->sub == sub) || !sub->parent->singlepath) {
if (sub->rtp) {
- res = ast_rtp_write(sub->rtp, frame);
+ res = ast_rtp_instance_write(sub->rtp, frame);
}
}
ast_mutex_unlock(&sub->lock);
@@ -1297,7 +1297,7 @@ static int mgcp_senddigit_begin(struct ast_channel *ast, char digit)
res = -1; /* Let asterisk play inband indications */
} else if (p->dtmfmode & MGCP_DTMF_RFC2833) {
ast_log(LOG_DEBUG, "Sending DTMF using RFC2833");
- ast_rtp_senddigit_begin(sub->rtp, digit);
+ ast_rtp_instance_dtmf_begin(sub->rtp, digit);
} else {
ast_log(LOG_ERROR, "Don't know about DTMF_MODE %d\n", p->dtmfmode);
}
@@ -1324,7 +1324,7 @@ static int mgcp_senddigit_end(struct ast_channel *ast, char digit, unsigned int
tmp[2] = digit;
tmp[3] = '\0';
transmit_notify_request(sub, tmp);
- ast_rtp_senddigit_end(sub->rtp, digit);
+ ast_rtp_instance_dtmf_end(sub->rtp, digit);
} else {
ast_log(LOG_ERROR, "Don't know about DTMF_MODE %d\n", p->dtmfmode);
}
@@ -1453,7 +1453,7 @@ static int mgcp_indicate(struct ast_channel *ast, int ind, const void *data, siz
ast_moh_stop(ast);
break;
case AST_CONTROL_SRCUPDATE:
- ast_rtp_new_source(sub->rtp);
+ ast_rtp_instance_new_source(sub->rtp);
break;
case -1:
transmit_notify_request(sub, "");
@@ -1481,7 +1481,7 @@ static struct ast_channel *mgcp_new(struct mgcp_subchannel *sub, int state)
fmt = ast_best_codec(tmp->nativeformats);
ast_string_field_build(tmp, name, "MGCP/%s@%s-%d", i->name, i->parent->name, sub->id);
if (sub->rtp)
- ast_channel_set_fd(tmp, 0, ast_rtp_fd(sub->rtp));
+ ast_channel_set_fd(tmp, 0, ast_rtp_instance_fd(sub->rtp, 0));
if (i->dtmfmode & (MGCP_DTMF_INBAND | MGCP_DTMF_HYBRID)) {
i->dsp = ast_dsp_new();
ast_dsp_set_features(i->dsp, DSP_FEATURE_DIGIT_DETECT);
@@ -1874,12 +1874,12 @@ static int process_sdp(struct mgcp_subchannel *sub, struct mgcp_request *req)
sin.sin_family = AF_INET;
memcpy(&sin.sin_addr, hp->h_addr, sizeof(sin.sin_addr));
sin.sin_port = htons(portno);
- ast_rtp_set_peer(sub->rtp, &sin);
+ ast_rtp_instance_set_remote_address(sub->rtp, &sin);
#if 0
printf("Peer RTP is at port %s:%d\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
#endif
/* Scan through the RTP payload types specified in a "m=" line: */
- ast_rtp_pt_clear(sub->rtp);
+ ast_rtp_codecs_payloads_clear(ast_rtp_instance_get_codecs(sub->rtp), sub->rtp);
codecs = ast_strdupa(m + len);
while (!ast_strlen_zero(codecs)) {
if (sscanf(codecs, "%d%n", &codec, &len) != 1) {
@@ -1888,7 +1888,7 @@ static int process_sdp(struct mgcp_subchannel *sub, struct mgcp_request *req)
ast_log(LOG_WARNING, "Error in codec string '%s' at '%s'\n", m, codecs);
return -1;
}
- ast_rtp_set_m_type(sub->rtp, codec);
+ ast_rtp_codecs_payloads_set_m_type(ast_rtp_instance_get_codecs(sub->rtp), sub->rtp, codec);
codec_count++;
codecs += len;
}
@@ -1901,11 +1901,11 @@ static int process_sdp(struct mgcp_subchannel *sub, struct mgcp_request *req)
if (sscanf(a, "rtpmap: %u %[^/]/", &codec, mimeSubtype) != 2)
continue;
/* Note: should really look at the 'freq' and '#chans' params too */
- ast_rtp_set_rtpmap_type(sub->rtp, codec, "audio", mimeSubtype, 0);
+ ast_rtp_codecs_payloads_set_rtpmap_type(ast_rtp_instance_get_codecs(sub->rtp), sub->rtp, codec, "audio", mimeSubtype, 0);
}
/* Now gather all of the codecs that were asked for: */
- ast_rtp_get_current_formats(sub->rtp, &peercapability, &peerNonCodecCapability);
+ ast_rtp_codecs_payload_formats(ast_rtp_instance_get_codecs(sub->rtp), &peercapability, &peerNonCodecCapability);
p->capability = capability & peercapability;
if (mgcpdebug) {
ast_verbose("Capabilities: us - %d, them - %d, combined - %d\n",
@@ -2043,7 +2043,7 @@ static int transmit_response(struct mgcp_subchannel *sub, char *msg, struct mgcp
}
-static int add_sdp(struct mgcp_request *resp, struct mgcp_subchannel *sub, struct ast_rtp *rtp)
+static int add_sdp(struct mgcp_request *resp, struct mgcp_subchannel *sub, struct ast_rtp_instance *rtp)
{
int len;
int codec;
@@ -2066,9 +2066,9 @@ static int add_sdp(struct mgcp_request *resp, struct mgcp_subchannel *sub, struc
ast_log(LOG_WARNING, "No way to add SDP without an RTP structure\n");
return -1;
}
- ast_rtp_get_us(sub->rtp, &sin);
+ ast_rtp_instance_get_local_address(sub->rtp, &sin);
if (rtp) {
- ast_rtp_get_peer(rtp, &dest);
+ ast_rtp_instance_get_remote_address(sub->rtp, &dest);
} else {
if (sub->tmpdest.sin_addr.s_addr) {
dest.sin_addr = sub->tmpdest.sin_addr;
@@ -2094,11 +2094,11 @@ static int add_sdp(struct mgcp_request *resp, struct mgcp_subchannel *sub, struc
if (mgcpdebug) {
ast_verbose("Answering with capability %d\n", x);
}
- codec = ast_rtp_lookup_code(sub->rtp, 1, x);
+ codec = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(sub->rtp), 1, x);
if (codec > -1) {
snprintf(costr, sizeof(costr), " %d", codec);
strncat(m, costr, sizeof(m) - strlen(m) - 1);
- snprintf(costr, sizeof(costr), "a=rtpmap:%d %s/8000\r\n", codec, ast_rtp_lookup_mime_subtype(1, x, 0));
+ snprintf(costr, sizeof(costr), "a=rtpmap:%d %s/8000\r\n", codec, ast_rtp_lookup_mime_subtype2(1, x, 0));
strncat(a, costr, sizeof(a) - strlen(a) - 1);
}
}
@@ -2108,11 +2108,11 @@ static int add_sdp(struct mgcp_request *resp, struct mgcp_subchannel *sub, struc
if (mgcpdebug) {
ast_verbose("Answering with non-codec capability %d\n", x);
}
- codec = ast_rtp_lookup_code(sub->rtp, 0, x);
+ codec = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(sub->rtp), 0, x);
if (codec > -1) {
snprintf(costr, sizeof(costr), " %d", codec);
strncat(m, costr, sizeof(m) - strlen(m) - 1);
- snprintf(costr, sizeof(costr), "a=rtpmap:%d %s/8000\r\n", codec, ast_rtp_lookup_mime_subtype(0, x, 0));
+ snprintf(costr, sizeof(costr), "a=rtpmap:%d %s/8000\r\n", codec, ast_rtp_lookup_mime_subtype2(0, x, 0));
strncat(a, costr, sizeof(a) - strlen(a) - 1);
if (x == AST_RTP_DTMF) {
/* Indicate we support DTMF... Not sure about 16,
@@ -2136,7 +2136,7 @@ static int add_sdp(struct mgcp_request *resp, struct mgcp_subchannel *sub, struc
return 0;
}
-static int transmit_modify_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp *rtp, int codecs)
+static int transmit_modify_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp_instance *rtp, int codecs)
{
struct mgcp_request resp;
char local[256];
@@ -2147,13 +2147,13 @@ static int transmit_modify_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp
if (ast_strlen_zero(sub->cxident) && rtp) {
/* We don't have a CXident yet, store the destination and
wait a bit */
- ast_rtp_get_peer(rtp, &sub->tmpdest);
+ ast_rtp_instance_get_remote_address(rtp, &sub->tmpdest);
return 0;
}
ast_copy_string(local, "p:20", sizeof(local));
for (x = 1; x <= AST_FORMAT_AUDIO_MASK; x <<= 1) {
if (p->capability & x) {
- snprintf(tmp, sizeof(tmp), ", a:%s", ast_rtp_lookup_mime_subtype(1, x, 0));
+ snprintf(tmp, sizeof(tmp), ", a:%s", ast_rtp_lookup_mime_subtype2(1, x, 0));
strncat(local, tmp, sizeof(local) - strlen(local) - 1);
}
}
@@ -2172,7 +2172,7 @@ static int transmit_modify_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp
return send_request(p, sub, &resp, oseq); /* SC */
}
-static int transmit_connect_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp *rtp)
+static int transmit_connect_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp_instance *rtp)
{
struct mgcp_request resp;
char local[256];
@@ -2183,7 +2183,7 @@ static int transmit_connect_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp
ast_copy_string(local, "p:20", sizeof(local));
for (x = 1; x <= AST_FORMAT_AUDIO_MASK; x <<= 1) {
if (p->capability & x) {
- snprintf(tmp, sizeof(tmp), ", a:%s", ast_rtp_lookup_mime_subtype(1, x, 0));
+ snprintf(tmp, sizeof(tmp), ", a:%s", ast_rtp_lookup_mime_subtype2(1, x, 0));
strncat(local, tmp, sizeof(local) - strlen(local) - 1);
}
}
@@ -2611,21 +2611,17 @@ static void start_rtp(struct mgcp_subchannel *sub)
ast_mutex_lock(&sub->lock);
/* check again to be on the safe side */
if (sub->rtp) {
- ast_rtp_destroy(sub->rtp);
+ ast_rtp_instance_destroy(sub->rtp);
sub->rtp = NULL;
}
/* Allocate the RTP now */
- sub->rtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr);
+ sub->rtp = ast_rtp_instance_new(NULL, sched, &bindaddr, NULL);
if (sub->rtp && sub->owner)
- ast_channel_set_fd(sub->owner, 0, ast_rtp_fd(sub->rtp));
+ ast_channel_set_fd(sub->owner, 0, ast_rtp_instance_fd(sub->rtp, 0));
if (sub->rtp) {
- ast_rtp_setqos(sub->rtp, qos.tos_audio, qos.cos_audio, "MGCP RTP");
- ast_rtp_setnat(sub->rtp, sub->nat);
+ ast_rtp_instance_set_qos(sub->rtp, qos.tos_audio, qos.cos_audio, "MGCP RTP");
+ ast_rtp_instance_set_prop(sub->rtp, AST_RTP_PROPERTY_NAT, sub->nat);
}
-#if 0
- ast_rtp_set_callback(p->rtp, rtpready);
- ast_rtp_set_data(p->rtp, p);
-#endif
/* Make a call*ID */
snprintf(sub->callid, sizeof(sub->callid), "%08lx%s", ast_random(), sub->txident);
/* Transmit the connection create */
@@ -3940,22 +3936,22 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
return (gw_reload ? NULL : gw);
}
-static enum ast_rtp_get_result mgcp_get_rtp_peer(struct ast_channel *chan, struct ast_rtp **rtp)
+static enum ast_rtp_glue_result mgcp_get_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance **instance)
{
struct mgcp_subchannel *sub = NULL;
if (!(sub = chan->tech_pvt) || !(sub->rtp))
- return AST_RTP_GET_FAILED;
+ return AST_RTP_GLUE_RESULT_FORBID;
- *rtp = sub->rtp;
+ *instance = sub->rtp ? ao2_ref(sub->rtp, +1), sub->rtp : NULL;
if (sub->parent->canreinvite)
- return AST_RTP_TRY_NATIVE;
+ return AST_RTP_GLUE_RESULT_REMOTE;
else
- return AST_RTP_TRY_PARTIAL;
+ return AST_RTP_GLUE_RESULT_LOCAL;
}
-static int mgcp_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, struct ast_rtp *trtp, int codecs, int nat_active)
+static int mgcp_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *rtp, struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, int codecs, int nat_active)
{
/* XXX Is there such thing as video support with MGCP? XXX */
struct mgcp_subchannel *sub;
@@ -3967,10 +3963,10 @@ static int mgcp_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, stru
return -1;
}
-static struct ast_rtp_protocol mgcp_rtp = {
+static struct ast_rtp_glue mgcp_rtp_glue = {
.type = "MGCP",
.get_rtp_info = mgcp_get_rtp_peer,
- .set_rtp_peer = mgcp_set_rtp_peer,
+ .update_peer = mgcp_set_rtp_peer,
};
static void destroy_endpoint(struct mgcp_endpoint *e)
@@ -3984,7 +3980,7 @@ static void destroy_endpoint(struct mgcp_endpoint *e)
transmit_connection_del(sub);
}
if (sub->rtp) {
- ast_rtp_destroy(sub->rtp);
+ ast_rtp_instance_destroy(sub->rtp);
sub->rtp = NULL;
}
memset(sub->magic, 0, sizeof(sub->magic));
@@ -4276,7 +4272,7 @@ static int load_module(void)
return AST_MODULE_LOAD_FAILURE;
}
- ast_rtp_proto_register(&mgcp_rtp);
+ ast_rtp_glue_register(&mgcp_rtp_glue);
ast_cli_register_multiple(cli_mgcp, sizeof(cli_mgcp) / sizeof(struct ast_cli_entry));
/* And start the monitor for the first time */
@@ -4379,7 +4375,7 @@ static int unload_module(void)
}
close(mgcpsock);
- ast_rtp_proto_unregister(&mgcp_rtp);
+ ast_rtp_glue_unregister(&mgcp_rtp_glue);
ast_cli_unregister_multiple(cli_mgcp, sizeof(cli_mgcp) / sizeof(struct ast_cli_entry));
sched_context_destroy(sched);
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 8afe7766a..4d0f06f4a 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -229,7 +229,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/pbx.h"
#include "asterisk/sched.h"
#include "asterisk/io.h"
-#include "asterisk/rtp.h"
+#include "asterisk/rtp_engine.h"
#include "asterisk/udptl.h"
#include "asterisk/acl.h"
#include "asterisk/manager.h"
@@ -271,6 +271,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/ast_version.h"
#include "asterisk/event.h"
#include "asterisk/tcptls.h"
+#include "asterisk/stun.h"
/*** DOCUMENTATION
<application name="SIPDtmfMode" language="en_US">
@@ -691,6 +692,7 @@ enum check_auth_result {
AUTH_PEER_NOT_DYNAMIC = -6,
AUTH_ACL_FAILED = -7,
AUTH_BAD_TRANSPORT = -8,
+ AUTH_RTP_FAILED = 9,
};
/*! \brief States for outbound registrations (with register= lines in sip.conf */
@@ -1011,6 +1013,7 @@ static const struct cfsip_options {
#define DEFAULT_USERAGENT "Asterisk PBX" /*!< Default Useragent: header unless re-defined in sip.conf */
#define DEFAULT_SDPSESSION "Asterisk PBX" /*!< Default SDP session name, (s=) header unless re-defined in sip.conf */
#define DEFAULT_SDPOWNER "root" /*!< Default SDP username field in (o=) header unless re-defined in sip.conf */
+#define DEFAULT_ENGINE "asterisk" /*!< Default RTP engine to use for sessions */
#endif
/*@}*/
@@ -1029,6 +1032,7 @@ static char default_mohinterpret[MAX_MUSICCLASS]; /*!< Global setting for moh c
static char default_mohsuggest[MAX_MUSICCLASS]; /*!< Global setting for moh class to suggest when putting
* a bridged channel on hold */
static char default_parkinglot[AST_MAX_CONTEXT]; /*!< Parkinglot */
+static char default_engine[256]; /*!< Default RTP engine */
static int default_maxcallbitrate; /*!< Maximum bitrate for call */
static struct ast_codec_pref default_prefs; /*!< Default codec prefs */
static unsigned int default_transports; /*!< Default Transports (enum sip_transport) that are acceptable */
@@ -1611,6 +1615,7 @@ struct sip_pvt {
AST_STRING_FIELD(rpid_from); /*!< Our RPID From header */
AST_STRING_FIELD(url); /*!< URL to be sent with next message to peer */
AST_STRING_FIELD(parkinglot); /*!< Parkinglot */
+ AST_STRING_FIELD(engine); /*!< RTP engine to use */
);
char via[128]; /*!< Via: header */
struct sip_socket socket; /*!< The socket used for this dialog */
@@ -1699,9 +1704,9 @@ struct sip_pvt {
struct sip_peer *relatedpeer; /*!< If this dialog is related to a peer, which one
Used in peerpoke, mwi subscriptions */
struct sip_registry *registry; /*!< If this is a REGISTER dialog, to which registry */
- struct ast_rtp *rtp; /*!< RTP Session */
- struct ast_rtp *vrtp; /*!< Video RTP session */
- struct ast_rtp *trtp; /*!< Text RTP session */
+ struct ast_rtp_instance *rtp; /*!< RTP Session */
+ struct ast_rtp_instance *vrtp; /*!< Video RTP session */
+ struct ast_rtp_instance *trtp; /*!< Text RTP session */
struct sip_pkt *packets; /*!< Packets scheduled for re-transmission */
struct sip_history_head *history; /*!< History of this SIP dialog */
size_t history_entries; /*!< Number of entires in the history */
@@ -1844,6 +1849,7 @@ struct sip_peer {
AST_STRING_FIELD(mohsuggest); /*!< Music on Hold class */
AST_STRING_FIELD(parkinglot); /*!< Parkinglot */
AST_STRING_FIELD(useragent); /*!< User agent in SIP request (saved from registration) */
+ AST_STRING_FIELD(engine); /*!< RTP Engine to use */
);
struct sip_socket socket; /*!< Socket used for this peer */
unsigned int transports:3; /*!< Transports (enum sip_transport) that are acceptable for this peer */
@@ -2564,14 +2570,6 @@ static void handle_response_subscribe(struct sip_pvt *p, int resp, char *rest, s
static int handle_response_register(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno);
static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno);
-/*----- RTP interface functions */
-static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, struct ast_rtp *trtp, int codecs, int nat_active);
-static enum ast_rtp_get_result sip_get_rtp_peer(struct ast_channel *chan, struct ast_rtp **rtp);
-static enum ast_rtp_get_result sip_get_vrtp_peer(struct ast_channel *chan, struct ast_rtp **rtp);
-static enum ast_rtp_get_result sip_get_trtp_peer(struct ast_channel *chan, struct ast_rtp **rtp);
-static int sip_get_codec(struct ast_channel *chan);
-static struct ast_frame *sip_rtp_read(struct ast_channel *ast, struct sip_pvt *p, int *faxdetect);
-
/*------ T38 Support --------- */
static int transmit_response_with_t38_sdp(struct sip_pvt *p, char *msg, struct sip_request *req, int retrans);
static struct ast_udptl *sip_get_udptl_peer(struct ast_channel *chan);
@@ -2592,6 +2590,9 @@ static enum st_refresher st_get_refresher(struct sip_pvt *);
static enum st_mode st_get_mode(struct sip_pvt *);
static struct sip_st_dlg* sip_st_alloc(struct sip_pvt *const p);
+/*------- RTP Glue functions -------- */
+static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_rtp_instance *vinstance, struct ast_rtp_instance *tinstance, int codecs, int nat_active);
+
/*!--- SIP MWI Subscription support */
static int sip_subscribe_mwi(const char *value, int lineno);
static void sip_subscribe_mwi_destroy(struct sip_subscription_mwi *mwi);
@@ -2620,8 +2621,8 @@ static const struct ast_channel_tech sip_tech = {
.fixup = sip_fixup, /* called with chan locked */
.send_digit_begin = sip_senddigit_begin, /* called with chan unlocked */
.send_digit_end = sip_senddigit_end,
- .bridge = ast_rtp_bridge, /* XXX chan unlocked ? */
- .early_bridge = ast_rtp_early_bridge,
+ .bridge = ast_rtp_instance_bridge, /* XXX chan unlocked ? */
+ .early_bridge = ast_rtp_instance_early_bridge,
.send_text = sip_sendtext, /* called with chan locked */
.func_channel_read = acf_channel_read,
.queryoption = sip_queryoption,
@@ -2694,17 +2695,6 @@ static int map_s_x(const struct _map_x_s *table, const char *s, int errorvalue)
return errorvalue;
}
-
-/*! \brief Interface structure with callbacks used to connect to RTP module */
-static struct ast_rtp_protocol sip_rtp = {
- .type = "SIP",
- .get_rtp_info = sip_get_rtp_peer,
- .get_vrtp_info = sip_get_vrtp_peer,
- .get_trtp_info = sip_get_trtp_peer,
- .set_rtp_peer = sip_set_rtp_peer,
- .get_codec = sip_get_codec,
-};
-
/*!
* duplicate a list of channel variables, \return the copy.
*/
@@ -4593,11 +4583,11 @@ static void do_setnat(struct sip_pvt *p, int natflags)
if (p->rtp) {
ast_debug(1, "Setting NAT on RTP to %s\n", mode);
- ast_rtp_setnat(p->rtp, natflags);
+ ast_rtp_instance_set_prop(p->rtp, AST_RTP_PROPERTY_NAT, natflags);
}
if (p->vrtp) {
ast_debug(1, "Setting NAT on VRTP to %s\n", mode);
- ast_rtp_setnat(p->vrtp, natflags);
+ ast_rtp_instance_set_prop(p->vrtp, AST_RTP_PROPERTY_NAT, natflags);
}
if (p->udptl) {
ast_debug(1, "Setting NAT on UDPTL to %s\n", mode);
@@ -4605,7 +4595,7 @@ static void do_setnat(struct sip_pvt *p, int natflags)
}
if (p->trtp) {
ast_debug(1, "Setting NAT on TRTP to %s\n", mode);
- ast_rtp_setnat(p->trtp, natflags);
+ ast_rtp_instance_set_prop(p->trtp, AST_RTP_PROPERTY_NAT, natflags);
}
}
@@ -4697,6 +4687,51 @@ static void copy_socket_data(struct sip_socket *to_sock, const struct sip_socket
*to_sock = *from_sock;
}
+/*! \brief Initialize RTP portion of a dialog
+ * \returns -1 on failure, 0 on success
+ */
+static int dialog_initialize_rtp(struct sip_pvt *dialog)
+{
+ if (!sip_methods[dialog->method].need_rtp) {
+ return 0;
+ }
+
+ if (!(dialog->rtp = ast_rtp_instance_new(dialog->engine, sched, &bindaddr, NULL))) {
+ return -1;
+ }
+
+ if (ast_test_flag(&dialog->flags[1], SIP_PAGE2_VIDEOSUPPORT) && (dialog->capability & AST_FORMAT_VIDEO_MASK)) {
+ if (!(dialog->vrtp = ast_rtp_instance_new(dialog->engine, sched, &bindaddr, NULL))) {
+ return -1;
+ }
+ ast_rtp_instance_set_timeout(dialog->vrtp, global_rtptimeout);
+ ast_rtp_instance_set_hold_timeout(dialog->vrtp, global_rtpholdtimeout);
+
+ ast_rtp_instance_set_prop(dialog->vrtp, AST_RTP_PROPERTY_RTCP, 1);
+ }
+
+ if (ast_test_flag(&dialog->flags[1], SIP_PAGE2_TEXTSUPPORT)) {
+ if (!(dialog->trtp = ast_rtp_instance_new(dialog->engine, sched, &bindaddr, NULL))) {
+ return -1;
+ }
+ ast_rtp_instance_set_timeout(dialog->trtp, global_rtptimeout);
+ ast_rtp_instance_set_hold_timeout(dialog->trtp, global_rtpholdtimeout);
+
+ ast_rtp_instance_set_prop(dialog->trtp, AST_RTP_PROPERTY_RTCP, 1);
+ }
+
+ ast_rtp_instance_set_timeout(dialog->rtp, global_rtptimeout);
+ ast_rtp_instance_set_hold_timeout(dialog->rtp, global_rtpholdtimeout);
+
+ ast_rtp_instance_set_prop(dialog->rtp, AST_RTP_PROPERTY_RTCP, 1);
+ ast_rtp_instance_set_prop(dialog->rtp, AST_RTP_PROPERTY_DTMF, ast_test_flag(&dialog->flags[0], SIP_DTMF) == SIP_DTMF_RFC2833);
+ ast_rtp_instance_set_prop(dialog->rtp, AST_RTP_PROPERTY_DTMF_COMPENSATE, ast_test_flag(&dialog->flags[1], SIP_PAGE2_RFC2833_COMPENSATE));
+
+ ast_rtp_instance_set_qos(dialog->rtp, global_tos_audio, 0, "SIP RTP");
+
+ return 0;
+}
+
/*! \brief Create address structure from peer reference.
* This function copies data from peer to the dialog, so we don't have to look up the peer
* again from memory or database during the life time of the dialog.
@@ -4724,17 +4759,6 @@ static int create_addr_from_peer(struct sip_pvt *dialog, struct sip_peer *peer)
ast_copy_flags(&dialog->flags[0], &peer->flags[0], SIP_FLAGS_TO_COPY);
ast_copy_flags(&dialog->flags[1], &peer->flags[1], SIP_PAGE2_FLAGS_TO_COPY);
dialog->capability = peer->capability;
- if (!ast_test_flag(&dialog->flags[1], SIP_PAGE2_VIDEOSUPPORT_ALWAYS) &&
- (!ast_test_flag(&dialog->flags[1], SIP_PAGE2_VIDEOSUPPORT) ||
- !(dialog->capability & AST_FORMAT_VIDEO_MASK)) &&
- dialog->vrtp) {
- ast_rtp_destroy(dialog->vrtp);
- dialog->vrtp = NULL;
- }
- if (!ast_test_flag(&dialog->flags[1], SIP_PAGE2_TEXTSUPPORT) && dialog->trtp) {
- ast_rtp_destroy(dialog->trtp);
- dialog->trtp = NULL;
- }
dialog->prefs = peer->prefs;
if (ast_test_flag(&dialog->flags[1], SIP_PAGE2_T38SUPPORT)) {
if (!dialog->udptl) {
@@ -4750,29 +4774,28 @@ static int create_addr_from_peer(struct sip_pvt *dialog, struct sip_peer *peer)
}
do_setnat(dialog, ast_test_flag(&dialog->flags[0], SIP_NAT) & SIP_NAT_ROUTE);
+ ast_string_field_set(dialog, engine, peer->engine);
+
+ if (dialog_initialize_rtp(dialog)) {
+ return -1;
+ }
+
if (dialog->rtp) { /* Audio */
- ast_rtp_setdtmf(dialog->rtp, ast_test_flag(&dialog->flags[0], SIP_DTMF) == SIP_DTMF_RFC2833);
- ast_rtp_setdtmfcompensate(dialog->rtp, ast_test_flag(&dialog->flags[1], SIP_PAGE2_RFC2833_COMPENSATE));
- ast_rtp_set_rtptimeout(dialog->rtp, peer->rtptimeout);
- ast_rtp_set_rtpholdtimeout(dialog->rtp, peer->rtpholdtimeout);
- ast_rtp_set_rtpkeepalive(dialog->rtp, peer->rtpkeepalive);
+ ast_rtp_instance_set_prop(dialog->rtp, AST_RTP_PROPERTY_DTMF, ast_test_flag(&dialog->flags[0], SIP_DTMF) == SIP_DTMF_RFC2833);
+ ast_rtp_instance_set_prop(dialog->rtp, AST_RTP_PROPERTY_DTMF_COMPENSATE, ast_test_flag(&dialog->flags[1], SIP_PAGE2_RFC2833_COMPENSATE));
+ ast_rtp_instance_set_timeout(dialog->rtp, peer->rtptimeout);
+ ast_rtp_instance_set_hold_timeout(dialog->rtp, peer->rtpholdtimeout);
/* Set Frame packetization */
- ast_rtp_codec_setpref(dialog->rtp, &dialog->prefs);
+ ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(dialog->rtp), dialog->rtp, &dialog->prefs);
dialog->autoframing = peer->autoframing;
}
if (dialog->vrtp) { /* Video */
- ast_rtp_setdtmf(dialog->vrtp, 0);
- ast_rtp_setdtmfcompensate(dialog->vrtp, 0);
- ast_rtp_set_rtptimeout(dialog->vrtp, peer->rtptimeout);
- ast_rtp_set_rtpholdtimeout(dialog->vrtp, peer->rtpholdtimeout);
- ast_rtp_set_rtpkeepalive(dialog->vrtp, peer->rtpkeepalive);
+ ast_rtp_instance_set_timeout(dialog->vrtp, peer->rtptimeout);
+ ast_rtp_instance_set_hold_timeout(dialog->vrtp, peer->rtpholdtimeout);
}
if (dialog->trtp) { /* Realtime text */
- ast_rtp_setdtmf(dialog->trtp, 0);
- ast_rtp_setdtmfcompensate(dialog->trtp, 0);
- ast_rtp_set_rtptimeout(dialog->trtp, peer->rtptimeout);
- ast_rtp_set_rtpholdtimeout(dialog->trtp, peer->rtpholdtimeout);
- ast_rtp_set_rtpkeepalive(dialog->trtp, peer->rtpkeepalive);
+ ast_rtp_instance_set_timeout(dialog->trtp, peer->rtptimeout);
+ ast_rtp_instance_set_hold_timeout(dialog->trtp, peer->rtpholdtimeout);
}
ast_string_field_set(dialog, peername, peer->name);
@@ -4786,6 +4809,7 @@ static int create_addr_from_peer(struct sip_pvt *dialog, struct sip_peer *peer)
ast_string_field_set(dialog, fullcontact, peer->fullcontact);
ast_string_field_set(dialog, context, peer->context);
ast_string_field_set(dialog, parkinglot, peer->parkinglot);
+ ast_string_field_set(dialog, engine, peer->engine);
ref_proxy(dialog, obproxy_get(dialog, peer));
dialog->callgroup = peer->callgroup;
dialog->pickupgroup = peer->pickupgroup;
@@ -4881,6 +4905,10 @@ static int create_addr(struct sip_pvt *dialog, const char *opeer, struct sockadd
return res;
}
+ if (dialog_initialize_rtp(dialog)) {
+ return -1;
+ }
+
do_setnat(dialog, ast_test_flag(&dialog->flags[0], SIP_NAT) & SIP_NAT_ROUTE);
ast_string_field_set(dialog, tohost, peername);
@@ -5155,15 +5183,13 @@ static void __sip_destroy(struct sip_pvt *p, int lockowner, int lockdialoglist)
p->notify_headers = NULL;
}
if (p->rtp) {
- ast_rtp_destroy(p->rtp);
+ ast_rtp_instance_destroy(p->rtp);
}
if (p->vrtp) {
- ast_rtp_destroy(p->vrtp);
+ ast_rtp_instance_destroy(p->vrtp);
}
if (p->trtp) {
- while (ast_rtp_get_bridged(p->trtp))
- usleep(1);
- ast_rtp_destroy(p->trtp);
+ ast_rtp_instance_destroy(p->trtp);
}
if (p->udptl)
ast_udptl_destroy(p->udptl);
@@ -5682,42 +5708,50 @@ static int sip_hangup(struct ast_channel *ast)
if (!p->pendinginvite) {
struct ast_channel *bridge = ast_bridged_channel(oldowner);
- char *audioqos = "";
- char *videoqos = "";
- char *textqos = "";
+ char quality_buf[AST_MAX_USER_FIELD], *quality;
- if (p->rtp)
- ast_rtp_set_vars(oldowner, p->rtp);
+ if (p->rtp) {
+ ast_rtp_instance_set_stats_vars(oldowner, p->rtp);
+ }
if (bridge) {
struct sip_pvt *q = bridge->tech_pvt;
- if (IS_SIP_TECH(bridge->tech) && q)
- ast_rtp_set_vars(bridge, q->rtp);
+ if (IS_SIP_TECH(bridge->tech) && q) {
+ ast_rtp_instance_set_stats_vars(bridge, q->rtp);
+ }
+ }
+
+ if (p->do_history || oldowner) {
+ if (p->rtp && (quality = ast_rtp_instance_get_quality(p->rtp, AST_RTP_INSTANCE_STAT_FIELD_QUALITY, quality_buf, sizeof(quality_buf)))) {
+ if (p->do_history) {
+ append_history(p, "RTCPaudio", "Quality:%s", quality);
+ }
+ if (oldowner) {
+ pbx_builtin_setvar_helper(oldowner, "RTPAUDIOQOS", quality);
+ }
+ }
+ if (p->vrtp && (quality = ast_rtp_instance_get_quality(p->vrtp, AST_RTP_INSTANCE_STAT_FIELD_QUALITY, quality_buf, sizeof(quality_buf)))) {
+ if (p->do_history) {
+ append_history(p, "RTCPvideo", "Quality:%s", quality);
+ }
+ if (oldowner) {
+ pbx_builtin_setvar_helper(oldowner, "RTPVIDEOQOS", quality);
+ }
+ }
+ if (p->trtp && (quality = ast_rtp_instance_get_quality(p->trtp, AST_RTP_INSTANCE_STAT_FIELD_QUALITY, quality_buf, sizeof(quality_buf)))) {
+ if (p->do_history) {
+ append_history(p, "RTCPtext", "Quality:%s", quality);
+ }
+ if (oldowner) {
+ pbx_builtin_setvar_helper(oldowner, "RTPTEXTQOS", quality);
+ }
+ }
}
- if (p->vrtp)
- videoqos = ast_rtp_get_quality(p->vrtp, NULL, RTPQOS_SUMMARY);
- if (p->trtp)
- textqos = ast_rtp_get_quality(p->trtp, NULL, RTPQOS_SUMMARY);
/* Send a hangup */
transmit_request_with_auth(p, SIP_BYE, 0, XMIT_RELIABLE, 1);
- /* Get RTCP quality before end of call */
- if (p->do_history) {
- if (p->rtp)
- append_history(p, "RTCPaudio", "Quality:%s", audioqos);
- if (p->vrtp)
- append_history(p, "RTCPvideo", "Quality:%s", videoqos);
- if (p->trtp)
- append_history(p, "RTCPtext", "Quality:%s", textqos);
- }
- if (p->rtp && oldowner)
- pbx_builtin_setvar_helper(oldowner, "RTPAUDIOQOS", audioqos);
- if (p->vrtp && oldowner)
- pbx_builtin_setvar_helper(oldowner, "RTPVIDEOQOS", videoqos);
- if (p->trtp && oldowner)
- pbx_builtin_setvar_helper(oldowner, "RTPTEXTQOS", textqos);
} else {
/* Note we will need a BYE when this all settles out
but we can't send one while we have "INVITE" outstanding. */
@@ -5772,7 +5806,10 @@ static int sip_answer(struct ast_channel *ast)
ast_setstate(ast, AST_STATE_UP);
ast_debug(1, "SIP answering channel: %s\n", ast->name);
- ast_rtp_new_source(p->rtp);
+ if (p->t38.state == T38_PEER_DIRECT) {
+ change_t38_state(p, T38_ENABLED);
+ }
+ ast_rtp_instance_new_source(p->rtp);
res = transmit_response_with_sdp(p, "200 OK", &p->initreq, XMIT_CRITICAL, FALSE);
ast_set_flag(&p->flags[1], SIP_PAGE2_DIALOG_ESTABLISHED);
}
@@ -5807,7 +5844,7 @@ static int sip_write(struct ast_channel *ast, struct ast_frame *frame)
if ((ast->_state != AST_STATE_UP) &&
!ast_test_flag(&p->flags[0], SIP_PROGRESS_SENT) &&
!ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
- ast_rtp_new_source(p->rtp);
+ ast_rtp_instance_new_source(p->rtp);
p->invitestate = INV_EARLY_MEDIA;
transmit_response_with_sdp(p, "183 Session Progress", &p->initreq, XMIT_UNRELIABLE, FALSE);
ast_set_flag(&p->flags[0], SIP_PROGRESS_SENT);
@@ -5816,7 +5853,7 @@ static int sip_write(struct ast_channel *ast, struct ast_frame *frame)
transmit_reinvite_with_sdp(p, FALSE, FALSE);
} else {
p->lastrtptx = time(NULL);
- res = ast_rtp_write(p->rtp, frame);
+ res = ast_rtp_instance_write(p->rtp, frame);
}
}
sip_pvt_unlock(p);
@@ -5835,7 +5872,7 @@ static int sip_write(struct ast_channel *ast, struct ast_frame *frame)
ast_set_flag(&p->flags[0], SIP_PROGRESS_SENT);
}
p->lastrtptx = time(NULL);
- res = ast_rtp_write(p->vrtp, frame);
+ res = ast_rtp_instance_write(p->vrtp, frame);
}
sip_pvt_unlock(p);
}
@@ -5844,7 +5881,7 @@ static int sip_write(struct ast_channel *ast, struct ast_frame *frame)
if (p) {
sip_pvt_lock(p);
if (p->red) {
- ast_red_buffer_t140(p->trtp, frame);
+ ast_rtp_red_buffer(p->trtp, frame);
} else {
if (p->trtp) {
/* Activate text early media */
@@ -5856,7 +5893,7 @@ static int sip_write(struct ast_channel *ast, struct ast_frame *frame)
ast_set_flag(&p->flags[0], SIP_PROGRESS_SENT);
}
p->lastrtptx = time(NULL);
- res = ast_rtp_write(p->trtp, frame);
+ res = ast_rtp_instance_write(p->trtp, frame);
}
}
sip_pvt_unlock(p);
@@ -5944,11 +5981,15 @@ static int sip_senddigit_begin(struct ast_channel *ast, char digit)
sip_pvt_lock(p);
switch (ast_test_flag(&p->flags[0], SIP_DTMF)) {
case SIP_DTMF_INBAND:
- res = -1; /* Tell Asterisk to generate inband indications */
+ if (p->rtp && ast_rtp_instance_dtmf_mode_get(p->rtp) == AST_RTP_DTMF_MODE_INBAND) {
+ ast_rtp_instance_dtmf_begin(p->rtp, digit);
+ } else {
+ res = -1; /* Tell Asterisk to generate inband indications */
+ }
break;
case SIP_DTMF_RFC2833:
if (p->rtp)
- ast_rtp_senddigit_begin(p->rtp, digit);
+ ast_rtp_instance_dtmf_begin(p->rtp, digit);
break;
default:
break;
@@ -5973,10 +6014,14 @@ static int sip_senddigit_end(struct ast_channel *ast, char digit, unsigned int d
break;
case SIP_DTMF_RFC2833:
if (p->rtp)
- ast_rtp_senddigit_end(p->rtp, digit);
+ ast_rtp_instance_dtmf_end(p->rtp, digit);
break;
case SIP_DTMF_INBAND:
- res = -1; /* Tell Asterisk to stop inband indications */
+ if (p->rtp && ast_rtp_instance_dtmf_mode_get(p->rtp) == AST_RTP_DTMF_MODE_INBAND) {
+ ast_rtp_instance_dtmf_end(p->rtp, digit);
+ } else {
+ res = -1; /* Tell Asterisk to stop inband indications */
+ }
break;
}
sip_pvt_unlock(p);
@@ -6071,11 +6116,11 @@ static int sip_indicate(struct ast_channel *ast, int condition, const void *data
res = -1;
break;
case AST_CONTROL_HOLD:
- ast_rtp_new_source(p->rtp);
+ ast_rtp_instance_new_source(p->rtp);
ast_moh_start(ast, data, p->mohinterpret);
break;
case AST_CONTROL_UNHOLD:
- ast_rtp_new_source(p->rtp);
+ ast_rtp_instance_new_source(p->rtp);
ast_moh_stop(ast);
break;
case AST_CONTROL_VIDUPDATE: /* Request a video frame update */
@@ -6121,7 +6166,7 @@ static int sip_indicate(struct ast_channel *ast, int condition, const void *data
}
break;
case AST_CONTROL_SRCUPDATE:
- ast_rtp_new_source(p->rtp);
+ ast_rtp_instance_new_source(p->rtp);
break;
case -1:
res = -1;
@@ -6235,23 +6280,29 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
ast_debug(3, "This channel will not be able to handle video.\n");
if ((ast_test_flag(&i->flags[0], SIP_DTMF) == SIP_DTMF_INBAND) || (ast_test_flag(&i->flags[0], SIP_DTMF) == SIP_DTMF_AUTO)) {
- i->vad = ast_dsp_new();
- ast_dsp_set_features(i->vad, DSP_FEATURE_DIGIT_DETECT);
- if (global_relaxdtmf)
- ast_dsp_set_digitmode(i->vad, DSP_DIGITMODE_DTMF | DSP_DIGITMODE_RELAXDTMF);
+ if (!i->rtp || ast_rtp_instance_dtmf_mode_set(i->rtp, AST_RTP_DTMF_MODE_INBAND)) {
+ i->vad = ast_dsp_new();
+ ast_dsp_set_features(i->vad, DSP_FEATURE_DIGIT_DETECT);
+ if (global_relaxdtmf)
+ ast_dsp_set_digitmode(i->vad, DSP_DIGITMODE_DTMF | DSP_DIGITMODE_RELAXDTMF);
+ }
+ } else if (ast_test_flag(&i->flags[0], SIP_DTMF) == SIP_DTMF_RFC2833) {
+ if (i->rtp) {
+ ast_rtp_instance_dtmf_mode_set(i->rtp, AST_RTP_DTMF_MODE_RFC2833);
+ }
}
/* Set file descriptors for audio, video, realtime text and UDPTL as needed */
if (i->rtp) {
- ast_channel_set_fd(tmp, 0, ast_rtp_fd(i->rtp));
- ast_channel_set_fd(tmp, 1, ast_rtcp_fd(i->rtp));
+ ast_channel_set_fd(tmp, 0, ast_rtp_instance_fd(i->rtp, 0));
+ ast_channel_set_fd(tmp, 1, ast_rtp_instance_fd(i->rtp, 1));
}
if (needvideo && i->vrtp) {
- ast_channel_set_fd(tmp, 2, ast_rtp_fd(i->vrtp));
- ast_channel_set_fd(tmp, 3, ast_rtcp_fd(i->vrtp));
+ ast_channel_set_fd(tmp, 2, ast_rtp_instance_fd(i->vrtp, 0));
+ ast_channel_set_fd(tmp, 3, ast_rtp_instance_fd(i->vrtp, 1));
}
if (needtext && i->trtp)
- ast_channel_set_fd(tmp, 4, ast_rtp_fd(i->trtp));
+ ast_channel_set_fd(tmp, 4, ast_rtp_instance_fd(i->trtp, 0));
if (i->udptl)
ast_channel_set_fd(tmp, 5, ast_udptl_fd(i->udptl));
@@ -6475,19 +6526,19 @@ static struct ast_frame *sip_rtp_read(struct ast_channel *ast, struct sip_pvt *p
switch(ast->fdno) {
case 0:
- f = ast_rtp_read(p->rtp); /* RTP Audio */
+ f = ast_rtp_instance_read(p->rtp, 0); /* RTP Audio */
break;
case 1:
- f = ast_rtcp_read(p->rtp); /* RTCP Control Channel */
+ f = ast_rtp_instance_read(p->rtp, 1); /* RTCP Control Channel */
break;
case 2:
- f = ast_rtp_read(p->vrtp); /* RTP Video */
+ f = ast_rtp_instance_read(p->vrtp, 0); /* RTP Video */
break;
case 3:
- f = ast_rtcp_read(p->vrtp); /* RTCP Control Channel for video */
+ f = ast_rtp_instance_read(p->vrtp, 1); /* RTCP Control Channel for video */
break;
case 4:
- f = ast_rtp_read(p->trtp); /* RTP Text */
+ f = ast_rtp_instance_read(p->trtp, 0); /* RTP Text */
if (sipdebug_text) {
int i;
unsigned char* arr = f->data.ptr;
@@ -6694,50 +6745,11 @@ static struct sip_pvt *sip_alloc(ast_string_field callid, struct sockaddr_in *si
p->ocseq = INITIAL_CSEQ;
if (sip_methods[intended_method].need_rtp) {
- p->rtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr);
- /* If the global videosupport flag is on, we always create a RTP interface for video */
- if (ast_test_flag(&p->flags[1], SIP_PAGE2_VIDEOSUPPORT))
- p->vrtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr);
- if (ast_test_flag(&p->flags[1], SIP_PAGE2_TEXTSUPPORT))
- p->trtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr);
- if (ast_test_flag(&p->flags[1], SIP_PAGE2_T38SUPPORT))
- p->udptl = ast_udptl_new_with_bindaddr(sched, io, 0, bindaddr.sin_addr);
- if (!p->rtp|| (ast_test_flag(&p->flags[1], SIP_PAGE2_VIDEOSUPPORT) && !p->vrtp)
- || (ast_test_flag(&p->flags[1], SIP_PAGE2_TEXTSUPPORT) && !p->trtp)) {
- ast_log(LOG_WARNING, "Unable to create RTP audio %s%ssession: %s\n",
- ast_test_flag(&p->flags[1], SIP_PAGE2_VIDEOSUPPORT) ? "and video " : "",
- ast_test_flag(&p->flags[1], SIP_PAGE2_TEXTSUPPORT) ? "and text " : "", strerror(errno));
- if (p->chanvars) {
- ast_variables_destroy(p->chanvars);
- p->chanvars = NULL;
- }
- ao2_t_ref(p, -1, "failed to create RTP audio session, drop p");
- return NULL;
- }
- ast_rtp_setqos(p->rtp, global_tos_audio, global_cos_audio, "SIP RTP");
- ast_rtp_setdtmf(p->rtp, ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_RFC2833);
- ast_rtp_setdtmfcompensate(p->rtp, ast_test_flag(&p->flags[1], SIP_PAGE2_RFC2833_COMPENSATE));
- ast_rtp_set_rtptimeout(p->rtp, global_rtptimeout);
- ast_rtp_set_rtpholdtimeout(p->rtp, global_rtpholdtimeout);
- ast_rtp_set_rtpkeepalive(p->rtp, global_rtpkeepalive);
- if (p->vrtp) {
- ast_rtp_setqos(p->vrtp, global_tos_video, global_cos_video, "SIP VRTP");
- ast_rtp_setdtmf(p->vrtp, 0);
- ast_rtp_setdtmfcompensate(p->vrtp, 0);
- ast_rtp_set_rtptimeout(p->vrtp, global_rtptimeout);
- ast_rtp_set_rtpholdtimeout(p->vrtp, global_rtpholdtimeout);
- ast_rtp_set_rtpkeepalive(p->vrtp, global_rtpkeepalive);
- }
- if (p->trtp) {
- ast_rtp_setqos(p->trtp, global_tos_text, global_cos_text, "SIP TRTP");
- ast_rtp_setdtmf(p->trtp, 0);
- ast_rtp_setdtmfcompensate(p->trtp, 0);
- }
- if (p->udptl)
+ if (ast_test_flag(&p->flags[1], SIP_PAGE2_T38SUPPORT) && (p->udptl = ast_udptl_new_with_bindaddr(sched, io, 0, bindaddr.sin_addr))) {
ast_udptl_setqos(p->udptl, global_tos_audio, global_cos_audio);
+ }
p->maxcallbitrate = default_maxcallbitrate;
p->autoframing = global_autoframing;
- ast_rtp_codec_setpref(p->rtp, &p->prefs);
}
if (useglobal_nat && sin) {
@@ -6769,6 +6781,7 @@ static struct sip_pvt *sip_alloc(ast_string_field callid, struct sockaddr_in *si
}
ast_string_field_set(p, context, sip_cfg.default_context);
ast_string_field_set(p, parkinglot, default_parkinglot);
+ ast_string_field_set(p, engine, default_engine);
AST_LIST_HEAD_INIT_NOLOCK(&p->request_queue);
@@ -7403,7 +7416,7 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
int iterator;
int sendonly = -1;
int numberofports;
- struct ast_rtp *newaudiortp, *newvideortp, *newtextrtp; /* Buffers for codec handling */
+ struct ast_rtp_codecs newaudiortp, newvideortp, newtextrtp;
int newjointcapability; /* Negotiated capability */
int newpeercapability;
int newnoncodeccapability;
@@ -7428,33 +7441,10 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
return -1;
}
- /* Initialize the temporary RTP structures we use to evaluate the offer from the peer */
-#ifdef LOW_MEMORY
- newaudiortp = ast_threadstorage_get(&ts_audio_rtp, ast_rtp_alloc_size());
-#else
- newaudiortp = alloca(ast_rtp_alloc_size());
-#endif
- memset(newaudiortp, 0, ast_rtp_alloc_size());
- ast_rtp_new_init(newaudiortp);
- ast_rtp_pt_clear(newaudiortp);
-
-#ifdef LOW_MEMORY
- newvideortp = ast_threadstorage_get(&ts_video_rtp, ast_rtp_alloc_size());
-#else
- newvideortp = alloca(ast_rtp_alloc_size());
-#endif
- memset(newvideortp, 0, ast_rtp_alloc_size());
- ast_rtp_new_init(newvideortp);
- ast_rtp_pt_clear(newvideortp);
-
-#ifdef LOW_MEMORY
- newtextrtp = ast_threadstorage_get(&ts_text_rtp, ast_rtp_alloc_size());
-#else
- newtextrtp = alloca(ast_rtp_alloc_size());
-#endif
- memset(newtextrtp, 0, ast_rtp_alloc_size());
- ast_rtp_new_init(newtextrtp);
- ast_rtp_pt_clear(newtextrtp);
+ /* Make sure that the codec structures are all cleared out */
+ ast_rtp_codecs_payloads_clear(&newaudiortp, NULL);
+ ast_rtp_codecs_payloads_clear(&newvideortp, NULL);
+ ast_rtp_codecs_payloads_clear(&newtextrtp, NULL);
/* Update our last rtprx when we receive an SDP, too */
p->lastrtprx = p->lastrtptx = time(NULL); /* XXX why both ? */
@@ -7536,11 +7526,13 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
p->novideo = TRUE;
p->notext = TRUE;
- if (p->vrtp)
- ast_rtp_pt_clear(newvideortp); /* Must be cleared in case no m=video line exists */
-
- if (p->trtp)
- ast_rtp_pt_clear(newtextrtp); /* Must be cleared in case no m=text line exists */
+ if (p->vrtp) {
+ ast_rtp_codecs_payloads_clear(&newvideortp, NULL);
+ }
+
+ if (p->trtp) {
+ ast_rtp_codecs_payloads_clear(&newtextrtp, NULL);
+ }
/* Find media streams in this SDP offer */
while ((m = get_sdp_iterate(&iterator, req, "m"))[0] != '\0') {
@@ -7565,7 +7557,8 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
}
if (debug)
ast_verbose("Found RTP audio format %d\n", codec);
- ast_rtp_set_m_type(newaudiortp, codec);
+
+ ast_rtp_codecs_payloads_set_m_type(&newaudiortp, NULL, codec);
}
} else if ((sscanf(m, "video %d/%d RTP/AVP %n", &x, &numberofports, &len) == 2 && len > 0) ||
(sscanf(m, "video %d RTP/AVP %n", &x, &len) == 1 && len >= 0)) {
@@ -7581,7 +7574,7 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
}
if (debug)
ast_verbose("Found RTP video format %d\n", codec);
- ast_rtp_set_m_type(newvideortp, codec);
+ ast_rtp_codecs_payloads_set_m_type(&newvideortp, NULL, codec);
}
} else if ((sscanf(m, "text %d/%d RTP/AVP %n", &x, &numberofports, &len) == 2 && len > 0) ||
(sscanf(m, "text %d RTP/AVP %n", &x, &len) == 1 && len > 0)) {
@@ -7597,7 +7590,7 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
}
if (debug)
ast_verbose("Found RTP text format %d\n", codec);
- ast_rtp_set_m_type(newtextrtp, codec);
+ ast_rtp_codecs_payloads_set_m_type(&newtextrtp, NULL, codec);
}
} else if (p->udptl && ( (sscanf(m, "image %d udptl t38%n", &x, &len) == 1 && len > 0) ||
(sscanf(m, "image %d UDPTL t38%n", &x, &len) == 1 && len > 0) )) {
@@ -7662,10 +7655,10 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
if (udptlportno > 0) {
sin.sin_port = htons(udptlportno);
if (ast_test_flag(&p->flags[0], SIP_NAT) && ast_test_flag(&p->flags[1], SIP_PAGE2_UDPTL_DESTINATION)) {
- struct sockaddr_in peer;
- ast_rtp_get_peer(p->rtp, &peer);
- if (peer.sin_addr.s_addr) {
- memcpy(&sin.sin_addr, &peer.sin_addr, sizeof(sin.sin_addr));
+ struct sockaddr_in remote_address;
+ ast_rtp_instance_get_remote_address(p->rtp, &remote_address);
+ if (remote_address.sin_addr.s_addr) {
+ memcpy(&sin, &remote_address, sizeof(sin));
if (debug) {
ast_log(LOG_DEBUG, "Peer T.38 UDPTL is set behind NAT and with destination, destination address now %s\n", ast_inet_ntoa(sin.sin_addr));
}
@@ -7685,7 +7678,7 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
if (p->rtp) {
if (portno > 0) {
sin.sin_port = htons(portno);
- ast_rtp_set_peer(p->rtp, &sin);
+ ast_rtp_instance_set_remote_address(p->rtp, &sin);
if (debug)
ast_verbose("Peer audio RTP is at port %s:%d\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
} else {
@@ -7693,7 +7686,7 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
if (debug)
ast_verbose("Got T.38 Re-invite without audio. Keeping RTP active during T.38 session. Callid %s\n", p->callid);
} else {
- ast_rtp_stop(p->rtp);
+ ast_rtp_instance_stop(p->rtp);
if (debug)
ast_verbose("Peer doesn't provide audio. Callid %s\n", p->callid);
}
@@ -7776,18 +7769,17 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
}
}
if (framing && p->autoframing) {
- struct ast_codec_pref *pref = ast_rtp_codec_getpref(p->rtp);
+ struct ast_codec_pref *pref = &ast_rtp_instance_get_codecs(p->rtp)->pref;
int codec_n;
- int format = 0;
- for (codec_n = 0; codec_n < MAX_RTP_PT; codec_n++) {
- format = ast_rtp_codec_getformat(codec_n);
- if (!format) /* non-codec or not found */
+ for (codec_n = 0; codec_n < AST_RTP_MAX_PT; codec_n++) {
+ struct ast_rtp_payload_type format = ast_rtp_codecs_payload_lookup(ast_rtp_instance_get_codecs(p->rtp), codec_n);
+ if (!format.asterisk_format || !format.code) /* non-codec or not found */
continue;
if (option_debug)
- ast_log(LOG_DEBUG, "Setting framing for %d to %ld\n", format, framing);
- ast_codec_pref_setsize(pref, format, framing);
+ ast_log(LOG_DEBUG, "Setting framing for %d to %ld\n", format.code, framing);
+ ast_codec_pref_setsize(pref, format.code, framing);
}
- ast_rtp_codec_setpref(p->rtp, pref);
+ ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(p->rtp), p->rtp, pref);
}
continue;
}
@@ -7799,7 +7791,7 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
sscanf(red_cp, "%u", &red_data_pt[red_num_gen]);
red_cp = strtok(red_cp, "/");
- while (red_cp && red_num_gen++ < RED_MAX_GENERATION) {
+ while (red_cp && red_num_gen++ < AST_RED_MAX_GENERATION) {
sscanf(red_cp, "%u", &red_data_pt[red_num_gen]);
red_cp = strtok(NULL, "/");
}
@@ -7808,15 +7800,15 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
}
if (sscanf(a, "fmtp: %u %63s", &codec, fmtp_string) == 2) {
- struct rtpPayloadType payload;
+ struct ast_rtp_payload_type payload;
unsigned int handled = 0;
- payload = ast_rtp_lookup_pt(newaudiortp, codec);
+ payload = ast_rtp_codecs_payload_lookup(&newaudiortp, codec);
if (!payload.code) {
/* it wasn't found, try the video rtp */
- payload = ast_rtp_lookup_pt(newvideortp, codec);
+ payload = ast_rtp_codecs_payload_lookup(&newvideortp, codec);
}
- if (payload.code && payload.isAstFormat) {
+ if (payload.code && payload.asterisk_format) {
unsigned int bit_rate;
switch (payload.code) {
@@ -7824,7 +7816,7 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
if (sscanf(fmtp_string, "bitrate=%u", &bit_rate) == 1) {
if (bit_rate != 32000) {
ast_log(LOG_WARNING, "Got Siren7 offer at %d bps, but only 32000 bps supported; ignoring.\n", bit_rate);
- ast_rtp_unset_m_type(newaudiortp, codec);
+ ast_rtp_codecs_payloads_unset(&newaudiortp, NULL, codec);
} else {
handled = 1;
}
@@ -7834,7 +7826,7 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
if (sscanf(fmtp_string, "bitrate=%u", &bit_rate) == 1) {
if (bit_rate != 48000) {
ast_log(LOG_WARNING, "Got Siren14 offer at %d bps, but only 48000 bps supported; ignoring.\n", bit_rate);
- ast_rtp_unset_m_type(newaudiortp, codec);
+ ast_rtp_codecs_payloads_unset(&newaudiortp, NULL, codec);
} else {
handled = 1;
}
@@ -7856,24 +7848,24 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
/* Note: should really look at the '#chans' params too */
/* Note: This should all be done in the context of the m= above */
if (!strncasecmp(mimeSubtype, "H26", 3) || !strncasecmp(mimeSubtype, "MP4", 3)) { /* Video */
- if (ast_rtp_set_rtpmap_type_rate(newvideortp, codec, "video", mimeSubtype, 0, sample_rate) != -1) {
+ if (ast_rtp_codecs_payloads_set_rtpmap_type_rate(&newvideortp, NULL, codec, "video", mimeSubtype, 0, sample_rate) != -1) {
if (debug)
ast_verbose("Found video description format %s for ID %d\n", mimeSubtype, codec);
found_rtpmap_codecs[last_rtpmap_codec] = codec;
last_rtpmap_codec++;
} else {
- ast_rtp_unset_m_type(newvideortp, codec);
+ ast_rtp_codecs_payloads_unset(&newvideortp, NULL, codec);
if (debug)
ast_verbose("Found unknown media description format %s for ID %d\n", mimeSubtype, codec);
}
} else if (!strncasecmp(mimeSubtype, "T140", 4)) { /* Text */
if (p->trtp) {
/* ast_verbose("Adding t140 mimeSubtype to textrtp struct\n"); */
- ast_rtp_set_rtpmap_type(newtextrtp, codec, "text", mimeSubtype, 0);
+ ast_rtp_codecs_payloads_set_rtpmap_type_rate(&newtextrtp, NULL, codec, "text", mimeSubtype, 0, sample_rate);
}
} else if (!strncasecmp(mimeSubtype, "RED", 3)) { /* Text with Redudancy */
if (p->trtp) {
- ast_rtp_set_rtpmap_type(newtextrtp, codec, "text", mimeSubtype, 0);
+ ast_rtp_codecs_payloads_set_rtpmap_type_rate(&newtextrtp, NULL, codec, "text", mimeSubtype, 0, sample_rate);
red_pt = codec;
sprintf(red_fmtp, "fmtp:%d ", red_pt);
@@ -7881,15 +7873,14 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
ast_verbose("RED submimetype has payload type: %d\n", red_pt);
}
} else { /* Must be audio?? */
- if (ast_rtp_set_rtpmap_type_rate(newaudiortp, codec, "audio", mimeSubtype,
- ast_test_flag(&p->flags[0], SIP_G726_NONSTANDARD) ? AST_RTP_OPT_G726_NONSTANDARD : 0,
- sample_rate) != -1) {
+ if (ast_rtp_codecs_payloads_set_rtpmap_type_rate(&newaudiortp, NULL, codec, "audio", mimeSubtype,
+ ast_test_flag(&p->flags[0], SIP_G726_NONSTANDARD) ? AST_RTP_OPT_G726_NONSTANDARD : 0, sample_rate) != -1) {
if (debug)
ast_verbose("Found audio description format %s for ID %d\n", mimeSubtype, codec);
found_rtpmap_codecs[last_rtpmap_codec] = codec;
last_rtpmap_codec++;
} else {
- ast_rtp_unset_m_type(newaudiortp, codec);
+ ast_rtp_codecs_payloads_unset(&newaudiortp, NULL, codec);
if (debug)
ast_verbose("Found unknown media description format %s for ID %d\n", mimeSubtype, codec);
}
@@ -8028,15 +8019,14 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
}
/* Now gather all of the codecs that we are asked for: */
- ast_rtp_get_current_formats(newaudiortp, &peercapability, &peernoncodeccapability);
- ast_rtp_get_current_formats(newvideortp, &vpeercapability, &vpeernoncodeccapability);
- ast_rtp_get_current_formats(newtextrtp, &tpeercapability, &tpeernoncodeccapability);
+ ast_rtp_codecs_payload_formats(&newaudiortp, &peercapability, &peernoncodeccapability);
+ ast_rtp_codecs_payload_formats(&newvideortp, &vpeercapability, &vpeernoncodeccapability);
+ ast_rtp_codecs_payload_formats(&newtextrtp, &tpeercapability, &tpeernoncodeccapability);
newjointcapability = p->capability & (peercapability | vpeercapability | tpeercapability);
newpeercapability = (peercapability | vpeercapability | tpeercapability);
newnoncodeccapability = p->noncodeccapability & peernoncodeccapability;
-
-
+
if (debug) {
/* shame on whoever coded this.... */
char s1[SIPBUFSIZE], s2[SIPBUFSIZE], s3[SIPBUFSIZE], s4[SIPBUFSIZE], s5[SIPBUFSIZE];
@@ -8047,11 +8037,17 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
ast_getformatname_multiple(s3, SIPBUFSIZE, vpeercapability),
ast_getformatname_multiple(s4, SIPBUFSIZE, tpeercapability),
ast_getformatname_multiple(s5, SIPBUFSIZE, newjointcapability));
+ }
+
+ if (debug) {
+ struct ast_str *s1 = ast_str_alloca(SIPBUFSIZE);
+ struct ast_str *s2 = ast_str_alloca(SIPBUFSIZE);
+ struct ast_str *s3 = ast_str_alloca(SIPBUFSIZE);
ast_verbose("Non-codec capabilities (dtmf): us - %s, peer - %s, combined - %s\n",
- ast_rtp_lookup_mime_multiple(s1, SIPBUFSIZE, p->noncodeccapability, 0, 0),
- ast_rtp_lookup_mime_multiple(s2, SIPBUFSIZE, peernoncodeccapability, 0, 0),
- ast_rtp_lookup_mime_multiple(s3, SIPBUFSIZE, newnoncodeccapability, 0, 0));
+ ast_rtp_lookup_mime_multiple2(s1, p->noncodeccapability, 0, 0),
+ ast_rtp_lookup_mime_multiple2(s2, peernoncodeccapability, 0, 0),
+ ast_rtp_lookup_mime_multiple2(s3, newnoncodeccapability, 0, 0));
}
if (!newjointcapability) {
/* If T.38 was not negotiated either, totally bail out... */
@@ -8082,11 +8078,13 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
p->red = 0;
}
- ast_rtp_pt_copy(p->rtp, newaudiortp);
- if (p->vrtp)
- ast_rtp_pt_copy(p->vrtp, newvideortp);
- if (p->trtp)
- ast_rtp_pt_copy(p->trtp, newtextrtp);
+ ast_rtp_codecs_payloads_copy(&newaudiortp, ast_rtp_instance_get_codecs(p->rtp), p->rtp);
+ if (p->vrtp) {
+ ast_rtp_codecs_payloads_copy(&newvideortp, ast_rtp_instance_get_codecs(p->vrtp), p->vrtp);
+ }
+ if (p->trtp) {
+ ast_rtp_codecs_payloads_copy(&newtextrtp, ast_rtp_instance_get_codecs(p->trtp), p->trtp);
+ }
if (ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_AUTO) {
ast_clear_flag(&p->flags[0], SIP_DTMF);
@@ -8094,8 +8092,8 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
/* XXX Would it be reasonable to drop the DSP at this point? XXX */
ast_set_flag(&p->flags[0], SIP_DTMF_RFC2833);
/* Since RFC2833 is now negotiated we need to change some properties of the RTP stream */
- ast_rtp_setdtmf(p->rtp, 1);
- ast_rtp_setdtmfcompensate(p->rtp, ast_test_flag(&p->flags[1], SIP_PAGE2_RFC2833_COMPENSATE));
+ ast_rtp_instance_set_prop(p->rtp, AST_RTP_PROPERTY_DTMF, 1);
+ ast_rtp_instance_set_prop(p->rtp, AST_RTP_PROPERTY_DTMF_COMPENSATE, ast_test_flag(&p->flags[1], SIP_PAGE2_RFC2833_COMPENSATE));
} else {
ast_set_flag(&p->flags[0], SIP_DTMF_INBAND);
}
@@ -8103,21 +8101,21 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
/* Setup audio port number */
if (p->rtp && sin.sin_port) {
- ast_rtp_set_peer(p->rtp, &sin);
+ ast_rtp_instance_set_remote_address(p->rtp, &sin);
if (debug)
ast_verbose("Peer audio RTP is at port %s:%d\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
}
/* Setup video port number */
if (p->vrtp && vsin.sin_port) {
- ast_rtp_set_peer(p->vrtp, &vsin);
+ ast_rtp_instance_set_remote_address(p->vrtp, &vsin);
if (debug)
ast_verbose("Peer video RTP is at port %s:%d\n", ast_inet_ntoa(vsin.sin_addr), ntohs(vsin.sin_port));
}
/* Setup text port number */
if (p->trtp && tsin.sin_port) {
- ast_rtp_set_peer(p->trtp, &tsin);
+ ast_rtp_instance_set_remote_address(p->trtp, &tsin);
if (debug)
ast_verbose("Peer text RTP is at port %s:%d\n", ast_inet_ntoa(tsin.sin_addr), ntohs(tsin.sin_port));
}
@@ -8164,7 +8162,7 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
S_OR(p->mohsuggest, NULL),
!ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
if (sendonly)
- ast_rtp_stop(p->rtp);
+ ast_rtp_instance_stop(p->rtp);
/* RTCP needs to go ahead, even if we're on hold!!! */
/* Activate a re-invite */
ast_queue_frame(p->owner, &ast_null_frame);
@@ -9001,19 +8999,19 @@ static void add_codec_to_sdp(const struct sip_pvt *p, int codec,
if (debug)
ast_verbose("Adding codec 0x%x (%s) to SDP\n", codec, ast_getformatname(codec));
- if ((rtp_code = ast_rtp_lookup_code(p->rtp, 1, codec)) == -1)
+ if ((rtp_code = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(p->rtp), 1, codec)) == -1)
return;
if (p->rtp) {
- struct ast_codec_pref *pref = ast_rtp_codec_getpref(p->rtp);
+ struct ast_codec_pref *pref = &ast_rtp_instance_get_codecs(p->rtp)->pref;
fmt = ast_codec_pref_getsize(pref, codec);
} else /* I dont see how you couldn't have p->rtp, but good to check for and error out if not there like earlier code */
return;
ast_str_append(m_buf, 0, " %d", rtp_code);
ast_str_append(a_buf, 0, "a=rtpmap:%d %s/%d\r\n", rtp_code,
- ast_rtp_lookup_mime_subtype(1, codec,
+ ast_rtp_lookup_mime_subtype2(1, codec,
ast_test_flag(&p->flags[0], SIP_G726_NONSTANDARD) ? AST_RTP_OPT_G726_NONSTANDARD : 0),
- ast_rtp_lookup_sample_rate(1, codec));
+ ast_rtp_lookup_sample_rate2(1, codec));
switch (codec) {
case AST_FORMAT_G729A:
@@ -9060,13 +9058,13 @@ static void add_vcodec_to_sdp(const struct sip_pvt *p, int codec,
if (debug)
ast_verbose("Adding video codec 0x%x (%s) to SDP\n", codec, ast_getformatname(codec));
- if ((rtp_code = ast_rtp_lookup_code(p->vrtp, 1, codec)) == -1)
+ if ((rtp_code = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(p->vrtp), 1, codec)) == -1)
return;
ast_str_append(m_buf, 0, " %d", rtp_code);
ast_str_append(a_buf, 0, "a=rtpmap:%d %s/%d\r\n", rtp_code,
- ast_rtp_lookup_mime_subtype(1, codec, 0),
- ast_rtp_lookup_sample_rate(1, codec));
+ ast_rtp_lookup_mime_subtype2(1, codec, 0),
+ ast_rtp_lookup_sample_rate2(1, codec));
/* Add fmtp code here */
}
@@ -9083,20 +9081,21 @@ static void add_tcodec_to_sdp(const struct sip_pvt *p, int codec,
if (debug)
ast_verbose("Adding text codec 0x%x (%s) to SDP\n", codec, ast_getformatname(codec));
- if ((rtp_code = ast_rtp_lookup_code(p->trtp, 1, codec)) == -1)
+ if ((rtp_code = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(p->trtp), 1, codec)) == -1)
return;
ast_str_append(m_buf, 0, " %d", rtp_code);
ast_str_append(a_buf, 0, "a=rtpmap:%d %s/%d\r\n", rtp_code,
- ast_rtp_lookup_mime_subtype(1, codec, 0),
- ast_rtp_lookup_sample_rate(1, codec));
+ ast_rtp_lookup_mime_subtype2(1, codec, 0),
+ ast_rtp_lookup_sample_rate2(1, codec));
/* Add fmtp code here */
if (codec == AST_FORMAT_T140RED) {
- ast_str_append(a_buf, 0, "a=fmtp:%d %d/%d/%d\r\n", rtp_code,
- ast_rtp_lookup_code(p->trtp, 1, AST_FORMAT_T140),
- ast_rtp_lookup_code(p->trtp, 1, AST_FORMAT_T140),
- ast_rtp_lookup_code(p->trtp, 1, AST_FORMAT_T140));
+ int t140code = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(p->trtp), 1, AST_FORMAT_T140);
+ ast_str_append(a_buf, 0, "a=fmtp:%d %d/%d/%d\r\n", rtp_code,
+ t140code,
+ t140code,
+ t140code);
}
}
@@ -9139,14 +9138,14 @@ static void add_noncodec_to_sdp(const struct sip_pvt *p, int format,
int rtp_code;
if (debug)
- ast_verbose("Adding non-codec 0x%x (%s) to SDP\n", format, ast_rtp_lookup_mime_subtype(0, format, 0));
- if ((rtp_code = ast_rtp_lookup_code(p->rtp, 0, format)) == -1)
+ ast_verbose("Adding non-codec 0x%x (%s) to SDP\n", format, ast_rtp_lookup_mime_subtype2(0, format, 0));
+ if ((rtp_code = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(p->rtp), 0, format)) == -1)
return;
ast_str_append(m_buf, 0, " %d", rtp_code);
ast_str_append(a_buf, 0, "a=rtpmap:%d %s/%d\r\n", rtp_code,
- ast_rtp_lookup_mime_subtype(0, format, 0),
- ast_rtp_lookup_sample_rate(0, format));
+ ast_rtp_lookup_mime_subtype2(0, format, 0),
+ ast_rtp_lookup_sample_rate2(0, format));
if (format == AST_RTP_DTMF) /* Indicate we support DTMF and FLASH... */
ast_str_append(a_buf, 0, "a=fmtp:%d 0-16\r\n", rtp_code);
}
@@ -9159,11 +9158,11 @@ static void get_our_media_address(struct sip_pvt *p, int needvideo,
struct sockaddr_in *dest, struct sockaddr_in *vdest)
{
/* First, get our address */
- ast_rtp_get_us(p->rtp, sin);
+ ast_rtp_instance_get_local_address(p->rtp, sin);
if (p->vrtp)
- ast_rtp_get_us(p->vrtp, vsin);
+ ast_rtp_instance_get_local_address(p->vrtp, vsin);
if (p->trtp)
- ast_rtp_get_us(p->trtp, tsin);
+ ast_rtp_instance_get_local_address(p->trtp, tsin);
/* Now, try to figure out where we want them to send data */
/* Is this a re-invite to move the media out, then use the original offer from caller */
@@ -9594,7 +9593,7 @@ static int transmit_response_with_sdp(struct sip_pvt *p, const char *msg, const
if (p->rtp) {
if (!p->autoframing && !ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
ast_debug(1, "Setting framing from config on incoming call\n");
- ast_rtp_codec_setpref(p->rtp, &p->prefs);
+ ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(p->rtp), p->rtp, &p->prefs);
}
try_suggested_sip_codec(p);
if (p->t38.state == T38_PEER_DIRECT || p->t38.state == T38_ENABLED) {
@@ -12087,12 +12086,6 @@ static enum check_auth_result register_verify(struct sip_pvt *p, struct sockaddr
}
if (peer) {
- /*! \todo OEJ Remove this - there's never RTP in a REGISTER dialog... */
- /* Set Frame packetization */
- if (p->rtp) {
- ast_rtp_codec_setpref(p->rtp, &peer->prefs);
- p->autoframing = peer->autoframing;
- }
if (!peer->host_dynamic) {
ast_log(LOG_ERROR, "Peer '%s' is trying to register, but not configured as host=dynamic\n", peer->name);
res = AUTH_PEER_NOT_DYNAMIC;
@@ -13024,7 +13017,7 @@ static enum check_auth_result check_peer_ok(struct sip_pvt *p, char *of,
/* XXX what about p->prefs = peer->prefs; ? */
/* Set Frame packetization */
if (p->rtp) {
- ast_rtp_codec_setpref(p->rtp, &peer->prefs);
+ ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(p->rtp), p->rtp, &peer->prefs);
p->autoframing = peer->autoframing;
}
@@ -13046,6 +13039,7 @@ static enum check_auth_result check_peer_ok(struct sip_pvt *p, char *of,
ast_string_field_set(p, mohinterpret, peer->mohinterpret);
ast_string_field_set(p, mohsuggest, peer->mohsuggest);
ast_string_field_set(p, parkinglot, peer->parkinglot);
+ ast_string_field_set(p, engine, peer->engine);
if (peer->callingpres) /* Peer calling pres setting will override RPID */
p->callingpres = peer->callingpres;
if (peer->maxms && peer->lastms)
@@ -13113,17 +13107,6 @@ static enum check_auth_result check_peer_ok(struct sip_pvt *p, char *of,
if (p->peercapability)
p->jointcapability &= p->peercapability;
p->maxcallbitrate = peer->maxcallbitrate;
- if (!ast_test_flag(&p->flags[1], SIP_PAGE2_VIDEOSUPPORT_ALWAYS) &&
- (!ast_test_flag(&p->flags[1], SIP_PAGE2_VIDEOSUPPORT) ||
- !(p->capability & AST_FORMAT_VIDEO_MASK)) &&
- p->vrtp) {
- ast_rtp_destroy(p->vrtp);
- p->vrtp = NULL;
- }
- if ((!ast_test_flag(&p->flags[1], SIP_PAGE2_TEXTSUPPORT) || !(p->capability & AST_FORMAT_TEXT_MASK)) && p->trtp) {
- ast_rtp_destroy(p->trtp);
- p->trtp = NULL;
- }
if ((ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_RFC2833) ||
(ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_AUTO))
p->noncodeccapability |= AST_RTP_DTMF;
@@ -13132,6 +13115,12 @@ static enum check_auth_result check_peer_ok(struct sip_pvt *p, char *of,
p->jointnoncodeccapability = p->noncodeccapability;
if (p->t38.peercapability)
p->t38.jointcapability &= p->t38.peercapability;
+ if (!dialog_initialize_rtp(p)) {
+ ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(p->rtp), p->rtp, &peer->prefs);
+ p->autoframing = peer->autoframing;
+ } else {
+ res = AUTH_RTP_FAILED;
+ }
}
unref_peer(peer, "check_peer_ok: unref_peer: tossing temp ptr to peer from find_peer");
return res;
@@ -13253,7 +13242,11 @@ static enum check_auth_result check_user_full(struct sip_pvt *p, struct sip_requ
/* Finally, apply the guest policy */
if (sip_cfg.allowguest) {
replace_cid(p, rpid_num, calleridname);
- res = AUTH_SUCCESSFUL;
+ if (!dialog_initialize_rtp(p)) {
+ res = AUTH_SUCCESSFUL;
+ } else {
+ res = AUTH_RTP_FAILED;
+ }
} else if (sip_cfg.alwaysauthreject)
res = AUTH_FAKE_AUTH; /* reject with fake authorization request */
else
@@ -14050,7 +14043,20 @@ static int dialog_needdestroy(void *dialogobj, void *arg, int flags)
*/
return 0;
}
-
+
+ /* We absolutely cannot destroy the rtp struct while a bridge is active or we WILL crash */
+ if (dialog->rtp && ast_rtp_instance_get_bridged(dialog->rtp)) {
+ ast_debug(2, "Bridge still active. Delaying destroy of SIP dialog '%s' Method: %s\n", dialog->callid, sip_methods[dialog->method].text);
+ sip_pvt_unlock(dialog);
+ return 0;
+ }
+
+ if (dialog->vrtp && ast_rtp_instance_get_bridged(dialog->vrtp)) {
+ ast_debug(2, "Bridge still active. Delaying destroy of SIP dialog '%s' Method: %s\n", dialog->callid, sip_methods[dialog->method].text);
+ sip_pvt_unlock(dialog);
+ return 0;
+ }
+
/* Check RTP timeouts and kill calls if we have a timeout set and do not get RTP */
check_rtp_timeout(dialog, *t);
@@ -14059,13 +14065,13 @@ static int dialog_needdestroy(void *dialogobj, void *arg, int flags)
- if that's the case, wait with destruction */
if (dialog->needdestroy && !dialog->packets && !dialog->owner) {
/* We absolutely cannot destroy the rtp struct while a bridge is active or we WILL crash */
- if (dialog->rtp && ast_rtp_get_bridged(dialog->rtp)) {
+ if (dialog->rtp && ast_rtp_instance_get_bridged(dialog->rtp)) {
ast_debug(2, "Bridge still active. Delaying destruction of SIP dialog '%s' Method: %s\n", dialog->callid, sip_methods[dialog->method].text);
sip_pvt_unlock(dialog);
return 0;
}
- if (dialog->vrtp && ast_rtp_get_bridged(dialog->vrtp)) {
+ if (dialog->vrtp && ast_rtp_instance_get_bridged(dialog->vrtp)) {
ast_debug(2, "Bridge still active. Delaying destroy of SIP dialog '%s' Method: %s\n", dialog->callid, sip_methods[dialog->method].text);
sip_pvt_unlock(dialog);
return 0;
@@ -14555,6 +14561,7 @@ static char *_sip_show_peer(int type, int fd, struct mansession *s, const struct
ast_cli(fd, " Sess-Refresh : %s\n", strefresher2str(peer->stimer.st_ref));
ast_cli(fd, " Sess-Expires : %d secs\n", peer->stimer.st_max_se);
ast_cli(fd, " Min-Sess : %d secs\n", peer->stimer.st_min_se);
+ ast_cli(fd, " RTP Engine : %s\n", peer->engine);
ast_cli(fd, "\n");
peer = unref_peer(peer, "sip_show_peer: unref_peer: done with peer ptr");
} else if (peer && type == 1) { /* manager listing */
@@ -14602,6 +14609,7 @@ static char *_sip_show_peer(int type, int fd, struct mansession *s, const struct
astman_append(s, "SIP-Sess-Refresh: %s\r\n", strefresher2str(peer->stimer.st_ref));
astman_append(s, "SIP-Sess-Expires: %d\r\n", peer->stimer.st_max_se);
astman_append(s, "SIP-Sess-Min: %d\r\n", peer->stimer.st_min_se);
+ astman_append(s, "SIP-RTP-Engine: %s\r\n", peer->engine);
/* - is enumerated */
astman_append(s, "SIP-DTMFmode: %s\r\n", dtmfmode2str(ast_test_flag(&peer->flags[0], SIP_DTMF)));
@@ -14734,6 +14742,7 @@ static char *sip_show_user(struct ast_cli_entry *e, int cmd, struct ast_cli_args
ast_cli(a->fd, " Sess-Refresh : %s\n", strefresher2str(user->stimer.st_ref));
ast_cli(a->fd, " Sess-Expires : %d secs\n", user->stimer.st_max_se);
ast_cli(a->fd, " Sess-Min-SE : %d secs\n", user->stimer.st_min_se);
+ ast_cli(a->fd, " RTP Engine : %s\n", user->engine);
ast_cli(a->fd, " Codec Order : (");
print_codec_to_cli(a->fd, &user->prefs);
@@ -14888,11 +14897,10 @@ static int show_chanstats_cb(void *__cur, void *__arg, int flags)
#define FORMAT2 "%-15.15s %-11.11s %-8.8s %-10.10s %-10.10s (%-2.2s) %-6.6s %-10.10s %-10.10s ( %%) %-6.6s\n"
#define FORMAT "%-15.15s %-11.11s %-8.8s %-10.10u%-1.1s %-10.10u (%-2.2u%%) %-6.6u %-10.10u%-1.1s %-10.10u (%-2.2u%%) %-6.6u\n"
struct sip_pvt *cur = __cur;
- unsigned int rxcount;
- unsigned int txcount;
+ struct ast_rtp_instance_stats stats;
char durbuf[10];
- int duration;
- int durh, durm, durs;
+ int duration;
+ int durh, durm, durs;
struct ast_channel *c = cur->owner;
struct __show_chan_arg *arg = __arg;
int fd = arg->fd;
@@ -14906,10 +14914,9 @@ static int show_chanstats_cb(void *__cur, void *__arg, int flags)
ast_cli(fd, "%-15.15s %-11.11s (inv state: %s) -- %s\n", ast_inet_ntoa(cur->sa.sin_addr), cur->callid, invitestate2string[cur->invitestate].desc, "-- No RTP active");
return 0; /* don't care, we scan all channels */
}
- rxcount = ast_rtp_get_qosvalue(cur->rtp, AST_RTP_RXCOUNT);
- txcount = ast_rtp_get_qosvalue(cur->rtp, AST_RTP_TXCOUNT);
- /* Find the duration of this channel */
+ ast_rtp_instance_get_stats(cur->rtp, &stats, AST_RTP_INSTANCE_STAT_ALL);
+
if (c && c->cdr && !ast_tvzero(c->cdr->start)) {
duration = (int)(ast_tvdiff_ms(ast_tvnow(), c->cdr->start) / 1000);
durh = duration / 3600;
@@ -14919,21 +14926,21 @@ static int show_chanstats_cb(void *__cur, void *__arg, int flags)
} else {
durbuf[0] = '\0';
}
- /* Print stats for every call with RTP */
+
ast_cli(fd, FORMAT,
ast_inet_ntoa(cur->sa.sin_addr),
cur->callid,
durbuf,
- rxcount > (unsigned int) 100000 ? (unsigned int) (rxcount)/(unsigned int) 1000 : rxcount,
- rxcount > (unsigned int) 100000 ? "K":" ",
- ast_rtp_get_qosvalue(cur->rtp, AST_RTP_RXPLOSS),
- rxcount > ast_rtp_get_qosvalue(cur->rtp, AST_RTP_RXPLOSS) ? (unsigned int) (ast_rtp_get_qosvalue(cur->rtp, AST_RTP_RXPLOSS) / rxcount * 100) : 0,
- ast_rtp_get_qosvalue(cur->rtp, AST_RTP_RXJITTER),
- txcount > (unsigned int) 100000 ? (unsigned int) (txcount)/(unsigned int) 1000 : txcount,
- txcount > (unsigned int) 100000 ? "K":" ",
- ast_rtp_get_qosvalue(cur->rtp, AST_RTP_TXPLOSS),
- txcount > ast_rtp_get_qosvalue(cur->rtp, AST_RTP_TXPLOSS) ? (unsigned int) (ast_rtp_get_qosvalue(cur->rtp, AST_RTP_TXPLOSS)/ txcount * 100) : 0,
- ast_rtp_get_qosvalue(cur->rtp, AST_RTP_TXJITTER)
+ stats.rxcount > (unsigned int) 100000 ? (unsigned int) (stats.rxcount)/(unsigned int) 1000 : stats.rxcount,
+ stats.rxcount > (unsigned int) 100000 ? "K":" ",
+ stats.rxploss,
+ stats.rxcount > stats.rxploss ? (stats.rxploss / stats.rxcount * 100) : 0,
+ stats.rxjitter,
+ stats.txcount > (unsigned int) 100000 ? (unsigned int) (stats.txcount)/(unsigned int) 1000 : stats.txcount,
+ stats.txcount > (unsigned int) 100000 ? "K":" ",
+ stats.txploss,
+ stats.txcount > stats.txploss ? (stats.txploss / stats.txcount * 100) : 0,
+ stats.txjitter
);
arg->numchans++;
@@ -16880,7 +16887,7 @@ static void handle_response_invite(struct sip_pvt *p, int resp, char *rest, stru
if (p->udptl && p->t38.state == T38_LOCAL_REINVITE) {
change_t38_state(p, T38_DISABLED);
/* Try to reset RTP timers */
- ast_rtp_set_rtptimers_onhold(p->rtp);
+ //ast_rtp_set_rtptimers_onhold(p->rtp);
/* Trigger a reinvite back to audio */
transmit_reinvite_with_sdp(p, FALSE, FALSE);
@@ -17300,11 +17307,11 @@ static void stop_media_flows(struct sip_pvt *p)
{
/* Immediately stop RTP, VRTP and UDPTL as applicable */
if (p->rtp)
- ast_rtp_stop(p->rtp);
+ ast_rtp_instance_stop(p->rtp);
if (p->vrtp)
- ast_rtp_stop(p->vrtp);
+ ast_rtp_instance_stop(p->vrtp);
if (p->trtp)
- ast_rtp_stop(p->trtp);
+ ast_rtp_instance_stop(p->trtp);
if (p->udptl)
ast_udptl_stop(p->udptl);
}
@@ -19032,8 +19039,8 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
build_contact(p); /* Build our contact header */
if (p->rtp) {
- ast_rtp_setdtmf(p->rtp, ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_RFC2833);
- ast_rtp_setdtmfcompensate(p->rtp, ast_test_flag(&p->flags[1], SIP_PAGE2_RFC2833_COMPENSATE));
+ ast_rtp_instance_set_prop(p->rtp, AST_RTP_PROPERTY_DTMF, ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_RFC2833);
+ ast_rtp_instance_set_prop(p->rtp, AST_RTP_PROPERTY_DTMF_COMPENSATE, ast_test_flag(&p->flags[1], SIP_PAGE2_RFC2833_COMPENSATE));
}
if (!replace_id && gotdest) { /* No matching extension found */
@@ -19852,7 +19859,7 @@ static int handle_request_cancel(struct sip_pvt *p, struct sip_request *req)
static int acf_channel_read(struct ast_channel *chan, const char *funcname, char *preparse, char *buf, size_t buflen)
{
struct sip_pvt *p = chan->tech_pvt;
- char *all = "", *parse = ast_strdupa(preparse);
+ char *parse = ast_strdupa(preparse);
int res = 0;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(param);
@@ -19890,61 +19897,70 @@ static int acf_channel_read(struct ast_channel *chan, const char *funcname, char
args.type = "audio";
if (!strcasecmp(args.type, "audio"))
- ast_rtp_get_peer(p->rtp, &sin);
+ ast_rtp_instance_get_remote_address(p->rtp, &sin);
else if (!strcasecmp(args.type, "video"))
- ast_rtp_get_peer(p->vrtp, &sin);
+ ast_rtp_instance_get_remote_address(p->vrtp, &sin);
else if (!strcasecmp(args.type, "text"))
- ast_rtp_get_peer(p->trtp, &sin);
+ ast_rtp_instance_get_remote_address(p->trtp, &sin);
else
return -1;
snprintf(buf, buflen, "%s:%d", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
} else if (!strcasecmp(args.param, "rtpqos")) {
- struct ast_rtp_quality qos;
- struct ast_rtp *rtp = p->rtp;
-
- memset(&qos, 0, sizeof(qos));
+ struct ast_rtp_instance *rtp = NULL;
- if (ast_strlen_zero(args.type))
+ if (ast_strlen_zero(args.type)) {
args.type = "audio";
- if (ast_strlen_zero(args.field))
- args.field = "all";
-
- if (!strcasecmp(args.type, "AUDIO")) {
- all = ast_rtp_get_quality(rtp = p->rtp, &qos, RTPQOS_SUMMARY);
- } else if (!strcasecmp(args.type, "VIDEO")) {
- all = ast_rtp_get_quality(rtp = p->vrtp, &qos, RTPQOS_SUMMARY);
- } else if (!strcasecmp(args.type, "TEXT")) {
- all = ast_rtp_get_quality(rtp = p->trtp, &qos, RTPQOS_SUMMARY);
+ }
+
+ if (!strcasecmp(args.type, "audio")) {
+ rtp = p->rtp;
+ } else if (!strcasecmp(args.type, "video")) {
+ rtp = p->vrtp;
+ } else if (!strcasecmp(args.type, "text")) {
+ rtp = p->trtp;
} else {
- return -1;
+ return -1;
}
-
- if (!strcasecmp(args.field, "local_ssrc"))
- snprintf(buf, buflen, "%u", qos.local_ssrc);
- else if (!strcasecmp(args.field, "local_lostpackets"))
- snprintf(buf, buflen, "%u", qos.local_lostpackets);
- else if (!strcasecmp(args.field, "local_jitter"))
- snprintf(buf, buflen, "%.0f", qos.local_jitter * 1000.0);
- else if (!strcasecmp(args.field, "local_count"))
- snprintf(buf, buflen, "%u", qos.local_count);
- else if (!strcasecmp(args.field, "remote_ssrc"))
- snprintf(buf, buflen, "%u", qos.remote_ssrc);
- else if (!strcasecmp(args.field, "remote_lostpackets"))
- snprintf(buf, buflen, "%u", qos.remote_lostpackets);
- else if (!strcasecmp(args.field, "remote_jitter"))
- snprintf(buf, buflen, "%.0f", qos.remote_jitter * 1000.0);
- else if (!strcasecmp(args.field, "remote_count"))
- snprintf(buf, buflen, "%u", qos.remote_count);
- else if (!strcasecmp(args.field, "rtt"))
- snprintf(buf, buflen, "%.0f", qos.rtt * 1000.0);
- else if (!strcasecmp(args.field, "all"))
- ast_copy_string(buf, all, buflen);
- else if (!ast_rtp_get_qos(rtp, args.field, buf, buflen))
- ;
- else {
- ast_log(LOG_WARNING, "Unrecognized argument '%s' to %s\n", preparse, funcname);
- return -1;
+
+ if (ast_strlen_zero(args.field) || !strcasecmp(args.field, "all")) {
+ char quality_buf[AST_MAX_USER_FIELD], *quality;
+
+ if (!(quality = ast_rtp_instance_get_quality(rtp, AST_RTP_INSTANCE_STAT_FIELD_QUALITY, quality_buf, sizeof(quality_buf)))) {
+ return -1;
+ }
+
+ ast_copy_string(buf, quality_buf, buflen);
+ return res;
+ } else {
+ struct ast_rtp_instance_stats stats;
+
+ if (ast_rtp_instance_get_stats(rtp, &stats, AST_RTP_INSTANCE_STAT_ALL)) {
+ return -1;
+ }
+
+ if (!strcasecmp(args.field, "local_ssrc")) {
+ snprintf(buf, buflen, "%u", stats.local_ssrc);
+ } else if (!strcasecmp(args.field, "local_lostpackets")) {
+ snprintf(buf, buflen, "%u", stats.rxploss);
+ } else if (!strcasecmp(args.field, "local_jitter")) {
+ snprintf(buf, buflen, "%u", stats.rxjitter);
+ } else if (!strcasecmp(args.field, "local_count")) {
+ snprintf(buf, buflen, "%u", stats.rxcount);
+ } else if (!strcasecmp(args.field, "remote_ssrc")) {
+ snprintf(buf, buflen, "%u", stats.remote_ssrc);
+ } else if (!strcasecmp(args.field, "remote_lostpackets")) {
+ snprintf(buf, buflen, "%u", stats.txploss);
+ } else if (!strcasecmp(args.field, "remote_jitter")) {
+ snprintf(buf, buflen, "%u", stats.txjitter);
+ } else if (!strcasecmp(args.field, "remote_count")) {
+ snprintf(buf, buflen, "%u", stats.txcount);
+ } else if (!strcasecmp(args.field, "rtt")) {
+ snprintf(buf, buflen, "%u", stats.rtt);
+ } else {
+ ast_log(LOG_WARNING, "Unrecognized argument '%s' to %s\n", preparse, funcname);
+ return -1;
+ }
}
} else {
res = -1;
@@ -19976,53 +19992,53 @@ static int handle_request_bye(struct sip_pvt *p, struct sip_request *req)
/* Get RTCP quality before end of call */
if (p->do_history || p->owner) {
+ char quality_buf[AST_MAX_USER_FIELD], *quality;
struct ast_channel *bridge = p->owner ? ast_bridged_channel(p->owner) : NULL;
- char *videoqos, *textqos;
- if (p->rtp) {
+ if (p->rtp && (quality = ast_rtp_instance_get_quality(p->rtp, AST_RTP_INSTANCE_STAT_FIELD_QUALITY, quality_buf, sizeof(quality_buf)))) {
if (p->do_history) {
- char *audioqos,
- *audioqos_jitter,
- *audioqos_loss,
- *audioqos_rtt;
-
- audioqos = ast_rtp_get_quality(p->rtp, NULL, RTPQOS_SUMMARY);
- audioqos_jitter = ast_rtp_get_quality(p->rtp, NULL, RTPQOS_JITTER);
- audioqos_loss = ast_rtp_get_quality(p->rtp, NULL, RTPQOS_LOSS);
- audioqos_rtt = ast_rtp_get_quality(p->rtp, NULL, RTPQOS_RTT);
-
- append_history(p, "RTCPaudio", "Quality:%s", audioqos);
- append_history(p, "RTCPaudioJitter", "Quality:%s", audioqos_jitter);
- append_history(p, "RTCPaudioLoss", "Quality:%s", audioqos_loss);
- append_history(p, "RTCPaudioRTT", "Quality:%s", audioqos_rtt);
+ append_history(p, "RTCPaudio", "Quality:%s", quality);
+
+ if ((quality = ast_rtp_instance_get_quality(p->rtp, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER, quality_buf, sizeof(quality_buf)))) {
+ append_history(p, "RTCPaudioJitter", "Quality:%s", quality);
+ }
+ if ((quality = ast_rtp_instance_get_quality(p->rtp, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS, quality_buf, sizeof(quality_buf)))) {
+ append_history(p, "RTCPaudioLoss", "Quality:%s", quality);
+ }
+ if ((quality = ast_rtp_instance_get_quality(p->rtp, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT, quality_buf, sizeof(quality_buf)))) {
+ append_history(p, "RTCPaudioRTT", "Quality:%s", quality);
+ }
}
-
+
if (p->owner) {
- ast_rtp_set_vars(p->owner, p->rtp);
+ ast_rtp_instance_set_stats_vars(p->owner, p->rtp);
}
+
}
if (bridge) {
struct sip_pvt *q = bridge->tech_pvt;
- if (IS_SIP_TECH(bridge->tech) && q->rtp)
- ast_rtp_set_vars(bridge, q->rtp);
+ if (IS_SIP_TECH(bridge->tech) && q->rtp) {
+ ast_rtp_instance_set_stats_vars(bridge, q->rtp);
+ }
}
- if (p->vrtp) {
- videoqos = ast_rtp_get_quality(p->vrtp, NULL, RTPQOS_SUMMARY);
- if (p->do_history)
- append_history(p, "RTCPvideo", "Quality:%s", videoqos);
- if (p->owner)
- pbx_builtin_setvar_helper(p->owner, "RTPVIDEOQOS", videoqos);
+ if (p->vrtp && (quality = ast_rtp_instance_get_quality(p->vrtp, AST_RTP_INSTANCE_STAT_FIELD_QUALITY, quality_buf, sizeof(quality_buf)))) {
+ if (p->do_history) {
+ append_history(p, "RTCPvideo", "Quality:%s", quality);
+ }
+ if (p->owner) {
+ pbx_builtin_setvar_helper(p->owner, "RTPVIDEOQOS", quality);
+ }
}
-
- if (p->trtp) {
- textqos = ast_rtp_get_quality(p->trtp, NULL, RTPQOS_SUMMARY);
- if (p->do_history)
- append_history(p, "RTCPtext", "Quality:%s", textqos);
- if (p->owner)
- pbx_builtin_setvar_helper(p->owner, "RTPTEXTQOS", textqos);
+ if (p->trtp && (quality = ast_rtp_instance_get_quality(p->trtp, AST_RTP_INSTANCE_STAT_FIELD_QUALITY, quality_buf, sizeof(quality_buf)))) {
+ if (p->do_history) {
+ append_history(p, "RTCPtext", "Quality:%s", quality);
+ }
+ if (p->owner) {
+ pbx_builtin_setvar_helper(p->owner, "RTPTEXTQOS", quality);
+ }
}
}
@@ -21211,15 +21227,8 @@ static void check_rtp_timeout(struct sip_pvt *dialog, time_t t)
return;
/* If we have no timers set, return now */
- if ((ast_rtp_get_rtpkeepalive(dialog->rtp) == 0) && (ast_rtp_get_rtptimeout(dialog->rtp) == 0) && (ast_rtp_get_rtpholdtimeout(dialog->rtp) == 0))
+ if (!ast_rtp_instance_get_timeout(dialog->rtp) && !ast_rtp_instance_get_hold_timeout(dialog->rtp)) {
return;
-
- /* Check AUDIO RTP keepalives */
- if (dialog->lastrtptx && ast_rtp_get_rtpkeepalive(dialog->rtp) &&
- (t > dialog->lastrtptx + ast_rtp_get_rtpkeepalive(dialog->rtp))) {
- /* Need to send an empty RTP packet */
- dialog->lastrtptx = time(NULL);
- ast_rtp_sendcng(dialog->rtp, 0);
}
/*! \todo Check video RTP keepalives
@@ -21229,16 +21238,10 @@ static void check_rtp_timeout(struct sip_pvt *dialog, time_t t)
*/
/* Check AUDIO RTP timers */
- if (dialog->lastrtprx && (ast_rtp_get_rtptimeout(dialog->rtp) || ast_rtp_get_rtpholdtimeout(dialog->rtp)) &&
- (t > dialog->lastrtprx + ast_rtp_get_rtptimeout(dialog->rtp))) {
-
- /* Might be a timeout now -- see if we're on hold */
- struct sockaddr_in sin;
- ast_rtp_get_peer(dialog->rtp, &sin);
- if (!ast_test_flag(&dialog->flags[1], SIP_PAGE2_CALL_ONHOLD) || (ast_rtp_get_rtpholdtimeout(dialog->rtp) &&
- (t > dialog->lastrtprx + ast_rtp_get_rtpholdtimeout(dialog->rtp)))) {
+ if (dialog->lastrtprx && (ast_rtp_instance_get_timeout(dialog->rtp) || ast_rtp_instance_get_hold_timeout(dialog->rtp)) && (t > dialog->lastrtprx + ast_rtp_instance_get_timeout(dialog->rtp))) {
+ if (!ast_test_flag(&dialog->flags[1], SIP_PAGE2_CALL_ONHOLD) || (ast_rtp_instance_get_hold_timeout(dialog->rtp) && (t > dialog->lastrtprx + ast_rtp_instance_get_hold_timeout(dialog->rtp)))) {
/* Needs a hangup */
- if (ast_rtp_get_rtptimeout(dialog->rtp)) {
+ if (ast_rtp_instance_get_timeout(dialog->rtp)) {
while (dialog->owner && ast_channel_trylock(dialog->owner)) {
sip_pvt_unlock(dialog);
usleep(1);
@@ -21253,11 +21256,11 @@ static void check_rtp_timeout(struct sip_pvt *dialog, time_t t)
has already been requested and we don't want to
repeatedly request hangups
*/
- ast_rtp_set_rtptimeout(dialog->rtp, 0);
- ast_rtp_set_rtpholdtimeout(dialog->rtp, 0);
+ ast_rtp_instance_set_timeout(dialog->rtp, 0);
+ ast_rtp_instance_set_hold_timeout(dialog->rtp, 0);
if (dialog->vrtp) {
- ast_rtp_set_rtptimeout(dialog->vrtp, 0);
- ast_rtp_set_rtpholdtimeout(dialog->vrtp, 0);
+ ast_rtp_instance_set_timeout(dialog->vrtp, 0);
+ ast_rtp_instance_set_hold_timeout(dialog->vrtp, 0);
}
}
}
@@ -22417,6 +22420,7 @@ static void set_peer_defaults(struct sip_peer *peer)
ast_string_field_set(peer, language, default_language);
ast_string_field_set(peer, mohinterpret, default_mohinterpret);
ast_string_field_set(peer, mohsuggest, default_mohsuggest);
+ ast_string_field_set(peer, engine, default_engine);
peer->addr.sin_family = AF_INET;
peer->defaddr.sin_family = AF_INET;
peer->capability = global_capability;
@@ -22756,6 +22760,8 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
ast_string_field_set(peer, mohsuggest, v->value);
} else if (!strcasecmp(v->name, "parkinglot")) {
ast_string_field_set(peer, parkinglot, v->value);
+ } else if (!strcasecmp(v->name, "rtp_engine")) {
+ ast_string_field_set(peer, engine, v->value);
} else if (!strcasecmp(v->name, "mailbox")) {
add_peer_mailboxes(peer, v->value);
} else if (!strcasecmp(v->name, "hasvoicemail")) {
@@ -23205,6 +23211,7 @@ static int reload_config(enum channelreloadreason reason)
ast_set_flag(&global_flags[0], SIP_DTMF_RFC2833); /*!< Default DTMF setting: RFC2833 */
ast_set_flag(&global_flags[0], SIP_NAT_RFC3581); /*!< NAT support if requested by device with rport */
ast_set_flag(&global_flags[0], SIP_CAN_REINVITE); /*!< Allow re-invites */
+ ast_copy_string(default_engine, DEFAULT_ENGINE, sizeof(default_engine));
/* Debugging settings, always default to off */
dumphistory = FALSE;
@@ -23945,156 +23952,176 @@ static int sip_set_udptl_peer(struct ast_channel *chan, struct ast_udptl *udptl)
return 0;
}
-/*! \brief Returns null if we can't reinvite audio (part of RTP interface) */
-static enum ast_rtp_get_result sip_get_rtp_peer(struct ast_channel *chan, struct ast_rtp **rtp)
+static enum ast_rtp_glue_result sip_get_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance **instance)
{
- struct sip_pvt *p = NULL;
- enum ast_rtp_get_result res = AST_RTP_TRY_PARTIAL;
+ struct sip_pvt *p = NULL;
+ enum ast_rtp_glue_result res = AST_RTP_GLUE_RESULT_LOCAL;
- if (!(p = chan->tech_pvt))
- return AST_RTP_GET_FAILED;
-
- sip_pvt_lock(p);
- if (!(p->rtp)) {
- sip_pvt_unlock(p);
- return AST_RTP_GET_FAILED;
+ if (!(p = chan->tech_pvt)) {
+ return AST_RTP_GLUE_RESULT_FORBID;
}
- *rtp = p->rtp;
+ sip_pvt_lock(p);
+ if (!(p->rtp)) {
+ sip_pvt_unlock(p);
+ return AST_RTP_GLUE_RESULT_FORBID;
+ }
- if (ast_rtp_getnat(*rtp) && !ast_test_flag(&p->flags[0], SIP_CAN_REINVITE_NAT))
- res = AST_RTP_TRY_PARTIAL;
- else if (ast_test_flag(&p->flags[0], SIP_CAN_REINVITE))
- res = AST_RTP_TRY_NATIVE;
- else if (ast_test_flag(&global_jbconf, AST_JB_FORCED))
- res = AST_RTP_GET_FAILED;
+ ao2_ref(p->rtp, +1);
+ *instance = p->rtp;
- sip_pvt_unlock(p);
+ if (!ast_test_flag(&p->flags[0], SIP_CAN_REINVITE_NAT)) {
+ res = AST_RTP_GLUE_RESULT_LOCAL;
+ } else if (ast_test_flag(&p->flags[0], SIP_CAN_REINVITE)) {
+ res = AST_RTP_GLUE_RESULT_REMOTE;
+ } else if (ast_test_flag(&global_jbconf, AST_JB_FORCED)) {
+ res = AST_RTP_GLUE_RESULT_FORBID;
+ }
- return res;
+ sip_pvt_unlock(p);
+
+ return res;
}
-/*! \brief Returns null if we can't reinvite video (part of RTP interface) */
-static enum ast_rtp_get_result sip_get_vrtp_peer(struct ast_channel *chan, struct ast_rtp **rtp)
+static enum ast_rtp_glue_result sip_get_vrtp_peer(struct ast_channel *chan, struct ast_rtp_instance **instance)
{
struct sip_pvt *p = NULL;
- enum ast_rtp_get_result res = AST_RTP_TRY_PARTIAL;
-
- if (!(p = chan->tech_pvt))
- return AST_RTP_GET_FAILED;
+ enum ast_rtp_glue_result res = AST_RTP_GLUE_RESULT_FORBID;
+
+ if (!(p = chan->tech_pvt)) {
+ return AST_RTP_GLUE_RESULT_FORBID;
+ }
sip_pvt_lock(p);
if (!(p->vrtp)) {
sip_pvt_unlock(p);
- return AST_RTP_GET_FAILED;
+ return AST_RTP_GLUE_RESULT_FORBID;
}
- *rtp = p->vrtp;
+ ao2_ref(p->vrtp, +1);
+ *instance = p->vrtp;
- if (ast_test_flag(&p->flags[0], SIP_CAN_REINVITE))
- res = AST_RTP_TRY_NATIVE;
+ if (ast_test_flag(&p->flags[0], SIP_CAN_REINVITE)) {
+ res = AST_RTP_GLUE_RESULT_REMOTE;
+ }
sip_pvt_unlock(p);
return res;
}
-/*! \brief Returns null if we can't reinvite text (part of RTP interface) */
-static enum ast_rtp_get_result sip_get_trtp_peer(struct ast_channel *chan, struct ast_rtp **rtp)
+static enum ast_rtp_glue_result sip_get_trtp_peer(struct ast_channel *chan, struct ast_rtp_instance **instance)
{
- struct sip_pvt *p = NULL;
- enum ast_rtp_get_result res = AST_RTP_TRY_PARTIAL;
-
- if (!(p = chan->tech_pvt))
- return AST_RTP_GET_FAILED;
+ struct sip_pvt *p = NULL;
+ enum ast_rtp_glue_result res = AST_RTP_GLUE_RESULT_FORBID;
- sip_pvt_lock(p);
- if (!(p->trtp)) {
- sip_pvt_unlock(p);
- return AST_RTP_GET_FAILED;
- }
+ if (!(p = chan->tech_pvt)) {
+ return AST_RTP_GLUE_RESULT_FORBID;
+ }
- *rtp = p->trtp;
+ sip_pvt_lock(p);
+ if (!(p->trtp)) {
+ sip_pvt_unlock(p);
+ return AST_RTP_GLUE_RESULT_FORBID;
+ }
- if (ast_test_flag(&p->flags[0], SIP_CAN_REINVITE))
- res = AST_RTP_TRY_NATIVE;
+ ao2_ref(p->trtp, +1);
+ *instance = p->trtp;
- sip_pvt_unlock(p);
+ if (ast_test_flag(&p->flags[0], SIP_CAN_REINVITE)) {
+ res = AST_RTP_GLUE_RESULT_REMOTE;
+ }
- return res;
+ sip_pvt_unlock(p);
+
+ return res;
}
-/*! \brief Set the RTP peer for this call */
-static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, struct ast_rtp *trtp, int codecs, int nat_active)
+static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_rtp_instance *vinstance, struct ast_rtp_instance *tinstance, int codecs, int nat_active)
{
- struct sip_pvt *p;
- int changed = 0;
+ struct sip_pvt *p;
+ int changed = 0;
- p = chan->tech_pvt;
- if (!p)
- return -1;
+ p = chan->tech_pvt;
+ if (!p)
+ return -1;
/* Disable early RTP bridge */
if (chan->_state != AST_STATE_UP && !sip_cfg.directrtpsetup) /* We are in early state */
return 0;
- sip_pvt_lock(p);
- if (p->alreadygone) {
- /* If we're destroyed, don't bother */
- sip_pvt_unlock(p);
- return 0;
- }
+ sip_pvt_lock(p);
+ if (p->alreadygone) {
+ /* If we're destroyed, don't bother */
+ sip_pvt_unlock(p);
+ return 0;
+ }
- /* if this peer cannot handle reinvites of the media stream to devices
- that are known to be behind a NAT, then stop the process now
+ /* if this peer cannot handle reinvites of the media stream to devices
+ that are known to be behind a NAT, then stop the process now
*/
- if (nat_active && !ast_test_flag(&p->flags[0], SIP_CAN_REINVITE_NAT)) {
- sip_pvt_unlock(p);
- return 0;
- }
+ if (nat_active && !ast_test_flag(&p->flags[0], SIP_CAN_REINVITE_NAT)) {
+ sip_pvt_unlock(p);
+ return 0;
+ }
- if (rtp) {
- changed |= ast_rtp_get_peer(rtp, &p->redirip);
- } else if (p->redirip.sin_addr.s_addr || ntohs(p->redirip.sin_port) != 0) {
- memset(&p->redirip, 0, sizeof(p->redirip));
- changed = 1;
- }
- if (vrtp) {
- changed |= ast_rtp_get_peer(vrtp, &p->vredirip);
- } else if (p->vredirip.sin_addr.s_addr || ntohs(p->vredirip.sin_port) != 0) {
- memset(&p->vredirip, 0, sizeof(p->vredirip));
- changed = 1;
- }
- if (trtp) {
- changed |= ast_rtp_get_peer(trtp, &p->tredirip);
- } else if (p->tredirip.sin_addr.s_addr || ntohs(p->tredirip.sin_port) != 0) {
- memset(&p->tredirip, 0, sizeof(p->tredirip));
- changed = 1;
- }
- if (codecs && (p->redircodecs != codecs)) {
- p->redircodecs = codecs;
- changed = 1;
- }
- if (changed && !ast_test_flag(&p->flags[0], SIP_GOTREFER) && !ast_test_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER)) {
- if (chan->_state != AST_STATE_UP) { /* We are in early state */
- if (p->do_history)
- append_history(p, "ExtInv", "Initial invite sent with remote bridge proposal.");
- ast_debug(1, "Early remote bridge setting SIP '%s' - Sending media to %s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr : p->ourip.sin_addr));
- } else if (!p->pendinginvite) { /* We are up, and have no outstanding invite */
- ast_debug(3, "Sending reinvite on SIP '%s' - It's audio soon redirected to IP %s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr : p->ourip.sin_addr));
- transmit_reinvite_with_sdp(p, FALSE, FALSE);
- } else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
- ast_debug(3, "Deferring reinvite on SIP '%s' - It's audio will be redirected to IP %s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr : p->ourip.sin_addr));
- /* We have a pending Invite. Send re-invite when we're done with the invite */
- ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
- }
- }
- /* Reset lastrtprx timer */
- p->lastrtprx = p->lastrtptx = time(NULL);
- sip_pvt_unlock(p);
- return 0;
+ if (instance) {
+ changed |= ast_rtp_instance_get_remote_address(instance, &p->redirip);
+ } else if (p->redirip.sin_addr.s_addr || ntohs(p->redirip.sin_port) != 0) {
+ memset(&p->redirip, 0, sizeof(p->redirip));
+ changed = 1;
+ }
+ if (vinstance) {
+ changed |= ast_rtp_instance_get_remote_address(vinstance, &p->vredirip);
+ } else if (p->vredirip.sin_addr.s_addr || ntohs(p->vredirip.sin_port) != 0) {
+ memset(&p->vredirip, 0, sizeof(p->vredirip));
+ changed = 1;
+ }
+ if (tinstance) {
+ changed |= ast_rtp_instance_get_remote_address(tinstance, &p->tredirip);
+ } else if (p->tredirip.sin_addr.s_addr || ntohs(p->tredirip.sin_port) != 0) {
+ memset(&p->tredirip, 0, sizeof(p->tredirip));
+ changed = 1;
+ }
+ if (codecs && (p->redircodecs != codecs)) {
+ p->redircodecs = codecs;
+ changed = 1;
+ }
+ if (changed && !ast_test_flag(&p->flags[0], SIP_GOTREFER) && !ast_test_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER)) {
+ if (chan->_state != AST_STATE_UP) { /* We are in early state */
+ if (p->do_history)
+ append_history(p, "ExtInv", "Initial invite sent with remote bridge proposal.");
+ ast_debug(1, "Early remote bridge setting SIP '%s' - Sending media to %s\n", p->callid, ast_inet_ntoa(instance ? p->redirip.sin_addr : p->ourip.sin_addr));
+ } else if (!p->pendinginvite) { /* We are up, and have no outstanding invite */
+ ast_debug(3, "Sending reinvite on SIP '%s' - It's audio soon redirected to IP %s\n", p->callid, ast_inet_ntoa(instance ? p->redirip.sin_addr : p->ourip.sin_addr));
+ transmit_reinvite_with_sdp(p, FALSE, FALSE);
+ } else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
+ ast_debug(3, "Deferring reinvite on SIP '%s' - It's audio will be redirected to IP %s\n", p->callid, ast_inet_ntoa(instance ? p->redirip.sin_addr : p->ourip.sin_addr));
+ /* We have a pending Invite. Send re-invite when we're done with the invite */
+ ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
+ }
+ }
+ /* Reset lastrtprx timer */
+ p->lastrtprx = p->lastrtptx = time(NULL);
+ sip_pvt_unlock(p);
+ return 0;
}
+static int sip_get_codec(struct ast_channel *chan)
+{
+ struct sip_pvt *p = chan->tech_pvt;
+ return p->peercapability ? p->peercapability : p->capability;
+}
+
+static struct ast_rtp_glue sip_rtp_glue = {
+ .type = "SIP",
+ .get_rtp_info = sip_get_rtp_peer,
+ .get_vrtp_info = sip_get_vrtp_peer,
+ .get_trtp_info = sip_get_trtp_peer,
+ .update_peer = sip_set_rtp_peer,
+ .get_codec = sip_get_codec,
+};
+
static char *app_dtmfmode = "SIPDtmfMode";
static char *app_sipaddheader = "SIPAddHeader";
static char *app_sipremoveheader = "SIPRemoveHeader";
@@ -24140,7 +24167,7 @@ static int sip_dtmfmode(struct ast_channel *chan, void *data)
} else
ast_log(LOG_WARNING, "I don't know about this dtmf mode: %s\n", mode);
if (p->rtp)
- ast_rtp_setdtmf(p->rtp, ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_RFC2833);
+ ast_rtp_instance_set_prop(p->rtp, AST_RTP_PROPERTY_DTMF, ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_RFC2833);
if (ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_INBAND) {
if (!p->vad) {
p->vad = ast_dsp_new();
@@ -24288,13 +24315,6 @@ static int sip_sipredirect(struct sip_pvt *p, const char *dest)
return 0;
}
-/*! \brief Return SIP UA's codec (part of the RTP interface) */
-static int sip_get_codec(struct ast_channel *chan)
-{
- struct sip_pvt *p = chan->tech_pvt;
- return p->jointcapability ? p->jointcapability : p->capability;
-}
-
/*! \brief Send a poke to all known peers */
static void sip_poke_all_peers(void)
{
@@ -24502,12 +24522,12 @@ static int load_module(void)
/* Register all CLI functions for SIP */
ast_cli_register_multiple(cli_sip, ARRAY_LEN(cli_sip));
- /* Tell the RTP subdriver that we're here */
- ast_rtp_proto_register(&sip_rtp);
-
/* Tell the UDPTL subdriver that we're here */
ast_udptl_proto_register(&sip_udptl);
+ /* Tell the RTP engine about our RTP glue */
+ ast_rtp_glue_register(&sip_rtp_glue);
+
/* Register dialplan applications */
ast_register_application_xml(app_dtmfmode, sip_dtmfmode);
ast_register_application_xml(app_sipaddheader, sip_addheader);
@@ -24578,12 +24598,12 @@ static int unload_module(void)
/* Unregister CLI commands */
ast_cli_unregister_multiple(cli_sip, ARRAY_LEN(cli_sip));
- /* Disconnect from the RTP subsystem */
- ast_rtp_proto_unregister(&sip_rtp);
-
/* Disconnect from UDPTL */
ast_udptl_proto_unregister(&sip_udptl);
+ /* Disconnect from RTP engine */
+ ast_rtp_glue_unregister(&sip_rtp_glue);
+
/* Unregister AMI actions */
ast_manager_unregister("SIPpeers");
ast_manager_unregister("SIPshowpeer");
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index e8330fa82..f4104a89e 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -49,7 +49,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/pbx.h"
#include "asterisk/sched.h"
#include "asterisk/io.h"
-#include "asterisk/rtp.h"
+#include "asterisk/rtp_engine.h"
#include "asterisk/netsock.h"
#include "asterisk/acl.h"
#include "asterisk/callerid.h"
@@ -1111,8 +1111,8 @@ static int matchdigittimeout = 3000;
struct skinny_subchannel {
ast_mutex_t lock;
struct ast_channel *owner;
- struct ast_rtp *rtp;
- struct ast_rtp *vrtp;
+ struct ast_rtp_instance *rtp;
+ struct ast_rtp_instance *vrtp;
unsigned int callid;
/* time_t lastouttime; */ /* Unused */
int progress;
@@ -1347,7 +1347,7 @@ static const struct ast_channel_tech skinny_tech = {
.fixup = skinny_fixup,
.send_digit_begin = skinny_senddigit_begin,
.send_digit_end = skinny_senddigit_end,
- .bridge = ast_rtp_bridge,
+ .bridge = ast_rtp_instance_bridge,
};
static int skinny_extensionstate_cb(char *context, char* exten, int state, void *data);
@@ -2557,46 +2557,48 @@ static void mwi_event_cb(const struct ast_event *event, void *userdata)
/* I do not believe skinny can deal with video.
Anyone know differently? */
/* Yes, it can. Currently 7985 and Cisco VT Advantage do video. */
-static enum ast_rtp_get_result skinny_get_vrtp_peer(struct ast_channel *c, struct ast_rtp **rtp)
+static enum ast_rtp_glue_result skinny_get_vrtp_peer(struct ast_channel *c, struct ast_rtp_instance **instance)
{
struct skinny_subchannel *sub = NULL;
if (!(sub = c->tech_pvt) || !(sub->vrtp))
- return AST_RTP_GET_FAILED;
+ return AST_RTP_GLUE_RESULT_FORBID;
- *rtp = sub->vrtp;
+ ao2_ref(sub->vrtp, +1);
+ *instance = sub->vrtp;
- return AST_RTP_TRY_NATIVE;
+ return AST_RTP_GLUE_RESULT_REMOTE;
}
-static enum ast_rtp_get_result skinny_get_rtp_peer(struct ast_channel *c, struct ast_rtp **rtp)
+static enum ast_rtp_glue_result skinny_get_rtp_peer(struct ast_channel *c, struct ast_rtp_instance **instance)
{
struct skinny_subchannel *sub = NULL;
struct skinny_line *l;
- enum ast_rtp_get_result res = AST_RTP_TRY_NATIVE;
+ enum ast_rtp_glue_result res = AST_RTP_GLUE_RESULT_REMOTE;
if (skinnydebug)
ast_verb(1, "skinny_get_rtp_peer() Channel = %s\n", c->name);
if (!(sub = c->tech_pvt))
- return AST_RTP_GET_FAILED;
+ return AST_RTP_GLUE_RESULT_FORBID;
ast_mutex_lock(&sub->lock);
if (!(sub->rtp)){
ast_mutex_unlock(&sub->lock);
- return AST_RTP_GET_FAILED;
+ return AST_RTP_GLUE_RESULT_FORBID;
}
-
- *rtp = sub->rtp;
+
+ ao2_ref(sub->rtp, +1);
+ *instance = sub->rtp;
l = sub->parent;
if (!l->canreinvite || l->nat){
- res = AST_RTP_TRY_PARTIAL;
+ res = AST_RTP_GLUE_RESULT_LOCAL;
if (skinnydebug)
- ast_verb(1, "skinny_get_rtp_peer() Using AST_RTP_TRY_PARTIAL \n");
+ ast_verb(1, "skinny_get_rtp_peer() Using AST_RTP_GLUE_RESULT_LOCAL \n");
}
ast_mutex_unlock(&sub->lock);
@@ -2605,7 +2607,7 @@ static enum ast_rtp_get_result skinny_get_rtp_peer(struct ast_channel *c, struct
}
-static int skinny_set_rtp_peer(struct ast_channel *c, struct ast_rtp *rtp, struct ast_rtp *vrtp, struct ast_rtp *trtp, int codecs, int nat_active)
+static int skinny_set_rtp_peer(struct ast_channel *c, struct ast_rtp_instance *rtp, struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, int codecs, int nat_active)
{
struct skinny_subchannel *sub;
struct skinny_line *l;
@@ -2630,7 +2632,7 @@ static int skinny_set_rtp_peer(struct ast_channel *c, struct ast_rtp *rtp, struc
s = d->session;
if (rtp){
- ast_rtp_get_peer(rtp, &them);
+ ast_rtp_instance_get_remote_address(rtp, &them);
/* Shutdown any early-media or previous media on re-invite */
if (!(req = req_alloc(sizeof(struct stop_media_transmission_message), STOP_MEDIA_TRANSMISSION_MESSAGE)))
@@ -2654,7 +2656,7 @@ static int skinny_set_rtp_peer(struct ast_channel *c, struct ast_rtp *rtp, struc
req->data.startmedia.conferenceId = htolel(sub->callid);
req->data.startmedia.passThruPartyId = htolel(sub->callid);
if (!(l->canreinvite) || (l->nat)){
- ast_rtp_get_us(rtp, &us);
+ ast_rtp_instance_get_local_address(rtp, &us);
req->data.startmedia.remoteIp = htolel(d->ourip.s_addr);
req->data.startmedia.remotePort = htolel(ntohs(us.sin_port));
} else {
@@ -2675,11 +2677,11 @@ static int skinny_set_rtp_peer(struct ast_channel *c, struct ast_rtp *rtp, struc
return 0;
}
-static struct ast_rtp_protocol skinny_rtp = {
+static struct ast_rtp_glue skinny_rtp_glue = {
.type = "Skinny",
.get_rtp_info = skinny_get_rtp_peer,
.get_vrtp_info = skinny_get_vrtp_peer,
- .set_rtp_peer = skinny_set_rtp_peer,
+ .update_peer = skinny_set_rtp_peer,
};
static char *handle_skinny_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
@@ -3559,29 +3561,36 @@ static void start_rtp(struct skinny_subchannel *sub)
ast_mutex_lock(&sub->lock);
/* Allocate the RTP */
- sub->rtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr);
+ sub->rtp = ast_rtp_instance_new(NULL, sched, &bindaddr, NULL);
if (hasvideo)
- sub->vrtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr);
-
+ sub->vrtp = ast_rtp_instance_new(NULL, sched, &bindaddr, NULL);
+
+ if (sub->rtp) {
+ ast_rtp_instance_set_prop(sub->rtp, AST_RTP_PROPERTY_RTCP, 1);
+ }
+ if (sub->vrtp) {
+ ast_rtp_instance_set_prop(sub->vrtp, AST_RTP_PROPERTY_RTCP, 1);
+ }
+
if (sub->rtp && sub->owner) {
- ast_channel_set_fd(sub->owner, 0, ast_rtp_fd(sub->rtp));
- ast_channel_set_fd(sub->owner, 1, ast_rtcp_fd(sub->rtp));
+ ast_channel_set_fd(sub->owner, 0, ast_rtp_instance_fd(sub->rtp, 0));
+ ast_channel_set_fd(sub->owner, 1, ast_rtp_instance_fd(sub->rtp, 1));
}
if (hasvideo && sub->vrtp && sub->owner) {
- ast_channel_set_fd(sub->owner, 2, ast_rtp_fd(sub->vrtp));
- ast_channel_set_fd(sub->owner, 3, ast_rtcp_fd(sub->vrtp));
+ ast_channel_set_fd(sub->owner, 2, ast_rtp_instance_fd(sub->vrtp, 0));
+ ast_channel_set_fd(sub->owner, 3, ast_rtp_instance_fd(sub->vrtp, 1));
}
if (sub->rtp) {
- ast_rtp_setqos(sub->rtp, qos.tos_audio, qos.cos_audio, "Skinny RTP");
- ast_rtp_setnat(sub->rtp, l->nat);
+ ast_rtp_instance_set_qos(sub->rtp, qos.tos_audio, qos.cos_audio, "Skinny RTP");
+ ast_rtp_instance_set_prop(sub->rtp, AST_RTP_PROPERTY_NAT, l->nat);
}
if (sub->vrtp) {
- ast_rtp_setqos(sub->vrtp, qos.tos_video, qos.cos_video, "Skinny VRTP");
- ast_rtp_setnat(sub->vrtp, l->nat);
+ ast_rtp_instance_set_qos(sub->vrtp, qos.tos_video, qos.cos_video, "Skinny VRTP");
+ ast_rtp_instance_set_prop(sub->vrtp, AST_RTP_PROPERTY_NAT, l->nat);
}
/* Set Frame packetization */
if (sub->rtp)
- ast_rtp_codec_setpref(sub->rtp, &l->prefs);
+ ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(sub->rtp), sub->rtp, &l->prefs);
/* Create the RTP connection */
transmit_connect(d, sub);
@@ -3852,7 +3861,7 @@ static int skinny_hangup(struct ast_channel *ast)
sub->alreadygone = 0;
sub->outgoing = 0;
if (sub->rtp) {
- ast_rtp_destroy(sub->rtp);
+ ast_rtp_instance_destroy(sub->rtp);
sub->rtp = NULL;
}
ast_mutex_unlock(&sub->lock);
@@ -3913,16 +3922,16 @@ static struct ast_frame *skinny_rtp_read(struct skinny_subchannel *sub)
switch(ast->fdno) {
case 0:
- f = ast_rtp_read(sub->rtp); /* RTP Audio */
+ f = ast_rtp_instance_read(sub->rtp, 0); /* RTP Audio */
break;
case 1:
- f = ast_rtcp_read(sub->rtp); /* RTCP Control Channel */
+ f = ast_rtp_instance_read(sub->rtp, 1); /* RTCP Control Channel */
break;
case 2:
- f = ast_rtp_read(sub->vrtp); /* RTP Video */
+ f = ast_rtp_instance_read(sub->vrtp, 0); /* RTP Video */
break;
case 3:
- f = ast_rtcp_read(sub->vrtp); /* RTCP Control Channel for video */
+ f = ast_rtp_instance_read(sub->vrtp, 1); /* RTCP Control Channel for video */
break;
#if 0
case 5:
@@ -3979,7 +3988,7 @@ static int skinny_write(struct ast_channel *ast, struct ast_frame *frame)
if (sub) {
ast_mutex_lock(&sub->lock);
if (sub->rtp) {
- res = ast_rtp_write(sub->rtp, frame);
+ res = ast_rtp_instance_write(sub->rtp, frame);
}
ast_mutex_unlock(&sub->lock);
}
@@ -4253,7 +4262,7 @@ static int skinny_indicate(struct ast_channel *ast, int ind, const void *data, s
case AST_CONTROL_PROCEEDING:
break;
case AST_CONTROL_SRCUPDATE:
- ast_rtp_new_source(sub->rtp);
+ ast_rtp_instance_new_source(sub->rtp);
break;
default:
ast_log(LOG_WARNING, "Don't know how to indicate condition %d\n", ind);
@@ -4312,7 +4321,7 @@ static struct ast_channel *skinny_new(struct skinny_line *l, int state)
if (skinnydebug)
ast_verb(1, "skinny_new: tmp->nativeformats=%d fmt=%d\n", tmp->nativeformats, fmt);
if (sub->rtp) {
- ast_channel_set_fd(tmp, 0, ast_rtp_fd(sub->rtp));
+ ast_channel_set_fd(tmp, 0, ast_rtp_instance_fd(sub->rtp, 0));
}
if (state == AST_STATE_RING) {
tmp->rings = 1;
@@ -5537,8 +5546,8 @@ static int handle_open_receive_channel_ack_message(struct skinny_req *req, struc
l = sub->parent;
if (sub->rtp) {
- ast_rtp_set_peer(sub->rtp, &sin);
- ast_rtp_get_us(sub->rtp, &us);
+ ast_rtp_instance_set_remote_address(sub->rtp, &sin);
+ ast_rtp_instance_get_local_address(sub->rtp, &us);
} else {
ast_log(LOG_ERROR, "No RTP structure, this is very bad\n");
return 0;
@@ -7289,7 +7298,7 @@ static int load_module(void)
return -1;
}
- ast_rtp_proto_register(&skinny_rtp);
+ ast_rtp_glue_register(&skinny_rtp_glue);
ast_cli_register_multiple(cli_skinny, ARRAY_LEN(cli_skinny));
ast_manager_register2("SKINNYdevices", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_skinny_show_devices,
@@ -7323,7 +7332,7 @@ static int unload_module(void)
struct skinny_subchannel *sub;
struct ast_context *con;
- ast_rtp_proto_unregister(&skinny_rtp);
+ ast_rtp_glue_unregister(&skinny_rtp_glue);
ast_channel_unregister(&skinny_tech);
ast_cli_unregister_multiple(cli_skinny, ARRAY_LEN(cli_skinny));
diff --git a/channels/chan_unistim.c b/channels/chan_unistim.c
index 818a32d71..1cd94e02f 100644
--- a/channels/chan_unistim.c
+++ b/channels/chan_unistim.c
@@ -60,7 +60,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/module.h"
#include "asterisk/pbx.h"
#include "asterisk/event.h"
-#include "asterisk/rtp.h"
+#include "asterisk/rtp_engine.h"
#include "asterisk/netsock.h"
#include "asterisk/acl.h"
#include "asterisk/callerid.h"
@@ -365,7 +365,7 @@ struct unistim_subchannel {
/*! Unistim line */
struct unistim_line *parent;
/*! RTP handle */
- struct ast_rtp *rtp;
+ struct ast_rtp_instance *rtp;
int alreadygone;
char ringvolume;
char ringstyle;
@@ -711,7 +711,7 @@ static const struct ast_channel_tech unistim_tech = {
.send_digit_begin = unistim_senddigit_begin,
.send_digit_end = unistim_senddigit_end,
.send_text = unistim_sendtext,
-/* .bridge = ast_rtp_bridge, */
+ .bridge = ast_rtp_instance_bridge,
};
static void display_last_error(const char *sz_msg)
@@ -1854,7 +1854,7 @@ static void cancel_dial(struct unistimsession *pte)
static void swap_subs(struct unistim_line *p, int a, int b)
{
/* struct ast_channel *towner; */
- struct ast_rtp *rtp;
+ struct ast_rtp_instance *rtp;
int fds;
if (unistimdebug)
@@ -2056,30 +2056,29 @@ static void start_rtp(struct unistim_subchannel *sub)
/* Allocate the RTP */
if (unistimdebug)
ast_verb(0, "Starting RTP. Bind on %s\n", ast_inet_ntoa(sout.sin_addr));
- sub->rtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, sout.sin_addr);
+ sub->rtp = ast_rtp_instance_new(NULL, sched, &sout, NULL);
if (!sub->rtp) {
ast_log(LOG_WARNING, "Unable to create RTP session: %s binaddr=%s\n",
strerror(errno), ast_inet_ntoa(sout.sin_addr));
ast_mutex_unlock(&sub->lock);
return;
}
- if (sub->rtp && sub->owner) {
- sub->owner->fds[0] = ast_rtp_fd(sub->rtp);
- sub->owner->fds[1] = ast_rtcp_fd(sub->rtp);
- }
- if (sub->rtp) {
- ast_rtp_setqos(sub->rtp, qos.tos_audio, qos.cos_audio, "UNISTIM RTP");
- ast_rtp_setnat(sub->rtp, sub->parent->parent->nat);
+ ast_rtp_instance_set_prop(sub->rtp, AST_RTP_PROPERTY_RTCP, 1);
+ if (sub->owner) {
+ sub->owner->fds[0] = ast_rtp_instance_fd(sub->rtp, 0);
+ sub->owner->fds[1] = ast_rtp_instance_fd(sub->rtp, 1);
}
+ ast_rtp_instance_set_qos(sub->rtp, qos.tos_audio, qos.cos_audio, "UNISTIM RTP");
+ ast_rtp_instance_set_prop(sub->rtp, AST_RTP_PROPERTY_NAT, sub->parent->parent->nat);
/* Create the RTP connection */
- ast_rtp_get_us(sub->rtp, &us);
+ ast_rtp_instance_get_local_address(sub->rtp, &us);
sin.sin_family = AF_INET;
/* Setting up RTP for our side */
memcpy(&sin.sin_addr, &sub->parent->parent->session->sin.sin_addr,
sizeof(sin.sin_addr));
sin.sin_port = htons(sub->parent->parent->rtp_port);
- ast_rtp_set_peer(sub->rtp, &sin);
+ ast_rtp_instance_set_remote_address(sub->rtp, &sin);
if (!(sub->owner->nativeformats & sub->owner->readformat)) {
int fmt;
fmt = ast_best_codec(sub->owner->nativeformats);
@@ -2091,7 +2090,7 @@ static void start_rtp(struct unistim_subchannel *sub)
sub->owner->readformat = fmt;
sub->owner->writeformat = fmt;
}
- codec = ast_rtp_lookup_code(sub->rtp, 1, sub->owner->readformat);
+ codec = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(sub->rtp), 1, sub->owner->readformat);
/* Setting up RTP of the phone */
if (public_ip.sin_family == 0) /* NAT IP override ? */
memcpy(&public, &us, sizeof(public)); /* No defined, using IP from recvmsg */
@@ -3724,7 +3723,7 @@ static int unistim_hangup(struct ast_channel *ast)
if (sub->rtp) {
if (unistimdebug)
ast_verb(0, "Destroying RTP session\n");
- ast_rtp_destroy(sub->rtp);
+ ast_rtp_instance_destroy(sub->rtp);
sub->rtp = NULL;
}
return 0;
@@ -3769,7 +3768,7 @@ static int unistim_hangup(struct ast_channel *ast)
if (sub->rtp) {
if (unistimdebug)
ast_verb(0, "Destroying RTP session\n");
- ast_rtp_destroy(sub->rtp);
+ ast_rtp_instance_destroy(sub->rtp);
sub->rtp = NULL;
}
return 0;
@@ -3794,7 +3793,7 @@ static int unistim_hangup(struct ast_channel *ast)
if (sub->rtp) {
if (unistimdebug)
ast_verb(0, "Destroying RTP session\n");
- ast_rtp_destroy(sub->rtp);
+ ast_rtp_instance_destroy(sub->rtp);
sub->rtp = NULL;
} else if (unistimdebug)
ast_verb(0, "No RTP session to destroy\n");
@@ -3921,10 +3920,10 @@ static struct ast_frame *unistim_rtp_read(const struct ast_channel *ast,
switch (ast->fdno) {
case 0:
- f = ast_rtp_read(sub->rtp); /* RTP Audio */
+ f = ast_rtp_instance_read(sub->rtp, 0); /* RTP Audio */
break;
case 1:
- f = ast_rtcp_read(sub->rtp); /* RTCP Control Channel */
+ f = ast_rtp_instance_read(sub->rtp, 1); /* RTCP Control Channel */
break;
default:
f = &ast_null_frame;
@@ -3990,7 +3989,7 @@ static int unistim_write(struct ast_channel *ast, struct ast_frame *frame)
if (sub) {
ast_mutex_lock(&sub->lock);
if (sub->rtp) {
- res = ast_rtp_write(sub->rtp, frame);
+ res = ast_rtp_instance_write(sub->rtp, frame);
}
ast_mutex_unlock(&sub->lock);
}
@@ -4455,8 +4454,8 @@ static struct ast_channel *unistim_new(struct unistim_subchannel *sub, int state
if ((sub->rtp) && (sub->subtype == 0)) {
if (unistimdebug)
ast_verb(0, "New unistim channel with a previous rtp handle ?\n");
- tmp->fds[0] = ast_rtp_fd(sub->rtp);
- tmp->fds[1] = ast_rtcp_fd(sub->rtp);
+ tmp->fds[0] = ast_rtp_instance_fd(sub->rtp, 0);
+ tmp->fds[1] = ast_rtp_instance_fd(sub->rtp, 1);
}
if (sub->rtp)
ast_jb_configure(tmp, &global_jbconf);
@@ -5526,51 +5525,19 @@ static int reload_config(void)
return 0;
}
-static enum ast_rtp_get_result unistim_get_vrtp_peer(struct ast_channel *chan,
- struct ast_rtp **rtp)
-{
- return AST_RTP_TRY_NATIVE;
-}
-
-static enum ast_rtp_get_result unistim_get_rtp_peer(struct ast_channel *chan,
- struct ast_rtp **rtp)
-{
- struct unistim_subchannel *sub;
- enum ast_rtp_get_result res = AST_RTP_GET_FAILED;
-
- if (unistimdebug)
- ast_verb(0, "unistim_get_rtp_peer called\n");
-
- sub = chan->tech_pvt;
- if (sub && sub->rtp) {
- *rtp = sub->rtp;
- res = AST_RTP_TRY_NATIVE;
- }
-
- return res;
-}
-
-static int unistim_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp,
- struct ast_rtp *vrtp, struct ast_rtp *trtp, int codecs, int nat_active)
+static enum ast_rtp_glue_result unistim_get_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance **instance)
{
- struct unistim_subchannel *sub;
-
- if (unistimdebug)
- ast_verb(0, "unistim_set_rtp_peer called\n");
-
- sub = chan->tech_pvt;
+ struct unistim_subchannel *sub = chan->tech_pvt;
- if (sub)
- return 0;
+ ao2_ref(sub->rtp, +1);
+ *instance = sub->rtp;
- return -1;
+ return AST_RTP_GLUE_RESULT_LOCAL;
}
-static struct ast_rtp_protocol unistim_rtp = {
+static struct ast_rtp_glue unistim_rtp_glue = {
.type = channel_type,
.get_rtp_info = unistim_get_rtp_peer,
- .get_vrtp_info = unistim_get_vrtp_peer,
- .set_rtp_peer = unistim_set_rtp_peer,
};
/*--- load_module: PBX load module - initialization ---*/
@@ -5603,7 +5570,7 @@ int load_module(void)
goto chanreg_failed;
}
- ast_rtp_proto_register(&unistim_rtp);
+ ast_rtp_glue_register(&unistim_rtp_glue);
ast_cli_register_multiple(unistim_cli, ARRAY_LEN(unistim_cli));
@@ -5634,7 +5601,7 @@ static int unload_module(void)
ast_cli_unregister_multiple(unistim_cli, ARRAY_LEN(unistim_cli));
ast_channel_unregister(&unistim_tech);
- ast_rtp_proto_unregister(&unistim_rtp);
+ ast_rtp_glue_unregister(&unistim_rtp_glue);
ast_mutex_lock(&monlock);
if (monitor_thread && (monitor_thread != AST_PTHREADT_STOP) && (monitor_thread != AST_PTHREADT_NULL)) {