Index: channels/chan_gtalk.c =================================================================== --- channels/chan_gtalk.c (revision 48116) +++ channels/chan_gtalk.c (working copy) @@ -163,7 +163,6 @@ }; static const char desc[] = "Gtalk Channel"; -static const char type[] = "Gtalk"; static int global_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW | AST_FORMAT_GSM | AST_FORMAT_H263; @@ -192,7 +191,7 @@ /*! \brief PBX interface structure for channel registration */ static const struct ast_channel_tech gtalk_tech = { - .type = type, + .type = "Gtalk", .description = "Gtalk Channel Driver", .capabilities = ((AST_FORMAT_MAX_AUDIO << 1) - 1), .requester = gtalk_request, @@ -220,7 +219,7 @@ /*! \brief RTP driver interface */ static struct ast_rtp_protocol gtalk_rtp = { - type: "gtalk", + type: "Gtalk", get_rtp_info: gtalk_get_rtp_peer, set_rtp_peer: gtalk_set_rtp_peer, get_codec: gtalk_get_codec, @@ -525,7 +524,7 @@ ast_mutex_lock(&p->lock); if (p->rtp){ *rtp = p->rtp; - res = AST_RTP_TRY_NATIVE; + res = AST_RTP_TRY_PARTIAL; } ast_mutex_unlock(&p->lock); @@ -826,9 +825,10 @@ { struct gtalk_pvt *tmp = NULL; struct aji_resource *resources = NULL; - struct aji_buddy *buddy; + struct aji_buddy *buddy = NULL; char idroster[200]; - char *data, *exten = NULL; + char *data = NULL; + char *exten = NULL; if (option_debug) ast_log(LOG_DEBUG, "The client is %s for alloc\n", client->name); @@ -921,10 +921,18 @@ fmt = ast_best_codec(tmp->nativeformats); if (i->rtp) { + /* STUN packets should not be bypassed by P2P RTP bridge and + must go through Gtalk's ast_read function for processing*/ + ast_rtp_setstun(i->rtp); + tmp->fds[0] = ast_rtp_fd(i->rtp); tmp->fds[1] = ast_rtcp_fd(i->rtp); } if (i->vrtp) { + /* STUN packets should not be bypassed by P2P RTP bridge and + must go through Gtalk's ast_read function for processing*/ + ast_rtp_setstun(i->rtp); + tmp->fds[2] = ast_rtp_fd(i->vrtp); tmp->fds[3] = ast_rtcp_fd(i->vrtp); } @@ -1174,9 +1182,16 @@ return 0; ast_copy_string(newcandidate->name, iks_find_attrib(traversenodes, "name"), sizeof(newcandidate->name)); + if (option_debug) + ast_log(LOG_DEBUG, "newcandidate->name : %s\n", newcandidate->name); ast_copy_string(newcandidate->ip, iks_find_attrib(traversenodes, "address"), sizeof(newcandidate->ip)); + if (option_debug) + ast_log(LOG_DEBUG, "newcandidate->ip : %s\n", newcandidate->ip); newcandidate->port = atoi(iks_find_attrib(traversenodes, "port")); + if (option_debug) { + ast_log(LOG_DEBUG, "newcandidate->port : %d\n", newcandidate->port); + } ast_copy_string(newcandidate->username, iks_find_attrib(traversenodes, "username"), sizeof(newcandidate->username)); ast_copy_string(newcandidate->password, iks_find_attrib(traversenodes, "password"), @@ -1790,7 +1805,7 @@ /* Make sure we can register our channel type */ if (ast_channel_register(>alk_tech)) { - ast_log(LOG_ERROR, "Unable to register channel class %s\n", type); + ast_log(LOG_ERROR, "Unable to register channel class %s\n", gtalk_tech.type); return -1; } return 0; Index: include/asterisk/rtp.h =================================================================== --- include/asterisk/rtp.h (revision 48116) +++ include/asterisk/rtp.h (working copy) @@ -186,6 +186,9 @@ /*! \brief Compensate for devices that send RFC2833 packets all at once */ void ast_rtp_setdtmfcompensate(struct ast_rtp *rtp, int compensate); +/*! \brief Indicate whether this RTP session is carrying STUN or not */ +void ast_rtp_setstun(struct ast_rtp *rtp); + int ast_rtp_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms); int ast_rtp_proto_register(struct ast_rtp_protocol *proto); Index: main/rtp.c =================================================================== --- main/rtp.c (revision 48116) +++ main/rtp.c (working copy) @@ -183,6 +183,7 @@ #define FLAG_P2P_NEED_DTMF (1 << 5) #define FLAG_CALLBACK_MODE (1 << 6) #define FLAG_DTMF_COMPENSATE (1 << 7) +#define FLAG_P2P_NEED_STUN (1 << 8) /*! * \brief Structure defining an RTCP session. @@ -545,6 +546,10 @@ ast_set2_flag(rtp, compensate ? 1 : 0, FLAG_DTMF_COMPENSATE); } +void ast_rtp_setstun(struct ast_rtp *rtp) +{ + ast_set_flag(rtp, FLAG_P2P_NEED_STUN); +} static struct ast_frame *send_dtmf(struct ast_rtp *rtp, enum ast_frame_type type) { if (((ast_test_flag(rtp, FLAG_DTMF_COMPENSATE) && type == AST_FRAME_DTMF_END) || @@ -2917,6 +2922,10 @@ if (ast_test_flag(rtp, FLAG_P2P_NEED_DTMF) || !rtp->io) return 0; + /* If we need STUN, then we can't do direct callback */ + if (ast_test_flag(rtp, FLAG_P2P_NEED_STUN)) + return 0; + /* If the RTP structure is already in callback mode, remove it temporarily */ if (rtp->ioid) { ast_io_remove(rtp->io, rtp->ioid);