From a6e0a783c0ca863c48bad63abb2d638345e94af6 Mon Sep 17 00:00:00 2001 From: Jerry Date: Sat, 29 Jul 2023 00:03:35 +0800 Subject: [PATCH] update --- codecs.conf | 16 +++++++--- confbridge.conf | 1 + extensions.conf | 78 ++++++++++++++++++++++++++++++++++++++++++++++--- pjsip.conf | 38 ++++++++++++++++++++++-- whois.py | 4 +-- 5 files changed, 124 insertions(+), 13 deletions(-) diff --git a/codecs.conf b/codecs.conf index a193dd1..2864d1e 100644 --- a/codecs.conf +++ b/codecs.conf @@ -1,20 +1,20 @@ [speex] ; CBR encoding quality [0..10] ; used only when vbr = false -quality => 3 +quality => 10 ; codec complexity [0..10] ; tradeoff between cpu/quality -complexity => 2 +complexity => 5 ; perceptual enhancement [true / false] ; improves clarity of decoded speech -enhancement => true +enhancement => false ; voice activity detection [true / false] ; reduces bitrate when no voice detected, used only for CBR ; (implicit in VBR/ABR) -vad => true +vad => false ; variable bit rate [true / false] ; uses bit rate proportionate to voice complexity @@ -231,9 +231,17 @@ type=opus max_playback_rate=48000 max_bandwidth=full bitrate=64000 +cbr=yes +packet_loss=10 +signal=music +application=audio [opus96] type=opus max_playback_rate=48000 max_bandwidth=full bitrate=96000 +cbr=yes +packet_loss=10 +signal=music +application=audio diff --git a/confbridge.conf b/confbridge.conf index b13a57d..4c120ac 100644 --- a/confbridge.conf +++ b/confbridge.conf @@ -45,3 +45,4 @@ dsp_drop_silence=yes [bridge1] type=bridge max_members=10 +sound_only_person=/opt/asterisk/sounds/confbridge-only-participant diff --git a/extensions.conf b/extensions.conf index e2c468a..ce8f946 100644 --- a/extensions.conf +++ b/extensions.conf @@ -3,6 +3,50 @@ static=yes writeprotect=no clearglobalvars=no +[extdn42modems] +exten => busy,1,NoOp() +same => n,PlayBack(silence/1&im-sorry&all-circuits-busy-now) +same => n,Hangup() + +exten => 00,200,NoOp() +same => n,GotoIf($["${DEVICE_STATE(PJSIP/modem0)}" = "BUSY"]?busy,1:) +same => n,Dial(PJSIP/modem0/sip:0@[fd07:d34:7969:2f::6]:5060) +same => n,Hangup() + +exten => 01,200,NoOp() +same => n,GotoIf($["${DEVICE_STATE(PJSIP/modem1)}" = "BUSY"]?busy,1:) +same => n,Dial(PJSIP/modem1/sip:0@[fd07:d34:7969:2f::6]:5061) +same => n,Hangup() + +exten => 02,200,NoOp() +same => n,GotoIf($["${DEVICE_STATE(PJSIP/modem2)}" = "BUSY"]?busy,1:) +same => n,Dial(PJSIP/modem2/sip:0@[fd07:d34:7969:2f::6]:5062) +same => n,Hangup() + +exten => 03,200,NoOp() +same => n,GotoIf($["${DEVICE_STATE(PJSIP/modem3)}" = "BUSY"]?busy,1:) +same => n,Dial(PJSIP/modem3/sip:0@[fd07:d34:7969:2f::6]:5063) +same => n,Hangup() + +exten => 04,200,NoOp() +same => n,GotoIf($["${DEVICE_STATE(PJSIP/modem4)}" = "BUSY"]?busy,1:) +same => n,Dial(PJSIP/modem4/sip:0@[fd07:d34:7969:2f::6]:5064) +same => n,Hangup() + +exten => 05,200,NoOp() +same => n,GotoIf($["${DEVICE_STATE(PJSIP/modem5)}" = "BUSY"]?busy,1:) +same => n,Dial(PJSIP/modem5/sip:0@[fd07:d34:7969:2f::6]:5065) +same => n,Hangup() + +exten => 06,200,NoOp() +same => n,GotoIf($["${DEVICE_STATE(PJSIP/modem6)}" = "BUSY"]?busy,1:) +same => n,Dial(PJSIP/modem6/sip:0@[fd07:d34:7969:2f::6]:5066) +same => n,Hangup() + +exten => _X!,200,NoOp() +same => n,Playback(silence/1&im-sorry&check-number-dial-again&silence/1) +same => n,Hangup() + [extdn42whois] exten => _X!,200,Set(CALLNUM=${EXTEN}) same => n,Goto(s,1) @@ -58,15 +102,27 @@ exten => 3,100,NoOp() same => n,Return() exten => 4,100,NoOp() - same => n,Read(TMPNOM,/opt/asterisk/sounds/0005-unreeeal_superhero_3,1,,1,0.1) + same => n,Dial(AudioSocket/10.127.8.195:3619/d17b8c7e-458e-4d4a-96a8-66b01dc082e2/c(slin),,g) same => n,Return() exten => 5,100,NoOp() - same => n,Read(TMPNOM,/opt/asterisk/sounds/0006-external,1,,1,0.1) + same => n,Read(TMPNOM,/opt/asterisk/sounds/0005-unreeeal_superhero_3,1,,999,0.1) same => n,Return() exten => 6,100,NoOp() - same => n,Read(TMPNOM,/opt/asterisk/sounds/0009-macroform-cold_day,1,,1,0.1) + same => n,Read(TMPNOM,/opt/asterisk/sounds/0006-external,1,,999,0.1) + same => n,Return() + +exten => 7,100,NoOp() + same => n,Read(TMPNOM,/opt/asterisk/sounds/0009-macroform-cold_day,1,,999,0.1) + same => n,Return() + +exten => 8,100,NoOp() + same => n,Read(TMPNOM,/opt/asterisk/sounds/0013-f9_lapix_ash,1,,999,0.1) + same => n,Return() + +exten => 9,100,NoOp() + same => n,Read(TMPNOM,/opt/asterisk/sounds/0004-little_computer_boy,1,,999,0.1) same => n,Return() exten => _X,100,NoOp() @@ -93,10 +149,19 @@ exten => 0006/_42403618X!,5,Dial(PJSIP/REDACTED,300,m) exten => 0007/_42403618X!,5,Dial(PJSIP/REDACTED,300,m) exten => 0008/_42403618X!,5,Dial(PJSIP/REDACTED,300,m) exten => 0009/424036180009,5,Goto(pstnrecv,${EXTEN},5) +exten => 0009/424036180006,5,Dial(PJSIP/REDACTED,60,r) +exten => 0009/424036180008,5,Dial(PJSIP/REDACTED,60,r) +exten => 0009/_42403618X!,5,Dial(PJSIP/REDACTED&PJSIP/REDACTED,60,r) +exten => 0010/_42403618X!,5,Dial(PJSIP/REDACTED&PJSIP/REDACTED,300,m) exten => 0000,5,Goto(extmymenu,${EXTEN},200) exten => 0 ,5,Goto(extmymenu,${EXTEN},200) +exten => 00 ,5,Dial(AudioSocket/10.127.8.195:3619/d17b8c7e-458e-4d4a-96a8-66b01dc082e2/c(slin)) exten => 3618,5,Goto(extmymenu,${EXTEN},210) +exten => 4200/_42403618X!,5,ChanSpy() +exten => 4201/_42403618X!,5,ChanSpy(,q) exten => 4242,5,Goto(extdn42whois,${EXTEN},200) +exten => 4243/_42403618X!,5,Dial(PJSIP/modem/sip:424026019@voip.burble.dn42:5060) +exten => _3618XX,5,Goto(extdn42modems,${EXTEN:4},200) exten => _X! ,5,Playback(silence/1&im-sorry&check-number-dial-again&silence/1) same => n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?chanunavail,1:) @@ -142,10 +207,15 @@ exten => _0XXXX. ,2,Goto(extpeers,424${EXTEN},5) exten => _X! ,2,Goto(extpeers,42403618${EXTEN},5) [pstnphone] +exten => 0,5,Goto(extmyself,00,5) +exten => 1,5,Goto(extmyself,0009,5) +exten => 2,5,Goto(extmyself,8613700000000,5) +exten => 3,5,Goto(extmyself,8613700000001,5) +exten => 4,5,Goto(extmyself,8613700000002,5) exten => _4240X!,5,Goto(extmyself,${EXTEN},5) exten => _X!,5,Goto(extmyself,86${EXTEN},5) [pstnrecv] exten => _X!,5,Set(CALLERID(number)=REDACTED) -same => n,Dial(PJSIP/REDACTED&PJSIP/REDACTED,300,r) +same => n,Dial(PJSIP/REDACTED&PJSIP/REDACTED,60,r) same => n,Hangup() diff --git a/pjsip.conf b/pjsip.conf index e754c3d..e72e7f0 100644 --- a/pjsip.conf +++ b/pjsip.conf @@ -18,7 +18,7 @@ bind=[::]:5060 type=endpoint context=jerry ;message_context=jerry-msg -allow=!all,opusloss,ulaw,alaw,speex +allow=!all,opus64,opusloss,speex32,ulaw,alaw direct_media=no ; proxy all calls rtp_ipv6=yes rtp_symmetric=yes @@ -31,7 +31,7 @@ rewrite_contact=yes [peers-endpoint-template](!,endpoint-template) context=jerry-peers -allow=!all,ulaw,alaw,opusloss +allow=!all,opus64,speex32,ulaw,alaw [auth-template](!) type=auth @@ -180,7 +180,6 @@ match=172.20.29.73 [jrb0001](peers-endpoint-template) aors = jrb0001 identify_by=ip -allow=!all,opusloss,speex,ulaw,alaw [jrb0001](aor-template) contact=sip:[fd42:5d71:219:1008:216:3eff:fe9d:882f]:5060 [jrb0001] @@ -197,3 +196,36 @@ contact=sip:172.20.14.37:5060 type=identify endpoint=kioubit match=172.20.14.37 + +[modem](peers-endpoint-template) +allow=!all,alaw,ulaw + +[modem0](peers-endpoint-template) +allow=!all,alaw,ulaw +device_state_busy_at=1 + +[modem1](peers-endpoint-template) +allow=!all,alaw,ulaw +device_state_busy_at=1 + +[modem2](peers-endpoint-template) +allow=!all,alaw,ulaw +device_state_busy_at=1 + +[modem3](peers-endpoint-template) +allow=!all,alaw,ulaw +device_state_busy_at=1 + +[modem4](peers-endpoint-template) +allow=!all,alaw,ulaw +device_state_busy_at=1 + +[modem5](peers-endpoint-template) +allow=!all,alaw,ulaw +device_state_busy_at=1 + +[modem6](peers-endpoint-template) +allow=!all,alaw,ulaw +device_state_busy_at=1 + +[anonymous](peers-endpoint-template) diff --git a/whois.py b/whois.py index 192e9ad..49e443d 100644 --- a/whois.py +++ b/whois.py @@ -36,7 +36,7 @@ def espeak(to_speak, outfile): timeout=10 ) p2 = subprocess.run(['ffmpeg', '-hide_banner', '-i', "-", - "-vn", "-ac", "1", "-ar", "8000", f"{outfile}"], + "-vn", "-ac", "1", "-ar", "24000", "-f", "s16le", f"{outfile}"], input=p1.stdout, capture_output=True, check=True, @@ -125,7 +125,7 @@ def main(): # argv[1]: as number # argv[2]: unique identifier unid = argv[2] - outfile = OUTDIR / f"{unid}.wav" + outfile = OUTDIR / f"{unid}.sln24" errfile = OUTDIR / f"{unid}{ERRSOUND.suffix}" cleanup(outfile, errfile) try: