[asterisk-commits] file: trunk r369864 - in /trunk: channels/chan_motif.c res/res_rtp_asterisk.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jul 10 06:54:05 CDT 2012
Author: file
Date: Tue Jul 10 06:49:18 2012
New Revision: 369864
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=369864
Log:
Add required items for Google video support.
This adds legacy STUN support for RTCP sockets, adds RTCP candidates to the Google transport information, and adds required codec parameters.
(closes issue ASTERISK-20106)
Reported by: Malcolm Davenport
Modified:
trunk/channels/chan_motif.c
trunk/res/res_rtp_asterisk.c
Modified: trunk/channels/chan_motif.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_motif.c?view=diff&rev=369864&r1=369863&r2=369864
==============================================================================
--- trunk/channels/chan_motif.c (original)
+++ trunk/channels/chan_motif.c Tue Jul 10 06:49:18 2012
@@ -820,12 +820,15 @@
break;
}
- /* We only support RTP candidates */
- if (candidate->id != 1) {
+ if (candidate->id == 1) {
+ iks_insert_attrib(local_candidate, "name", !video ? "rtp" : "video_rtp");
+ } else if (candidate->id == 2) {
+ iks_insert_attrib(local_candidate, "name", !video ? "rtcp" : "video_rtcp");
+ } else {
+ iks_delete(local_candidate);
continue;
}
- iks_insert_attrib(local_candidate, "name", !video ? "rtp" : "video_rtp");
iks_insert_attrib(local_candidate, "address", ast_sockaddr_stringify_host(&candidate->address));
iks_insert_attrib(local_candidate, "port", ast_sockaddr_stringify_port(&candidate->address));
@@ -1150,6 +1153,27 @@
iks_insert_attrib(payload, "clockrate", tmp);
}
+ if ((type == AST_FORMAT_TYPE_VIDEO) && (session->transport == JINGLE_TRANSPORT_GOOGLE_V2)) {
+ iks *parameter;
+
+ /* Google requires these parameters to be set, but alas we can not give accurate values so use some safe defaults */
+ if ((parameter = iks_new("parameter"))) {
+ iks_insert_attrib(parameter, "name", "width");
+ iks_insert_attrib(parameter, "value", "640");
+ iks_insert_node(payload, parameter);
+ }
+ if ((parameter = iks_new("parameter"))) {
+ iks_insert_attrib(parameter, "name", "height");
+ iks_insert_attrib(parameter, "value", "480");
+ iks_insert_node(payload, parameter);
+ }
+ if ((parameter = iks_new("parameter"))) {
+ iks_insert_attrib(parameter, "name", "framerate");
+ iks_insert_attrib(parameter, "value", "30");
+ iks_insert_node(payload, parameter);
+ }
+ }
+
iks_insert_node(description, payload);
payloads[i++] = payload;
}
@@ -2007,6 +2031,11 @@
/* We only support UDP so skip any other protocols */
if (!ast_strlen_zero(protocol) && strcasecmp(protocol, "udp")) {
+ continue;
+ }
+
+ /* We only permit audio and video, not RTCP */
+ if (strcasecmp(name, "rtp") && strcasecmp(name, "video_rtp")) {
continue;
}
Modified: trunk/res/res_rtp_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_rtp_asterisk.c?view=diff&rev=369864&r1=369863&r2=369864
==============================================================================
--- trunk/res/res_rtp_asterisk.c (original)
+++ trunk/res/res_rtp_asterisk.c Tue Jul 10 06:49:18 2012
@@ -2421,14 +2421,14 @@
{
struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
struct ast_sockaddr addr;
- unsigned int rtcpdata[8192 + AST_FRIENDLY_OFFSET];
+ unsigned char rtcpdata[8192 + AST_FRIENDLY_OFFSET];
unsigned int *rtcpheader = (unsigned int *)(rtcpdata + AST_FRIENDLY_OFFSET);
int res, packetwords, position = 0;
struct ast_frame *f = &ast_null_frame;
/* Read in RTCP data from the socket */
if ((res = rtcp_recvfrom(instance, rtcpdata + AST_FRIENDLY_OFFSET,
- sizeof(rtcpdata) - sizeof(unsigned int) * AST_FRIENDLY_OFFSET,
+ sizeof(rtcpdata) - AST_FRIENDLY_OFFSET,
0, &addr)) < 0) {
ast_assert(errno != EBADF);
if (errno != EAGAIN) {
@@ -2440,6 +2440,28 @@
/* If this was handled by the ICE session don't do anything further */
if (!res) {
+ return &ast_null_frame;
+ }
+
+ if (!*(rtcpdata + AST_FRIENDLY_OFFSET)) {
+ struct sockaddr_in addr_tmp;
+ struct ast_sockaddr addr_v4;
+
+ if (ast_sockaddr_is_ipv4(&addr)) {
+ ast_sockaddr_to_sin(&addr, &addr_tmp);
+ } else if (ast_sockaddr_ipv4_mapped(&addr, &addr_v4)) {
+ ast_debug(1, "Using IPv6 mapped address %s for STUN\n",
+ ast_sockaddr_stringify(&addr));
+ ast_sockaddr_to_sin(&addr_v4, &addr_tmp);
+ } else {
+ ast_debug(1, "Cannot do STUN for non IPv4 address %s\n",
+ ast_sockaddr_stringify(&addr));
+ return &ast_null_frame;
+ }
+ if ((ast_stun_handle_packet(rtp->rtcp->s, &addr_tmp, rtcpdata + AST_FRIENDLY_OFFSET, res, NULL, NULL) == AST_STUN_ACCEPT)) {
+ ast_sockaddr_from_sin(&addr, &addr_tmp);
+ ast_sockaddr_copy(&rtp->rtcp->them, &addr);
+ }
return &ast_null_frame;
}
More information about the asterisk-commits
mailing list