Opened 14 months ago

Last modified 14 months ago

#10578 new defect

send RTSP keep alive even when paused

Reported by: tmc2001 Owned by:
Priority: normal Component: avformat
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description (last modified by tmc2001)

Workflow:

  1. Have a RTSP server that supports Pause.
  2. Have ffmpeg play a video from that server (rtsp://<ipaddr>:...).
  3. Pause the video in ffmpeg (call av_read_pause)
  4. ffmpeg does NOT properly send the keep alive when Paused (either "GET_PARAMETER" or "OPTIONS"). This is the bug.
  5. Since the RTSP server expects the keep alive, after the specified timeout (usually 60s) it closes the connection.

The bug is in:
File: libavformat/rtspdec.c
Method: rtsp_read_packet

This method first does ff_rtsp_fetch_packet, which fails when the server is Paused, causing it to never send the "GET_PARAMETER" or "OPTIONS" which is placed immediately after this call.

Potential easy fix:
Simply move that block of code before ff_rtsp_fetch_packet.

That is, move the entire if block:
if (!(rt->rtsp_flags & RTSP_FLAG_LISTEN)) { ... }

just before the call to:
ret = ff_rtsp_fetch_packet(s, pkt);

I have tested this and it seems to work well for our cases.
Sent this to ffmpeg-devel mailing list as well:
http://ffmpeg.org/pipermail/ffmpeg-devel/2023-August/313608.html

Would appreciate if an experienced DEV would approve and integrate into ffmpeg.
Thank you.

Change History (1)

comment:1 by tmc2001, 14 months ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.