drachtio / drachtio-siprec-recording-server

SIPREC recording server based on drachtio and rtpengine
MIT License
81 stars 31 forks source link

Fix sdp payload parser #60

Closed fabian-borot closed 1 year ago

fabian-borot commented 1 year ago

Adding Asterisk as another media server

fabian-borot commented 1 year ago

This fixes an issue I found both in Freeswitch and in Asterisk. With AcmePacket SBCs, the INVITE with multiple SDPs comes like this: 1- SDP1 has several offerings (i.e. ulaw, alaw, g729, gsm) 2- SDP2 has only the codec chosen for the actual call (ulaw). So the actual call that we want to record was established using 'ulaw' in this case.

So the media server receives an INVITE from drachtio sip server with SDP1, and as such it can choose any codec form the offering, 'alaw' for example. Then when it sends the INVITE back to drachtio server it sends it with the codecs setup for that outbound endpoint but the response from the drachtio sip server chooses the one codec in its SDP2 ('ulaw'). So the media server expects 'alaw' on the A leg and 'ulaw' on the B leg. At this point, the SBC starts sending a copy of the RTP packets, but since the call was established on 'ulaw', all the RTP packets received by the media server will be 'ulaw' packets. This causes the 'wav' file created to contain only the packets from one leg, the other ones are 'dropped'. If you enable 'debug' logs on Asterisk you will see these messages: [Jan 31 16:47:46] DEBUG[27197][C-0000000e] chan_pjsip.c: Oooh, got a frame with format of alaw on channel 'PJSIP/drachtio_in-0000001a' when it has not been negotiated