mirror of https://git.ffmpeg.org/ffmpeg.git
Split rtsp_send_cmd() into two functions, one for the actual sending of the
command and a second, new function to read the reply to this command. This will make it possible to read server notices that are not in response to a command in future versions, such as EOS or interrupt notices. See "[PATCH] rtsp.c: split rtsp_send_cmd() in a send- and a receive-function" thread. Originally committed as revision 17797 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
6a85fb34c9
commit
29b9f58b37
|
@ -739,35 +739,20 @@ static void rtsp_skip_packet(AVFormatContext *s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rtsp_send_cmd(AVFormatContext *s,
|
static void
|
||||||
const char *cmd, RTSPMessageHeader *reply,
|
rtsp_read_reply (AVFormatContext *s, RTSPMessageHeader *reply,
|
||||||
unsigned char **content_ptr)
|
unsigned char **content_ptr)
|
||||||
{
|
{
|
||||||
RTSPState *rt = s->priv_data;
|
RTSPState *rt = s->priv_data;
|
||||||
char buf[4096], buf1[1024], *q;
|
char buf[4096], buf1[1024], *q;
|
||||||
unsigned char ch;
|
unsigned char ch;
|
||||||
const char *p;
|
const char *p;
|
||||||
int content_length, line_count;
|
int content_length, line_count = 0;
|
||||||
unsigned char *content = NULL;
|
unsigned char *content = NULL;
|
||||||
|
|
||||||
memset(reply, 0, sizeof(*reply));
|
memset(reply, 0, sizeof(*reply));
|
||||||
|
|
||||||
rt->seq++;
|
|
||||||
av_strlcpy(buf, cmd, sizeof(buf));
|
|
||||||
snprintf(buf1, sizeof(buf1), "CSeq: %d\r\n", rt->seq);
|
|
||||||
av_strlcat(buf, buf1, sizeof(buf));
|
|
||||||
if (rt->session_id[0] != '\0' && !strstr(cmd, "\nIf-Match:")) {
|
|
||||||
snprintf(buf1, sizeof(buf1), "Session: %s\r\n", rt->session_id);
|
|
||||||
av_strlcat(buf, buf1, sizeof(buf));
|
|
||||||
}
|
|
||||||
av_strlcat(buf, "\r\n", sizeof(buf));
|
|
||||||
#ifdef DEBUG
|
|
||||||
printf("Sending:\n%s--\n", buf);
|
|
||||||
#endif
|
|
||||||
url_write(rt->rtsp_hd, buf, strlen(buf));
|
|
||||||
|
|
||||||
/* parse reply (XXX: use buffers) */
|
/* parse reply (XXX: use buffers) */
|
||||||
line_count = 0;
|
|
||||||
rt->last_reply[0] = '\0';
|
rt->last_reply[0] = '\0';
|
||||||
for(;;) {
|
for(;;) {
|
||||||
q = buf;
|
q = buf;
|
||||||
|
@ -821,6 +806,30 @@ static void rtsp_send_cmd(AVFormatContext *s,
|
||||||
av_free(content);
|
av_free(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void rtsp_send_cmd(AVFormatContext *s,
|
||||||
|
const char *cmd, RTSPMessageHeader *reply,
|
||||||
|
unsigned char **content_ptr)
|
||||||
|
{
|
||||||
|
RTSPState *rt = s->priv_data;
|
||||||
|
char buf[4096], buf1[1024];
|
||||||
|
|
||||||
|
rt->seq++;
|
||||||
|
av_strlcpy(buf, cmd, sizeof(buf));
|
||||||
|
snprintf(buf1, sizeof(buf1), "CSeq: %d\r\n", rt->seq);
|
||||||
|
av_strlcat(buf, buf1, sizeof(buf));
|
||||||
|
if (rt->session_id[0] != '\0' && !strstr(cmd, "\nIf-Match:")) {
|
||||||
|
snprintf(buf1, sizeof(buf1), "Session: %s\r\n", rt->session_id);
|
||||||
|
av_strlcat(buf, buf1, sizeof(buf));
|
||||||
|
}
|
||||||
|
av_strlcat(buf, "\r\n", sizeof(buf));
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("Sending:\n%s--\n", buf);
|
||||||
|
#endif
|
||||||
|
url_write(rt->rtsp_hd, buf, strlen(buf));
|
||||||
|
|
||||||
|
rtsp_read_reply(rt, reply, content_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* close and free RTSP streams */
|
/* close and free RTSP streams */
|
||||||
static void rtsp_close_streams(RTSPState *rt)
|
static void rtsp_close_streams(RTSPState *rt)
|
||||||
|
|
Loading…
Reference in New Issue