Merge of the "sdpcleanup" branch. Thanks to John Martin for a lot of tests

and some patches (all disclaimed).

- Don't change RTP properties if we reject a re-INVITE
- Don't add video to an outbound channel if there's no video on the inbound channel
- Don't include video in the "preferred codec" list for codec selection
- Clean up and document code that parses and adds SDP attachments

Since we do not transcode video, we can't handle video the same way as audio. This is a
bug fix patch. In future releases, we need to work on a solution for video negotiation,
not codecs but formats and framerates instead.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@32597 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.4
Olle Johansson 20 years ago
parent 016034115e
commit 479181951a

@ -539,7 +539,7 @@ char *ast_transfercapability2str(int transfercapability)
} }
} }
/*! \brief Pick the best codec */ /*! \brief Pick the best audio codec */
int ast_best_codec(int fmts) int ast_best_codec(int fmts)
{ {
/* This just our opinion, expressed in code. We are asked to choose /* This just our opinion, expressed in code. We are asked to choose
@ -573,6 +573,8 @@ int ast_best_codec(int fmts)
AST_FORMAT_G723_1, AST_FORMAT_G723_1,
}; };
/* Strip out video */
fmts &= AST_FORMAT_AUDIO_MASK;
/* Find the first preferred codec in the format given */ /* Find the first preferred codec in the format given */
for (x=0; x < (sizeof(prefs) / sizeof(prefs[0]) ); x++) for (x=0; x < (sizeof(prefs) / sizeof(prefs[0]) ); x++)
@ -2614,6 +2616,7 @@ struct ast_channel *ast_request(const char *type, int format, void *data, int *c
int fmt; int fmt;
int res; int res;
int foo; int foo;
int videoformat = format & AST_FORMAT_VIDEO_MASK;
if (!cause) if (!cause)
cause = &foo; cause = &foo;
@ -2629,7 +2632,7 @@ struct ast_channel *ast_request(const char *type, int format, void *data, int *c
continue; continue;
capabilities = chan->tech->capabilities; capabilities = chan->tech->capabilities;
fmt = format; fmt = format & AST_FORMAT_AUDIO_MASK;
res = ast_translator_best_choice(&fmt, &capabilities); res = ast_translator_best_choice(&fmt, &capabilities);
if (res < 0) { if (res < 0) {
ast_log(LOG_WARNING, "No translator path exists for channel type %s (native %d) to %d\n", type, chan->tech->capabilities, format); ast_log(LOG_WARNING, "No translator path exists for channel type %s (native %d) to %d\n", type, chan->tech->capabilities, format);
@ -2640,7 +2643,7 @@ struct ast_channel *ast_request(const char *type, int format, void *data, int *c
if (!chan->tech->requester) if (!chan->tech->requester)
return NULL; return NULL;
if (!(c = chan->tech->requester(type, capabilities, data, cause))) if (!(c = chan->tech->requester(type, capabilities | videoformat, data, cause)))
return NULL; return NULL;
if (c->_state == AST_STATE_DOWN) { if (c->_state == AST_STATE_DOWN) {

File diff suppressed because it is too large Load Diff

@ -1008,9 +1008,12 @@ int ast_codec_choose(struct ast_codec_pref *pref, int formats, int find_best)
break; break;
} }
} }
if(ret) if(ret & AST_FORMAT_AUDIO_MASK)
return ret; return ret;
if (option_debug > 3)
ast_log(LOG_DEBUG, "Could not find preferred codec - %s\n", find_best ? "Going for the best codec" : "Returning zero codec");
return find_best ? ast_best_codec(formats) : 0; return find_best ? ast_best_codec(formats) : 0;
} }
@ -1034,7 +1037,10 @@ void ast_parse_allow_disallow(struct ast_codec_pref *pref, int *mask, const char
*mask &= ~format; *mask &= ~format;
} }
if (pref) { /* Set up a preference list for audio. Do not include video in preferences
since we can not transcode video and have to use whatever is offered
*/
if (pref && (format & AST_FORMAT_AUDIO_MASK)) {
if (strcasecmp(this, "all")) { if (strcasecmp(this, "all")) {
if (allowing) if (allowing)
ast_codec_pref_append(pref, format); ast_codec_pref_append(pref, format);

@ -40,13 +40,13 @@ extern "C" {
/* Codes for RTP-specific data - not defined by our AST_FORMAT codes */ /* Codes for RTP-specific data - not defined by our AST_FORMAT codes */
/*! DTMF (RFC2833) */ /*! DTMF (RFC2833) */
#define AST_RTP_DTMF (1 << 0) #define AST_RTP_DTMF (1 << 0)
/*! 'Comfort Noise' (RFC3389) */ /*! 'Comfort Noise' (RFC3389) */
#define AST_RTP_CN (1 << 1) #define AST_RTP_CN (1 << 1)
/*! DTMF (Cisco Proprietary) */ /*! DTMF (Cisco Proprietary) */
#define AST_RTP_CISCO_DTMF (1 << 2) #define AST_RTP_CISCO_DTMF (1 << 2)
/*! Maximum RTP-specific code */ /*! Maximum RTP-specific code */
#define AST_RTP_MAX AST_RTP_CISCO_DTMF #define AST_RTP_MAX AST_RTP_CISCO_DTMF
#define MAX_RTP_PT 256 #define MAX_RTP_PT 256
@ -62,6 +62,9 @@ struct ast_rtp_protocol {
AST_LIST_ENTRY(ast_rtp_protocol) list; AST_LIST_ENTRY(ast_rtp_protocol) list;
}; };
#define FLAG_3389_WARNING (1 << 0)
typedef int (*ast_rtp_callback)(struct ast_rtp *rtp, struct ast_frame *f, void *data); typedef int (*ast_rtp_callback)(struct ast_rtp *rtp, struct ast_frame *f, void *data);
@ -71,7 +74,6 @@ typedef int (*ast_rtp_callback)(struct ast_rtp *rtp, struct ast_frame *f, void *
* RTP session is defined on page 9 of RFC 3550: "An association among a set of participants communicating with RTP. A participant may be involved in multiple RTP sessions at the same time [...]" * RTP session is defined on page 9 of RFC 3550: "An association among a set of participants communicating with RTP. A participant may be involved in multiple RTP sessions at the same time [...]"
* *
*/ */
/*! \brief The value of each payload format mapping: */ /*! \brief The value of each payload format mapping: */
struct rtpPayloadType { struct rtpPayloadType {
int isAstFormat; /*!< whether the following code is an AST_FORMAT */ int isAstFormat; /*!< whether the following code is an AST_FORMAT */

@ -23,7 +23,8 @@
#ifndef _ASTERISK_TRANSLATE_H #ifndef _ASTERISK_TRANSLATE_H
#define _ASTERISK_TRANSLATE_H #define _ASTERISK_TRANSLATE_H
#define MAX_FORMAT 32 //#define MAX_FORMAT 15 /* Do not include video here */
#define MAX_FORMAT 32 /* Do include video here */
#if defined(__cplusplus) || defined(c_plusplus) #if defined(__cplusplus) || defined(c_plusplus)
extern "C" { extern "C" {

@ -1350,7 +1350,7 @@ int ast_rtp_make_compatible(struct ast_channel *dest, struct ast_channel *src, i
return 1; return 1;
} }
/*! \brief Make a note of a RTP paymoad type that was seen in a SDP "m=" line. /*! \brief Make a note of a RTP payload type that was seen in a SDP "m=" line.
* By default, use the well-known value for this type (although it may * By default, use the well-known value for this type (although it may
* still be set to a different value by a subsequent "a=rtpmap:" line) * still be set to a different value by a subsequent "a=rtpmap:" line)
*/ */
@ -1359,9 +1359,8 @@ void ast_rtp_set_m_type(struct ast_rtp* rtp, int pt)
if (pt < 0 || pt > MAX_RTP_PT) if (pt < 0 || pt > MAX_RTP_PT)
return; /* bogus payload type */ return; /* bogus payload type */
if (static_RTP_PT[pt].code != 0) { if (static_RTP_PT[pt].code != 0)
rtp->current_RTP_PT[pt] = static_RTP_PT[pt]; rtp->current_RTP_PT[pt] = static_RTP_PT[pt];
}
} }
/*! \brief Make a note of a RTP payload type (with MIME type) that was seen in /*! \brief Make a note of a RTP payload type (with MIME type) that was seen in
@ -2245,7 +2244,7 @@ int ast_rtp_write(struct ast_rtp *rtp, struct ast_frame *_f)
/* Make sure we have enough space for RTP header */ /* Make sure we have enough space for RTP header */
if ((_f->frametype != AST_FRAME_VOICE) && (_f->frametype != AST_FRAME_VIDEO)) { if ((_f->frametype != AST_FRAME_VOICE) && (_f->frametype != AST_FRAME_VIDEO)) {
ast_log(LOG_WARNING, "RTP can only send voice\n"); ast_log(LOG_WARNING, "RTP can only send voice and video\n");
return -1; return -1;
} }

Loading…
Cancel
Save