summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2010-02-17 19:24:02 +0000
committerRonald S. Bultje <rsbultje@gmail.com>2010-02-17 19:24:02 +0000
commitdfd017bf0aa882d3b441a0a22de9171ca0bd0257 (patch)
treea40561bb47d60560d218022cff8154b494e8f8f8 /libavformat
parent69a28f3e2bdbf10ac5b4e73fafa447eb570e1da4 (diff)
Add functions to send RTSP commands with content attached to them. This will
be used eventually in the RTSP muxer (see thread "[PATCH] RTSP muxer, round 3" on mailinglist). Patch by Martin Storsjö <$firstname $firstname st>. Originally committed as revision 21862 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/rtsp.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index f379b781b0..a6584d33fb 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -932,7 +932,10 @@ static int rtsp_read_reply(AVFormatContext *s, RTSPMessageHeader *reply,
return 0;
}
-static void rtsp_send_cmd_async(AVFormatContext *s, const char *cmd)
+static void rtsp_send_cmd_with_content_async(AVFormatContext *s,
+ const char *cmd,
+ const unsigned char *send_content,
+ int send_content_length)
{
RTSPState *rt = s->priv_data;
char buf[4096], buf1[1024];
@@ -949,14 +952,23 @@ static void rtsp_send_cmd_async(AVFormatContext *s, const char *cmd)
av_strlcatf(buf, sizeof(buf),
"Authorization: Basic %s\r\n",
rt->auth_b64);
+ if (send_content_length > 0 && send_content)
+ av_strlcatf(buf, sizeof(buf), "Content-Length: %d\r\n", send_content_length);
av_strlcat(buf, "\r\n", sizeof(buf));
dprintf(s, "Sending:\n%s--\n", buf);
url_write(rt->rtsp_hd, buf, strlen(buf));
+ if (send_content_length > 0 && send_content)
+ url_write(rt->rtsp_hd, send_content, send_content_length);
rt->last_cmd_time = av_gettime();
}
+static void rtsp_send_cmd_async(AVFormatContext *s, const char *cmd)
+{
+ rtsp_send_cmd_with_content_async(s, cmd, NULL, 0);
+}
+
static void rtsp_send_cmd(AVFormatContext *s,
const char *cmd, RTSPMessageHeader *reply,
unsigned char **content_ptr)
@@ -966,6 +978,18 @@ static void rtsp_send_cmd(AVFormatContext *s,
rtsp_read_reply(s, reply, content_ptr, 0);
}
+static void rtsp_send_cmd_with_content(AVFormatContext *s,
+ const char *cmd,
+ RTSPMessageHeader *reply,
+ unsigned char **content_ptr,
+ const unsigned char *send_content,
+ int send_content_length)
+{
+ rtsp_send_cmd_with_content_async(s, cmd, send_content, send_content_length);
+
+ rtsp_read_reply(s, reply, content_ptr, 0);
+}
+
/**
* @returns 0 on success, <0 on error, 1 if protocol is unavailable.
*/