Why the caller don't hear echo when I'm relpying the RTP packets I receied

无人久伴 提交于 2021-02-11 12:49:41

问题


I'm trying to play audio for who is calling me all by using NodeJS.

He is using SIP and initiate a call. I was able to receive the call and record his audio.

Now I'm trying to use the RTP protocol to play back audio to him.

So what I tried is to save each RTP packet I got, and send it back as is. But I'm don't undestand why he don't hear nothing.

The INVITE command

INVITE sip:1@104.154.78.142 SIP/2.0
Via: SIP/2.0/UDP 31.168.3.211:5060;branch=z9hG4bK071d7c26
Max-Forwards: 70
From: "0555042354" <sip:0523737233@31.168.3.211>;tag=as710f47f3
To: <sip:1@104.154.78.142>
Contact: <sip:0523737233@31.168.3.211:5060>
Call-ID: 36bde5b72f7a67956f7559a8581ea010@31.168.3.211:5060
CSeq: 102 INVITE
User-Agent: Asterisk PBX 11.18.0
Date: Fri, 05 Feb 2021 00:22:51 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 236

v=0
o=root 2117083987 2117083987 IN IP4 31.168.3.211
s=Asterisk PBX 11.18.0
c=IN IP4 31.168.3.211
t=0 0
m=audio 16006 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=sendrecv

I took it's port (15574) from the INVITE command: m=audio 15574 RTP/AVP 8 101 and the IP also from the INVITE command: c=IN IP4 31.168.3.195 Now I'm sending back every UDP packet he sent me. But he don't hear nothing.

(It's after OK, and ACK by him).

ourSocket.on('message', (rtpPacketBuffer) => {
  dgramServer.send(rtpPacketBuffer, 16006, 31.168.3.211)
})

In other words: According to RTP protocol, is sending back the packet can work, or do I need to reconstruct them?

(We're able to hear the other side, and record the call.)


回答1:


In other words: According to RTP protocol, is sending back the packet can work, or do I need to reconstruct them?

You need to construct a dedicated RTP header and add the received payload. SSRC and timestamp must be generated in a meaningful way or the receiver may discard those packets.



来源:https://stackoverflow.com/questions/66055522/why-the-caller-dont-hear-echo-when-im-relpying-the-rtp-packets-i-receied

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!