[asterisk-commits] mmichelson: branch mmichelson/direct_media r383033 - in /team/mmichelson/dire...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Mar 13 11:14:50 CDT 2013
Author: mmichelson
Date: Wed Mar 13 11:14:47 2013
New Revision: 383033
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=383033
Log:
Put in changes so that proper codecs are placed in direct media SDPs.
Modified:
team/mmichelson/direct_media/include/asterisk/res_sip_session.h
team/mmichelson/direct_media/res/res_sip_sdp_audio.c
team/mmichelson/direct_media/res/res_sip_session.c
Modified: team/mmichelson/direct_media/include/asterisk/res_sip_session.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/direct_media/include/asterisk/res_sip_session.h?view=diff&rev=383033&r1=383032&r2=383033
==============================================================================
--- team/mmichelson/direct_media/include/asterisk/res_sip_session.h (original)
+++ team/mmichelson/direct_media/include/asterisk/res_sip_session.h Wed Mar 13 11:14:47 2013
@@ -100,6 +100,8 @@
AST_LIST_HEAD_NOLOCK(, ast_sip_session_delayed_request) delayed_requests;
/* When we need to reschedule a reinvite, we use this structure to do it */
pj_timer_entry rescheduled_reinvite;
+ /* Format capabilities pertaining to direct media */
+ struct ast_format_cap *direct_media_cap;
};
typedef int (*ast_sip_session_request_creation_cb)(struct ast_sip_session *session, pjsip_tx_data *tdata);
Modified: team/mmichelson/direct_media/res/res_sip_sdp_audio.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/direct_media/res/res_sip_sdp_audio.c?view=diff&rev=383033&r1=383032&r2=383033
==============================================================================
--- team/mmichelson/direct_media/res/res_sip_sdp_audio.c (original)
+++ team/mmichelson/direct_media/res/res_sip_sdp_audio.c Wed Mar 13 11:14:47 2013
@@ -148,6 +148,15 @@
pj_str_t stmp;
pjmedia_sdp_attr *attr;
int index = 0, min_packet_size = 0, noncodec = (session->endpoint->dtmf == AST_SIP_DTMF_RFC_4733) ? AST_RTP_DTMF : 0;
+ RAII_VAR(struct ast_format_cap *, cap, ast_format_cap_alloc_nolock(), ast_format_cap_destroy);
+ int direct_media_enabled = !ast_sockaddr_isnull(&session->media[AST_SIP_MEDIA_AUDIO].direct_media_addr) &&
+ !ast_format_cap_is_empty(session->direct_media_cap);
+
+ if (direct_media_enabled) {
+ ast_format_cap_joint_copy(session->endpoint->codecs, session->direct_media_cap, cap);
+ } else {
+ ast_format_cap_copy(cap, session->endpoint->codecs);
+ }
if (!ast_format_cap_has_type(session->endpoint->codecs, AST_FORMAT_TYPE_AUDIO)) {
/* If no audio formats are configured don't add a stream */
@@ -166,7 +175,7 @@
media->desc.transport = STR_RTP_AVP;
/* Add connection level details */
- if (!ast_sockaddr_isnull(&session->media[AST_SIP_MEDIA_AUDIO].direct_media_addr)) {
+ if (direct_media_enabled) {
ast_sockaddr_copy(&addr, &session->media[AST_SIP_MEDIA_AUDIO].direct_media_addr);
} else {
ast_rtp_instance_get_local_address(session->media[AST_SIP_MEDIA_AUDIO].rtp, &addr);
@@ -180,6 +189,7 @@
/* Add formats */
for (index = 0; (index < AST_CODEC_PREF_SIZE); index++) {
struct ast_format format;
+ struct ast_format compat_format;
int rtp_code;
pjmedia_sdp_rtpmap rtpmap;
struct ast_codec_pref *pref = &ast_rtp_instance_get_codecs(session->media[AST_SIP_MEDIA_AUDIO].rtp)->pref;
@@ -188,8 +198,10 @@
break;
} else if (AST_FORMAT_GET_TYPE(format.id) != AST_FORMAT_TYPE_AUDIO) {
continue;
+ } else if (!ast_format_cap_get_compatible_format(cap, &format, &compat_format)) {
+ continue;
} else if ((rtp_code = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(session->media[AST_SIP_MEDIA_AUDIO].rtp),
- 1, &format, 0)) == -1) {
+ 1, &compat_format, 0)) == -1) {
return -1;
}
@@ -269,6 +281,8 @@
RAII_VAR(struct ast_format_cap *, jointcap, NULL, ast_format_cap_destroy);
RAII_VAR(struct ast_format_cap *, peercap, NULL, ast_format_cap_destroy);
struct ast_format fmt;
+ int direct_media_enabled = !ast_sockaddr_isnull(&session->media[AST_SIP_MEDIA_AUDIO].direct_media_addr) &&
+ !ast_format_cap_is_empty(session->direct_media_cap);
/* Create an RTP instance if need be */
if (!session->media[AST_SIP_MEDIA_AUDIO].rtp && audio_create_rtp(session, session->endpoint->rtp_ipv6)) {
@@ -341,7 +355,11 @@
}
/* Using the configured codecs and the codecs in this SDP we determine the joint formats for *audio only* */
- ast_format_cap_copy(cap, session->endpoint->codecs);
+ if (direct_media_enabled) {
+ ast_format_cap_joint_copy(session->endpoint->codecs, session->direct_media_cap, cap);
+ } else {
+ ast_format_cap_copy(cap, session->endpoint->codecs);
+ }
ast_format_cap_remove_bytype(cap, AST_FORMAT_TYPE_VIDEO);
if (!(jointcap = ast_format_cap_joint(cap, peercap))) {
Modified: team/mmichelson/direct_media/res/res_sip_session.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/direct_media/res/res_sip_session.c?view=diff&rev=383033&r1=383032&r2=383033
==============================================================================
--- team/mmichelson/direct_media/res/res_sip_session.c (original)
+++ team/mmichelson/direct_media/res/res_sip_session.c Wed Mar 13 11:14:47 2013
@@ -681,6 +681,7 @@
iter->session_begin(session);
}
}
+ session->direct_media_cap = ast_format_cap_alloc_nolock();
inv_session->mod_data[session_module.id] = session;
AST_LIST_HEAD_INIT_NOLOCK(&session->delayed_requests);
ao2_ref(session, +1);
More information about the asterisk-commits
mailing list