[FFmpeg-devel] [PATCH]User-Agent for rtsp streams
Carl Eugen Hoyos
cehoyos at ag.or.at
Thu Jul 11 12:56:12 CEST 2013
Hi!
Attached a two patches that both fix ticket #2761, the small one was tested by
the OP, the second one is untested.
An alternative would be to send no user-agent by default but only if one was
specified on the command line.
Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c
index da571a8..57d335c 100644
--- a/libavformat/rtspdec.c
+++ b/libavformat/rtspdec.c
@@ -574,6 +574,9 @@ int ff_rtsp_setup_input_streams(AVFormatContext *s, RTSPMessageHeader *reply)
/* describe the stream */
snprintf(cmd, sizeof(cmd),
"Accept: application/sdp\r\n");
+ av_strlcat(cmd,
+ "User-Agent: Lavf/" AV_STRINGIFY(LIBAVFORMAT_VERSION) "\r\n",
+ sizeof(cmd));
if (rt->server_type == RTSP_SERVER_REAL) {
/**
* The Require: attribute is needed for proper streaming from
-------------- next part --------------
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 6310d79..5421bb2 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -62,6 +62,8 @@
#define DEC AV_OPT_FLAG_DECODING_PARAM
#define ENC AV_OPT_FLAG_ENCODING_PARAM
+#define DEFAULT_USER_AGENT "Lavf/" AV_STRINGIFY(LIBAVFORMAT_VERSION)
+
#define RTSP_FLAG_OPTS(name, longname) \
{ name, longname, OFFSET(rtsp_flags), AV_OPT_TYPE_FLAGS, {.i64 = 0}, INT_MIN, INT_MAX, DEC, "rtsp_flags" }, \
{ "filter_src", "Only receive packets from the negotiated peer IP", 0, AV_OPT_TYPE_CONST, {.i64 = RTSP_FLAG_FILTER_SRC}, 0, 0, DEC, "rtsp_flags" }, \
@@ -91,6 +93,7 @@ const AVOption ff_rtsp_options[] = {
{ "timeout", "Maximum timeout (in seconds) to wait for incoming connections. -1 is infinite. Implies flag listen", OFFSET(initial_timeout), AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX, DEC },
{ "stimeout", "timeout (in micro seconds) of socket i/o operations.", OFFSET(stimeout), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, DEC },
RTSP_REORDERING_OPTS(),
+ { "user-agent", "override User-Agent header", OFFSET(user_agent), AV_OPT_TYPE_STRING, {.str = DEFAULT_USER_AGENT}, 0, 0, DEC },
{ NULL },
};
diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h
index 4af3507..9e6e237 100644
--- a/libavformat/rtsp.h
+++ b/libavformat/rtsp.h
@@ -399,6 +399,11 @@ typedef struct RTSPState {
* Size of RTP packet reordering queue.
*/
int reordering_queue_size;
+
+ /**
+ * User-Agent string
+ */
+ char *user_agent;
} RTSPState;
#define RTSP_FLAG_FILTER_SRC 0x1 /**< Filter incoming UDP packets -
diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c
index da571a8..99a21cd 100644
--- a/libavformat/rtspdec.c
+++ b/libavformat/rtspdec.c
@@ -574,6 +574,8 @@ int ff_rtsp_setup_input_streams(AVFormatContext *s, RTSPMessageHeader *reply)
/* describe the stream */
snprintf(cmd, sizeof(cmd),
"Accept: application/sdp\r\n");
+ av_strlcatf(cmd, sizeof(cmd),
+ "User-Agent: %s\r\n", rt->user_agent);
if (rt->server_type == RTSP_SERVER_REAL) {
/**
* The Require: attribute is needed for proper streaming from
More information about the ffmpeg-devel
mailing list