noxxi / p5-net-sip

Net::SIP Perl Module
Other
15 stars 22 forks source link

Add support for DTMF via PCMA #26

Closed pali closed 4 years ago

pali commented 4 years ago

Some telecommunication operators prefer PCMA codec over PCMU. Analogue fixed telephone lines support DTMF only via in-band channel so RFC2833 cannot be used.

This patch adds simple support for generating and extracting DTMF via PCMA codec. PCMU is still preferred and default. DTMF over PCMA would be used only when user explicitly configure PCMA via rtp_param or when remote peer is using PCMA (and not PCMU).

noxxi commented 4 years ago

Thanks for the patch. Could you please add a test for this new functionality to t/19_call_with_dtmf.t too?

pali commented 4 years ago

Done! I added PCMA test into file t/19_call_with_dtmf.t and also added a new simple test t/24_dtmf_audio.t directly for DTMF audio module which does not use SIP.

During testing I found two issues. First issue was that I used incorrect formula for calculating a-law algorithm and second issue was in parsing media attributes in sub dtmf (name 'PCMA/8000' does not have to be present but there can be format 8 which is PCMA). Both issues I fixed and updated pull request.

If you think that that tests should be extended, please let me know. I can imagine another test: generate PCMU DTMF, convert PCMU to PCMA according to ITU-T Rec. G.711 tables and then extract DTMF from this PCMA audio. This could prove that PCMU a PCMA audio code is compatible.

pali commented 4 years ago

@noxxi Anything else related to this pull request is needed?

noxxi commented 4 years ago

Thanks for your contribution. I've merged it into Net::SIP but add some smaller enhancements and fixes on top, see bf9e4fc8d.

pali commented 4 years ago

ok, great!