[asterisk-commits] trunk r37501 - in /trunk: ./ channels/
include/asterisk/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed Jul 12 18:38:47 MST 2006
Author: kpfleming
Date: Wed Jul 12 20:38:47 2006
New Revision: 37501
URL: http://svn.digium.com/view/asterisk?rev=37501&view=rev
Log:
allow users of RTP to use G726-32 AAL2 packing even when RFC3551 packing has been requested (Sipura/Grandstream ATAs and others will need this)
Modified:
trunk/channels/chan_jingle.c
trunk/channels/chan_mgcp.c
trunk/channels/chan_sip.c
trunk/include/asterisk/rtp.h
trunk/rtp.c
Modified: trunk/channels/chan_jingle.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_jingle.c?rev=37501&r1=37500&r2=37501&view=diff
==============================================================================
--- trunk/channels/chan_jingle.c (original)
+++ trunk/channels/chan_jingle.c Wed Jul 12 20:38:47 2006
@@ -882,7 +882,7 @@
while (codec) {
ast_rtp_set_m_type(p->rtp, atoi(iks_find_attrib(codec, "id")));
ast_rtp_set_rtpmap_type(p->rtp, atoi(iks_find_attrib(codec, "id")), "audio",
- iks_find_attrib(codec, "name"));
+ iks_find_attrib(codec, "name"), 0);
codec = iks_next(codec);
}
Modified: trunk/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_mgcp.c?rev=37501&r1=37500&r2=37501&view=diff
==============================================================================
--- trunk/channels/chan_mgcp.c (original)
+++ trunk/channels/chan_mgcp.c Wed Jul 12 20:38:47 2006
@@ -1882,7 +1882,7 @@
if (sscanf(a, "rtpmap: %u %[^/]/", &codec, mimeSubtype) != 2)
continue;
/* Note: should really look at the 'freq' and '#chans' params too */
- ast_rtp_set_rtpmap_type(sub->rtp, codec, "audio", mimeSubtype);
+ ast_rtp_set_rtpmap_type(sub->rtp, codec, "audio", mimeSubtype, 0);
}
/* Now gather all of the codecs that were asked for: */
@@ -2081,7 +2081,7 @@
if (codec > -1) {
snprintf(costr, sizeof(costr), " %d", codec);
strncat(m, costr, sizeof(m) - strlen(m) - 1);
- snprintf(costr, sizeof(costr), "a=rtpmap:%d %s/8000\r\n", codec, ast_rtp_lookup_mime_subtype(1, x));
+ snprintf(costr, sizeof(costr), "a=rtpmap:%d %s/8000\r\n", codec, ast_rtp_lookup_mime_subtype(1, x, 0));
strncat(a, costr, sizeof(a) - strlen(a) - 1);
}
}
@@ -2095,7 +2095,7 @@
if (codec > -1) {
snprintf(costr, sizeof(costr), " %d", codec);
strncat(m, costr, sizeof(m) - strlen(m) - 1);
- snprintf(costr, sizeof(costr), "a=rtpmap:%d %s/8000\r\n", codec, ast_rtp_lookup_mime_subtype(0, x));
+ snprintf(costr, sizeof(costr), "a=rtpmap:%d %s/8000\r\n", codec, ast_rtp_lookup_mime_subtype(0, x, 0));
strncat(a, costr, sizeof(a) - strlen(a) - 1);
if (x == AST_RTP_DTMF) {
/* Indicate we support DTMF... Not sure about 16,
@@ -2140,7 +2140,7 @@
snprintf(local, sizeof(local), "p:20");
for (x=1;x<= AST_FORMAT_MAX_AUDIO; x <<= 1) {
if (p->capability & x) {
- snprintf(tmp, sizeof(tmp), ", a:%s", ast_rtp_lookup_mime_subtype(1, x));
+ snprintf(tmp, sizeof(tmp), ", a:%s", ast_rtp_lookup_mime_subtype(1, x, 0));
strncat(local, tmp, sizeof(local) - strlen(local) - 1);
}
}
@@ -2170,7 +2170,7 @@
snprintf(local, sizeof(local), "p:20");
for (x=1;x<= AST_FORMAT_MAX_AUDIO; x <<= 1) {
if (p->capability & x) {
- snprintf(tmp, sizeof(tmp), ", a:%s", ast_rtp_lookup_mime_subtype(1, x));
+ snprintf(tmp, sizeof(tmp), ", a:%s", ast_rtp_lookup_mime_subtype(1, x, 0));
strncat(local, tmp, sizeof(local) - strlen(local) - 1);
}
}
Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=37501&r1=37500&r2=37501&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Wed Jul 12 20:38:47 2006
@@ -4719,9 +4719,9 @@
ast_verbose("Found description format %s for ID %d\n", mimeSubtype, codec);
/* Note: should really look at the 'freq' and '#chans' params too */
- ast_rtp_set_rtpmap_type(newaudiortp, codec, "audio", mimeSubtype);
+ ast_rtp_set_rtpmap_type(newaudiortp, codec, "audio", mimeSubtype, 0);
if (p->vrtp)
- ast_rtp_set_rtpmap_type(newvideortp, codec, "video", mimeSubtype);
+ ast_rtp_set_rtpmap_type(newvideortp, codec, "video", mimeSubtype, 0);
}
if (udptlportno != -1) {
@@ -4855,15 +4855,15 @@
char s1[BUFSIZ], s2[BUFSIZ], s3[BUFSIZ], s4[BUFSIZ];
ast_verbose("Capabilities: us - %s, peer - audio=%s/video=%s, combined - %s\n",
- ast_getformatname_multiple(s1, BUFSIZ, p->capability),
- ast_getformatname_multiple(s2, BUFSIZ, newpeercapability),
- ast_getformatname_multiple(s3, BUFSIZ, vpeercapability),
- ast_getformatname_multiple(s4, BUFSIZ, newjointcapability));
+ ast_getformatname_multiple(s1, BUFSIZ, p->capability),
+ ast_getformatname_multiple(s2, BUFSIZ, newpeercapability),
+ ast_getformatname_multiple(s3, BUFSIZ, vpeercapability),
+ ast_getformatname_multiple(s4, BUFSIZ, newjointcapability));
ast_verbose("Non-codec capabilities (dtmf): us - %s, peer - %s, combined - %s\n",
- ast_rtp_lookup_mime_multiple(s1, BUFSIZ, noncodeccapability, 0),
- ast_rtp_lookup_mime_multiple(s2, BUFSIZ, peernoncodeccapability, 0),
- ast_rtp_lookup_mime_multiple(s3, BUFSIZ, newnoncodeccapability, 0));
+ ast_rtp_lookup_mime_multiple(s1, BUFSIZ, noncodeccapability, 0, 0),
+ ast_rtp_lookup_mime_multiple(s2, BUFSIZ, peernoncodeccapability, 0, 0),
+ ast_rtp_lookup_mime_multiple(s3, BUFSIZ, newnoncodeccapability, 0, 0));
}
if (!newjointcapability) {
ast_log(LOG_NOTICE, "No compatible codecs, not accepting this offer!\n");
@@ -5571,7 +5571,7 @@
ast_build_string(m_buf, m_size, " %d", rtp_code);
ast_build_string(a_buf, a_size, "a=rtpmap:%d %s/%d\r\n", rtp_code,
- ast_rtp_lookup_mime_subtype(1, codec),
+ ast_rtp_lookup_mime_subtype(1, codec, 0),
sample_rate);
if (codec == AST_FORMAT_G729A) {
/* Indicate that we don't support VAD (G.729 annex B) */
@@ -5727,13 +5727,13 @@
int rtp_code;
if (debug)
- ast_verbose("Adding non-codec 0x%x (%s) to SDP\n", format, ast_rtp_lookup_mime_subtype(0, format));
+ ast_verbose("Adding non-codec 0x%x (%s) to SDP\n", format, ast_rtp_lookup_mime_subtype(0, format, 0));
if ((rtp_code = ast_rtp_lookup_code(p->rtp, 0, format)) == -1)
return;
ast_build_string(m_buf, m_size, " %d", rtp_code);
ast_build_string(a_buf, a_size, "a=rtpmap:%d %s/%d\r\n", rtp_code,
- ast_rtp_lookup_mime_subtype(0, format),
+ ast_rtp_lookup_mime_subtype(0, format, 0),
sample_rate);
if (format == AST_RTP_DTMF)
/* Indicate we support DTMF and FLASH... */
Modified: trunk/include/asterisk/rtp.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/rtp.h?rev=37501&r1=37500&r2=37501&view=diff
==============================================================================
--- trunk/include/asterisk/rtp.h (original)
+++ trunk/include/asterisk/rtp.h Wed Jul 12 20:38:47 2006
@@ -49,6 +49,10 @@
#define AST_RTP_MAX AST_RTP_CISCO_DTMF
#define MAX_RTP_PT 256
+
+enum ast_rtp_options {
+ AST_RTP_OPT_G726_NONSTANDARD = (1 << 0),
+};
struct ast_rtp_protocol {
/*! Get RTP struct, or NULL if unwilling to transfer */
@@ -141,7 +145,8 @@
void ast_rtp_set_m_type(struct ast_rtp* rtp, int pt);
void ast_rtp_set_rtpmap_type(struct ast_rtp* rtp, int pt,
- char* mimeType, char* mimeSubtype);
+ char *mimeType, char *mimeSubtype,
+ enum ast_rtp_options options);
/*! \brief Mapping between RTP payload format codes and Asterisk codes: */
struct rtpPayloadType ast_rtp_lookup_pt(struct ast_rtp* rtp, int pt);
@@ -151,10 +156,12 @@
int* astFormats, int* nonAstFormats);
/*! \brief Mapping an Asterisk code into a MIME subtype (string): */
-char* ast_rtp_lookup_mime_subtype(int isAstFormat, int code);
+const char *ast_rtp_lookup_mime_subtype(int isAstFormat, int code,
+ enum ast_rtp_options options);
/*! \brief Build a string of MIME subtype names from a capability list */
-char *ast_rtp_lookup_mime_multiple(char *buf, int size, const int capability, const int isAstFormat);
+char *ast_rtp_lookup_mime_multiple(char *buf, size_t size, const int capability,
+ const int isAstFormat, enum ast_rtp_options options);
void ast_rtp_setnat(struct ast_rtp *rtp, int nat);
Modified: trunk/rtp.c
URL: http://svn.digium.com/view/asterisk/trunk/rtp.c?rev=37501&r1=37500&r2=37501&view=diff
==============================================================================
--- trunk/rtp.c (original)
+++ trunk/rtp.c Wed Jul 12 20:38:47 2006
@@ -1439,19 +1439,25 @@
}
/*! \brief Make a note of a RTP payload type (with MIME type) that was seen in
- a SDP "a=rtpmap:" line. */
-void ast_rtp_set_rtpmap_type(struct ast_rtp* rtp, int pt,
- char* mimeType, char* mimeSubtype)
-{
- int i;
+ * an SDP "a=rtpmap:" line.
+ */
+void ast_rtp_set_rtpmap_type(struct ast_rtp *rtp, int pt,
+ char *mimeType, char *mimeSubtype,
+ enum ast_rtp_options options)
+{
+ unsigned int i;
if (pt < 0 || pt > MAX_RTP_PT)
return; /* bogus payload type */
- for (i = 0; i < sizeof mimeTypes/sizeof mimeTypes[0]; ++i) {
+ for (i = 0; i < sizeof(mimeTypes)/sizeof(mimeTypes[0]); ++i) {
if (strcasecmp(mimeSubtype, mimeTypes[i].subtype) == 0 &&
- strcasecmp(mimeType, mimeTypes[i].type) == 0) {
+ strcasecmp(mimeType, mimeTypes[i].type) == 0) {
rtp->current_RTP_PT[pt] = mimeTypes[i].payloadType;
+ if ((mimeTypes[i].payloadType.code == AST_FORMAT_G726) &&
+ mimeTypes[i].payloadType.isAstFormat &&
+ (options & AST_RTP_OPT_G726_NONSTANDARD))
+ rtp->current_RTP_PT[pt].code = AST_FORMAT_G726_AAL2;
return;
}
}
@@ -1524,19 +1530,27 @@
return -1;
}
-char* ast_rtp_lookup_mime_subtype(const int isAstFormat, const int code)
-{
-
- int i;
-
- for (i = 0; i < sizeof mimeTypes/sizeof mimeTypes[0]; ++i) {
- if (mimeTypes[i].payloadType.code == code && mimeTypes[i].payloadType.isAstFormat == isAstFormat)
- return mimeTypes[i].subtype;
- }
+const char *ast_rtp_lookup_mime_subtype(const int isAstFormat, const int code,
+ enum ast_rtp_options options)
+{
+ unsigned int i;
+
+ for (i = 0; i < sizeof(mimeTypes)/sizeof(mimeTypes[0]); ++i) {
+ if ((mimeTypes[i].payloadType.code == code) && (mimeTypes[i].payloadType.isAstFormat == isAstFormat)) {
+ if (isAstFormat &&
+ (code == AST_FORMAT_G726_AAL2) &&
+ (options & AST_RTP_OPT_G726_NONSTANDARD))
+ return "AAL2-G726-32";
+ else
+ return mimeTypes[i].subtype;
+ }
+ }
+
return "";
}
-char *ast_rtp_lookup_mime_multiple(char *buf, int size, const int capability, const int isAstFormat)
+char *ast_rtp_lookup_mime_multiple(char *buf, size_t size, const int capability,
+ const int isAstFormat, enum ast_rtp_options options)
{
int format;
unsigned len;
@@ -1555,7 +1569,8 @@
for (format = 1; format < AST_RTP_MAX; format <<= 1) {
if (capability & format) {
- const char *name = ast_rtp_lookup_mime_subtype(isAstFormat, format);
+ const char *name = ast_rtp_lookup_mime_subtype(isAstFormat, format, options);
+
snprintf(end, size, "%s|", name);
len = strlen(end);
end += len;
More information about the asterisk-commits
mailing list