Author: jrose
Date: Wed Oct  1 17:52:09 2014
New Revision: 424333

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=424333
Log:
chan_pjsip: Fix an assertion for channels that lack formats on creation

ASTERISK-24222 #close
Reported by: Mark Michelson
Review: https://reviewboard.asterisk.org/r/4017/


Modified:
    branches/13/channels/chan_pjsip.c

Modified: branches/13/channels/chan_pjsip.c
URL: 
http://svnview.digium.com/svn/asterisk/branches/13/channels/chan_pjsip.c?view=diff&rev=424333&r1=424332&r2=424333
==============================================================================
--- branches/13/channels/chan_pjsip.c (original)
+++ branches/13/channels/chan_pjsip.c Wed Oct  1 17:52:09 2014
@@ -371,7 +371,6 @@
 {
        struct ast_channel *chan;
        struct ast_format_cap *caps;
-       struct ast_format *fmt;
        RAII_VAR(struct chan_pjsip_pvt *, pvt, NULL, ao2_cleanup);
        struct ast_sip_channel_pvt *channel;
        struct ast_variable *var;
@@ -418,16 +417,20 @@
 
        ast_channel_nativeformats_set(chan, caps);
 
-       /*
-        * XXX Probably should pick the first audio codec instead
-        * of simply the first codec.  The first codec may be video.
-        */
-       fmt = ast_format_cap_get_format(caps, 0);
-       ast_channel_set_writeformat(chan, fmt);
-       ast_channel_set_rawwriteformat(chan, fmt);
-       ast_channel_set_readformat(chan, fmt);
-       ast_channel_set_rawreadformat(chan, fmt);
-       ao2_ref(fmt, -1);
+       if (!ast_format_cap_empty(caps)) {
+               /*
+                * XXX Probably should pick the first audio codec instead
+                * of simply the first codec.  The first codec may be video.
+                */
+               struct ast_format *fmt = ast_format_cap_get_format(caps, 0);
+
+               ast_channel_set_writeformat(chan, fmt);
+               ast_channel_set_rawwriteformat(chan, fmt);
+               ast_channel_set_readformat(chan, fmt);
+               ast_channel_set_rawreadformat(chan, fmt);
+               ao2_ref(fmt, -1);
+       }
+
        ao2_ref(caps, -1);
 
        if (state == AST_STATE_RING) {


-- 
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

svn-commits mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/svn-commits

Reply via email to