ONVIF Profile-T Camera RTSP stream stops after 1 minute
When using gstreamer to process RTSP stream from camera with onvif profile-T support, the stream stops after 1 minute.
How to reproduce (Same behaviour on 1.16.2 and 1.17.2):
gst-launch-1.0 rtspsrc location="rtsp://admin:pass@192.168.22.145:554/media/video1" protocols=tcp ! queue ! checksumsink
Profile-T onvif cameras negotiates video and meta data streams
DESCRIBE rtsp://192.168.22.145:554/media/video1 RTSP/1.0
Accept: application/sdp
CSeq: 3
User-Agent: Lavf58.29.100
Authorization: Digest username="admin", realm="999a63d42ca1", nonce="999ad5e322732acb606dae0f68567f11", uri="rtsp://192.168.22.145:554/media/video1", response="999434127ac6b07a2861077c50e2f111"
RTSP/1.0 200 OK
CSeq: 3
Content-Base: rtsp://192.168.22.145:554/media/video1
Content-Length: 546
Content-Type: application/sdp
v=0
o=- 1001 1 IN IP4 192.168.22.145
s=VCP IPC Realtime stream
m=video 0 RTP/AVP 105
c=IN IP4 192.168.22.145
a=control:rtsp://192.168.22.145/media/video1/video
a=rtpmap:105 H264/90000
a=fmtp:105 profile-level-id=640032; packetization-mode=1; sprop-parameter-sets=999q2EAQwgCGEAQwgCGEAQwgCEO1AUAFrTcBAQFAAAD6AAAw1CEA==,aO4xs77=
a=recvonly
m=application 0 RTP/AVP 107
c=IN IP4 192.168.22.145
a=control:rtsp://192.168.22.145/media/video1/metadata
a=rtpmap:107 vnd.onvif.metadata/90000
a=fmtp:107 DecoderTag=h3c-v3 RTCP=0
a=recvonly
Channel media/video1/metadata
receives few packets when the stream starts, then no more packets are sent.
The problem starts to happen after sometime (around 15 seconds after stream starts), with this DEBUG log message:
rtpsession rtpsession.c:3855:session_cleanup:[00m sender source 0e5ab0bb timed out and became receiver, last 44:53:26.230475361
Because the media/video1/metadata
channel is not a continuous stream like media/video1/video
, camera will only send packets when there is some camera event (like motion or tampering). Since no packets are being received, rtp session changed this source to receiver.
After around 20 seconds, rtspsrc decides that this metadata
stream is EOS; with this DEBUG log messages:
rtspsrc gstrtspsrc.c:3458:on_timeout_common:[00m source 0e5ab0bb, stream 0e5ab0bb in session 1 timed out rtspsrc gstrtspsrc.c:3417:gst_rtspsrc_do_stream_eos:[00m setting stream for session 1 to EOS
After some time (normally each minute), camera will send few packets on the media/video1/metadata
channel. When rtsp tries to send this packet to the rtp session, it will find it is EOS already.
rtspsrc gstrtspsrc.c:6043:gst_rtspsrc_loop:[00m pausing task, reason eos
Then rtsp will stop consuming TCP packets, video will freeze and TCP buffers will keep filling up, until it TCP buffer is 100% , then connection will be closed.