esp-adf icon indicating copy to clipboard operation
esp-adf copied to clipboard

Access Incoming Call Identification or Username from SIP Invite Header (AUD-6162)

Open carlosrodridel opened this issue 9 months ago • 14 comments

Is your feature request related to a problem? Please describe.

Currently, when processing SIP invites in ESP-ADF, we are unable to extract any caller identification details from the "From" header. There is no built-in functionality to access the username or phone number, leaving us without any means to process this information. This limitation complicates handling incoming calls and integrating with SIP-based applications.

Describe the solution you'd like

I would like to see an enhancement in ESP-ADF that automatically parses the "From" header in incoming SIP invites to extract caller identification details. The feature should provide an API that directly returns the username or phone number from the header, eliminating the need for manual parsing. For example :

const char* get_incoming_call_userinfo();

Describe alternatives you've considered

An alternative approach could be to expose the raw SIP packets or provide access to a SIP structure that contains all header information. This would allow developers to implement their own parsing logic for the "From" header. However, having a native solution within ESP-ADF would simplify development and reduce the risk of parsing errors.

Additional context

For example, an incoming SIP invite may include a header like:

From: "+337444XXXXX" <sip:[email protected];user=phone>;tag=15216-DM-dbd66072-00d621094

With this enhancement, ESP-ADF would be able to directly extract and provide access to the caller's phone number ("+337444XXXXX") or the corresponding username, greatly simplifying call management and improving integration with SIP applications.

carlosrodridel avatar Mar 10 '25 15:03 carlosrodridel

I see that already provide a API to get call from which peer const char *esp_rtc_get_peer(esp_rtc_handle_t esp_rtc);. Is it enough for you? https://github.com/espressif/esp-adf-libs/blob/master/esp_media_protocols/include/esp_rtc.h#L169

TempoTian avatar Mar 13 '25 03:03 TempoTian

Hi everyone. Esp_rtc.h file has esp_rtc_set_private_header function which can be used for setting headers, but I can't find any doc for it. Having a function to read any or all headers would be a great advantage.

Hasaken avatar Mar 16 '25 18:03 Hasaken

Private header is just a string, and it will append to each send request to meet special needs of server. The simple realization code as below:

Image

TempoTian avatar Mar 17 '25 02:03 TempoTian

@TempoTian Thank you for the info. What type is "sip" variable in the example above?

And what about reading headers of SIP request incoming to ESP32?

Hasaken avatar Mar 17 '25 04:03 Hasaken

@Hasaken The showed code is in the lib, currently common header are processed by lib directly, if there are special headers user layer need to process, please let me know, I will add API for it.

TempoTian avatar Mar 17 '25 05:03 TempoTian

@TempoTian We have a project built on previous version of ADF. That version had following functions for SIP message processing:

  1. esp_sip_read_incomming_messages - this function was returning sip_messages_info_t structure, having headers of incoming SIP message;
  2. esp_sip_set_invite_info - this function was used to write sip_messages_info_t structure to SIP client message headers before inviting ;

It would be great to have such functions in new versions of ADF.

Hasaken avatar Mar 17 '25 06:03 Hasaken

@TempoTian Any update on the topic?

Hasaken avatar Mar 19 '25 15:03 Hasaken

@Hasaken I have check the code, the mentioned API still existed in sip header file, but not exported through esp_rtc.h. Do you still depedent on the function? If yes, I will try to export it to esp_rtc.h.

TempoTian avatar Mar 21 '25 02:03 TempoTian

@TempoTian Yes, our code depends on those functions. We would be very grateful, if you enable them. So we will move to the up-to-date version of ADF.

Hasaken avatar Mar 21 '25 03:03 Hasaken

@TempoTian Hi Friend! Hope you're doing well and work on enabling those functions. Could you please rename "esp_sip_read_incomMing_messages" function to "esp_sip_read_incoming_messages", also? )) Thanks in advance.

Hasaken avatar Mar 25 '25 03:03 Hasaken

@Hasaken I will build one lib for you soon, but it will needs some time so that I can merge it to libs. You are working on esp32 or esp32s3?

TempoTian avatar Mar 26 '25 02:03 TempoTian

@TempoTian ESP32, currently.

Hasaken avatar Mar 26 '25 05:03 Hasaken

You can use follow lib to test. add_message_info_for_sip.zip Export mapped API out in esp_rtc.h

int esp_rtc_set_invite_info(esp_rtc_handle_t esp_rtc, const esp_rtc_sip_message_info_t *sip_set_info);

int esp_rtc_read_incoming_messages(esp_rtc_handle_t esp_rtc, esp_rtc_sip_message_info_t *sip_read_info);

TempoTian avatar Mar 26 '25 08:03 TempoTian

@TempoTian Thank you! We'll test it asap.

Hasaken avatar Mar 26 '25 08:03 Hasaken