[asterisk-dev] [Code Review] 4017: chan_pjsip: Don't attempt to apply formats if there aren't any capabilities defined when creating a new channel

Jonathan Rose reviewboard at asterisk.org
Tue Sep 30 16:25:43 CDT 2014


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/4017/
-----------------------------------------------------------

(Updated Sept. 30, 2014, 4:25 p.m.)


Review request for Asterisk Developers, Joshua Colp and Mark Michelson.


Changes
-------

Remove the goto statement, throw what I was skipping into the inverted condition instead.


Bugs: ASTERISK-24222
    https://issues.asterisk.org/jira/browse/ASTERISK-24222


Repository: Asterisk


Description
-------

This is the test scenario:

A has disallow=all and no allow lines
B has disallow=all, allow=ulaw

A dials an extension that 

Prior to Asterisk 13, calls like this would actually start dialing and the call would only hangup after answering. In 13, some major formats rework went in and this has led to some differences from that behavior. Namely the asserts mentioned in the issue, but another issue that this patch doesn't address is that in Asterisk 13, no outbound dial occurs in this case either... that might actually be a good thing.


Diffs (updated)
-----

  /branches/13/channels/chan_pjsip.c 423661 

Diff: https://reviewboard.asterisk.org/r/4017/diff/


Testing
-------

Dialed from A to B in the above scenario in 12, 13 (unpatched) and 13 with the patch. Made sure the channels involved were hung up properly and that no asserts occurred when the patch was in place.


Example output in Asterisk 12:
*CLI> [Sep 22 15:59:50] WARNING[9969]: channel.c:834 ast_best_codec: Don't know any of (nothing) formats
    -- Executing [1603 at default:1] Dial("PJSIP/1601-00000004", "PJSIP/1603") in new stack
    -- Called PJSIP/1603
    -- PJSIP/1603-00000005 is ringing
[Sep 22 15:59:52] WARNING[10087][C-00000003]: channel.c:5128 ast_write: Codec mismatch on channel PJSIP/1601-00000004 setting write format to ulaw from unknown native formats (nothing)
[Sep 22 15:59:52] WARNING[10087][C-00000003]: channel.c:5365 set_format: Unable to find a codec translation path from (nothing) to (ulaw)
[Sep 22 15:59:52] WARNING[10087][C-00000003]: chan_pjsip.c:639 chan_pjsip_write: Asked to transmit frame type ulaw, while native formats is (nothing) (read/write = unknown/unknown)
[Sep 22 15:59:52] WARNING[10087][C-00000003]: channel.c:5128 ast_write: Codec mismatch on channel PJSIP/1601-00000004 setting write format to ulaw from unknown native formats (nothing)
[Sep 22 15:59:52] WARNING[10087][C-00000003]: channel.c:5365 set_format: Unable to find a codec translation path from (nothing) to (ulaw)
[Sep 22 15:59:52] WARNING[10087][C-00000003]: chan_pjsip.c:639 chan_pjsip_write: Asked to transmit frame type ulaw, while native formats is (nothing) (read/write = unknown/unknown)
[Sep 22 15:59:52] WARNING[10087][C-00000003]: channel.c:5128 ast_write: Codec mismatch on channel PJSIP/1601-00000004 setting write format to ulaw from unknown native formats (nothing)
[Sep 22 15:59:52] WARNING[10087][C-00000003]: channel.c:5365 set_format: Unable to find a codec translation path from (nothing) to (ulaw)
[Sep 22 15:59:52] WARNING[10087][C-00000003]: chan_pjsip.c:639 chan_pjsip_write: Asked to transmit frame type ulaw, while native formats is (nothing) (read/write = unknown/unknown)
    -- PJSIP/1603-00000005 answered PJSIP/1601-00000004
    -- Channel PJSIP/1603-00000005 joined 'simple_bridge' basic-bridge <cca32573-8057-4791-8261-b0270821b33f>
    -- Channel PJSIP/1601-00000004 joined 'simple_bridge' basic-bridge <cca32573-8057-4791-8261-b0270821b33f>
