[asterisk-commits] file: branch file/rtp_engine-mark2 r183698 - /team/file/rtp_engine-mark2/chan...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Mar 23 12:42:20 CDT 2009
Author: file
Date: Mon Mar 23 12:42:17 2009
New Revision: 183698
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=183698
Log:
Convert chan_jingle over to RTP engine architecture.
Modified:
team/file/rtp_engine-mark2/channels/chan_jingle.c
Modified: team/file/rtp_engine-mark2/channels/chan_jingle.c
URL: http://svn.digium.com/svn-view/asterisk/team/file/rtp_engine-mark2/channels/chan_jingle.c?view=diff&rev=183698&r1=183697&r2=183698
==============================================================================
--- team/file/rtp_engine-mark2/channels/chan_jingle.c (original)
+++ team/file/rtp_engine-mark2/channels/chan_jingle.c Mon Mar 23 12:42:17 2009
@@ -53,7 +53,7 @@
#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 @@
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 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 @@
.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 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 @@
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,18 @@
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;
+ *instance = p->rtp;
+ res = AST_RTP_GLUE_RESULT_LOCAL;
}
ast_mutex_unlock(&p->lock);
@@ -422,7 +407,7 @@
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;
@@ -441,6 +426,13 @@
ast_mutex_unlock(&p->lock);
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)
{
@@ -621,7 +613,7 @@
goto safeout;
}
- ast_rtp_get_us(p->rtp, &sin);
+ memcpy(&sin, &p->rtp->local_address, sizeof(sin));
ast_find_ourip(&us, bindaddr);
/* Setup our first jingle candidate */
@@ -779,7 +771,7 @@
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 +817,18 @@
/* Set Frame packetization */
if (i->rtp)
- ast_rtp_codec_setpref(i->rtp, &i->prefs);
+ ast_rtp_codecs_packetization_set(&i->rtp->codecs, 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 +934,9 @@
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 +1001,8 @@
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(&p->rtp->codecs, p->rtp, atoi(iks_find_attrib(codec, "id")));
+ ast_rtp_codecs_payloads_set_rtpmap_type(&p->rtp->codecs, p->rtp, atoi(iks_find_attrib(codec, "id")), "audio", iks_find_attrib(codec, "name"), 0);
codec = iks_next(codec);
}
}
@@ -1025,8 +1017,8 @@
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(&p->rtp->codecs, p->rtp, atoi(iks_find_attrib(codec, "id")));
+ ast_rtp_codecs_payloads_set_rtpmap_type(&p->rtp->codecs, p->rtp, atoi(iks_find_attrib(codec, "id")), "audio", iks_find_attrib(codec, "name"), 0);
codec = iks_next(codec);
}
}
@@ -1079,7 +1071,7 @@
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 +1161,7 @@
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 +1212,7 @@
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 +1221,7 @@
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 +1871,7 @@
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 +1894,7 @@
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 */
More information about the asterisk-commits
mailing list