Merged revisions 48168 via svnmerge from
authorJoshua Colp <jcolp@digium.com>
Thu, 30 Nov 2006 21:22:01 +0000 (21:22 +0000)
committerJoshua Colp <jcolp@digium.com>
Thu, 30 Nov 2006 21:22:01 +0000 (21:22 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r48168 | file | 2006-11-30 16:18:24 -0500 (Thu, 30 Nov 2006) | 2 lines

Do not do a partial bridge for Google Talk since we need to handle STUN. (issue #8448 reported by phsultan)

........

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@48169 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_gtalk.c
include/asterisk/rtp.h
main/rtp.c

index f64bc12..e5ec59d 100644 (file)
@@ -163,7 +163,6 @@ struct gtalk_container {
 };
 
 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 @@ static int gtalk_get_codec(struct ast_channel *chan);
 
 /*! \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 @@ static struct in_addr __ourip;
 
 /*! \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,
@@ -921,10 +920,12 @@ static struct ast_channel *gtalk_new(struct gtalk *client, struct gtalk_pvt *i,
        fmt = ast_best_codec(tmp->nativeformats);
 
        if (i->rtp) {
+               ast_rtp_setstun(i->rtp, 1);
                tmp->fds[0] = ast_rtp_fd(i->rtp);
                tmp->fds[1] = ast_rtcp_fd(i->rtp);
        }
        if (i->vrtp) {
+               ast_rtp_setstun(i->rtp, 1);
                tmp->fds[2] = ast_rtp_fd(i->vrtp);
                tmp->fds[3] = ast_rtcp_fd(i->vrtp);
        }
@@ -1790,7 +1791,7 @@ static int load_module(void)
 
        /* Make sure we can register our channel type */
        if (ast_channel_register(&gtalk_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 03f2044..aab598a 100644 (file)
@@ -186,6 +186,9 @@ void ast_rtp_setdtmf(struct ast_rtp *rtp, int dtmf);
 /*! \brief Compensate for devices that send RFC2833 packets all at once */
 void ast_rtp_setdtmfcompensate(struct ast_rtp *rtp, int compensate);
 
+/*! \brief Enable STUN capability */
+void ast_rtp_setstun(struct ast_rtp *rtp, int stun_enable);
+
 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 8381052..3d394a0 100644 (file)
@@ -183,6 +183,7 @@ static int bridge_p2p_rtcp_write(struct ast_rtp *rtp, unsigned int *rtcpheader,
 #define FLAG_P2P_NEED_DTMF              (1 << 5)
 #define FLAG_CALLBACK_MODE              (1 << 6)
 #define FLAG_DTMF_COMPENSATE            (1 << 7)
+#define FLAG_HAS_STUN                   (1 << 8)
 
 /*!
  * \brief Structure defining an RTCP session.
@@ -545,6 +546,11 @@ void ast_rtp_setdtmfcompensate(struct ast_rtp *rtp, int compensate)
        ast_set2_flag(rtp, compensate ? 1 : 0, FLAG_DTMF_COMPENSATE);
 }
 
+void ast_rtp_setstun(struct ast_rtp *rtp, int stun_enable)
+{
+       ast_set2_flag(rtp, stun_enable ? 1 : 0, FLAG_HAS_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) ||
@@ -2913,8 +2919,8 @@ static int p2p_rtp_callback(int *id, int fd, short events, void *cbdata)
 /*! \brief Helper function to switch a channel and RTP stream into callback mode */
 static int p2p_callback_enable(struct ast_channel *chan, struct ast_rtp *rtp, int **iod)
 {
-       /* If we need DTMF or we have no IO structure, then we can't do direct callback */
-       if (ast_test_flag(rtp, FLAG_P2P_NEED_DTMF) || !rtp->io)
+       /* If we need DTMF, are looking for STUN, or we have no IO structure then we can't do direct callback */
+       if (ast_test_flag(rtp, FLAG_P2P_NEED_DTMF) || ast_test_flag(rtp, FLAG_HAS_STUN) || !rtp->io)
                return 0;
 
        /* If the RTP structure is already in callback mode, remove it temporarily */