summaryrefslogtreecommitdiff
path: root/channels/chan_gtalk.c
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2013-07-05 17:33:33 +0000
committerMatthew Jordan <mjordan@digium.com>2013-07-05 17:33:33 +0000
commitd0a55fa52dcc29f2db3e22549c9c2f2e68cada56 (patch)
treeb3d339dcfa5611a7be0e12b99131d21d206719a3 /channels/chan_gtalk.c
parentd789681eaff813affe6f88f33813aebcc99d8b6a (diff)
Refactor RTCP events over to Stasis; associate with channels
This patch does the following: * It merges Jaco Kroon's patch from ASTERISK-20754, which provides channel information in the RTCP events. Because Stasis provides a cache, Jaco's patch was modified to pass the channel uniqueid to the RTP layer as opposed to a pointer to the channel. This has the following benefits: (1) It keeps the RTP engine 'clean' of references back to channels (2) It prevents circular dependencies and other potential ref counting issues * The RTP engine now allows any RTP implementation to raise RTCP messages. Potentially, other implementations (such as res_rtp_multicast) could also raise RTCP information. The engine provides structs to represent RTCP headers and RTCP SR/RR reports. * Some general refactoring in res_rtp_asterisk was done to try and tame the RTCP code. It isn't perfect - that's *way* beyond the scope of this work - but it does feel marginally better. * A few random bugs were fixed in the RTCP statistics. (Example: performing an assignment of a = a is probably not correct) * We now raise RTCP events for each SR/RR sent/received. Previously we wouldn't raise an event when we sent a RR report. Note that this work will be of use to others who want to monitor call quality or build modules that report call quality statistics. Since the events are now moving across the Stasis message bus, this is far easier to accomplish. It is also a first step (though by no means the last step) towards getting Olle's pinefrog work incorporated. Again: note that the patch by Jaco Kroon was modified slightly for this work; however, he did all of the hard work in finding the right places to set the channel in the RTP engine across the channel drivers. Much thanks goes to Jaco for his hard work here. Review: https://reviewboard.asterisk.org/r/2603/ (closes issue ASTERISK-20574) Reported by: Jaco Kroon patches: asterisk-rtcp-channel.patch uploaded by jkroon (License 5671) (closes issue ASTERISK-21471) Reported by: Matt Jordan git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@393740 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_gtalk.c')
-rw-r--r--channels/chan_gtalk.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/channels/chan_gtalk.c b/channels/chan_gtalk.c
index 8a7083eb2..639de4749 100644
--- a/channels/chan_gtalk.c
+++ b/channels/chan_gtalk.c
@@ -210,6 +210,7 @@ static char *gtalk_show_settings(struct ast_cli_entry *e, int cmd, struct ast_cl
static int gtalk_update_externip(void);
static int gtalk_parser(void *data, ikspak *pak);
static int gtalk_create_candidates(struct gtalk *client, struct gtalk_pvt *p, char *sid, char *from, char *to);
+static void gtalk_set_owner(struct gtalk_pvt *p, struct ast_channel *chan);
/*! \brief PBX interface structure for channel registration */
static struct ast_channel_tech gtalk_tech = {
@@ -1007,6 +1008,17 @@ safeout:
return 1;
}
+static void gtalk_set_owner(struct gtalk_pvt *p, struct ast_channel *chan)
+{
+ p->owner = chan;
+ if (p->rtp) {
+ ast_rtp_instance_set_channel_id(p->rtp, chan ? ast_channel_uniqueid(chan) : "");
+ }
+ if (p->vrtp) {
+ ast_rtp_instance_set_channel_id(p->vrtp, chan ? ast_channel_uniqueid(chan) : "");
+ }
+}
+
static struct gtalk_pvt *gtalk_alloc(struct gtalk *client, const char *us, const char *them, const char *sid)
{
struct gtalk_pvt *tmp = NULL;
@@ -1198,7 +1210,7 @@ static struct ast_channel *gtalk_new(struct gtalk *client, struct gtalk_pvt *i,
ast_channel_musicclass_set(tmp, client->musicclass);
if (!ast_strlen_zero(client->parkinglot))
ast_channel_parkinglot_set(tmp, client->parkinglot);
- i->owner = tmp;
+ gtalk_set_owner(i, tmp);
ast_module_ref(ast_module_info->self);
ast_channel_context_set(tmp, client->context);
ast_channel_exten_set(tmp, i->exten);
@@ -1712,8 +1724,9 @@ static int gtalk_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
ast_mutex_unlock(&p->lock);
return -1;
}
- if (p->owner == oldchan)
- p->owner = newchan;
+ if (p->owner == oldchan) {
+ gtalk_set_owner(p, newchan);
+ }
ast_mutex_unlock(&p->lock);
return 0;
}
@@ -1889,7 +1902,7 @@ static int gtalk_hangup(struct ast_channel *ast)
ast_mutex_lock(&p->lock);
client = p->parent;
- p->owner = NULL;
+ gtalk_set_owner(p, NULL);
ast_channel_tech_pvt_set(ast, NULL);
if (!p->alreadygone) {
gtalk_action(client, p, "terminate");