espressif / esp-adf

Espressif Audio Development Framework
Other
1.48k stars 666 forks source link

RTSP Server stop problem (AUD-5224) #1157

Open matz-9 opened 4 months ago

matz-9 commented 4 months ago

Environment

Problem Description

Hi, I'm using the RTSP example to stream video via RTSP server. I removed the CLI functionalities and I'm trying to stop the RTSP server via the rtsp_service_stop() function provided by the example and I get a "Guru Meditation Error: Core 0 panic'ed (InstrFetchProhibited)". I tried to call the function when receiving the RTSP_STATE_TEARDOWN event (in the switch case) and i also tried to trigger the function using input keys right after starting the server. I get different errors, you can see it below.

Am I choosing the wrong place to call the function? If so, what would be the best point to call it? Thanks in advance.

Debug Logs

THIS IS THE OUTPUT WHEN CALLING IT IN THE TEARDOWN CASE

I (730835) AV_STREAM: _video_enc task stoped

I (730835) RTSP_SERVICE: RTSP_STATE_TEARDOWN

Guru Meditation Error: Core 0 panic'ed (InstrFetchProhibited). Exception was unhandled.

Core 0 register dump:

PC : 0x1112141e PS : 0x00060230 A0 : 0x8207ecd5 A1 : 0x3c243120

A2 : 0x3c213f98 A3 : 0x3c240f9c A4 : 0x2b2d2e26 A5 : 0x000b26d3

A6 : 0x3c158474 A7 : 0x00000000 A8 : 0x8207ecc0 A9 : 0x3c243100

A10 : 0x3c213f98 A11 : 0x3c158474 A12 : 0x3c158630 A13 : 0x3c243120

A14 : 0x3c243100 A15 : 0x0000000c SAR : 0x0000000e EXCCAUSE: 0x00000014

EXCVADDR: 0x1112141c LBEG : 0x40056f5c LEND : 0x40056f72 LCOUNT : 0xffffffff

0x40056f5c: memcpy in ROM

0x40056f72: memcpy in ROM

Backtrace: 0x1112141b:0x3c243120 0x4207ecd2:0x3c243140 0x4207e979:0x3c243160 0x4200dac3:0x3c243180 0x4200db45:0x3c2431a0 0x4207e24c:0x3c2431c0 0x40386026:0x3c243290

0x4207ecd2: rtc_transport_list_destroy at /builds/adf/esp-adf-libs-source/esp_media_protocols/esp_rtc/esp_rtc_media/transport/rtc_transport.c:113

0x4207e979: esp_rtsp_server_stop at /builds/adf/esp-adf-libs-source/esp_media_protocols/esp_rtc/esp_rtc_core/esp_rtsp/esp_rtsp_server.c:511

0x4200dac3: rtsp_service_stop at /home/matteo/esp-v51/esp-rtsp_sso/main/utils/rtsp_service.c:235

0x4200db45: _esp_rtsp_state_handler at /home/matteo/esp-v51/esp-rtsp_sso/main/utils/rtsp_service.c:121 (discriminator 13)

0x4207e24c: _rtsp_server_task at /builds/adf/esp-adf-libs-source/esp_media_protocols/esp_rtc/esp_rtc_core/esp_rtsp/esp_rtsp_server.c:416

0x40386026: vPortTaskWrapper at /home/matteo/esp-v51/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:162

THIS IS THE OUTPUT WHEN CALLING IT WITH INPUT KEY

E (201859) ESP_RTSP_SERVER: Unable to accept connection: errno 128Guru Meditation Error: Core 1 panic'ed (InstrFetchProhibited). Exception was unhandled.

Core 1 register dump:

PC : 0x1112141e PS : 0x00060230 A0 : 0x8207ecd5 A1 : 0x3c1e69f0

A2 : 0x3c213fa8 A3 : 0x3c240fac A4 : 0x2b2d2e26 A5 : 0x00031483

A6 : 0x3c158474 A7 : 0x00000003 A8 : 0x8207ecc0 A9 : 0x3c1e69d0

A10 : 0x3c213fa8 A11 : 0x3c158474 A12 : 0x3c158630 A13 : 0x3c1e69f0

A14 : 0x3c1e69d0 A15 : 0x0000000c SAR : 0x0000000d EXCCAUSE: 0x00000014

EXCVADDR: 0x1112141c LBEG : 0x40056f5c LEND : 0x40056f72 LCOUNT : 0xffffffff

0x40056f5c: memcpy in ROM

0x40056f72: memcpy in ROM

Backtrace: 0x1112141b:0x3c1e69f0 0x4207ecd2:0x3c1e6a10 0x4207e979:0x3c1e6a30 0x4200dac3:0x3c1e6a50 0x4200db61:0x3c1e6a70 0x4200e019:0x3c1e6a90 0x4200f665:0x3c1e6ac0 0x40386026:0x3c1e6b10

0x4207ecd2: rtc_transport_list_destroy at /builds/adf/esp-adf-libs-source/esp_media_protocols/esp_rtc/esp_rtc_media/transport/rtc_transport.c:113

0x4207e979: esp_rtsp_server_stop at /builds/adf/esp-adf-libs-source/esp_media_protocols/esp_rtc/esp_rtc_core/esp_rtsp/esp_rtsp_server.c:511

0x4200dac3: rtsp_service_stop at /home/matteo/esp-v51/esp-rtsp_sso/main/utils/rtsp_service.c:235

0x4200db61: _input_key_service_cb at /home/matteo/esp-v51/esp-rtsp_sso/main/utils/rtsp_service.c:78

0x4200e019: periph_service_callback at /home/matteo/esp-v51/esp-adf/components/esp_dispatcher/periph_service.c:134 (discriminator 4)

0x4200f665: input_key_service_task at /home/matteo/esp-v51/esp-adf/components/input_key_service/input_key_service.c:113

0x40386026: vPortTaskWrapper at /home/matteo/esp-v51/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:162

ahhfzhang commented 4 months ago

Hi @matz-9 ,

In the two situations you mentioned, we should add error processing.

The purpose of RTSP_STATE_TEARDOWN is to tell the user that remote client has disconnected and needs to destroy media resources. You can stop rtsp server at any time after this event, but not within this event, because this will block server tasks.

But there should be no problem pressing the button to stop the service. I need to check further.

Thanks.

matz-9 commented 4 months ago

Hi @ahhfzhang,

Thank you for your answer, please let me know if you have any news. What I'm trying to do is start both the camera and the MicroSD (Korvo 2), to save a frame in the SD, but they seem to be incompatible, so I thought I'd stop RTSP, destroy the peripherals and start the MicroSD.

Thanks.

matz-9 commented 2 months ago

Hi @ahhfzhang, any update on this? (pressing the button to stop the RTSP service)

Thanks.