[asterisk-commits] mjordan: branch group/media_formats-reviewed-trunk r418710 - /team/group/medi...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jul 15 14:42:03 CDT 2014
Author: mjordan
Date: Tue Jul 15 14:41:58 2014
New Revision: 418710
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=418710
Log:
chan_sip: Fix a slew of errors
This patch fixes a number of bugs in chan_sip:
* When adding codecs to an outgoing SDP, we failed to add the added format to
the alreadysent capability structure for peer codecs. This could result in
duplicate codecs getting added to the SDP.
* TWo paths existed that associated a dialog sip_pvt structure with a peer,
while failing to remove existing capabilities on the sip_pvt. This resulted
in the 'general' section codecs getting sent in a 200 OK to an inbound
INVITE, along with the peer's codecs.
* Direct media checks needs to make sure that things have actually changed in
a capabilities structure between checks from the RTP layer; otherwise the
channel driver will spam the poor UA with re-INVITE requests.
* When offered non-audio media streams, chan_sip would crash. This was due to
its preferred codec logic attempting to grab the preferred audio format and
not checking to see if it is NULL. This patch keeps the audio logic as it
mirrors closely what occurs prior to this work, but also falls back to
getting the preferred format of any type if the audio lookup fails to find a
format.
Review: https://reviewboard.asterisk.org/r/3791/
Review: https://reviewboard.asterisk.org/r/3789/
Review: https://reviewboard.asterisk.org/r/3788/
Modified:
team/group/media_formats-reviewed-trunk/channels/chan_sip.c
Modified: team/group/media_formats-reviewed-trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/channels/chan_sip.c?view=diff&rev=418710&r1=418709&r2=418710
==============================================================================
--- team/group/media_formats-reviewed-trunk/channels/chan_sip.c (original)
+++ team/group/media_formats-reviewed-trunk/channels/chan_sip.c Tue Jul 15 14:41:58 2014
@@ -6052,7 +6052,11 @@
ast_copy_flags(&dialog->flags[0], &peer->flags[0], SIP_FLAGS_TO_COPY);
ast_copy_flags(&dialog->flags[1], &peer->flags[1], SIP_PAGE2_FLAGS_TO_COPY);
ast_copy_flags(&dialog->flags[2], &peer->flags[2], SIP_PAGE3_FLAGS_TO_COPY);
- ast_format_cap_append_from_cap(dialog->caps, peer->caps, AST_MEDIA_TYPE_UNKNOWN);
+ /* Take the peer's caps */
+ if (peer->caps) {
+ ast_format_cap_remove_by_type(dialog->caps, AST_MEDIA_TYPE_UNKNOWN);
+ ast_format_cap_append_from_cap(dialog->caps, peer->caps, AST_MEDIA_TYPE_UNKNOWN);
+ }
dialog->amaflags = peer->amaflags;
ast_string_field_set(dialog, engine, peer->engine);
@@ -8100,8 +8104,19 @@
ast_format_cap_append_from_cap(caps, what, AST_MEDIA_TYPE_UNKNOWN);
/* Use only the preferred audio format, which is stored at the '0' index */
fmt = ast_format_cap_get_best_by_type(what, AST_MEDIA_TYPE_AUDIO); /* get the best audio format */
- ast_format_cap_remove_by_type(caps, AST_MEDIA_TYPE_AUDIO); /* remove only the other audio formats */
- ast_format_cap_append(caps, fmt, 0); /* add our best choice back */
+ if (fmt) {
+ ast_format_cap_remove_by_type(caps, AST_MEDIA_TYPE_AUDIO); /* remove only the other audio formats */
+ ast_format_cap_append(caps, fmt, 0); /* add our best choice back */
+ } else {
+ /* If we don't have an audio format, try to get something */
+ fmt = ast_format_cap_get_format(caps, 0);
+ if (!fmt) {
+ ast_log(LOG_WARNING, "No compatible formats could be found for %s\n", ast_channel_name(tmp));
+ ao2_ref(caps, -1);
+ tmp = ast_channel_unref(tmp);
+ return NULL;
+ }
+ }
ast_channel_nativeformats_set(tmp, caps);
ao2_ref(caps, -1);
@@ -13480,6 +13495,7 @@
add_tcodec_to_sdp(p, tmp_fmt, &m_text, &a_text, debug, &min_text_packet_size);
}
+ ast_format_cap_append(alreadysent, tmp_fmt, 0);
ao2_ref(tmp_fmt, -1);
}
@@ -18632,7 +18648,9 @@
p->named_callgroups = ast_ref_namedgroups(peer->named_callgroups);
ast_unref_namedgroups(p->named_pickupgroups);
p->named_pickupgroups = ast_ref_namedgroups(peer->named_pickupgroups);
+ ast_format_cap_remove_by_type(p->caps, AST_MEDIA_TYPE_UNKNOWN);
ast_format_cap_append_from_cap(p->caps, peer->caps, AST_MEDIA_TYPE_UNKNOWN);
+ ast_format_cap_remove_by_type(p->jointcaps, AST_MEDIA_TYPE_UNKNOWN);
ast_format_cap_append_from_cap(p->jointcaps, peer->caps, AST_MEDIA_TYPE_UNKNOWN);
ast_copy_string(p->zone, peer->zone, sizeof(p->zone));
if (peer->maxforwards > 0) {
@@ -32551,7 +32569,7 @@
memset(&p->tredirip, 0, sizeof(p->tredirip));
changed = 1;
}
- if (cap && ast_format_cap_count(cap)) {
+ if (cap && ast_format_cap_count(cap) && !ast_format_cap_identical(cap, p->redircaps)) {
ast_format_cap_remove_by_type(p->redircaps, AST_MEDIA_TYPE_UNKNOWN);
ast_format_cap_append_from_cap(p->redircaps, cap, AST_MEDIA_TYPE_UNKNOWN);
changed = 1;
More information about the asterisk-commits
mailing list