[Sep 22 15:59:52] WARNING[10087][C-00000003]: channel.c:5365 set_format: Unable to find a codec translation path from (nothing) to (ulaw)
[Sep 22 15:59:52] WARNING[10087][C-00000003]: bridge.c:957 bridge_make_compatible: Failed to set channel PJSIP/1601-00000004 to read format ulaw
[Sep 22 15:59:52] WARNING[10087][C-00000003]: channel.c:5128 ast_write: Codec mismatch on channel PJSIP/1601-00000004 setting write format to ulaw from unknown native formats (nothing)
[Sep 22 15:59:52] WARNING[10087][C-00000003]: channel.c:5365 set_format: Unable to find a codec translation path from (nothing) to (ulaw)
[Sep 22 15:59:52] WARNING[10087][C-00000003]: chan_pjsip.c:639 chan_pjsip_write: Asked to transmit frame type ulaw, while native formats is (nothing) (read/write = unknown/unknown)
[Sep 22 15:59:52] WARNING[10087][C-00000003]: channel.c:5128 ast_write: Codec mismatch on channel PJSIP/1601-00000004 setting write format to ulaw from unknown native formats (nothing)
[Sep 22 15:59:52] WARNING[10087][C-00000003]: channel.c:5365 set_format: Unable to find a codec translation path from (nothing) to (ulaw)
[Sep 22 15:59:52] WARNING[10087][C-00000003]: chan_pjsip.c:639 chan_pjsip_write: Asked to transmit frame type ulaw, while native formats is (nothing) (read/write = unknown/unknown)
[Sep 22 15:59:52] WARNING[10087][C-00000003]: channel.c:5128 ast_write: Codec mismatch on channel PJSIP/1601-00000004 setting write format to ulaw from unknown native formats (nothing)
[Sep 22 15:59:52] WARNING[10087][C-00000003]: channel.c:5365 set_format: Unable to find a codec translation path from (nothing) to (ulaw)
[Sep 22 15:59:52] WARNING[10087][C-00000003]: chan_pjsip.c:639 chan_pjsip_write: Asked to transmit frame type ulaw, while native formats is (nothing) (read/write = unknown/unknown)
[Sep 22 15:59:52] WARNING[10087][C-00000003]: channel.c:5128 ast_write: Codec mismatch on channel PJSIP/1601-00000004 setting write format to ulaw from unknown native formats (nothing)
[Sep 22 15:59:52] WARNING[10087][C-00000003]: channel.c:5365 set_format: Unable to find a codec translation path from (nothing) to (ulaw)
[Sep 22 15:59:52] WARNING[10087][C-00000003]: chan_pjsip.c:639 chan_pjsip_write: Asked to transmit frame type ulaw, while native formats is (nothing) (read/write = unknown/unknown)
[Sep 22 15:59:52] WARNING[9969]: res_pjsip_sdp_rtp.c:234 set_caps: No joint capabilities between our configuration((nothing)) and incoming SDP((ulaw|alaw|g726|g729|g722|slin16|silk8))
[Sep 22 15:59:52] WARNING[10087][C-00000003]: channel.c:5128 ast_write: Codec mismatch on channel PJSIP/1601-00000004 setting write format to ulaw from unknown native formats (nothing)
[Sep 22 15:59:52] WARNING[10087][C-00000003]: channel.c:5365 set_format: Unable to find a codec translation path from (nothing) to (ulaw)
[Sep 22 15:59:52] WARNING[10087][C-00000003]: chan_pjsip.c:639 chan_pjsip_write: Asked to transmit frame type ulaw, while native formats is (nothing) (read/write = unknown/unknown)
[Sep 22 15:59:52] WARNING[10087][C-00000003]: channel.c:5128 ast_write: Codec mismatch on channel PJSIP/1601-00000004 setting write format to ulaw from unknown native formats (nothing)
[Sep 22 15:59:52] WARNING[10087][C-00000003]: channel.c:5365 set_format: Unable to find a codec translation path from (nothing) to (ulaw)
[Sep 22 15:59:52] WARNING[10087][C-00000003]: chan_pjsip.c:639 chan_pjsip_write: Asked to transmit frame type ulaw, while native formats is (nothing) (read/write = unknown/unknown)
[Sep 22 15:59:52] WARNING[10087][C-00000003]: channel.c:5128 ast_write: Codec mismatch on channel PJSIP/1601-00000004 setting write format to ulaw from unknown native formats (nothing)
[Sep 22 15:59:52] WARNING[10087][C-00000003]: channel.c:5365 set_format: Unable to find a codec translation path from (nothing) to (ulaw)
[Sep 22 15:59:52] WARNING[10087][C-00000003]: chan_pjsip.c:639 chan_pjsip_write: Asked to transmit frame type ulaw, while native formats is (nothing) (read/write = unknown/unknown)
    -- Channel PJSIP/1601-00000004 left 'simple_bridge' basic-bridge <cca32573-8057-4791-8261-b0270821b33f>
    -- Channel PJSIP/1603-00000005 left 'simple_bridge' basic-bridge <cca32573-8057-4791-8261-b0270821b33f>
  == Spawn extension (default, 1603, 1) exited non-zero on 'PJSIP/1601-00000004'
    -- Executing [h at default:1] NoOp("PJSIP/1601-00000004", "AGI Exit Status: ") in new stack


