geeksville / Micro-RTSP

A RTSP video server intended for very small CPUs (ESP32 etc)
MIT License
755 stars 199 forks source link

gstreamer rtsp timeout #31

Open kennycoder opened 4 years ago

kennycoder commented 4 years ago

I'm trying to send video via rtsp through gstreamer but for some reason it's timing out. VLC and ffmpeg work fine. I worked with gstreamer before and it still works fine with other cameras that support RTSP. After a bit of debugging, the handshake is fine: OPTIONS and DESCRIBE commands work perfectly fine. When PLAY command comes from gstreamer, micro-rtsp responds correctly but then no data is transmitted and after pre-defined timeout gstreamer throws an error.

After adding some debugging linkes, this is the output from Micro-RTSP server:

...WiFi connected
192.168.0.23
LinkedListElement (0x3fff5008)-(0x3fff5008)-(0x3fff5008)
Creating TSP streamer
Created streamer width=800, height=600
client: 192.168.0.14
LinkedListElement (0x3fff5008)-(0x3fff56f4)-(0x3fff5008)
Creating RTSP session
==================================
OPTIONS rtsp://192.168.0.23:8554/mjpeg/1 RTSP/1.0
CSeq: 1
User-Agent: GStreamer/1.14.5
User-Agent: RealMedia Player Version 6.0.9.1235 (linux-2.0-libc6-i386-gcc2.95)
ClientChallenge: 9e26d33f2984236010ef6253fb1887f7
CompanyID: KnKV4M4I/B2FjJ1TToLycw==
GUID: 00000000-0000-0000-0000-000000000000
RegionData: 0
PlayerStarttime: [28/03/2003:22:50:23 00:00]
ClientID: Linux_2.4_6.0.9.1235_play32_RN01_EN_586
Date: Fri, 15 May 2020 14:11:08 GMT
==================================
RTSP received OPTIONS
==================================
RTSP/1.0 200 OK
CSeq: 1
Server: MyServer
Public: DESCRIBE, SETUP, TEARDOWN, PLAY
==================================
==================================
DESCRIBE rtsp://192.168.0.23:8554/mjpeg/1 RTSP/1.0
CSeq: 2
User-Agent: GStreamer/1.14.5
Accept: application/sdp
Date: Fri, 15 May 2020 14:11:09 GMT
==================================
RTSP received DESCRIBE
==================================
RTSP/1.0 200 OK
CSeq: 2
Server: MyServer
Date: Thu, Jan 01 1970 00:00:19 GMT
Content-Base: rtsp://192.168.0.23:8554/mjpeg/1/
Content-Type: application/sdp
Content-Length: 94
v=0
o=- 1481765933 1 IN IP4 192.168.0.23
s=
t=0 0
m=video 0 RTP/AVP 26
c=IN IP4 0.0.0.0
==================================
==================================
SETUP rtsp://192.168.0.23:8554/mjpeg/1/ RTSP/1.0
CSeq: 3
User-Agent: GStreamer/1.14.5
Transport: RTP/AVP;unicast;client_port=36808-36809
Date: Fri, 15 May 2020 14:11:10 GMT
==================================
RTSP received SETUP
==================================
RTSP/1.0 200 OK
CSeq: 3
Date: Thu, Jan 01 1970 00:00:20 GMT
Server: MyServer
Transport: RTP/AVP;unicast;destination=192.168.0.20;source=192.168.0.24;client_port=36808-36809;server_port=6970-6971;mode=play
Session: -2147429540
==================================
==================================
PLAY rtsp://192.168.0.23:8554/mjpeg/1/ RTSP/1.0
CSeq: 4
User-Agent: GStreamer/1.14.5
Range: npt=0-
Session: -2147429540
Date: Fri, 15 May 2020 14:11:11 GMT
==================================
RTSP received PLAY
==================================
RTSP/1.0 200 OK
CSeq: 4
Server: MyServer
Date: Thu, Jan 01 1970 00:00:21 GMT
Range: npt=0.000-
Session: -2147429540
RTP-Info: url=rtsp://192.168.0.24:8554/mjpeg/1/track1;seq=0
==================================
==================================
TEARDOWN rtsp://192.168.0.23:8554/mjpeg/1/ RTSP/1.0
CSeq: 5
User-Agent: GStreamer/1.14.5
Session: -2147429540
Date: Fri, 15 May 2020 14:11:17 GMT
==================================
RTSP received TEARDOWN
closing UDP socket
closing UDP socket
closing TCP socket
~LinkedListElement(0x3fff5008)-(0x3fff56f4)-(0x3fff5008)
client: 192.168.0.14
~LinkedListElement after: (0x3fff5008)-(0x3fff5008)LinkedListElement (0x3fff5008)-(0x3fff622c)-(0x3fff5008)
Creating RTSP session
==================================
TEARDOWN rtsp://192.168.0.23:8554/mjpeg/1/ RTSP/1.0
CSeq: 0
User-Agent: GStreamer/1.14.5
Session: -2147429540
Date: Fri, 15 May 2020 14:11:19 GMT
==================================
RTSP received TEARDOWN
closing TCP socket
~LinkedListElement(0x3fff5008)-(0x3fff622c)-(0x3fff5008)

