diff mbox series

[FFmpeg-devel,v2,2/2] avformat/rtsp: Send mode=record instead of mode=receive in Transport header

Message ID cb9f2532-877b-4679-a47e-bdfff3184932@gmail.com
State New
Headers show
Series [FFmpeg-devel,v2,1/2] avformat/rtsp: Support mode field of Transport header being sent in upper case | expand

Checks

Context Check Description
andriy/configure_x86 warning Failed to apply patch
yinshiyou/configure_loongarch64 warning Failed to apply patch

Commit Message

Paul Orlyk Jan. 15, 2024, 8:37 p.m. UTC
Fixes server compatibility issues with rtspclientsink GStreamer plugin.

>From specification:
RFC 7826 "Real-Time Streaming Protocol Version 2.0" (https://datatracker.ietf.org/doc/html/rfc7826), section 18.54:
    mode: The mode parameter indicates the methods to be supported for
          this session.  The currently defined valid value is "PLAY".  If
          not provided, the default is "PLAY".  The "RECORD" value was
          defined in RFC 2326; in this specification, it is unspecified
          but reserved.  RECORD and other values may be specified in the
          future.
RFC 2326 "Real Time Streaming Protocol (RTSP)" (https://datatracker.ietf.org/doc/html/rfc2326), section 12.39:
    mode:
           The mode parameter indicates the methods to be supported for
           this session. Valid values are PLAY and RECORD. If not
           provided, the default is PLAY.

mode=receive was always like this, from the initial commit 'a8ad6ffa rtsp: Add listen mode'.

For comparison, Wowza was used to push RTSP stream to. Both GStreamer and FFmpeg had no issues.
Here is the capture of Wowza responding to SETUP request:
200 OK
CSeq: 3
Server: Wowza Streaming Engine 4.8.26+4 build20231212155517
Cache-Control: no-cache
Expires: Mon, 15 Jan 2024 19:40:31 GMT
Transport: RTP/AVP/UDP;unicast;client_port=11640-11641;mode=record;source=172.17.0.2;server_port=6976-6977
Date: Mon, 15 Jan 2024 19:40:31 GMT
Session: 1401457689;timeout=60

Test setup:
     Server: ffmpeg -loglevel trace -y -rtsp_flags listen -i rtsp://0.0.0.0:30800/live.stream t.mp4
     FFmpeg client: ffmpeg -re -i "Big Buck Bunny - FULL HD 30FPS.mp4" -c:v libx264 -f rtsp rtsp://127.0.0.1:30800/live.stream
     GStreamer client: gst-launch-1.0 videotestsrc is-live=true pattern=smpte ! queue ! videorate ! videoscale ! video/x-raw,width=640,height=360,framerate=60/1 ! timeoverlay font-desc="Sans, 84" halignment=center valignment=center ! queue ! videoconvert ! tee name=t t. ! x264enc bitrate=9000 pass=cbr speed-preset=ultrafast byte-stream=false key-int-max=15 threads=1 ! video/x-h264,profile=baseline ! queue ! rsink. audiotestsrc ! voaacenc ! queue ! rsink. t. ! queue ! autovideosink rtspclientsink name=rsink location=rtsp://localhost:30800/live.stream

Test results:
modified FFmpeg client -> stock server    : ok
stock FFmpeg client    -> modified server : ok
modified FFmpeg client -> modified server : ok
GStreamer client       -> modified server : ok

Signed-off-by: Paul Orlyk <paul.orlyk@gmail.com>
---
  libavformat/rtspdec.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Michael Niedermayer Jan. 16, 2024, 12:20 a.m. UTC | #1
On Mon, Jan 15, 2024 at 10:37:25PM +0200, Paul Orlyk wrote:
> Fixes server compatibility issues with rtspclientsink GStreamer plugin.
> 
> > From specification:
> RFC 7826 "Real-Time Streaming Protocol Version 2.0" (https://datatracker.ietf.org/doc/html/rfc7826), section 18.54:
>    mode: The mode parameter indicates the methods to be supported for
>          this session.  The currently defined valid value is "PLAY".  If
>          not provided, the default is "PLAY".  The "RECORD" value was
>          defined in RFC 2326; in this specification, it is unspecified
>          but reserved.  RECORD and other values may be specified in the
>          future.
> RFC 2326 "Real Time Streaming Protocol (RTSP)" (https://datatracker.ietf.org/doc/html/rfc2326), section 12.39:
>    mode:
>           The mode parameter indicates the methods to be supported for
>           this session. Valid values are PLAY and RECORD. If not
>           provided, the default is PLAY.
> 
> mode=receive was always like this, from the initial commit 'a8ad6ffa rtsp: Add listen mode'.
> 
> For comparison, Wowza was used to push RTSP stream to. Both GStreamer and FFmpeg had no issues.
> Here is the capture of Wowza responding to SETUP request:
> 200 OK
> CSeq: 3
> Server: Wowza Streaming Engine 4.8.26+4 build20231212155517
> Cache-Control: no-cache
> Expires: Mon, 15 Jan 2024 19:40:31 GMT
> Transport: RTP/AVP/UDP;unicast;client_port=11640-11641;mode=record;source=172.17.0.2;server_port=6976-6977
> Date: Mon, 15 Jan 2024 19:40:31 GMT
> Session: 1401457689;timeout=60
> 
> Test setup:
>     Server: ffmpeg -loglevel trace -y -rtsp_flags listen -i rtsp://0.0.0.0:30800/live.stream t.mp4
>     FFmpeg client: ffmpeg -re -i "Big Buck Bunny - FULL HD 30FPS.mp4" -c:v libx264 -f rtsp rtsp://127.0.0.1:30800/live.stream
>     GStreamer client: gst-launch-1.0 videotestsrc is-live=true pattern=smpte ! queue ! videorate ! videoscale ! video/x-raw,width=640,height=360,framerate=60/1 ! timeoverlay font-desc="Sans, 84" halignment=center valignment=center ! queue ! videoconvert ! tee name=t t. ! x264enc bitrate=9000 pass=cbr speed-preset=ultrafast byte-stream=false key-int-max=15 threads=1 ! video/x-h264,profile=baseline ! queue ! rsink. audiotestsrc ! voaacenc ! queue ! rsink. t. ! queue ! autovideosink rtspclientsink name=rsink location=rtsp://localhost:30800/live.stream
> 
> Test results:
> modified FFmpeg client -> stock server    : ok
> stock FFmpeg client    -> modified server : ok
> modified FFmpeg client -> modified server : ok
> GStreamer client       -> modified server : ok
> 
> Signed-off-by: Paul Orlyk <paul.orlyk@gmail.com>
> ---
>  libavformat/rtspdec.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Thats a nice commit message
will apply

thx

[...]
diff mbox series

Patch

diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c
index 39fd92fb66..d6a223cbc6 100644
--- a/libavformat/rtspdec.c
+++ b/libavformat/rtspdec.c
@@ -303,7 +303,7 @@  static int rtsp_read_setup(AVFormatContext *s, char* host, char *controlurl)
          rtsp_st->interleaved_min = request.transports[0].interleaved_min;
          rtsp_st->interleaved_max = request.transports[0].interleaved_max;
          snprintf(responseheaders, sizeof(responseheaders), "Transport: "
-                 "RTP/AVP/TCP;unicast;mode=receive;interleaved=%d-%d"
+                 "RTP/AVP/TCP;unicast;mode=record;interleaved=%d-%d"
                   "\r\n", request.transports[0].interleaved_min,
                   request.transports[0].interleaved_max);
      } else {
@@ -333,7 +333,7 @@  static int rtsp_read_setup(AVFormatContext *s, char* host, char *controlurl)
  
          localport = ff_rtp_get_local_rtp_port(rtsp_st->rtp_handle);
          snprintf(responseheaders, sizeof(responseheaders), "Transport: "
-                 "RTP/AVP/UDP;unicast;mode=receive;source=%s;"
+                 "RTP/AVP/UDP;unicast;mode=record;source=%s;"
                   "client_port=%d-%d;server_port=%d-%d\r\n",
                   host, request.transports[0].client_port_min,
                   request.transports[0].client_port_max, localport,