espressif / esp-adf

Espressif Audio Development Framework
Other
1.53k stars 671 forks source link

To configure DTMF RTP events duration and volume. (AUD-5521) #1227

Open Zoyolin opened 2 months ago

Zoyolin commented 2 months ago

Describe the situation I use the esp_rtc_send_dtmf to send dtmf events out-of-band as part of the VOIP (rtp/sip) stream. In order for the receiving device to understand them certain durations and volume are required. This arrises even more when the out-of-band dtmf packet reaches a gateway device that converts it in analogue, in band, for a PSTN (non-packetted) telephone network.

The current values I see are :

Describe the solution you'd like

Additional context

Screenshot 2024-07-09 at 11 22 10

To dive deeper in the protocol, here is what I see, none of that is concretely problematic. In the above sniffed packets, the Dtmf event starts on packet N°2468 and ends after 3 end-event packets on N°2881. According to the RFC, the event duration should increase with each non-end-event rtp packet. We sniffed these 9 non-end-event packets a bunch of milliseconds apart (2-5ms) corresponding to increases of roughly about 40units, instead, I see the duration stay fixed. This can be especially practical for a gateway converting an analogue dtmf, in-band, to a digital RTP/SIP, out-of-band, dtmf. It allows for minimal latency and full information. Again, no issue here, the behaviour as is is satisfactory for my current needs.

OS darwin arm64 23.5.0 Visual Studio Code version 1.90.2 Visual Studio Code language en Visual Studio Code shell /bin/zsh ESP-IDF Extension version 1.8.0 Git version 2.45.0 ESP-IDF version v4.4.5 ADF version v2.6-122-g28736657 Python version 3.12.4 Python's pip version 24.0 Chip used: ESP32-S3 custom board Build system: idf.py

TempoTian commented 1 month ago

I think may be int esp_rtc_send_dtmf(esp_rtc_handle_t esp_rtc, uint8_t dtmf_event, uint8_t vol, uint16_t duration (unit ms)); fit your needs. Also I see in code it send all packet at once, is it fit your needs, or do you need to handle the send packet by yoursellf, like provide API `int esp_rtc_send_dtmf(esp_rtc_handle_t esp_rtc, uint8_t dtmf_event, uint8_t vol, uint16_t duration, bool end);, repeat call it to construct a DTMF event.

Zoyolin commented 1 month ago

Hello @TempoTian, Indeed the first prototype API would satisfy us, thanks!! We don't need (at present) to control the rtp packets individually. As you said, int esp_rtc_send_dtmf(esp_rtc_handle_t esp_rtc, uint8_t dtmf_event, uint8_t vol, uint16_t duration (unit ms)); is what we'd need. You're welcome to keep the present behaviour of sending X times the same rtp packet + Y end rtp packets or the alike for resilience.

TempoTian commented 1 month ago

I have implement the new API, you can use library to verify it also. https://github.com/user-attachments/files/16308908/esp_media_protocols.zip

Zoyolin commented 1 month ago

Hi @TempoTian, Thanks a lot for this api! -- I'm on holiday at the moment but will try it soon ! --