The Chinese name of uft8 is displayed incorrectly
Describe the bug
When obtaining the information of "FROM" or "TO", if it is a Chinese name, garbled characters will be displayed. But when I test with other softphone software or terminals, the displayed text is normal like: INVITE sip:[email protected]:5060;ob SIP/2.0 Allow: INVITE, ACK, CANCEL, BYE, PRACK, NOTIFY, REFER, SUBSCRIBE, OPTIONS, UPDATE, INFO Supported: replaces,timer,path User-Agent: OmniPCX Enterprise R12.2 m3.402.32 Session-Expires: 1800;refresher=uac Min-SE: 900 Alert-Info: urn:alert:tone:internal Content-Type: application/sdp To: "AI" sip:[email protected];user=phone From: "鏉庢旦濡? sip:[email protected];user=phone;tag=cccbca3af5cee36a935fbab5608a1f71 Contact: sip:[email protected];transport=UDP Call-ID: [email protected] CSeq: 1324127786 INVITE Via: SIP/2.0/UDP 101.168.0.224;branch=z9hG4bK4a434489a33a805c9a7c74f6d42e7aaf Max-Forwards: 70 Content-Length: 218
Steps to reproduce
Developed using PJSUA2 C#
PJSIP version
2.15.1
Context
WINDOWS C# WINFROM PJSUA
Log, call stack, etc
“
11:16:51.208 sip_endpoint.c .Module "mod-pjsua-log" registered
11:16:51.223 sip_endpoint.c .Module "mod-tsx-layer" registered
11:16:51.223 sip_endpoint.c .Module "mod-stateful-util" registered
11:16:51.223 sip_endpoint.c .Module "mod-ua" registered
11:16:51.223 sip_endpoint.c .Module "mod-100rel" registered
11:16:51.223 sip_endpoint.c .Module "mod-pjsua" registered
11:16:51.223 sip_endpoint.c .Module "mod-invite" registered
11:16:51.270 wmme_dev.c ..WMME found 3 devices:
11:16:51.270 wmme_dev.c .. dev_id 0: Wave mapper (in=2, out=2)
11:16:51.270 wmme_dev.c .. dev_id 1: 麦克风阵列 (Realtek High Defini (in=2, out=0)
11:16:51.270 wmme_dev.c .. dev_id 2: 喇叭/耳机 (Realtek High Definit (in=0, out=2)
11:16:51.270 wmme_dev.c ..WMME initialized
11:16:51.286 pjlib ..select() I/O Queue created (10E4056C)
11:16:51.286 sip_endpoint.c .Module "mod-evsub" registered
11:16:51.286 sip_endpoint.c !.Module "mod-presence" registered
11:16:51.286 sip_endpoint.c .Module "mod-dlg_even" registered
11:16:51.301 sip_endpoint.c .Module "mod-mwi" registered
11:16:51.301 sip_endpoint.c .Module "mod-refer" registered
11:16:51.301 sip_endpoint.c .Module "mod-pjsua-pres" registered
11:16:51.301 sip_endpoint.c .Module "mod-pjsua-im" registered
11:16:51.301 sip_endpoint.c .Module "mod-pjsua-options" registered
11:16:51.301 pjsua_core.c .1 SIP worker threads created
11:16:51.301 pjsua_core.c !.pjsua version 2.15.1 for win32-6.2/i386/msvc-19.0 initialized
11:16:51.301 pjsua_core.c .PJSUA state changed: CREATED --> INIT
“SoftphoneDemo2.exe”(CoreCLR: clrhost): 已加载“C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App\8.0.16\System.Private.Uri.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
11:16:51.341 pjsua_core.c SIP UDP socket reachable at 10.168.1.144:5060
11:16:51.341 udp00945620 SIP UDP transport started, published address is 10.168.1.144:5060
11:16:51.341 pjsua_core.c PJSUA state changed: INIT --> STARTING
11:16:51.341 sip_endpoint.c .Module "mod-unsolicited-mwi" registered
11:16:51.341 pjsua_core.c .PJSUA state changed: STARTING --> RUNNING
11:16:51.356 pjsua_acc.c Adding account: id=sip:[email protected]
11:16:51.372 pjsua_acc.c .Account sip:[email protected] added with id 0
11:16:51.372 pjsua_acc.c .Acc 0: setting registration..
11:16:51.372 pjsua_acc.c ..Contact for acc 0 updated: <sip:[email protected]:5060;ob>
11:16:51.372 pjsua_core.c ...TX 488 bytes Request msg REGISTER/cseq=41134 (tdta10D996FC) to UDP 101.168.0.224:5060:
REGISTER sip:101.168.0.224 SIP/2.0
Via: SIP/2.0/UDP 10.168.1.144:5060;rport;branch=z9hG4bKPj5bbb2f1dd6bc4b74a3b16af59b97e6ac
Max-Forwards: 70
From: <sip:[email protected]>;tag=7242a9389a82495eaa3e863d0988f354
To: <sip:[email protected]>
Call-ID: 0450ce6d263e447e9f9119a7a2eafb4a
CSeq: 41134 REGISTER
Contact: <sip:[email protected]:5060;ob>
Expires: 300
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Content-Length: 0
--end msg--
11:16:51.372 pjsua_acc.c ..Acc 0: Registration sent
“SoftphoneDemo2.exe”(CoreCLR: clrhost): 已加载“C:\Program Files (x86)\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.16\Microsoft.Win32.SystemEvents.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
11:16:51.388 pjsua_core.c .RX 458 bytes Response msg 401/REGISTER/cseq=41134 (rdata10D949E4) from UDP 101.168.0.224:5060:
SIP/2.0 401 Unauthorized
WWW-Authenticate: Digest qop="auth",nonce="bdecbf0c54204e69eed3f1eea97887a3",realm="ALE"
To: <sip:[email protected]>;tag=e243af8305b612a7a522bba62290646b
From: <sip:[email protected]>;tag=7242a9389a82495eaa3e863d0988f354
Call-ID: 0450ce6d263e447e9f9119a7a2eafb4a
CSeq: 41134 REGISTER
Via: SIP/2.0/UDP 10.168.1.144:5060;received=10.168.1.144;rport=5060;branch=z9hG4bKPj5bbb2f1dd6bc4b74a3b16af59b97e6ac
Content-Length: 0
--end msg--
11:16:51.403 pjsua_core.c ....TX 719 bytes Request msg REGISTER/cseq=41135 (tdta10D996FC) to UDP 101.168.0.224:5060:
REGISTER sip:101.168.0.224 SIP/2.0
Via: SIP/2.0/UDP 10.168.1.144:5060;rport;branch=z9hG4bKPj6abf7445db0048efaa4d222e3d2743c3
Max-Forwards: 70
From: <sip:[email protected]>;tag=7242a9389a82495eaa3e863d0988f354
To: <sip:[email protected]>
Call-ID: 0450ce6d263e447e9f9119a7a2eafb4a
CSeq: 41135 REGISTER
Contact: <sip:[email protected]:5060;ob>
Expires: 300
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Authorization: Digest username="48101", realm="ALE", nonce="bdecbf0c54204e69eed3f1eea97887a3", uri="sip:101.168.0.224", response="6f4e36a3b86aa76bdd56a55006677e35", cnonce="4f1b1afb613d4313a8ff9bec0865d1df", qop=auth, nc=00000001
Content-Length: 0
--end msg--
11:16:51.403 pjsua_core.c .RX 397 bytes Response msg 423/REGISTER/cseq=41135 (rdata10D949E4) from UDP 101.168.0.224:5060:
SIP/2.0 423 Registration Too Brief
Min-Expires: 1800
To: <sip:[email protected]>;tag=c7d1504feae1f375753f3bb55b1d62f8
From: <sip:[email protected]>;tag=7242a9389a82495eaa3e863d0988f354
Call-ID: 0450ce6d263e447e9f9119a7a2eafb4a
CSeq: 41135 REGISTER
Via: SIP/2.0/UDP 10.168.1.144:5060;received=10.168.1.144;rport=5060;branch=z9hG4bKPj6abf7445db0048efaa4d222e3d2743c3
Content-Length: 0
--end msg--
11:16:51.466 pjsua_core.c ....TX 489 bytes Request msg REGISTER/cseq=41136 (tdta10DA047C) to UDP 101.168.0.224:5060:
REGISTER sip:101.168.0.224 SIP/2.0
Via: SIP/2.0/UDP 10.168.1.144:5060;rport;branch=z9hG4bKPjaf8833c0ce13448bb15b0b09bca1e96b
Max-Forwards: 70
From: <sip:[email protected]>;tag=7074dd4ea21342beab9d1ceea5ac29b3
To: <sip:[email protected]>
Call-ID: 0450ce6d263e447e9f9119a7a2eafb4a
CSeq: 41136 REGISTER
Contact: <sip:[email protected]:5060;ob>
Expires: 1800
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Content-Length: 0
--end msg--
11:16:51.466 pjsua_core.c .RX 458 bytes Response msg 401/REGISTER/cseq=41136 (rdata10D949E4) from UDP 101.168.0.224:5060:
SIP/2.0 401 Unauthorized
WWW-Authenticate: Digest qop="auth",nonce="bdecbf0c54204e69eed3f1eea97887a3",realm="ALE"
To: <sip:[email protected]>;tag=2338f3bc4ca706f94824460fc074bdb6
From: <sip:[email protected]>;tag=7074dd4ea21342beab9d1ceea5ac29b3
Call-ID: 0450ce6d263e447e9f9119a7a2eafb4a
CSeq: 41136 REGISTER
Via: SIP/2.0/UDP 10.168.1.144:5060;received=10.168.1.144;rport=5060;branch=z9hG4bKPjaf8833c0ce13448bb15b0b09bca1e96b
Content-Length: 0
--end msg--
11:16:51.466 pjsua_core.c ....TX 720 bytes Request msg REGISTER/cseq=41137 (tdta10DA047C) to UDP 101.168.0.224:5060:
REGISTER sip:101.168.0.224 SIP/2.0
Via: SIP/2.0/UDP 10.168.1.144:5060;rport;branch=z9hG4bKPj05bdbd8c41e0485591c1d0dc2fc8b571
Max-Forwards: 70
From: <sip:[email protected]>;tag=7074dd4ea21342beab9d1ceea5ac29b3
To: <sip:[email protected]>
Call-ID: 0450ce6d263e447e9f9119a7a2eafb4a
CSeq: 41137 REGISTER
Contact: <sip:[email protected]:5060;ob>
Expires: 1800
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Authorization: Digest username="48101", realm="ALE", nonce="bdecbf0c54204e69eed3f1eea97887a3", uri="sip:101.168.0.224", response="66b8f58fb0299aa8bfc3bcfade438e46", cnonce="4f1b1afb613d4313a8ff9bec0865d1df", qop=auth, nc=00000002
Content-Length: 0
--end msg--
11:16:51.481 pjsua_core.c .RX 414 bytes Response msg 200/REGISTER/cseq=41137 (rdata10D949E4) from UDP 101.168.0.224:5060:
SIP/2.0 200 OK
Contact: <sip:[email protected]:5060;ob>;expires=1800
To: <sip:[email protected]>;tag=99603e4de2ec059478c4141985253c12
From: <sip:[email protected]>;tag=7074dd4ea21342beab9d1ceea5ac29b3
Call-ID: 0450ce6d263e447e9f9119a7a2eafb4a
CSeq: 41137 REGISTER
Via: SIP/2.0/UDP 10.168.1.144:5060;received=10.168.1.144;rport=5060;branch=z9hG4bKPj05bdbd8c41e0485591c1d0dc2fc8b571
Content-Length: 0
--end msg--
11:16:51.481 pjsua_acc.c ....SIP outbound status for acc 0 is not active
11:16:51.497 pjsua_acc.c ....Service-Route updated for acc 0 with 0 URI(s)
11:16:51.497 pjsua_acc.c ....sip:[email protected]: registration success, status=200 (OK), will re-register in 1800 seconds
11:16:51.497 pjsua_acc.c ....Keep-alive timer started for acc 0, destination:101.168.0.224:5060, interval:13s
“SoftphoneDemo2.exe”(CoreCLR: clrhost): 已加载“C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App\8.0.16\System.Collections.NonGeneric.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
11:16:55.806 pjsua_core.c .RX 942 bytes Request msg INVITE/cseq=1244313164 (rdata10D949E4) from UDP 101.168.0.224:5060:
INVITE sip:[email protected]:5060;ob SIP/2.0
Allow: INVITE, ACK, CANCEL, BYE, PRACK, NOTIFY, REFER, SUBSCRIBE, OPTIONS, UPDATE, INFO
Supported: replaces,timer,path
User-Agent: OmniPCX Enterprise R12.2 m3.402.32
Session-Expires: 1800;refresher=uac
Min-SE: 900
Alert-Info: <urn:alert:tone:internal>
Content-Type: application/sdp
To: "AI" <sip:[email protected];user=phone>
From: "鏉庢旦濡? <sip:[email protected];user=phone>;tag=4f0d3462345aa03ee6b41bf8c34eca70
Contact: <sip:[email protected];transport=UDP>
Call-ID: [email protected]
CSeq: 1244313164 INVITE
Via: SIP/2.0/UDP 101.168.0.224;branch=z9hG4bK674c29c24a48b157cdf0c0bfa7d1e4e3
Max-Forwards: 70
Content-Length: 218
v=0
o=OXE 1748315814 1748315814 IN IP4 101.168.0.224
s=abs
c=IN IP4 101.168.0.230
t=0 0
m=audio 32616 RTP/AVP 8 101
a=sendrecv
a=rtpmap:8 PCMA/8000
a=ptime:20
a=maxptime:30
a=rtpmap:101 telephone-event/8000
--end msg--
11:16:55.806 pjsua_call.c .Incoming Request msg INVITE/cseq=1244313164 (rdata10D949E4)
11:16:55.822 pjsua_media.c ..Call 0: initializing media..
11:16:55.837 pjsua_media.c ...RTP socket reachable at 10.168.1.144:4000
11:16:55.837 pjsua_media.c ...RTCP socket reachable at 10.168.1.144:4001
11:16:55.837 srtp10E31ED0 ...SRTP transport created
11:16:55.837 pjsua_media.c ...Media index 0 selected for audio call 0
“SoftphoneDemo2.exe”(CoreCLR: clrhost): 已加载“E:\文档\Visual Studio 2022\Projects\SoftphoneDemo2\SoftphoneDemo2\bin\Debug\net8.0-windows\SIPSorcery.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“SoftphoneDemo2.exe”(CoreCLR: clrhost): 已加载“E:\文档\Visual Studio 2022\Projects\SoftphoneDemo2\SoftphoneDemo2\bin\Debug\net8.0-windows\SIPSorceryMedia.Abstractions.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
11:16:55.900 udp10E12C28 ...UDP media transport created
11:16:55.900 pjsua_core.c .....TX 364 bytes Response msg 100/INVITE/cseq=1244313164 (tdta0BC930AC) to UDP 101.168.0.224:5060:
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 101.168.0.224;received=101.168.0.224;branch=z9hG4bK674c29c24a48b157cdf0c0bfa7d1e4e3
Call-ID: [email protected]
From: "鏉庢旦濡? <sip:[email protected];user=phone>;tag=4f0d3462345aa03ee6b41bf8c34eca70
To: "AI" <sip:[email protected];user=phone>
CSeq: 1244313164 INVITE
Content-Length: 0
--end msg--
OnCallStateOut: PJSIP_INV_STATE_INCOMING
11:16:59.414 pjsua_core.c .RX 472 bytes Request msg CANCEL/cseq=1244313164 (rdata10D949E4) from UDP 101.168.0.224:5060:
CANCEL sip:[email protected]:5060;ob SIP/2.0
Supported: replaces,timer,path,100rel
User-Agent: OmniPCX Enterprise R12.2 m3.402.32
Call-ID: [email protected]
To: "AI" <sip:[email protected];user=phone>
CSeq: 1244313164 CANCEL
From: "鏉庢旦濡? <sip:[email protected];user=phone>;tag=4f0d3462345aa03ee6b41bf8c34eca70
Via: SIP/2.0/UDP 101.168.0.224;branch=z9hG4bK674c29c24a48b157cdf0c0bfa7d1e4e3
Max-Forwards: 70
Content-Length: 0
--end msg--
11:16:59.414 pjsua_core.c .......TX 397 bytes Response msg 200/CANCEL/cseq=1244313164 (tdta1107DD94) to UDP 101.168.0.224:5060:
SIP/2.0 200 OK
Via: SIP/2.0/UDP 101.168.0.224;received=101.168.0.224;branch=z9hG4bK674c29c24a48b157cdf0c0bfa7d1e4e3
Call-ID: [email protected]
From: "鏉庢旦濡? <sip:[email protected];user=phone>;tag=4f0d3462345aa03ee6b41bf8c34eca70
To: "AI" <sip:[email protected];user=phone>;tag=48fec3905a6b4a43965f918bcdaea3a1
CSeq: 1244313164 CANCEL
Content-Length: 0
--end msg--
11:16:59.414 pjsua_core.c .......TX 413 bytes Response msg 487/INVITE/cseq=1244313164 (tdta0BC930AC) to UDP 101.168.0.224:5060:
SIP/2.0 487 Request Terminated
Via: SIP/2.0/UDP 101.168.0.224;received=101.168.0.224;branch=z9hG4bK674c29c24a48b157cdf0c0bfa7d1e4e3
Call-ID: [email protected]
From: "鏉庢旦濡? <sip:[email protected];user=phone>;tag=4f0d3462345aa03ee6b41bf8c34eca70
To: "AI" <sip:[email protected];user=phone>;tag=48fec3905a6b4a43965f918bcdaea3a1
CSeq: 1244313164 INVITE
Content-Length: 0
--end msg--
11:16:59.414 pjsua_media.c ..........Call 0: deinitializing media..
11:16:59.429 pjsua_media.c ...........
[DISCONNECTED] To: "鏉庢旦濡? <sip:[email protected];user=phone>;tag=4f0d3462345aa03ee6b41bf8c34eca70
Call time: 00h:00m:00s, 1st res in 3592 ms, conn in 0ms
11:16:59.429 pjsua_media.c ...........Call 0: cleaning up provisional media, prov_med_cnt=1, med_cnt=0
11:16:59.429 srtp10E31ED0 ...........Destroying SRTP transport
11:16:59.429 udp10E12C28 ...........UDP media transport destroying
11:16:59.429 udp10E12C28 ...........UDP media transport destroyed
11:16:59.444 srtp10E31ED0 ...........SRTP transport destroyed
OnCallStateOut: PJSIP_INV_STATE_DISCONNECTED
11:16:59.444 pjsua_core.c .RX 416 bytes Request msg ACK/cseq=1244313164 (rdata10D949E4) from UDP 101.168.0.224:5060:
ACK sip:[email protected]:5060;ob SIP/2.0
Call-ID: [email protected]
From: "鏉庢旦濡? <sip:[email protected];user=phone>;tag=4f0d3462345aa03ee6b41bf8c34eca70
To: "AI" <sip:[email protected];user=phone>;tag=48fec3905a6b4a43965f918bcdaea3a1
Via: SIP/2.0/UDP 101.168.0.224;branch=z9hG4bK674c29c24a48b157cdf0c0bfa7d1e4e3
CSeq: 1244313164 ACK
Max-Forwards: 70
Content-Length: 0
--end msg--
24/5000 I tested it with the pjsua program, and the displayed user name was also incorrect
v=0 o=OXE 1748592199 1748592199 IN IP4 101.168.0.224 s=abs c=IN IP4 101.168.0.230 t=0 0 m=audio 32616 RTP/AVP 8 101 a=sendrecv a=rtpmap:8 PCMA/8000 a=ptime:20 a=maxptime:30 a=rtpmap:101 telephone-event/8000
--end msg-- 16:03:20.064 pjsua_call.c .Incoming Request msg INVITE/cseq=665605882 (rdata00AEACEC) 16:03:20.068 pjsua_media.c ..Call 0: initializing media.. 16:03:20.076 pjsua_media.c ...RTP socket reachable at 10.168.1.144:4000 16:03:20.076 pjsua_media.c ...RTCP socket reachable at 10.168.1.144:4001 16:03:20.081 srtp00B61628 ...SRTP transport created 16:03:20.081 pjsua_media.c ...Media index 0 selected for audio call 0 16:03:20.081 udp00B41620 ...UDP media transport created 16:03:20.081 pjsua_core.c .....TX 363 bytes Response msg 100/INVITE/cseq=665605882 (tdta00B4E26C) to UDP 101.168.0.224:5060: SIP/2.0 100 Trying Via: SIP/2.0/UDP 101.168.0.224;received=101.168.0.224;branch=z9hG4bK8c957b4ef2988fea71a6c5cbe3ca31ec Call-ID: [email protected] From: "鏉庢旦濡? sip:[email protected];user=phone;tag=b79de006322085278f210f79198f2985 To: "AI" sip:[email protected];user=phone CSeq: 665605882 INVITE Content-Length: 0
--end msg-- 16:03:20.085 pjsua_aud.c ..Conf connect: 2 --> 0 16:03:20.085 pjsua_aud.c ...Set sound device: capture=-1, playback=-2, mode=0, use_default_settings=0 16:03:20.085 pjsua_app.c ....Turning sound device -1 -2 ON 16:03:20.085 pjsua_aud.c ....Opening sound device (speaker + mic) PCM@16000/1/20ms 16:03:20.283 wmme_dev.c ..... WaveAPI Sound player "Wave mapper" initialized (format=PCM, clock_rate=16000, channel_count=1, samples_per_frame=320 (20ms)) 16:03:20.544 wmme_dev.c ..... WaveAPI Sound recorder "Wave mapper" initialized (format=PCM, clock_rate=16000, channel_count=1, samples_per_frame=320 (20ms)) 16:03:20.556 ec00B7D0F0 .....Speex AEC created, clock_rate=16000, channel=1, samples per frame=320, tail length=200 ms, latency=0 ms 16:03:20.560 sound_port.c .....Sound port uses native clock 16:03:20.564 wmme_dev.c .....WMME playback stream started 16:03:20.568 wmme_dev.c .....WMME capture stream started 16:03:20.572 conference.c ....Connect ports 2->0 queued 16:03:20.576 pjsua_app.c ..Incoming call for account 2! Media count: 1 audio & 0 video From: "鏉庢旦濡? sip:[email protected];user=phone To: "AI" sip:[email protected];user=phone Press a to answer or h to reject call 16:03:20.604 conference.c !.Added port 1 (ringback), port count=2 16:03:20.608 conference.c .Added port 2 (ring), port count=3 16:03:20.608 conference.c .Port 2 (ring) transmitting to port 0 (Wave mapper) 16:03:27.943 pjsua_core.c .RX 471 bytes Request msg CANCEL/cseq=665605882 (rdata00AEACEC) from UDP 101.168.0.224:5060: CANCEL sip:[email protected]:5060;ob SIP/2.0 Supported: replaces,timer,path,100rel User-Agent: OmniPCX Enterprise R12.2 m3.402.32 Call-ID: [email protected] To: "AI" sip:[email protected];user=phone CSeq: 665605882 CANCEL From: "鏉庢旦濡? sip:[email protected];user=phone;tag=b79de006322085278f210f79198f2985 Via: SIP/2.0/UDP 101.168.0.224;branch=z9hG4bK8c957b4ef2988fea71a6c5cbe3ca31ec Max-Forwards: 70 Content-Length: 0
--end msg-- 16:03:27.943 pjsua_core.c .......TX 396 bytes Response msg 200/CANCEL/cseq=665605882 (tdta00BB98DC) to UDP 101.168.0.224:5060: SIP/2.0 200 OK Via: SIP/2.0/UDP 101.168.0.224;received=101.168.0.224;branch=z9hG4bK8c957b4ef2988fea71a6c5cbe3ca31ec Call-ID: [email protected] From: "鏉庢旦濡? sip:[email protected];user=phone;tag=b79de006322085278f210f79198f2985 To: "AI" sip:[email protected];user=phone;tag=8f8a93ef526941f3880ec35652c3b08f CSeq: 665605882 CANCEL Content-Length: 0
--end msg-- 16:03:27.947 pjsua_core.c .......TX 412 bytes Response msg 487/INVITE/cseq=665605882 (tdta00B4E26C) to UDP 101.168.0.224:5060: SIP/2.0 487 Request Terminated Via: SIP/2.0/UDP 101.168.0.224;received=101.168.0.224;branch=z9hG4bK8c957b4ef2988fea71a6c5cbe3ca31ec Call-ID: [email protected] From: "鏉庢旦濡? sip:[email protected];user=phone;tag=b79de006322085278f210f79198f2985 To: "AI" sip:[email protected];user=phone;tag=8f8a93ef526941f3880ec35652c3b08f CSeq: 665605882 INVITE Content-Length: 0
--end msg-- 16:03:27.947 pjsua_media.c ..........Call 0: deinitializing media.. 16:03:27.947 pjsua_media.c ........... [DISCONNECTED] To: "鏉庢旦濡? sip:[email protected];user=phone;tag=b79de006322085278f210f79198f2985 Call time: 00h:00m:00s, 1st res in 7883 ms, conn in 0ms 16:03:27.947 pjsua_media.c ...........Call 0: cleaning up provisional media, prov_med_cnt=1, med_cnt=0 16:03:27.951 srtp00B61628 ...........Destroying SRTP transport 16:03:27.951 udp00B41620 ...........UDP media transport destroying 16:03:27.951 udp00B41620 ...........UDP media transport destroyed 16:03:27.951 srtp00B61628 ...........SRTP transport destroyed 16:03:27.955 pjsua_aud.c ..........Conf disconnect: 2 -x- 0 16:03:27.959 conference.c ............Disconnect ports 2->0 queued 16:03:27.959 pjsua_app.c ..........Call 0 is DISCONNECTED [reason=487 (Request Terminated)] 16:03:27.959 pjsua_core.c .RX 415 bytes Request msg ACK/cseq=665605882 (rdata00AEACEC) from UDP 101.168.0.224:5060: ACK sip:[email protected]:5060;ob SIP/2.0 Call-ID: [email protected] From: "鏉庢旦濡? sip:[email protected];user=phone;tag=b79de006322085278f210f79198f2985 To: "AI" sip:[email protected];user=phone;tag=8f8a93ef526941f3880ec35652c3b08f Via: SIP/2.0/UDP 101.168.0.224;branch=z9hG4bK8c957b4ef2988fea71a6c5cbe3ca31ec CSeq: 665605882 ACK Max-Forwards: 70 Content-Length: 0
--end msg-- 16:03:27.983 conference.c !.Port 2 (ring) stop transmitting to port 0 (Wave mapper) 16:03:28.970 pjsua_aud.c !Closing sound device after idle for 1 second(s) 16:03:28.973 pjsua_app.c .Turning sound device -1 -2 OFF 16:03:28.977 pjsua_aud.c .Closing Wave mapper sound playback device and Wave mapper sound capture device 16:03:28.985 wmme_dev.c .Stopped WMME playback stream 16:03:28.993 wmme_dev.c .Stopped WMME capture stream 16:03:28.993 wmme_dev.c .Stopped WMME playback stream 16:03:28.993 wmme_dev.c .Stopped WMME capture stream
Right, honestly we don't work with utf8 much, so this comment may not be relevant.
The incoming SIP message should be parsed correctly, in this case as utf8. Note that the display name field of the From/To header is stored as pjsip_name_addr.display with type pj_str_t. To display it correctly, I guess you need to convert it to the display encoding, e.g: pj_unicode_to_ansi() if the display is using ANSI.
Right, honestly we don't work with utf8 much, so this comment may not be relevant.
The incoming SIP message should be parsed correctly, in this case as utf8. Note that the display name field of the From/To header is stored as
pjsip_name_addr.displaywith typepj_str_t. To display it correctly, I guess you need to convert it to the display encoding, e.g:pj_unicode_to_ansi()if the display is using ANSI.
I am currently developing through pjsua2 c#. Could you please explain in detail how to obtain this original byte array?
Because what I saw in the memory monitoring was the correct bytes, but the actual returned remoteUri parameter was incorrect.
When I want to transcode through a string, the converted bytecode seems to have overflowed and cannot be restored to the original bytecode for UTF8 transcoding
var cinfo = call.getInfo();
var u = Encoding.GetEncoding("gbk").GetBytes(cinfo.remoteUri);
var name = Encoding.UTF8.GetString(u);
I have a very limited knowledge with encoding/transcoding, so for now I'd just try to describe the remote URI info generations in pjsua & pjsua2 (C/C++):
The original bytes from the wire/SIP message is byte-copied this way:
https://github.com/pjsip/pjproject/blob/032fd661c21345c432c8d3f253df9d0fee4008e5/pjsip/src/pjsip/sip_uri.c#L579-L584
I guess this make the pjsua_call_info.remote_info contain the original bytes from the wire (utf8 encoded?).
Then the pjsua_call_info.remote_info, whose type is pj_str_t, is 'converted to callInfo.remoteUri, whose type is C++ std::string, this way:
https://github.com/pjsip/pjproject/blob/032fd661c21345c432c8d3f253df9d0fee4008e5/pjsip/src/pjsua2/util.hpp#L37-L42
Not sure if the string constructor modify the bytes here (I guess it still contains the original bytes).
Lastly, there is C++ std::string to C# string conversion, not sure if the original bytes is maintained here.
Btw, when you mentioned about testing using pjsua, did you check the content of pjsua_call_info.remote_info (pj_str_t) and it was incorrect?
And rather OOT (in case we need it later), here is something about std::string to C# conversion using SWIG:
https://stackoverflow.com/questions/19783363/how-to-wrap-utf-8-encoded-c-stdstrings-with-swig-in-c
Btw, when you mentioned about testing using pjsua, did you check the content of
pjsua_call_info.remote_info (pj_str_t)and it was incorrect?And rather OOT (in case we need it later), here is something about
std::stringto C# conversion using SWIG: https://stackoverflow.com/questions/19783363/how-to-wrap-utf-8-encoded-c-stdstrings-with-swig-in-c
The display of UTF8 characters can be supported in the way you mentioned, but I have found another problem. If the character data exceeds 2, the final display will still be abnormal.
If I set the name to 张三, it will be displayed as follows**(rdata.wholeMsg)**: INVITE sip:[email protected]:5060;ob SIP/2.0 Allow: INVITE, ACK, CANCEL, BYE, PRACK, NOTIFY, REFER, SUBSCRIBE, OPTIONS, UPDATE, INFO Supported: replaces,timer,path User-Agent: OmniPCX Enterprise R12.2 m3.402.32 Session-Expires: 1800;refresher=uac Min-SE: 900 Alert-Info: urn:alert:tone:internal Content-Type: application/sdp To: "AI" sip:[email protected];user=phone From: "张三" sip:[email protected];user=phone;tag=bc2ccc40e09b81579aa156d37c281f1c Contact: sip:[email protected];transport=UDP Call-ID: [email protected] CSeq: 1318531750 INVITE Via: SIP/2.0/UDP 101.168.0.224;branch=z9hG4bKe788cde15be49e6fa15e01c46edc2f31 Max-Forwards: 70 Content-Length: 218
If I set the name to 张三三, it will be displayed as follows**(rdata.wholeMsg)**: INVITE sip:[email protected]:5060;ob SIP/2.0 Allow: INVITE, ACK, CANCEL, BYE, PRACK, NOTIFY, REFER, SUBSCRIBE, OPTIONS, UPDATE, INFO Supported: replaces,timer,path User-Agent: OmniPCX Enterprise R12.2 m3.402.32 Session-Expires: 1800;refresher=uac Min-SE: 900 Alert-Info: urn:alert:tone:internal Content-Type: application/sdp To: "AI" sip:[email protected];user=phone From: "张三�? sip:[email protected];user=phone;tag=dda3b141cc0dcf6a9792f630c7d1546f Contact: sip:[email protected];transport=UDP Call-ID: [email protected] CSeq: 1739040855 INVITE Via: SIP/2.0/UDP 101.168.0.224;branch=z9hG4bKb18b2d6f8802c142c7680fbe7e8f0c53 Max-Forwards: 70 Content-Length: 218
I tested with other SIP soft phones and found that they could support the display of more than two Chinese characters
张三三: The correct BYTE stream should be: E5-BC-A0-E4-B8-89-E4-B8-89
But what I captured when I set the breakpoint was:
E5-BC-A0-E4-B8-89-E4-B8-3F
I also captured the packets on the network through packet capture software. The packets sent by the server were correct
But what I captured when I set the breakpoint was:
E5-BC-A0-E4-B8-89-E4-B8-3F
Which variable exactly is this?
Could you also check the bytes of rdata.wholeMsg, is it broken too?
rdata.wholeMsg
yes,rdata.wholeMsg is also incorrect,It is incorrect starting from the third character
Since you mentioned that the problem already happens with pjsua, let's test with pjsua first (instead of with C#).
If I tested it here using pjsua with 张三三, it seems to be correct:
REGISTER sip:sip.pjsip.org;transport=tls SIP/2.0
...
From: "张三三/401" <sips:[email protected]>;tag=B6C0828D-0066-4B9D-9428-BADDF239414B
To: "张三三/401" <sips:[email protected]>
Since you mentioned that the problem already happens with pjsua, let's test with pjsua first (instead of with C#).既然你提到了 pjsua 已经出现问题,那么让我们先使用 pjsua(而不是 C#)进行测试。
If I tested it here using pjsua with
张三三, it seems to be correct:如果我在这里使用带有张三三的pjsua 对其进行测试,它似乎是正确的:REGISTER sip:sip.pjsip.org;transport=tls SIP/2.0 ... From: "张三三/401" <sips:[email protected]>;tag=B6C0828D-0066-4B9D-9428-BADDF239414B To: "张三三/401" <sips:[email protected]>
This is my test using the pjsua program in the windows 10 environment. It shows that the name of "From" is incorrect. The test software is pjsua-i386-win32-vc14-release-dynamic.exe, which is not a program developed in c#
ok, what's the correct id so I can try it here?
ok, what's the correct id so I can try it here?
The name is 张三三,The following is the content displayed by the pjsua program,along with packet capture(wireshark)
14:59:32.197 sip_endpoint.c !.Module "mod-pjsua-log" registered 14:59:32.200 sip_endpoint.c .Module "mod-tsx-layer" registered 14:59:32.200 sip_endpoint.c .Module "mod-stateful-util" registered 14:59:32.200 sip_endpoint.c .Module "mod-ua" registered 14:59:32.201 sip_endpoint.c .Module "mod-100rel" registered 14:59:32.201 sip_endpoint.c .Module "mod-pjsua" registered 14:59:32.201 sip_endpoint.c .Module "mod-invite" registered 14:59:32.233 wmme_dev.c ..WMME found 3 devices: 14:59:32.233 wmme_dev.c .. dev_id 0: Wave mapper (in=2, out=2) 14:59:32.234 wmme_dev.c .. dev_id 1: 麦克风阵列 (Realtek High Defini (in=2, out=0) 14:59:32.234 wmme_dev.c .. dev_id 2: 喇叭/耳机 (Realtek High Definit (in=0, out=2) 14:59:32.234 wmme_dev.c ..WMME initialized 14:59:32.235 pjlib ..select() I/O Queue created (00DC9314) 14:59:32.236 sip_endpoint.c !.Module "mod-evsub" registered 14:59:32.237 sip_endpoint.c !.Module "mod-presence" registered 14:59:32.237 sip_endpoint.c .Module "mod-dlg_even" registered 14:59:32.237 sip_endpoint.c .Module "mod-mwi" registered 14:59:32.237 sip_endpoint.c .Module "mod-refer" registered 14:59:32.237 sip_endpoint.c .Module "mod-pjsua-pres" registered 14:59:32.237 sip_endpoint.c .Module "mod-pjsua-im" registered 14:59:32.238 sip_endpoint.c .Module "mod-pjsua-options" registered 14:59:32.238 pjsua_core.c .1 SIP worker threads created 14:59:32.238 pjsua_core.c .pjsua version 2.15.1 for win32-6.2/i386/msvc-19.0 initialized 14:59:32.238 pjsua_core.c !.PJSUA state changed: CREATED --> INIT 14:59:32.238 sip_endpoint.c Module "mod-default-handler" registered 14:59:32.238 conference.c .Add port 1 (ringback) queued 14:59:32.238 conference.c .Add port 2 (ring) queued 14:59:32.251 pjsua_core.c SIP UDP socket reachable at 10.168.1.144:5060 14:59:32.251 udp00E05078 SIP UDP transport started, published address is 10.168.1.144:5060 14:59:32.252 pjsua_acc.c Adding account: id=sip:10.168.1.144:5060 14:59:32.253 pjsua_acc.c .Account sip:10.168.1.144:5060 added with id 0 14:59:32.253 pjsua_acc.c Modifying account 0 14:59:32.254 pjsua_acc.c Acc 0: setting online status to 1.. 14:59:32.266 tcptp:5060 SIP TCP listener ready for incoming connections at 10.168.1.144:5060 14:59:32.267 pjsua_acc.c Adding account: id=sip:10.168.1.144:5060;transport=TCP 14:59:32.268 pjsua_acc.c .Account sip:10.168.1.144:5060;transport=TCP added with id 1 14:59:32.269 pjsua_acc.c Modifying account 1 14:59:32.269 pjsua_acc.c Acc 1: setting online status to 1.. 14:59:32.270 pjsua_core.c PJSUA state changed: INIT --> STARTING 14:59:32.271 sip_endpoint.c .Module "mod-unsolicited-mwi" registered 14:59:32.274 pjsua_core.c .PJSUA state changed: STARTING --> RUNNING 14:59:32.276 main.c Ready: Success
Account list: [ 0] sip:10.168.1.144:5060: does not register Online status: Online *[ 1] sip:10.168.1.144:5060;transport=TCP: does not register Online status: Online Buddy list: -none-
+=============================================================================+ You have 0 active call
+a Your SIP URL: (empty to cancel): sip:[email protected] URL of the registrar: (empty to cancel): sip:101.168.0.224 Auth Realm: (empty to cancel): * Auth Username: (empty to cancel): 48101 Auth Password: (empty to cancel): 0000 15:00:53.085 pjsua_acc.c Adding account: id=sip:[email protected] 15:00:53.088 pjsua_acc.c .Account sip:[email protected] added with id 2 15:00:53.089 pjsua_acc.c .Acc 2: setting registration.. 15:00:53.090 pjsua_acc.c ..Contact for acc 2 updated: sip:[email protected]:5060;ob 15:00:53.091 pjsua_core.c ...TX 540 bytes Request msg REGISTER/cseq=31484 (tdta00DB5D2C) to UDP 101.168.0.224:5060: REGISTER sip:101.168.0.224 SIP/2.0 Via: SIP/2.0/UDP 10.168.1.144:5060;rport;branch=z9hG4bKPj20080027c8c94dd3805693cda496295f Max-Forwards: 70 From: sip:[email protected];tag=a425cd8a96404dda837632f7523b5081 To: sip:[email protected] Call-ID: 78f5d12982444b20a3b46cfadef77847 CSeq: 31484 REGISTER User-Agent: PJSUA v2.15.1 win32-6.2/i386/msvc-19.0 Contact: sip:[email protected]:5060;ob Expires: 300 Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS Content-Length: 0
--end msg-- 15:00:53.093 pjsua_acc.c ..Acc 2: Registration sent
15:00:53.097 pjsua_core.c .RX 458 bytes Response msg 401/REGISTER/cseq=31484 (rdata00E27ED4) from UDP 101.168.0.224:5060: SIP/2.0 401 Unauthorized WWW-Authenticate: Digest qop="auth",nonce="bdecbf0c54204e69eed3f1eea97887a3",realm="ALE" To: sip:[email protected];tag=50015e401549fe45e3572353c8bd5a0a From: sip:[email protected];tag=a425cd8a96404dda837632f7523b5081 Call-ID: 78f5d12982444b20a3b46cfadef77847 CSeq: 31484 REGISTER Via: SIP/2.0/UDP 10.168.1.144:5060;received=10.168.1.144;rport=5060;branch=z9hG4bKPj20080027c8c94dd3805693cda496295f Content-Length: 0
--end msg-- 15:00:53.098 pjsua_core.c ....TX 771 bytes Request msg REGISTER/cseq=31485 (tdta00DB5D2C) to UDP 101.168.0.224:5060: REGISTER sip:101.168.0.224 SIP/2.0 Via: SIP/2.0/UDP 10.168.1.144:5060;rport;branch=z9hG4bKPjf518860aa6c347959f2b57c20cfb01f5 Max-Forwards: 70 From: sip:[email protected];tag=a425cd8a96404dda837632f7523b5081 To: sip:[email protected] Call-ID: 78f5d12982444b20a3b46cfadef77847 CSeq: 31485 REGISTER User-Agent: PJSUA v2.15.1 win32-6.2/i386/msvc-19.0 Contact: sip:[email protected]:5060;ob Expires: 300 Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS Authorization: Digest username="48101", realm="ALE", nonce="bdecbf0c54204e69eed3f1eea97887a3", uri="sip:101.168.0.224", response="64fda3b54589aa60608f172b8e15249d", cnonce="31373d7589c945df94e79ead59f8e417", qop=auth, nc=00000001 Content-Length: 0
--end msg-- 15:00:53.103 pjsua_core.c .RX 397 bytes Response msg 423/REGISTER/cseq=31485 (rdata00E27ED4) from UDP 101.168.0.224:5060: SIP/2.0 423 Registration Too Brief Min-Expires: 1800 To: sip:[email protected];tag=c1c5810ec7837e56710c19a0e0dd6f7a From: sip:[email protected];tag=a425cd8a96404dda837632f7523b5081 Call-ID: 78f5d12982444b20a3b46cfadef77847 CSeq: 31485 REGISTER Via: SIP/2.0/UDP 10.168.1.144:5060;received=10.168.1.144;rport=5060;branch=z9hG4bKPjf518860aa6c347959f2b57c20cfb01f5 Content-Length: 0
--end msg-- 15:00:53.104 pjsua_core.c ....TX 541 bytes Request msg REGISTER/cseq=31486 (tdta00DD65EC) to UDP 101.168.0.224:5060: REGISTER sip:101.168.0.224 SIP/2.0 Via: SIP/2.0/UDP 10.168.1.144:5060;rport;branch=z9hG4bKPj3b9fe31771dd4ffe8808d55eb0fe0cae Max-Forwards: 70 From: sip:[email protected];tag=0acfb87553d246a88f1e0628651b55ed To: sip:[email protected] Call-ID: 78f5d12982444b20a3b46cfadef77847 CSeq: 31486 REGISTER User-Agent: PJSUA v2.15.1 win32-6.2/i386/msvc-19.0 Contact: sip:[email protected]:5060;ob Expires: 1800 Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS Content-Length: 0
--end msg-- 15:00:53.108 pjsua_core.c .RX 458 bytes Response msg 401/REGISTER/cseq=31486 (rdata00E27ED4) from UDP 101.168.0.224:5060: SIP/2.0 401 Unauthorized WWW-Authenticate: Digest qop="auth",nonce="bdecbf0c54204e69eed3f1eea97887a3",realm="ALE" To: sip:[email protected];tag=549871b3f35e63defeba393e0269097e From: sip:[email protected];tag=0acfb87553d246a88f1e0628651b55ed Call-ID: 78f5d12982444b20a3b46cfadef77847 CSeq: 31486 REGISTER Via: SIP/2.0/UDP 10.168.1.144:5060;received=10.168.1.144;rport=5060;branch=z9hG4bKPj3b9fe31771dd4ffe8808d55eb0fe0cae Content-Length: 0
--end msg-- 15:00:53.111 pjsua_core.c ....TX 772 bytes Request msg REGISTER/cseq=31487 (tdta00DD65EC) to UDP 101.168.0.224:5060: REGISTER sip:101.168.0.224 SIP/2.0 Via: SIP/2.0/UDP 10.168.1.144:5060;rport;branch=z9hG4bKPj390da1f6781144d59bc10a4f99b1385a Max-Forwards: 70 From: sip:[email protected];tag=0acfb87553d246a88f1e0628651b55ed To: sip:[email protected] Call-ID: 78f5d12982444b20a3b46cfadef77847 CSeq: 31487 REGISTER User-Agent: PJSUA v2.15.1 win32-6.2/i386/msvc-19.0 Contact: sip:[email protected]:5060;ob Expires: 1800 Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS Authorization: Digest username="48101", realm="ALE", nonce="bdecbf0c54204e69eed3f1eea97887a3", uri="sip:101.168.0.224", response="57ab9b6e1b9571ca148da1276fa748c3", cnonce="31373d7589c945df94e79ead59f8e417", qop=auth, nc=00000002 Content-Length: 0
--end msg-- 15:00:53.118 pjsua_core.c .RX 414 bytes Response msg 200/REGISTER/cseq=31487 (rdata00E27ED4) from UDP 101.168.0.224:5060: SIP/2.0 200 OK Contact: sip:[email protected]:5060;ob;expires=1800 To: sip:[email protected];tag=c7443146392fed0b6e79120e45e78fe6 From: sip:[email protected];tag=0acfb87553d246a88f1e0628651b55ed Call-ID: 78f5d12982444b20a3b46cfadef77847 CSeq: 31487 REGISTER Via: SIP/2.0/UDP 10.168.1.144:5060;received=10.168.1.144;rport=5060;branch=z9hG4bKPj390da1f6781144d59bc10a4f99b1385a Content-Length: 0
--end msg-- 15:00:53.118 pjsua_acc.c ....SIP outbound status for acc 2 is not active 15:00:53.119 pjsua_acc.c ....Service-Route updated for acc 2 with 0 URI(s) 15:00:53.120 pjsua_acc.c ....sip:[email protected]: registration success, status=200 (OK), will re-register in 1800 seconds 15:00:53.121 pjsua_acc.c ....Keep-alive timer started for acc 2, destination:101.168.0.224:5060, interval:13s 15:01:12.395 pjsua_core.c .RX 942 bytes Request msg INVITE/cseq=1092443767 (rdata00E27ED4) from UDP 101.168.0.224:5060: INVITE sip:[email protected]:5060;ob SIP/2.0 Allow: INVITE, ACK, CANCEL, BYE, PRACK, NOTIFY, REFER, SUBSCRIBE, OPTIONS, UPDATE, INFO Supported: replaces,timer,path User-Agent: OmniPCX Enterprise R12.2 m3.402.32 Session-Expires: 1800;refresher=uac Min-SE: 900 Alert-Info: urn:alert:tone:internal Content-Type: application/sdp To: "AI" sip:[email protected];user=phone From: "寮犱笁涓? sip:[email protected];user=phone;tag=94cdd28867d0a0fb799213cecb3260a0 Contact: sip:[email protected];transport=UDP Call-ID: [email protected] CSeq: 1092443767 INVITE Via: SIP/2.0/UDP 101.168.0.224;branch=z9hG4bK3d66135fbbc84aab5b9d2ed5f07ae4aa Max-Forwards: 70 Content-Length: 218
v=0 o=OXE 1749538873 1749538873 IN IP4 101.168.0.224 s=abs c=IN IP4 101.168.0.230 t=0 0 m=audio 32588 RTP/AVP 8 101 a=sendrecv a=rtpmap:8 PCMA/8000 a=ptime:20 a=maxptime:30 a=rtpmap:101 telephone-event/8000
--end msg-- 15:01:12.410 pjsua_call.c .Incoming Request msg INVITE/cseq=1092443767 (rdata00E27ED4) 15:01:12.413 pjsua_media.c ..Call 0: initializing media.. 15:01:12.431 pjsua_media.c ...RTP socket reachable at 10.168.1.144:4000 15:01:12.432 pjsua_media.c ...RTCP socket reachable at 10.168.1.144:4001 15:01:12.433 srtp00E2F6F8 ...SRTP transport created 15:01:12.434 pjsua_media.c ...Media index 0 selected for audio call 0 15:01:12.434 udp00E2D780 ...UDP media transport created 15:01:12.435 pjsua_core.c .....TX 364 bytes Response msg 100/INVITE/cseq=1092443767 (tdta00E3BEFC) to UDP 101.168.0.224:5060: SIP/2.0 100 Trying Via: SIP/2.0/UDP 101.168.0.224;received=101.168.0.224;branch=z9hG4bK3d66135fbbc84aab5b9d2ed5f07ae4aa Call-ID: [email protected] From: "寮犱笁涓? sip:[email protected];user=phone;tag=94cdd28867d0a0fb799213cecb3260a0 To: "AI" sip:[email protected];user=phone CSeq: 1092443767 INVITE Content-Length: 0
--end msg-- 15:01:12.437 pjsua_aud.c ..Conf connect: 2 --> 0 15:01:12.438 pjsua_aud.c ...Set sound device: capture=-1, playback=-2, mode=0, use_default_settings=0 15:01:12.440 pjsua_app.c ....Turning sound device -1 -2 ON 15:01:12.441 pjsua_aud.c ....Opening sound device (speaker + mic) PCM@16000/1/20ms 15:01:12.716 wmme_dev.c ..... WaveAPI Sound player "Wave mapper" initialized (format=PCM, clock_rate=16000, channel_count=1, samples_per_frame=320 (20ms)) 15:01:12.975 wmme_dev.c ..... WaveAPI Sound recorder "Wave mapper" initialized (format=PCM, clock_rate=16000, channel_count=1, samples_per_frame=320 (20ms)) 15:01:12.995 ec00E4E980 .....Speex AEC created, clock_rate=16000, channel=1, samples per frame=320, tail length=200 ms, latency=0 ms 15:01:12.999 sound_port.c .....Sound port uses native clock 15:01:13.002 wmme_dev.c .....WMME playback stream started 15:01:13.008 wmme_dev.c .....WMME capture stream started 15:01:13.015 conference.c ....Connect ports 2->0 queued 15:01:13.015 pjsua_app.c ..Incoming call for account 2! Media count: 1 audio & 0 video From: "寮犱笁涓? sip:[email protected];user=phone To: "AI" sip:[email protected];user=phone Press a to answer or h to reject call 15:01:13.044 conference.c !.Added port 1 (ringback), port count=2 15:01:13.044 conference.c .Added port 2 (ring), port count=3 15:01:13.048 conference.c .Port 2 (ring) transmitting to port 0 (Wave mapper)
Account list: [ 0] sip:10.168.1.144:5060: does not register Online status: Online [ 1] sip:10.168.1.144:5060;transport=TCP: does not register Online status: Online *[ 2] sip:[email protected]: 200/OK (expires=1767) Online status: Offline Buddy list: -none-
You have 1 active call Current call id=0 to "寮犱笁涓? sip:[email protected];user=phone [INCOMING]
a Answer with code (100-699) (empty to cancel): 200 15:01:32.236 pjsua_call.c !Answering call 0: code=200 15:01:32.239 inv00DD65EC ..SDP negotiation done: Success 15:01:32.240 pjsua_media.c ...Call 0: updating media.. 15:01:32.241 pjsua_media.c .....Media stream call00:0 is destroyed 15:01:32.242 udp00E2D780 ....UDP media transport started 15:01:32.243 pjsua_aud.c ....Audio channel update for index 0 for call 0... 15:01:32.243 strm00E80484 .....VAD temporarily disabled 15:01:32.244 udp00E2D780 .....UDP media transport attached 15:01:32.245 strm00E80484 .....Encoder stream started 15:01:32.246 strm00E80484 .....Decoder stream started 15:01:32.247 conference.c ......Add port 3 (sip:[email protected];user=phone) queued 15:01:32.247 pjsua_media.c ....Audio updated, stream #0: PCMA (sendrecv) 15:01:32.248 pjsua_app.c ...Call 0 media 0 [type=audio], status is Active 15:01:32.248 pjsua_aud.c ...Conf disconnect: 2 -x- 0 15:01:32.249 conference.c .....Disconnect ports 2->0 queued 15:01:32.250 pjsua_aud.c ...Conf connect: 3 --> 0 15:01:32.250 conference.c .....Connect ports 3->0 queued 15:01:32.251 pjsua_aud.c ...Conf connect: 0 --> 3 15:01:32.251 conference.c .....Connect ports 0->3 queued 15:01:32.252 pjsua_core.c ....TX 989 bytes Response msg 200/INVITE/cseq=1092443767 (tdta00DB5D2C) to UDP 101.168.0.224:5060: SIP/2.0 200 OK Via: SIP/2.0/UDP 101.168.0.224;received=101.168.0.224;branch=z9hG4bK3d66135fbbc84aab5b9d2ed5f07ae4aa Call-ID: [email protected] From: "寮犱笁涓? sip:[email protected];user=phone;tag=94cdd28867d0a0fb799213cecb3260a0 To: "AI" sip:[email protected];user=phone;tag=518f252e8ab74753b8d2bc190e8816be CSeq: 1092443767 INVITE Contact: sip:[email protected]:5060;ob Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS Supported: replaces, 100rel, timer, norefersub Session-Expires: 1800;refresher=uac Require: timer Content-Type: application/sdp Content-Length: 316
v=0 o=- 3958556472 3958556473 IN IP4 10.168.1.144 s=pjmedia b=AS:84 t=0 0 a=X-nat:0 m=audio 4000 RTP/AVP 8 101 c=IN IP4 10.168.1.144 b=TIAS:64000 a=rtcp:4001 IN IP4 10.168.1.144 a=sendrecv a=rtpmap:8 PCMA/8000 a=ssrc:1256275308 cname:644366bb428b26a6 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-16
--end msg-- 15:01:32.253 pjsua_app.c .......Call 0 state changed to CONNECTING
15:01:32.254 conference.c !.Added port 3 (sip:[email protected];user=phone), port count=4 15:01:32.257 conference.c .Port 2 (ring) stop transmitting to port 0 (Wave mapper) 15:01:32.258 conference.c .Port 3 (sip:[email protected];user=phone) transmitting to port 0 (Wave mapper) 15:01:32.259 conference.c .Port 0 (Wave mapper) transmitting to port 3 (sip:[email protected];user=phone) 15:01:32.260 Master/sound Underflow, buf_cnt=0, will generate 1 frame 15:01:32.260 strm00E80484 Resetting jitter buffer in stream playback start 15:01:32.307 pjsua_core.c .RX 512 bytes Request msg ACK/cseq=1092443767 (rdata00E27ED4) from UDP 101.168.0.224:5060: ACK sip:[email protected]:5060;ob SIP/2.0 Contact: sip:[email protected];transport=UDP User-Agent: OmniPCX Enterprise R12.2 m3.402.32 To: "AI" sip:[email protected];user=phone;tag=518f252e8ab74753b8d2bc190e8816be From: "寮犱笁涓? sip:[email protected];user=phone;tag=94cdd28867d0a0fb799213cecb3260a0 Call-ID: [email protected] CSeq: 1092443767 ACK Via: SIP/2.0/UDP 101.168.0.224;branch=z9hG4bK8289b50f7af5818c9da2bde5e3d83b40 Max-Forwards: 70 Content-Length: 0
--end msg-- 15:01:32.310 pjsua_app.c ...Call 0 state changed to CONFIRMED 15:01:32.884 strm00E80484 !VAD re-enabled
Account list: [ 0] sip:10.168.1.144:5060: does not register Online status: Online [ 1] sip:10.168.1.144:5060;transport=TCP: does not register Online status: Online *[ 2] sip:[email protected]: 200/OK (expires=1750) Online status: Offline Buddy list: -none-
You have 1 active call Current call id=0 to "寮犱笁涓? sip:[email protected];user=phone [CONFIRMED]
h 15:01:41.287 pjsua_call.c !Call 0 hanging up: code=0.. 15:01:41.289 pjsua_media.c .Call 0: deinitializing media.. 15:01:41.290 pjsua_media.c .. [CONFIRMED] To: "寮犱笁涓? sip:[email protected];user=phone;tag=94cdd28867d0a0fb799213cecb3260a0 Call time: 00h:00m:08s, 1st res in 19827 ms, conn in 19898ms #0 audio PCMA @8kHz, sendrecv, peer=101.168.0.230:32588 SRTP status: Not active Crypto-suite: RX pt=8, last update:00h:00m:03.775s ago total 445pkt 71.2KB (89.0KB +IP hdr) @avg=62.9Kbps/78.7Kbps pkt loss=0 (0.0%), discrd=0 (0.0%), dup=0 (0.0%), reord=0 (0.0%) (msec) min avg max last dev loss period: 0.000 0.000 0.000 0.000 0.000 jitter : 0.000 0.203 1.625 0.125 0.263 TX pt=8, ptime=20, last update:00h:00m:03.969s ago total 40pkt 6.4KB (8.0KB +IP hdr) @avg=5.6Kbps/7.0Kbps pkt loss=0 (0.0%), dup=0 (0.0%), reorder=0 (0.0%) (msec) min avg max last dev loss period: 0.000 0.000 0.000 0.000 0.000 jitter : 47.750 47.750 47.750 47.750 0.000 RTT msec : 3.784 3.784 3.784 3.784 0.000 15:01:41.291 conference.c ....Remove port 3 queued 15:01:41.292 strm00E80484 ...Stream destroying 15:01:41.293 udp00E2D780 ...UDP media transport detached 15:01:41.294 pjsua_media.c ...Media stream call00:0 is destroyed 15:01:41.295 conference.c !.Stop any transmission to port 3 (sip:[email protected];user=phone) 15:01:41.295 srtp00E2F6F8 ..Destroying SRTP transport 15:01:41.296 conference.c !.Port 0 (Wave mapper) stop transmitting to port 3 (sip:[email protected];user=phone) 15:01:41.296 udp00E2D780 !..UDP media transport destroying 15:01:41.297 conference.c .Stop any transmission from port 3 (sip:[email protected];user=phone) 15:01:41.298 pjsua_app.c !.Call 0 is DISCONNECTED [reason=200 (OK)] 15:01:41.299 conference.c !.Port 3 (sip:[email protected];user=phone) stop transmitting to port 0 (Wave mapper) 15:01:41.299 pjsua_core.c ....TX 481 bytes Request msg BYE/cseq=23811 (tdta00E85EF4) to UDP 101.168.0.224:5060: BYE sip:[email protected];transport=UDP SIP/2.0 Via: SIP/2.0/UDP 10.168.1.144:5060;rport;branch=z9hG4bKPj2e5e6e0ffedc4c43a90ae8c7cd59e10b Max-Forwards: 70 From: "AI" sip:[email protected];user=phone;tag=518f252e8ab74753b8d2bc190e8816be To: "寮犱笁涓? sip:[email protected];user=phone;tag=94cdd28867d0a0fb799213cecb3260a0 Call-ID: [email protected] CSeq: 23811 BYE User-Agent: PJSUA v2.15.1 win32-6.2/i386/msvc-19.0 Content-Length: 0
--end msg-- 15:01:41.300 conference.c !.Removed port 3 (sip:[email protected];user=phone), port count=3
15:01:41.301 udp00E2D780 !.UDP media transport destroyed 15:01:41.302 srtp00E2F6F8 .SRTP transport destroyed 15:01:41.302 strm00E80484 .Stream destroyed 15:01:41.811 pjsua_core.c .TX 481 bytes Request msg BYE/cseq=23811 (tdta00E85EF4) to UDP 101.168.0.224:5060: BYE sip:[email protected];transport=UDP SIP/2.0 Via: SIP/2.0/UDP 10.168.1.144:5060;rport;branch=z9hG4bKPj2e5e6e0ffedc4c43a90ae8c7cd59e10b Max-Forwards: 70 From: "AI" sip:[email protected];user=phone;tag=518f252e8ab74753b8d2bc190e8816be To: "寮犱笁涓? sip:[email protected];user=phone;tag=94cdd28867d0a0fb799213cecb3260a0 Call-ID: [email protected] CSeq: 23811 BYE User-Agent: PJSUA v2.15.1 win32-6.2/i386/msvc-19.0 Content-Length: 0
--end msg-- 15:01:42.308 pjsua_aud.c Closing sound device after idle for 1 second(s) 15:01:42.310 pjsua_app.c .Turning sound device -1 -2 OFF 15:01:42.312 pjsua_aud.c .Closing Wave mapper sound playback device and Wave mapper sound capture device 15:01:42.323 wmme_dev.c .Stopped WMME playback stream 15:01:42.338 wmme_dev.c .Stopped WMME capture stream 15:01:42.340 wmme_dev.c .Stopped WMME playback stream 15:01:42.341 wmme_dev.c .Stopped WMME capture stream 15:01:42.820 pjsua_core.c .TX 481 bytes Request msg BYE/cseq=23811 (tdta00E85EF4) to UDP 101.168.0.224:5060: BYE sip:[email protected];transport=UDP SIP/2.0 Via: SIP/2.0/UDP 10.168.1.144:5060;rport;branch=z9hG4bKPj2e5e6e0ffedc4c43a90ae8c7cd59e10b Max-Forwards: 70 From: "AI" sip:[email protected];user=phone;tag=518f252e8ab74753b8d2bc190e8816be To: "寮犱笁涓? sip:[email protected];user=phone;tag=94cdd28867d0a0fb799213cecb3260a0 Call-ID: [email protected] CSeq: 23811 BYE User-Agent: PJSUA v2.15.1 win32-6.2/i386/msvc-19.0 Content-Length: 0
--end msg-- 15:01:43.376 pjsua_core.c .RX 574 bytes Response msg 200/BYE/cseq=23811 (rdata00E27ED4) from UDP 101.168.0.224:5060: SIP/2.0 200 OK Allow: INVITE, ACK, CANCEL, BYE, PRACK, NOTIFY, REFER, SUBSCRIBE, OPTIONS, UPDATE Supported: replaces,timer,path,100rel User-Agent: OmniPCX Enterprise R12.2 m3.402.32 To: "寮犱笁涓? sip:[email protected];user=phone;tag=94cdd28867d0a0fb799213cecb3260a0 From: "AI" sip:[email protected];user=phone;tag=518f252e8ab74753b8d2bc190e8816be Call-ID: [email protected] CSeq: 23811 BYE Via: SIP/2.0/UDP 10.168.1.144:5060;received=10.168.1.144;rport=5060;branch=z9hG4bKPj2e5e6e0ffedc4c43a90ae8c7cd59e10b Content-Length: 0
--end msg-- 15:01:43.382 pjsua_core.c .RX 437 bytes Response msg 481/BYE/cseq=23811 (rdata00E27ED4) from UDP 101.168.0.224:5060: SIP/2.0 481 Call Leg/Transaction Does Not Exist To: "寮犱笁涓? sip:[email protected];user=phone;tag=94cdd28867d0a0fb799213cecb3260a0 From: "AI" sip:[email protected];user=phone;tag=518f252e8ab74753b8d2bc190e8816be Call-ID: [email protected] CSeq: 23811 BYE Via: SIP/2.0/UDP 10.168.1.144:5060;received=10.168.1.144;rport=5060;branch=z9hG4bKPj2e5e6e0ffedc4c43a90ae8c7cd59e10b Content-Length: 0
--end msg-- 15:01:43.382 pjsua_core.c .RX 437 bytes Response msg 481/BYE/cseq=23811 (rdata00E27ED4) from UDP 101.168.0.224:5060: SIP/2.0 481 Call Leg/Transaction Does Not Exist To: "寮犱笁涓? sip:[email protected];user=phone;tag=94cdd28867d0a0fb799213cecb3260a0 From: "AI" sip:[email protected];user=phone;tag=518f252e8ab74753b8d2bc190e8816be Call-ID: [email protected] CSeq: 23811 BYE Via: SIP/2.0/UDP 10.168.1.144:5060;received=10.168.1.144;rport=5060;branch=z9hG4bKPj2e5e6e0ffedc4c43a90ae8c7cd59e10b Content-Length: 0
--end msg--
I've done a bit more research on this. In pjsua2 C++, the std::string content (e.g: in CallInfo.remoteUri) appears to be correct. The problem arises in pjsua2 C#, and as previously suspected, it is very likely introduced in the SWIG conversion from C++ std::string to C# string. If that's the case, some potential alternative solutions include:
- https://stackoverflow.com/questions/19783363/how-to-wrap-utf-8-encoded-c-stdstrings-with-swig-in-c (as mentioned earlier)
- https://www.github.com/swig/swig/pull/2364
Note that both solutions involve modifications to the SWIG library, so I'm afraid there's not much we can do on the PJSIP side.
I've done a bit more research on this. In pjsua2 C++, the
std::stringcontent (e.g: inCallInfo.remoteUri) appears to be correct. The problem arises in pjsua2 C#, and as previously suspected, it is very likely introduced in the SWIG conversion from C++std::stringto C#string. If that's the case, some potential alternative solutions include:
- https://stackoverflow.com/questions/19783363/how-to-wrap-utf-8-encoded-c-stdstrings-with-swig-in-c (as mentioned earlier)
- https://www.github.com/swig/swig/pull/2364
Note that both solutions involve modifications to the SWIG library, so I'm afraid there's not much we can do on the PJSIP side.
Thank you for your help, I use the method of https://stackoverflow.com/questions/19783363/how-to-wrap-utf-8-encoded-c-stdstrings-with-swig-in-c, It can support UTF8 Chinese character display, but I found a bug here. I'm not sure if it's a problem with swig or pjsua2?
When the length of Chinese characters is 3 digits, garbled characters will be displayed when the last character is Chinese.
For instance, "李李李"(including quotation marks), the normal encoding is 22-e6-d9-8e-e6-d9-8e-e6-d9-8e-22. The packet I captured through wireshark was also correct. However, the content captured from pjsua2 will become 22-e6-d9-8e-e6-d9-8e-e6-d9-3f, and one byte will be missing. It's the same when set to other Chinese languages. It seems that 3f is always displayed.
I have also tested it. When the text is less than 2 characters or more than 3 characters, it displays normally. If it is only 3 characters long and the third character is in English, it also displays normally.
