diff options
author | Matthew Jordan <mjordan@digium.com> | 2013-07-05 17:33:33 +0000 |
---|---|---|
committer | Matthew Jordan <mjordan@digium.com> | 2013-07-05 17:33:33 +0000 |
commit | d0a55fa52dcc29f2db3e22549c9c2f2e68cada56 (patch) | |
tree | b3d339dcfa5611a7be0e12b99131d21d206719a3 /channels/chan_mgcp.c | |
parent | d789681eaff813affe6f88f33813aebcc99d8b6a (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_mgcp.c')
-rw-r--r-- | channels/chan_mgcp.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c index 5a0b7ad84..da3fefa8a 100644 --- a/channels/chan_mgcp.c +++ b/channels/chan_mgcp.c @@ -431,6 +431,7 @@ static int mgcpsock = -1; static struct sockaddr_in bindaddr; +static void mgcp_set_owner(struct mgcp_subchannel *sub, struct ast_channel *chan); static struct ast_frame *mgcp_read(struct ast_channel *ast); static int transmit_response(struct mgcp_subchannel *sub, char *msg, struct mgcp_request *req, char *msgrest); static int transmit_notify_request(struct mgcp_subchannel *sub, char *tone); @@ -528,7 +529,7 @@ static int unalloc_sub(struct mgcp_subchannel *sub) } ast_debug(1, "Released sub %d of channel %s@%s\n", sub->id, p->name, p->parent->name); - sub->owner = NULL; + mgcp_set_owner(sub, NULL); if (!ast_strlen_zero(sub->cxident)) { transmit_connection_del(sub); } @@ -945,7 +946,7 @@ static int mgcp_hangup(struct ast_channel *ast) } } - sub->owner = NULL; + mgcp_set_owner(sub, NULL); /* for deleting gate */ if (p->pktcgatealloc && sub->gate) { @@ -1225,6 +1226,13 @@ static struct ast_frame *mgcp_rtp_read(struct mgcp_subchannel *sub) return f; } +static void mgcp_set_owner(struct mgcp_subchannel *sub, struct ast_channel *chan) +{ + sub->owner = chan; + if (sub->rtp) { + ast_rtp_instance_set_channel_id(sub->rtp, sub->owner ? ast_channel_uniqueid(chan) : ""); + } +} static struct ast_frame *mgcp_read(struct ast_channel *ast) { @@ -1288,7 +1296,7 @@ static int mgcp_fixup(struct ast_channel *oldchan, struct ast_channel *newchan) ast_log(LOG_WARNING, "old channel wasn't %p but was %p\n", oldchan, sub->owner); return -1; } - sub->owner = newchan; + mgcp_set_owner(sub, newchan); ast_mutex_unlock(&sub->lock); return 0; } @@ -1529,7 +1537,7 @@ static struct ast_channel *mgcp_new(struct mgcp_subchannel *sub, int state, cons ast_channel_accountcode_set(tmp, i->accountcode); if (i->amaflags) ast_channel_amaflags_set(tmp, i->amaflags); - sub->owner = tmp; + mgcp_set_owner(sub, tmp); ast_module_ref(ast_module_info->self); ast_channel_callgroup_set(tmp, i->callgroup); ast_channel_pickupgroup_set(tmp, i->pickupgroup); |