And this is from gstreamer side:

Progress: (connect) Connecting to rtsp://192.168.0.23:8554/mjpeg/1
Progress: (open) Retrieving server options
Progress: (open) Retrieving media info
Progress: (request) SETUP stream 0
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager: latency = 2000
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager: ntp-sync = false
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager: rfc7273-sync = false
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager: ntp-time-source = NTP time based on realtime clock
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager: drop-on-latency = false
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager: max-rtcp-rtp-time-diff = 1000
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager: max-ts-offset-adjustment = 0
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager: buffer-mode = Slave receiver to sender clock
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc1: timeout = 5000000000
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc1: caps = application/x-rtp, media=(string)video, payload=(int)26, clock-rate=(int)90000
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc2: caps = application/x-rtcp
Progress: (open) Opened Stream
Setting pipeline to PLAYING ...
New clock: GstSystemClock
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager: buffer-mode = Slave receiver to sender clock
Progress: (request) Sending PLAY request
Progress: (request) Sending PLAY request
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc1: caps = application/x-rtp, media=(string)video, payload=(int)26, clock-rate=(int)90000, npt-start=(guint64)0, play-speed=(double)1, play-scale=(double)1
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc1.GstPad:src: caps = application/x-rtp, media=(string)video, payload=(int)26, clock-rate=(int)90000, npt-start=(guint64)0, play-speed=(double)1, play-scale=(double)1
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager.GstGhostPad:recv_rtp_sink_0.GstProxyPad:proxypad0: caps = application/x-rtp, media=(string)video, payload=(int)26, clock-rate=(int)90000, npt-start=(guint64)0, play-speed=(double)1, play-scale=(double)1
Progress: (request) Sent PLAY request
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager/GstFunnel:funnel0.GstFunnelPad:funnelpad0: caps = application/x-rtp, media=(string)video, payload=(int)26, clock-rate=(int)90000, npt-start=(guint64)0, play-speed=(double)1, play-scale=(double)1
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager.GstGhostPad:recv_rtp_sink_0: caps = application/x-rtp, media=(string)video, payload=(int)26, clock-rate=(int)90000, npt-start=(guint64)0, play-speed=(double)1, play-scale=(double)1
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc2.GstPad:src: caps = application/x-rtcp
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager.GstGhostPad:recv_rtcp_sink_0.GstProxyPad:proxypad1: caps = application/x-rtcp
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager/GstFunnel:funnel1.GstFunnelPad:funnelpad1: caps = application/x-rtcp
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager.GstGhostPad:recv_rtcp_sink_0: caps = application/x-rtcp
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager/GstFunnel:funnel0.GstFunnelPad:funnelpad0: caps = NULL
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager/GstFunnel:funnel1.GstFunnelPad:funnelpad1: caps = NULL
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager.GstGhostPad:recv_rtp_sink_0.GstProxyPad:proxypad0: caps = NULL
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager.GstGhostPad:recv_rtp_sink_0: caps = NULL
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager.GstGhostPad:recv_rtcp_sink_0.GstProxyPad:proxypad1: caps = NULL
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstRtpBin:manager.GstGhostPad:recv_rtcp_sink_0: caps = NULL
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc1.GstPad:src: caps = NULL
/GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc2.GstPad:src: caps = NULL
ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0: Could not write to resource.
Additional debug info:
gstrtspsrc.c(7671): gst_rtspsrc_close (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0:
Could not send message. (Received end-of-file)
Execution ended after 0:00:08.227758557
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

I know this is not gstreamer support but maybe you have any ideas. Also after accessing rtsp stream twice in a row there is a kernel panic on esp32-cam right after PLAY command is issued:

Core 1 register dump:
PC      : 0x400d32ab  PS      : 0x00060f30  A0      : 0x800d351e  A1      : 0x3ffb1ea0  
A2      : 0x3fff4fec  A3      : 0x00000000  A4      : 0x00003740  A5      : 0x0000044c  
A6      : 0x000004e4  A7      : 0x3fff6378  A8      : 0x800d32a0  A9      : 0x3ffb1e80  
A10     : 0x3fff6678  A11     : 0x3ffb1ed8  A12     : 0x0000d09e  A13     : 0x3ffc875c  
A14     : 0xd4462500  A15     : 0xd4462500  SAR     : 0x00000018  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000000  LBEG    : 0x4000c2e0  LEND    : 0x4000c2f6  LCOUNT  : 0x00000000  

Backtrace: 0x400d32ab:0x3ffb1ea0 0x400d351b:0x3ffb1f00 0x400d370c:0x3ffb1f40 0x400d23db:0x3ffb1f60 0x400d9715:0x3ffb1fb0 0x4008d7c1:0x3ffb1fd0

Rebooting...
christianhelbig commented 1 year ago

This is a long shot since this issue is already 2 years old, but could you ever get this to work? I'm facing a similar issue right now and I need to get this to work for my thesis!