--- /root/svn/chan_sip.c 2006-01-04 18:13:32.000000000 +0000 +++ channels/chan_sip.c 2006-01-04 18:20:21.000000000 +0000 @@ -421,8 +421,6 @@ static int tos = 0; -static int videosupport = 0; - static int compactheaders = 0; /*!< send compact sip headers */ static int recordhistory = 0; /*!< Record SIP history. Off by default */ @@ -566,11 +564,13 @@ #define SIP_CALL_LIMIT (1 << 29) /* Remote Party-ID Support */ #define SIP_SENDRPID (1 << 30) +/* SIP Video Options */ +#define SIP_VIDEOSUPPORT (1 << 31) #define SIP_FLAGS_TO_COPY \ (SIP_PROMISCREDIR | SIP_TRUSTRPID | SIP_SENDRPID | SIP_DTMF | SIP_REINVITE | \ SIP_PROG_INBAND | SIP_OSPAUTH | SIP_USECLIENTCODE | SIP_NAT | \ - SIP_INSECURE_PORT | SIP_INSECURE_INVITE) + SIP_INSECURE_PORT | SIP_INSECURE_INVITE | SIP_VIDEOSUPPORT) /* a new page of flags for peer */ #define SIP_PAGE2_RTCACHEFRIENDS (1 << 0) @@ -1849,6 +1849,12 @@ ast_copy_flags(r, peer, SIP_FLAGS_TO_COPY); r->capability = peer->capability; r->prefs = peer->prefs; + + if (!ast_test_flag(r, SIP_VIDEOSUPPORT) && r->vrtp) { + ast_rtp_destroy(r->vrtp); + r->vrtp = NULL; + } + if (r->rtp) { ast_log(LOG_DEBUG, "Setting NAT on RTP to %d\n", (ast_test_flag(r, SIP_NAT) & SIP_NAT_ROUTE)); ast_rtp_setnat(r->rtp, (ast_test_flag(r, SIP_NAT) & SIP_NAT_ROUTE)); @@ -3091,6 +3097,8 @@ memcpy(&p->ourip, &__ourip, sizeof(p->ourip)); } + ast_copy_flags(p, &global_flags, SIP_FLAGS_TO_COPY); + p->branch = thread_safe_rand(); make_our_tag(p->tag, sizeof(p->tag)); /* Start with 101 instead of 1 */ @@ -3098,10 +3106,10 @@ if (sip_methods[intended_method].need_rtp) { p->rtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr); - if (videosupport) + if (ast_test_flag(p, SIP_VIDEOSUPPORT)) p->vrtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr); - if (!p->rtp || (videosupport && !p->vrtp)) { - ast_log(LOG_WARNING, "Unable to create RTP audio %s session: %s\n", videosupport ? "and video" : "", strerror(errno)); + if (!p->rtp || (ast_test_flag(p, SIP_VIDEOSUPPORT) && !p->vrtp)) { + ast_log(LOG_WARNING, "Unable to create RTP audio %s session: %s\n", ast_test_flag(p, SIP_VIDEOSUPPORT) ? "and video" : "", strerror(errno)); ast_mutex_destroy(&p->lock); if (p->chanvars) { ast_variables_destroy(p->chanvars); @@ -3135,7 +3143,6 @@ build_callid(p->callid, sizeof(p->callid), p->ourip, p->fromdomain); else ast_copy_string(p->callid, callid, sizeof(p->callid)); - ast_copy_flags(p, &global_flags, SIP_FLAGS_TO_COPY); /* Assign default music on hold class */ strcpy(p->musicclass, global_musicclass); p->capability = global_capability; @@ -4468,7 +4475,7 @@ } /* Now send any other common codecs, and non-codec formats: */ - for (x = 1; x <= ((videosupport && p->vrtp) ? AST_FORMAT_MAX_VIDEO : AST_FORMAT_MAX_AUDIO); x <<= 1) { + for (x = 1; x <= ((ast_test_flag(p, SIP_VIDEOSUPPORT) && p->vrtp) ? AST_FORMAT_MAX_VIDEO : AST_FORMAT_MAX_AUDIO); x <<= 1) { if (!(capability & x)) continue; @@ -7091,6 +7098,10 @@ p->callingpres = user->callingpres; p->capability = user->capability; p->jointcapability = user->capability; + if (!ast_test_flag(p, SIP_VIDEOSUPPORT) && p->vrtp) { + ast_rtp_destroy(p->vrtp); + p->vrtp = NULL; + } if (p->peercapability) p->jointcapability &= p->peercapability; if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_RFC2833) || (ast_test_flag(p, SIP_DTMF) == SIP_DTMF_AUTO)) @@ -7199,6 +7210,10 @@ p->capability = peer->capability; p->prefs = peer->prefs; p->jointcapability = peer->capability; + if (!ast_test_flag(p, SIP_VIDEOSUPPORT) && p->vrtp) { + ast_rtp_destroy(p->vrtp); + p->vrtp = NULL; + } if (p->peercapability) p->jointcapability &= p->peercapability; if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_RFC2833) || (ast_test_flag(p, SIP_DTMF) == SIP_DTMF_AUTO)) @@ -7573,6 +7588,7 @@ "IPport: %d\r\n" "Dynamic: %s\r\n" "Natsupport: %s\r\n" + "Video Support: %s\r\n" "ACL: %s\r\n" "Status: %s\r\n\r\n", idtext, @@ -7581,6 +7597,7 @@ ntohs(iterator->addr.sin_port), ast_test_flag(iterator, SIP_DYNAMIC) ? "yes" : "no", /* Dynamic or not? */ (ast_test_flag(iterator, SIP_NAT) & SIP_NAT_ROUTE) ? "yes" : "no", /* NAT=yes? */ + ast_test_flag(iterator, SIP_VIDEOSUPPORT) ? "yes" : "no", /* VIDEOSUPPORT=yes? */ iterator->ha ? "yes" : "no", /* permit/deny */ status); } @@ -7961,6 +7978,7 @@ ast_cli(fd, " CanReinvite : %s\n", (ast_test_flag(peer, SIP_CAN_REINVITE)?"Yes":"No")); ast_cli(fd, " PromiscRedir : %s\n", (ast_test_flag(peer, SIP_PROMISCREDIR)?"Yes":"No")); ast_cli(fd, " User=Phone : %s\n", (ast_test_flag(peer, SIP_USEREQPHONE)?"Yes":"No")); + ast_cli(fd, " Video Support: %s\n", (ast_test_flag(peer, SIP_VIDEOSUPPORT)?"Yes":"No")); ast_cli(fd, " Trust RPID : %s\n", (ast_test_flag(peer, SIP_TRUSTRPID) ? "Yes" : "No")); ast_cli(fd, " Send RPID : %s\n", (ast_test_flag(peer, SIP_SENDRPID) ? "Yes" : "No")); @@ -8037,6 +8055,7 @@ ast_cli(fd, "SIP-CanReinvite: %s\r\n", (ast_test_flag(peer, SIP_CAN_REINVITE)?"Y":"N")); ast_cli(fd, "SIP-PromiscRedir: %s\r\n", (ast_test_flag(peer, SIP_PROMISCREDIR)?"Y":"N")); ast_cli(fd, "SIP-UserPhone: %s\r\n", (ast_test_flag(peer, SIP_USEREQPHONE)?"Y":"N")); + ast_cli(fd, "SIP-VideoSupport: %s\r\n", (ast_test_flag(peer, SIP_VIDEOSUPPORT)?"Y":"N")); /* - is enumerated */ ast_cli(fd, "SIP-DTMFmode %s\r\n", dtmfmode2str(ast_test_flag(peer, SIP_DTMF))); @@ -8183,7 +8202,7 @@ ast_cli(fd, "----------------\n"); ast_cli(fd, " SIP Port: %d\n", ntohs(bindaddr.sin_port)); ast_cli(fd, " Bindaddress: %s\n", ast_inet_ntoa(tmp, sizeof(tmp), bindaddr.sin_addr)); - ast_cli(fd, " Videosupport: %s\n", videosupport ? "Yes" : "No"); + ast_cli(fd, " Videosupport: %s\n", ast_test_flag(&global_flags, SIP_VIDEOSUPPORT) ? "Yes" : "No"); ast_cli(fd, " AutoCreatePeer: %s\n", autocreatepeer ? "Yes" : "No"); ast_cli(fd, " Allow unknown access: %s\n", global_allowguest ? "Yes" : "No"); ast_cli(fd, " Promsic. redir: %s\n", ast_test_flag(&global_flags, SIP_PROMISCREDIR) ? "Yes" : "No"); @@ -12117,7 +12136,10 @@ ast_copy_string(peer->fromdomain, v->value, sizeof(peer->fromdomain)); else if (!strcasecmp(v->name, "usereqphone")) ast_set2_flag(peer, ast_true(v->value), SIP_USEREQPHONE); - else if (!strcasecmp(v->name, "fromuser")) + else if (!strcasecmp(v->name, "videosupport")) { + if (ast_test_flag((&global_flags), SIP_VIDEOSUPPORT)) + ast_set2_flag(peer, ast_true(v->value), SIP_VIDEOSUPPORT); + } else if (!strcasecmp(v->name, "fromuser")) ast_copy_string(peer->fromuser, v->value, sizeof(peer->fromuser)); else if (!strcasecmp(v->name, "host") || !strcasecmp(v->name, "outboundproxy")) { if (!strcasecmp(v->value, "dynamic")) { @@ -12321,7 +12343,6 @@ memset(&outboundproxyip, 0, sizeof(outboundproxyip)); outboundproxyip.sin_port = htons(DEFAULT_SIP_PORT); outboundproxyip.sin_family = AF_INET; /* Type of address: IPv4 */ - videosupport = 0; compactheaders = 0; dumphistory = 0; recordhistory = 0; @@ -12402,7 +12423,7 @@ global_rtpkeepalive = 0; } } else if (!strcasecmp(v->name, "videosupport")) { - videosupport = ast_true(v->value); + ast_set2_flag((&global_flags), ast_true(v->value), SIP_VIDEOSUPPORT); } else if (!strcasecmp(v->name, "compactheaders")) { compactheaders = ast_true(v->value); } else if (!strcasecmp(v->name, "notifymimetype")) {