--- a/res/res_rtp_asterisk.c 2012-09-25 21:32:46.000000000 +0200 +++ b/res/res_rtp_asterisk.c 2012-11-30 14:55:20.267238581 +0200 @@ -994,6 +994,7 @@ static int ast_rtcp_write_sr(struct ast_rtp_instance *instance) { struct ast_rtp *rtp = ast_rtp_instance_get_data(instance); + struct ast_channel *chan = ast_rtp_instance_get_chan(instance); int res; int len = 0; struct timeval now; @@ -1093,6 +1094,7 @@ ast_verbose(" DLSR: %4.4f (sec)\n\n", (double)(ntohl(rtcpheader[12])/65536.0)); } manager_event(EVENT_FLAG_REPORTING, "RTCPSent", "To: %s\r\n" + "Channel: %s\r\n" "OurSSRC: %u\r\n" "SentNTP: %u.%010u\r\n" "SentRTP: %u\r\n" @@ -1105,6 +1107,7 @@ "TheirLastSR: %u\r\n" "DLSR: %4.4f (sec)\r\n", ast_sockaddr_stringify(&rtp->rtcp->them), + chan ? chan->name : NULL, rtp->ssrc, (unsigned int)now.tv_sec, (unsigned int)now.tv_usec*4096, rtp->lastts, @@ -1774,6 +1777,7 @@ static struct ast_frame *ast_rtcp_read(struct ast_rtp_instance *instance) { struct ast_rtp *rtp = ast_rtp_instance_get_data(instance); + struct ast_channel *chan = ast_rtp_instance_get_chan(instance); struct ast_sockaddr addr; unsigned int rtcpdata[8192 + AST_FRIENDLY_OFFSET]; unsigned int *rtcpheader = (unsigned int *)(rtcpdata + AST_FRIENDLY_OFFSET); @@ -1958,6 +1962,7 @@ } if (rtt) { manager_event(EVENT_FLAG_REPORTING, "RTCPReceived", "From: %s\r\n" + "Channel: %s\r\n" "PT: %d(%s)\r\n" "ReceptionReports: %d\r\n" "SenderSSRC: %u\r\n" @@ -1970,6 +1975,7 @@ "DLSR: %4.4f(sec)\r\n" "RTT: %llu(sec)\r\n", ast_sockaddr_stringify(&addr), + chan ? chan->name : NULL, pt, (pt == 200) ? "Sender Report" : (pt == 201) ? "Receiver Report" : (pt == 192) ? "H.261 FUR" : "Unknown", rc, rtcpheader[i + 1], @@ -1983,6 +1989,7 @@ (unsigned long long)rtt); } else { manager_event(EVENT_FLAG_REPORTING, "RTCPReceived", "From: %s\r\n" + "Channel: %s\r\n" "PT: %d(%s)\r\n" "ReceptionReports: %d\r\n" "SenderSSRC: %u\r\n" @@ -1994,6 +2001,7 @@ "LastSR: %lu.%010lu\r\n" "DLSR: %4.4f(sec)\r\n", ast_sockaddr_stringify(&addr), + chan ? chan->name : NULL, pt, (pt == 200) ? "Sender Report" : (pt == 201) ? "Receiver Report" : (pt == 192) ? "H.261 FUR" : "Unknown", rc, rtcpheader[i + 1], --- a/main/rtp_engine.c 2012-06-15 17:56:08.000000000 +0200 +++ b/main/rtp_engine.c 2012-11-30 14:55:20.268238581 +0200 @@ -1764,6 +1764,12 @@ return instance->chan; } +void ast_rtp_instance_set_chan(struct ast_rtp_instance *instance, struct ast_channel *channel) +{ + ast_verb(3, "Setting RTP instance channel to %s.\n", channel ? channel->name : "(no channel)"); + instance->chan = channel; +} + int ast_rtp_engine_register_srtp(struct ast_srtp_res *srtp_res, struct ast_srtp_policy_res *policy_res) { if (res_srtp || res_srtp_policy) { --- a/include/asterisk/rtp_engine.h 2012-02-24 17:07:09.000000000 +0200 +++ b/include/asterisk/rtp_engine.h 2012-11-30 14:55:20.269238581 +0200 @@ -1802,7 +1802,7 @@ struct ast_rtp_glue *ast_rtp_instance_get_active_glue(struct ast_rtp_instance *instance); /*! - * \brief Get the channel that is associated with an RTP instance while in a bridge + * \brief Get the channel that is associated with an RTP instance * * \param instance The RTP instance * @@ -1816,13 +1816,30 @@ * * This gets the channel associated with the RTP instance pointed to by 'instance'. * - * \note This will only return a channel while in a local or remote bridge. - * * \since 1.8 */ struct ast_channel *ast_rtp_instance_get_chan(struct ast_rtp_instance *instance); /*! + * \brief Set the channel that is associated with an RTP instance + * + * \param instance The RTP instance + * + * \retval pointer to the channel + * + * Example: + * + * \code + * ast_rtp_instance_set_chan(instance, channel); + * \endcode + * + * This sets the channel associated with the RTP instance pointed to by 'instance'. + * + * \since 1.8 + */ +void ast_rtp_instance_set_chan(struct ast_rtp_instance *instance, struct ast_channel* channel); + +/*! * \brief Send a comfort noise packet to the RTP instance * * \param instance The RTP instance --- a/channels/chan_sip.c 2012-10-04 19:39:18.000000000 +0200 +++ b/channels/chan_sip.c 2012-11-30 15:42:35.360154694 +0200 @@ -1212,6 +1212,7 @@ /*--- PBX interface functions */ static struct ast_channel *sip_request_call(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause); +static void sip_set_owner(struct sip_pvt* p, struct ast_channel* newowner); static int sip_devicestate(void *data); static int sip_sendtext(struct ast_channel *ast, const char *text); static int sip_call(struct ast_channel *ast, char *dest, int timeout); @@ -2968,7 +2969,7 @@ owner->tech_pvt = dialog_unref(owner->tech_pvt, "resetting channel dialog ptr in unlink_all"); ast_channel_unlock(owner); ast_channel_unref(owner); - dialog->owner = NULL; + sip_set_owner(dialog, NULL); } sip_pvt_unlock(dialog); @@ -5266,12 +5267,14 @@ if (!(dialog->rtp = ast_rtp_instance_new(dialog->engine, sched, &bindaddr_tmp, NULL))) { return -1; } + ast_rtp_instance_set_chan(dialog->rtp, dialog->owner); 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))) { if (!(dialog->vrtp = ast_rtp_instance_new(dialog->engine, sched, &bindaddr_tmp, NULL))) { return -1; } + ast_rtp_instance_set_chan(dialog->vrtp, dialog->owner); ast_rtp_instance_set_timeout(dialog->vrtp, dialog->rtptimeout); ast_rtp_instance_set_hold_timeout(dialog->vrtp, dialog->rtpholdtimeout); ast_rtp_instance_set_keepalive(dialog->vrtp, dialog->rtpkeepalive); @@ -5284,6 +5287,7 @@ if (!(dialog->trtp = ast_rtp_instance_new(dialog->engine, sched, &bindaddr_tmp, NULL))) { return -1; } + ast_rtp_instance_set_chan(dialog->trtp, dialog->owner); /* Do not timeout text as its not constant*/ ast_rtp_instance_set_keepalive(dialog->trtp, dialog->rtpkeepalive); @@ -6359,7 +6363,7 @@ p->needdestroy = 0; p->owner->tech_pvt = dialog_unref(p->owner->tech_pvt, "unref p->owner->tech_pvt"); sip_pvt_lock(p); - p->owner = NULL; /* Owner will be gone after we return, so take it away */ + sip_set_owner(p, NULL); /* Owner will be gone after we return, so take it away */ sip_pvt_unlock(p); ast_module_unref(ast_module_info->self); return 0; @@ -6394,7 +6398,8 @@ /* Disconnect */ disable_dsp_detect(p); - p->owner = NULL; + sip_set_owner(p, NULL); + ast->tech_pvt = dialog_unref(ast->tech_pvt, "unref ast->tech_pvt"); ast_module_unref(ast_module_info->self); @@ -6713,7 +6718,7 @@ if (p->owner != oldchan) ast_log(LOG_WARNING, "old channel wasn't %p but was %p\n", oldchan, p->owner); else { - p->owner = newchan; + sip_set_owner(p, newchan); /* Re-invite RTP back to Asterisk. Needed if channel is masqueraded out of a native RTP bridge (i.e., RTP not going through Asterisk): RTP bridge code might not be able to do this if the masquerade happens before the bridge breaks (e.g., AMI @@ -7261,7 +7266,7 @@ tmp->amaflags = i->amaflags; if (!ast_strlen_zero(i->language)) ast_string_field_set(tmp, language, i->language); - i->owner = tmp; + sip_set_owner(i, tmp); ast_module_ref(ast_module_info->self); ast_copy_string(tmp->context, i->context, sizeof(tmp->context)); /*Since it is valid to have extensions in the dialplan that have unescaped characters in them @@ -26928,6 +26933,18 @@ return tmpc; } +/*! \brief Update the owner channel of a sip_pvt */ +static void sip_set_owner(struct sip_pvt* p, struct ast_channel* newowner) +{ + p->owner = newowner; + if (p->rtp) + ast_rtp_instance_set_chan(p->rtp, newowner); + if (p->vrtp) + ast_rtp_instance_set_chan(p->vrtp, newowner); + if (p->trtp) + ast_rtp_instance_set_chan(p->trtp, newowner); +} + /*! \brief Parse insecure= setting in sip.conf and set flags according to setting */ static void set_insecure_flags (struct ast_flags *flags, const char *value, int lineno) { --- a/channels/chan_multicast_rtp.c 2011-07-14 22:13:06.000000000 +0200 +++ b/channels/chan_multicast_rtp.c 2012-11-30 16:38:17.815055796 +0200 @@ -154,6 +154,7 @@ goto failure; } + ast_rtp_instance_set_chan(instance, chan); ast_rtp_instance_set_remote_address(instance, &destination_address); chan->tech = &multicast_rtp_tech; --- a/channels/sip/dialplan_functions.c 2012-06-15 17:56:08.000000000 +0200 +++ b/channels/sip/dialplan_functions.c 2012-11-30 14:55:20.275238581 +0200 @@ -352,6 +352,7 @@ res = AST_TEST_NOT_RUN; goto done; } + ast_rtp_instance_set_chan(p->rtp, chan); chan->tech = &sip_tech; chan->tech_pvt = p; p->owner = chan; --- a/channels/chan_skinny.c 2012-05-29 20:30:25.000000000 +0200 +++ b/channels/chan_skinny.c 2012-11-30 15:50:01.977141479 +0200 @@ -1374,6 +1374,7 @@ }; static struct ast_channel *skinny_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause); +static void skinny_set_owner(struct skinny_subchannel* sub, struct ast_channel* newchan); static AST_LIST_HEAD_STATIC(sessions, skinnysession); static int skinny_devicestate(void *data); @@ -3739,9 +3740,11 @@ sub->vrtp = ast_rtp_instance_new("asterisk", sched, &bindaddr_tmp, NULL); if (sub->rtp) { + ast_rtp_instance_set_chan(sub->rtp, sub->owner); ast_rtp_instance_set_prop(sub->rtp, AST_RTP_PROPERTY_RTCP, 1); } if (sub->vrtp) { + ast_rtp_instance_set_chan(sub->vrtp, sub->owner); ast_rtp_instance_set_prop(sub->vrtp, AST_RTP_PROPERTY_RTCP, 1); } @@ -4054,7 +4057,7 @@ } } ast_mutex_lock(&sub->lock); - sub->owner = NULL; + skinny_set_owner(sub, NULL); ast->tech_pvt = NULL; sub->alreadygone = 0; sub->outgoing = 0; @@ -4208,7 +4211,7 @@ ast_log(LOG_WARNING, "old channel wasn't %p but was %p\n", oldchan, sub->owner); return -1; } - sub->owner = newchan; + skinny_set_owner(sub, newchan); return 0; } @@ -4506,6 +4509,15 @@ return 0; } +static void skinny_set_owner(struct skinny_subchannel* sub, struct ast_channel* newchan) +{ + sub->owner = newchan; + if (sub->rtp) + ast_rtp_instance_set_chan(sub->rtp, newchan); + if (sub->vrtp) + ast_rtp_instance_set_chan(sub->vrtp, newchan); +} + static struct ast_channel *skinny_new(struct skinny_line *l, int state, const char *linkedid) { struct ast_channel *tmp; @@ -4531,7 +4543,7 @@ } else { ast_mutex_init(&sub->lock); - sub->owner = tmp; + skinny_set_owner(sub, tmp); sub->callid = callnums++; d->lastlineinstance = l->instance; d->lastcallreference = sub->callid; --- a/channels/chan_jingle.c 2012-07-31 21:31:42.000000000 +0200 +++ b/channels/chan_jingle.c 2012-11-30 15:57:29.181128249 +0200 @@ -171,6 +171,7 @@ /* Forward declarations */ static struct ast_channel *jingle_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause); +static void jingle_set_owner(struct jingle_pvt* p, struct ast_channel* c); static int jingle_sendtext(struct ast_channel *ast, const char *text); static int jingle_digit_begin(struct ast_channel *ast, char digit); static int jingle_digit_end(struct ast_channel *ast, char digit, unsigned int duration); @@ -794,6 +795,7 @@ ast_free(tmp); return NULL; } + ast_rtp_instance_set_chan(tmp->rtp, tmp->owner); ast_copy_string(tmp->exten, "s", sizeof(tmp->exten)); ast_mutex_init(&tmp->lock); ast_mutex_lock(&jinglelock); @@ -803,6 +805,16 @@ return tmp; } +/*! \brief Updates the owner of a jingle_pvt, also updating all the rtp stream's channel association */ +static void jingle_set_owner(struct jingle_pvt* p, struct ast_channel* c) +{ + p->owner = c; + if (p->rtp) + ast_rtp_instance_set_chan(p->rtp, c); + if (p->vrtp) + ast_rtp_instance_set_chan(p->vrtp, c); +} + /*! \brief Start new jingle channel */ static struct ast_channel *jingle_new(struct jingle *client, struct jingle_pvt *i, int state, const char *title, const char *linkedid) { @@ -867,7 +879,7 @@ ast_string_field_set(tmp, language, client->language); if (!ast_strlen_zero(client->musicclass)) ast_string_field_set(tmp, musicclass, client->musicclass); - i->owner = tmp; + jingle_set_owner(i, tmp); ast_copy_string(tmp->context, client->context, sizeof(tmp->context)); ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten)); /* Don't use ast_set_callerid() here because it will @@ -1277,7 +1289,7 @@ return -1; } if (p->owner == oldchan) - p->owner = newchan; + jingle_set_owner(p, newchan); ast_mutex_unlock(&p->lock); return 0; } @@ -1493,7 +1505,7 @@ ast_mutex_lock(&p->lock); client = p->parent; - p->owner = NULL; + jingle_set_owner(p, NULL); ast->tech_pvt = NULL; if (!p->alreadygone) jingle_action(client, p, JINGLE_TERMINATE); --- a/channels/chan_h323.c 2012-01-14 17:23:32.000000000 +0200 +++ b/channels/chan_h323.c 2012-11-30 16:02:02.517120159 +0200 @@ -234,6 +234,7 @@ static void delete_aliases(void); static void prune_peers(void); +static void oh323_set_owner(struct oh323_pvt *pvt, struct ast_channel *c); static struct ast_channel *oh323_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause); static int oh323_digit_begin(struct ast_channel *c, char digit); static int oh323_digit_end(struct ast_channel *c, char digit, unsigned int duration); @@ -704,7 +705,7 @@ return 0; } - pvt->owner = NULL; + oh323_set_owner(pvt, NULL); c->tech_pvt = NULL; if (c->hangupcause) { @@ -956,7 +957,7 @@ ast_log(LOG_WARNING, "old channel wasn't %p but was %p\n", oldchan, pvt->owner); return -1; } - pvt->owner = newchan; + oh323_set_owner(pvt, newchan); ast_mutex_unlock(&pvt->lock); return 0; } @@ -985,6 +986,7 @@ ast_log(LOG_WARNING, "Unable to create RTP session: %s\n", strerror(errno)); return -1; } + ast_rtp_instance_set_chan(pvt->rtp, pvt->owner); if (h323debug) ast_debug(1, "Created RTP channel\n"); @@ -1076,7 +1078,7 @@ /* Register channel functions. */ ch->tech_pvt = pvt; /* Set the owner of this channel */ - pvt->owner = ch; + oh323_set_owner(pvt, ch); ast_copy_string(ch->context, pvt->context, sizeof(ch->context)); ast_copy_string(ch->exten, pvt->exten, sizeof(ch->exten)); @@ -1755,6 +1757,14 @@ return 0; } } + +static void oh323_set_owner(struct oh323_pvt *pvt, struct ast_channel *c) +{ + pvt->owner = c; + if (pvt->rtp) + ast_rtp_instance_set_chan(pvt->rtp, c); +} + static struct ast_channel *oh323_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause) { struct oh323_pvt *pvt; --- a/channels/chan_unistim.c 2012-04-19 04:08:44.000000000 +0200 +++ b/channels/chan_unistim.c 2012-11-30 16:38:50.490054826 +0200 @@ -679,6 +679,7 @@ /*! Protos */ static struct ast_channel *unistim_new(struct unistim_subchannel *sub, int state, const char *linkedid); +static void unistim_set_owner(struct unistim_subchannel *sub, struct ast_channel *ast); static int load_module(void); static int reload(void); static int unload_module(void); @@ -2078,6 +2079,7 @@ ast_mutex_unlock(&sub->lock); return; } + ast_rtp_instance_set_chan(sub->rtp, sub->owner); 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); @@ -3792,7 +3794,7 @@ if (!s) { ast_debug(1, "Asked to hangup channel not connected\n"); ast_mutex_lock(&sub->lock); - sub->owner = NULL; + unistim_set_owner(sub, NULL); ast->tech_pvt = NULL; sub->alreadygone = 0; ast_mutex_unlock(&sub->lock); @@ -3811,7 +3813,7 @@ if ((l->subs[SUB_THREEWAY]) && (sub->subtype == SUB_REAL)) { if (unistimdebug) ast_verb(0, "Real call disconnected while talking to threeway\n"); - sub->owner = NULL; + unistim_set_owner(sub, NULL); ast->tech_pvt = NULL; return 0; } @@ -3827,14 +3829,14 @@ swap_subs(l, SUB_THREEWAY, SUB_REAL); l->parent->moh = 0; ast_mutex_lock(&sub->lock); - sub->owner = NULL; + unistim_set_owner(sub, NULL); ast->tech_pvt = NULL; ast_mutex_unlock(&sub->lock); unalloc_sub(l, SUB_THREEWAY); return 0; } ast_mutex_lock(&sub->lock); - sub->owner = NULL; + unistim_set_owner(sub, NULL); ast->tech_pvt = NULL; sub->alreadygone = 0; ast_mutex_unlock(&sub->lock); @@ -4089,7 +4091,7 @@ return -1; } - p->owner = newchan; + unistim_set_owner(p, newchan); ast_mutex_unlock(&p->lock); @@ -4560,7 +4562,7 @@ tmp->tech = &unistim_tech; if (!ast_strlen_zero(l->language)) ast_string_field_set(tmp, language, l->language); - sub->owner = tmp; + unistim_set_owner(sub, tmp); ast_mutex_lock(&usecnt_lock); usecnt++; ast_mutex_unlock(&usecnt_lock); @@ -4596,6 +4598,13 @@ return tmp; } +static void unistim_set_owner(struct unistim_subchannel *sub, struct ast_channel *ast) +{ + sub->owner = ast; + if (sub->rtp) + ast_rtp_instance_set_chan(sub->rtp, ast); +} + static void *do_monitor(void *data) { struct unistimsession *cur = NULL; --- a/channels/chan_gtalk.c 2012-07-31 21:31:42.000000000 +0200 +++ b/channels/chan_gtalk.c 2012-11-30 16:34:39.041062260 +0200 @@ -1,4 +1,3 @@ -/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. @@ -196,6 +195,7 @@ 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 *c); /*! \brief PBX interface structure for channel registration */ static const struct ast_channel_tech gtalk_tech = { @@ -1039,6 +1039,7 @@ ast_free(tmp); return NULL; } + ast_rtp_instance_set_chan(tmp->rtp, tmp->owner); ast_rtp_instance_set_prop(tmp->rtp, AST_RTP_PROPERTY_RTCP, 1); ast_rtp_instance_set_prop(tmp->rtp, AST_RTP_PROPERTY_STUN, 1); ast_rtp_instance_set_prop(tmp->rtp, AST_RTP_PROPERTY_DTMF, 1); @@ -1077,6 +1078,16 @@ return tmp; } +/*! \brief Update the owner of the gtalk_pvt */ +static void gtalk_set_owner(struct gtalk_pvt *p, struct ast_channel *c) +{ + p->owner = c; + if (p->rtp) + ast_rtp_instance_set_chan(p->rtp, c); + if (p->vrtp) + ast_rtp_instance_set_chan(p->vrtp, c); +} + /*! \brief Start new gtalk channel */ static struct ast_channel *gtalk_new(struct gtalk *client, struct gtalk_pvt *i, int state, const char *title, const char *linkedid) { @@ -1144,7 +1155,7 @@ ast_string_field_set(tmp, musicclass, client->musicclass); if (!ast_strlen_zero(client->parkinglot)) ast_string_field_set(tmp, parkinglot, client->parkinglot); - i->owner = tmp; + gtalk_set_owner(i, tmp); ast_module_ref(ast_module_info->self); ast_copy_string(tmp->context, client->context, sizeof(tmp->context)); ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten)); @@ -1660,7 +1671,7 @@ return -1; } if (p->owner == oldchan) - p->owner = newchan; + gtalk_set_owner(p, newchan); ast_mutex_unlock(&p->lock); return 0; } @@ -1834,7 +1845,7 @@ ast_mutex_lock(&p->lock); client = p->parent; - p->owner = NULL; + gtalk_set_owner(p, NULL); ast->tech_pvt = NULL; if (!p->alreadygone) { gtalk_action(client, p, "terminate"); --- a/channels/chan_mgcp.c 2012-04-06 20:09:19.000000000 +0200 +++ b/channels/chan_mgcp.c 2012-12-02 16:33:15.307946699 +0200 @@ -425,6 +425,7 @@ static struct sockaddr_in bindaddr; +static void mgcp_set_owner(struct mgcp_subchannel *sub, struct ast_channel *ast); 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); @@ -522,7 +523,7 @@ } 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); } @@ -948,7 +949,7 @@ } } - sub->owner = NULL; + mgcp_set_owner(sub, NULL); /* for deleting gate */ if (p->pktcgatealloc && sub->gate) { @@ -1228,6 +1229,12 @@ return f; } +static void mgcp_set_owner(struct mgcp_subchannel *sub, struct ast_channel *ast) +{ + sub->owner = ast; + if (sub->rtp) + ast_rtp_instance_set_chan(sub->rtp, ast); +} static struct ast_frame *mgcp_read(struct ast_channel *ast) { @@ -1291,7 +1298,7 @@ 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 +1536,7 @@ ast_string_field_set(tmp, accountcode, i->accountcode); if (i->amaflags) tmp->amaflags = i->amaflags; - sub->owner = tmp; + mgcp_set_owner(sub, tmp); ast_module_ref(ast_module_info->self); tmp->callgroup = i->callgroup; tmp->pickupgroup = i->pickupgroup; @@ -2924,8 +2931,10 @@ /* Allocate the RTP now */ ast_sockaddr_from_sin(&bindaddr_tmp, &bindaddr); sub->rtp = ast_rtp_instance_new("asterisk", sched, &bindaddr_tmp, NULL); - if (sub->rtp && sub->owner) + if (sub->rtp && sub->owner) { + ast_rtp_instance_set_chan(sub->rtp, sub->owner); ast_channel_set_fd(sub->owner, 0, ast_rtp_instance_fd(sub->rtp, 0)); + } if (sub->rtp) { 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);