summaryrefslogtreecommitdiff
path: root/channels/chan_unistim.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_unistim.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_unistim.c')
-rw-r--r--channels/chan_unistim.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/channels/chan_unistim.c b/channels/chan_unistim.c
index 5a5674daa..53ffa0044 100644
--- a/channels/chan_unistim.c
+++ b/channels/chan_unistim.c
@@ -675,6 +675,7 @@ static int load_module(void);
static int reload(void);
static int unload_module(void);
static int reload_config(void);
+static void unistim_set_owner(struct unistim_subchannel *sub, struct ast_channel *chan);
static void show_main_page(struct unistimsession *pte);
static struct ast_channel *unistim_request(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor,
const char *dest, int *cause);
@@ -2749,6 +2750,7 @@ static void start_rtp(struct unistim_subchannel *sub)
return;
}
ast_rtp_instance_set_prop(sub->rtp, AST_RTP_PROPERTY_RTCP, 1);
+ ast_rtp_instance_set_channel_id(sub->rtp, ast_channel_uniqueid(sub->owner));
ast_channel_internal_fd_set(sub->owner, 0, ast_rtp_instance_fd(sub->rtp, 0));
ast_channel_internal_fd_set(sub->owner, 1, ast_rtp_instance_fd(sub->rtp, 1));
ast_rtp_instance_set_qos(sub->rtp, qos.tos_audio, qos.cos_audio, "UNISTIM RTP");
@@ -4736,7 +4738,7 @@ static int unistim_call(struct ast_channel *ast, const char *dest, int timeout)
static int unistim_hangup_clean(struct ast_channel *ast, struct unistim_subchannel *sub) {
ast_mutex_lock(&sub->lock);
ast_channel_tech_pvt_set(ast, NULL);
- sub->owner = NULL;
+ unistim_set_owner(sub, NULL);
sub->alreadygone = 0;
ast_mutex_unlock(&sub->lock);
if (sub->rtp) {
@@ -5072,7 +5074,7 @@ static int unistim_fixup(struct ast_channel *oldchan, struct ast_channel *newcha
return -1;
}
- p->owner = newchan;
+ unistim_set_owner(p, newchan);
ast_mutex_unlock(&p->lock);
@@ -5589,7 +5591,7 @@ static struct ast_channel *unistim_new(struct unistim_subchannel *sub, int state
if (!ast_strlen_zero(l->parent->language)) {
ast_channel_language_set(tmp, l->parent->language);
}
- sub->owner = tmp;
+ unistim_set_owner(sub, tmp);
ast_update_use_count();
ast_channel_callgroup_set(tmp, l->callgroup);
ast_channel_pickupgroup_set(tmp, l->pickupgroup);
@@ -5623,6 +5625,14 @@ static struct ast_channel *unistim_new(struct unistim_subchannel *sub, int state
return tmp;
}
+static void unistim_set_owner(struct unistim_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(sub->owner) : "");
+ }
+}
+
static void *do_monitor(void *data)
{
struct unistimsession *cur = NULL;