Example output in Asterisk 13 (unpatched):
*CLI> FRACK!, Failed assertion position < AST_VECTOR_SIZE(&cap->preference_order) (0) at line 380 in ast_format_cap_get_format of format_cap.c
[Sep 22 16:00:58] ERROR[11026]: format_cap.c:380 ast_format_cap_get_format: FRACK!, Failed assertion position < AST_VECTOR_SIZE(&cap->preference_order) (0)
Got 18 backtrace records
#0: [0x61fc3b] main/utils.c:2649 __ast_assert_failed() (0x61fbbc+7F)
#1: [0x531924] main/format_cap.c:382 ast_format_cap_get_format() (0x5318b1+73)
#2: [0x7f10feecc443] channels/chan_pjsip.c:425 chan_pjsip_new()
#3: [0x7f10feed0ac8] channels/chan_pjsip.c:2021 chan_pjsip_incoming_request()
#4: [0x7f1148657ca7] res/res_pjsip_session.c:1797 handle_incoming_request()
#5: [0x7f1148656deb] res/res_pjsip_session.c:1580 new_invite()
#6: [0x606d04] main/taskprocessor.c:768 ast_taskprocessor_execute() (0x606c04+100)
#7: [0x60f7bc] main/threadpool.c:1152 execute_tasks()
#8: [0x606d04] main/taskprocessor.c:768 ast_taskprocessor_execute() (0x606c04+100)
#9: [0x60dfec] main/threadpool.c:351 threadpool_execute()
#10: [0x60f4a2] main/threadpool.c:1072 worker_active()
#11: [0x60f25e] main/threadpool.c:993 worker_start()
FRACK!, Failed assertion 0 (0) at line 409 in internal_ao2_ref of astobj2.c
#12: [0x61b9a5] main/utils.c:1201 dummy_start()
[Sep 22 16:00:59] ERROR[11026]: astobj2.c:116 INTERNAL_OBJ: user_data is NULL
[Sep 22 16:00:59] ERROR[11026]: astobj2.c:409 internal_ao2_ref: FRACK!, Failed assertion 0 (0)
Got 19 backtrace records
#0: [0x61fc3b] main/utils.c:2649 __ast_assert_failed() (0x61fbbc+7F)
#1: [0x45f366] main/astobj2.c:410 internal_ao2_ref()
#2: [0x45f78f] main/astobj2.c:514 __ao2_ref() (0x45f761+2E)
#3: [0x7f10feecc4c2] channels/chan_pjsip.c:431 chan_pjsip_new()
#4: [0x7f10feed0ac8] channels/chan_pjsip.c:2021 chan_pjsip_incoming_request()
#5: [0x7f1148657ca7] res/res_pjsip_session.c:1797 handle_incoming_request()
#6: [0x7f1148656deb] res/res_pjsip_session.c:1580 new_invite()
#7: [0x606d04] main/taskprocessor.c:768 ast_taskprocessor_execute() (0x606c04+100)
#8: [0x60f7bc] main/threadpool.c:1152 execute_tasks()
#9: [0x606d04] main/taskprocessor.c:768 ast_taskprocessor_execute() (0x606c04+100)
#10: [0x60dfec] main/threadpool.c:351 threadpool_execute()
#11: [0x60f4a2] main/threadpool.c:1072 worker_active()
#12: [0x60f25e] main/threadpool.c:993 worker_start()
#13: [0x61b9a5] main/utils.c:1201 dummy_start()
    -- Executing [1603 at default:1] Dial("PJSIP/1601-00000000", "PJSIP/1603") in new stack
[Sep 22 16:00:59] ERROR[11112][C-00000000]: translate.c:1280 ast_translator_best_choice: Cannot determine best translation path since one capability supports no formats
failed to extend from 64 to 98
[Sep 22 16:00:59] WARNING[11112][C-00000000]: channel.c:5888 ast_request: No translator path exists for channel type PJSIP (native (g723|ulaw|alaw|gsm|g726|g726aal2|adpcm|slin|slin|slin|slin|)) to (nothing)
[Sep 22 16:00:59] WARNING[11112][C-00000000]: app_dial.c:2431 dial_exec_full: Unable to create channel of type 'PJSIP' (cause 58 - Bearer capability not available)
  == Everyone is busy/congested at this time (1:0/0/1)
    -- Auto fallthrough, channel 'PJSIP/1601-00000000' status is 'CHANUNAVAIL'
    -- Executing [h at default:1] NoOp("PJSIP/1601-00000000", "AGI Exit Status: ") in new stack
[Sep 22 16:01:05] WARNING[11026]: res_pjsip_mwi.c:679 mwi_new_subscribe: AOR 1601 has no configured mailboxes. MWI subscription failed


And for comparison sake... the output in 13 with the patch applied:
*CLI>     -- Executing [1603 at default:1] Dial("PJSIP/1601-00000000", "PJSIP/1603") in new stack
[Sep 22 16:01:59] ERROR[12441][C-00000000]: translate.c:1280 ast_translator_best_choice: Cannot determine best translation path since one capability supports no formats
failed to extend from 64 to 98
[Sep 22 16:01:59] WARNING[12441][C-00000000]: channel.c:5888 ast_request: No translator path exists for channel type PJSIP (native (g723|ulaw|alaw|gsm|g726|g726aal2|adpcm|slin|slin|slin|slin|)) to (nothing)
[Sep 22 16:01:59] WARNING[12441][C-00000000]: app_dial.c:2431 dial_exec_full: Unable to create channel of type 'PJSIP' (cause 58 - Bearer capability not available)
  == Everyone is busy/congested at this time (1:0/0/1)
    -- Auto fallthrough, channel 'PJSIP/1601-00000000' status is 'CHANUNAVAIL'
    -- Executing [h at default:1] NoOp("PJSIP/1601-00000000", "AGI Exit Status: ") in new stack

Oooh, now isn't that clean.


Thanks,

Jonathan Rose

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20140930/a4e12a81/attachment-0001.html>


More information about the asterisk-dev mailing list