New submission from John Wimer <[email protected]>:

This patch allows the Bandwidth header to be set in RTSP requests. This 
allows RTSP clients to specify the maximum bit rate that the RTSP server 
should stream to them.

Refer to RFC 2326 section 12.6

----------
files: rtsp-bandwidth-header.patch
messages: 12861
priority: normal
status: new
substatus: new
title: rtsp bandwidth header
topic: rtsp
type: patch

________________________________________________
FFmpeg issue tracker <[email protected]>
<https://roundup.ffmpeg.org/issue2407>
________________________________________________
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 86ef13a..c09ed9d 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -787,6 +787,9 @@ typedef struct AVFormatContext {
      */
     int bit_rate;
 
+    /* Maximum bitrate to request from rtsp server. */
+    int max_bitrate;
+
     /* av_read_frame() support */
     AVStream *cur_st;
 #if FF_API_LAVF_UNUSED
diff --git a/libavformat/options.c b/libavformat/options.c
index 27eb8da..eb69e94 100644
--- a/libavformat/options.c
+++ b/libavformat/options.c
@@ -61,6 +61,7 @@ static const AVOption options[]={
 {"fdebug", "print specific debug info", OFFSET(debug), FF_OPT_TYPE_FLAGS, DEFAULT, 0, INT_MAX, E|D, "fdebug"},
 {"ts", NULL, 0, FF_OPT_TYPE_CONST, FF_FDEBUG_TS, INT_MIN, INT_MAX, E|D, "fdebug"},
 {"max_delay", "maximum muxing or demuxing delay in microseconds", OFFSET(max_delay), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, E|D},
+{"bandwidth", "maximum bandwidth", OFFSET(max_bitrate), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, D},
 {NULL},
 };
 
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 643fde3..d458e03 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1071,6 +1071,9 @@ static int make_setup_request(AVFormatContext *s, const char *host, int port,
                         "RealChallenge2: %s, sd=%s\r\n",
                         rt->session_id, real_res, real_csum);
         }
+        if (s->max_bitrate > 0) {
+            av_strlcatf(cmd, sizeof(cmd), "Bandwidth: %i\r\n", s->max_bitrate);
+        }
         ff_rtsp_send_cmd(s, "SETUP", rtsp_st->control_url, cmd, reply, NULL);
         if (reply->status_code == 461 /* Unsupported protocol */ && i == 0) {
             err = 1;
diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c
index 213f709..a058b1c 100644
--- a/libavformat/rtspdec.c
+++ b/libavformat/rtspdec.c
@@ -50,6 +50,9 @@ static int rtsp_read_play(AVFormatContext *s)
                      "Range: npt=%0.3f-\r\n",
                      (double)rt->seek_timestamp / AV_TIME_BASE);
         }
+        if (s->max_bitrate > 0) {
+            av_strlcatf(cmd, sizeof(cmd), "Bandwidth: %i\r\n", s->max_bitrate);
+        }
         ff_rtsp_send_cmd(s, "PLAY", rt->control_uri, cmd, reply, NULL);
         if (reply->status_code != RTSP_STATUS_OK) {
             return -1;

Reply via email to