|
|
@ -42,6 +42,7 @@ |
|
|
|
#include "version.h" |
|
|
|
#include "version.h" |
|
|
|
#include "ffserver.h" |
|
|
|
#include "ffserver.h" |
|
|
|
#include "random.h" |
|
|
|
#include "random.h" |
|
|
|
|
|
|
|
#include "avstring.h" |
|
|
|
|
|
|
|
|
|
|
|
#undef exit |
|
|
|
#undef exit |
|
|
|
|
|
|
|
|
|
|
@ -390,7 +391,7 @@ static void start_children(FFStream *feed) |
|
|
|
close(i); |
|
|
|
close(i); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pstrcpy(pathname, sizeof(pathname), my_program_name); |
|
|
|
av_strlcpy(pathname, my_program_name, sizeof(pathname)); |
|
|
|
|
|
|
|
|
|
|
|
slash = strrchr(pathname, '/'); |
|
|
|
slash = strrchr(pathname, '/'); |
|
|
|
if (!slash) { |
|
|
|
if (!slash) { |
|
|
@ -1144,17 +1145,17 @@ static void compute_real_filename(char *filename, int max_size) |
|
|
|
FFStream *stream; |
|
|
|
FFStream *stream; |
|
|
|
|
|
|
|
|
|
|
|
/* compute filename by matching without the file extensions */ |
|
|
|
/* compute filename by matching without the file extensions */ |
|
|
|
pstrcpy(file1, sizeof(file1), filename); |
|
|
|
av_strlcpy(file1, filename, sizeof(file1)); |
|
|
|
p = strrchr(file1, '.'); |
|
|
|
p = strrchr(file1, '.'); |
|
|
|
if (p) |
|
|
|
if (p) |
|
|
|
*p = '\0'; |
|
|
|
*p = '\0'; |
|
|
|
for(stream = first_stream; stream != NULL; stream = stream->next) { |
|
|
|
for(stream = first_stream; stream != NULL; stream = stream->next) { |
|
|
|
pstrcpy(file2, sizeof(file2), stream->filename); |
|
|
|
av_strlcpy(file2, stream->filename, sizeof(file2)); |
|
|
|
p = strrchr(file2, '.'); |
|
|
|
p = strrchr(file2, '.'); |
|
|
|
if (p) |
|
|
|
if (p) |
|
|
|
*p = '\0'; |
|
|
|
*p = '\0'; |
|
|
|
if (!strcmp(file1, file2)) { |
|
|
|
if (!strcmp(file1, file2)) { |
|
|
|
pstrcpy(filename, max_size, stream->filename); |
|
|
|
av_strlcpy(filename, stream->filename, max_size); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1187,7 +1188,7 @@ static int http_parse_request(HTTPContext *c) |
|
|
|
|
|
|
|
|
|
|
|
p = c->buffer; |
|
|
|
p = c->buffer; |
|
|
|
get_word(cmd, sizeof(cmd), (const char **)&p); |
|
|
|
get_word(cmd, sizeof(cmd), (const char **)&p); |
|
|
|
pstrcpy(c->method, sizeof(c->method), cmd); |
|
|
|
av_strlcpy(c->method, cmd, sizeof(c->method)); |
|
|
|
|
|
|
|
|
|
|
|
if (!strcmp(cmd, "GET")) |
|
|
|
if (!strcmp(cmd, "GET")) |
|
|
|
c->post = 0; |
|
|
|
c->post = 0; |
|
|
@ -1197,13 +1198,13 @@ static int http_parse_request(HTTPContext *c) |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
|
|
get_word(url, sizeof(url), (const char **)&p); |
|
|
|
get_word(url, sizeof(url), (const char **)&p); |
|
|
|
pstrcpy(c->url, sizeof(c->url), url); |
|
|
|
av_strlcpy(c->url, url, sizeof(c->url)); |
|
|
|
|
|
|
|
|
|
|
|
get_word(protocol, sizeof(protocol), (const char **)&p); |
|
|
|
get_word(protocol, sizeof(protocol), (const char **)&p); |
|
|
|
if (strcmp(protocol, "HTTP/1.0") && strcmp(protocol, "HTTP/1.1")) |
|
|
|
if (strcmp(protocol, "HTTP/1.0") && strcmp(protocol, "HTTP/1.1")) |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
|
|
pstrcpy(c->protocol, sizeof(c->protocol), protocol); |
|
|
|
av_strlcpy(c->protocol, protocol, sizeof(c->protocol)); |
|
|
|
|
|
|
|
|
|
|
|
if (ffserver_debug) |
|
|
|
if (ffserver_debug) |
|
|
|
http_log("New connection: %s %s\n", cmd, url); |
|
|
|
http_log("New connection: %s %s\n", cmd, url); |
|
|
@ -1211,13 +1212,13 @@ static int http_parse_request(HTTPContext *c) |
|
|
|
/* find the filename and the optional info string in the request */ |
|
|
|
/* find the filename and the optional info string in the request */ |
|
|
|
p = strchr(url, '?'); |
|
|
|
p = strchr(url, '?'); |
|
|
|
if (p) { |
|
|
|
if (p) { |
|
|
|
pstrcpy(info, sizeof(info), p); |
|
|
|
av_strlcpy(info, p, sizeof(info)); |
|
|
|
*p = '\0'; |
|
|
|
*p = '\0'; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
info[0] = '\0'; |
|
|
|
info[0] = '\0'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pstrcpy(filename, sizeof(filename)-1, url + ((*url == '/') ? 1 : 0)); |
|
|
|
av_strlcpy(filename, url + ((*url == '/') ? 1 : 0), sizeof(filename)-1); |
|
|
|
|
|
|
|
|
|
|
|
for (p = c->buffer; *p && *p != '\r' && *p != '\n'; ) { |
|
|
|
for (p = c->buffer; *p && *p != '\r' && *p != '\n'; ) { |
|
|
|
if (strncasecmp(p, "User-Agent:", 11) == 0) { |
|
|
|
if (strncasecmp(p, "User-Agent:", 11) == 0) { |
|
|
@ -1254,7 +1255,7 @@ static int http_parse_request(HTTPContext *c) |
|
|
|
|
|
|
|
|
|
|
|
// "redirect" / request to index.html
|
|
|
|
// "redirect" / request to index.html
|
|
|
|
if (!strlen(filename)) |
|
|
|
if (!strlen(filename)) |
|
|
|
pstrcpy(filename, sizeof(filename) - 1, "index.html"); |
|
|
|
av_strlcpy(filename, "index.html", sizeof(filename) - 1); |
|
|
|
|
|
|
|
|
|
|
|
stream = first_stream; |
|
|
|
stream = first_stream; |
|
|
|
while (stream != NULL) { |
|
|
|
while (stream != NULL) { |
|
|
@ -1392,7 +1393,7 @@ static int http_parse_request(HTTPContext *c) |
|
|
|
{ |
|
|
|
{ |
|
|
|
char hostname[256], *p; |
|
|
|
char hostname[256], *p; |
|
|
|
/* extract only hostname */ |
|
|
|
/* extract only hostname */ |
|
|
|
pstrcpy(hostname, sizeof(hostname), hostbuf); |
|
|
|
av_strlcpy(hostname, hostbuf, sizeof(hostname)); |
|
|
|
p = strrchr(hostname, ':'); |
|
|
|
p = strrchr(hostname, ':'); |
|
|
|
if (p) |
|
|
|
if (p) |
|
|
|
*p = '\0'; |
|
|
|
*p = '\0'; |
|
|
@ -1634,7 +1635,7 @@ static void compute_stats(HTTPContext *c) |
|
|
|
char *eosf; |
|
|
|
char *eosf; |
|
|
|
|
|
|
|
|
|
|
|
if (stream->feed != stream) { |
|
|
|
if (stream->feed != stream) { |
|
|
|
pstrcpy(sfilename, sizeof(sfilename) - 10, stream->filename); |
|
|
|
av_strlcpy(sfilename, stream->filename, sizeof(sfilename) - 10); |
|
|
|
eosf = sfilename + strlen(sfilename); |
|
|
|
eosf = sfilename + strlen(sfilename); |
|
|
|
if (eosf - sfilename >= 4) { |
|
|
|
if (eosf - sfilename >= 4) { |
|
|
|
if (strcmp(eosf - 4, ".asf") == 0) { |
|
|
|
if (strcmp(eosf - 4, ".asf") == 0) { |
|
|
@ -1998,14 +1999,14 @@ static int http_prepare_data(HTTPContext *c) |
|
|
|
switch(c->state) { |
|
|
|
switch(c->state) { |
|
|
|
case HTTPSTATE_SEND_DATA_HEADER: |
|
|
|
case HTTPSTATE_SEND_DATA_HEADER: |
|
|
|
memset(&c->fmt_ctx, 0, sizeof(c->fmt_ctx)); |
|
|
|
memset(&c->fmt_ctx, 0, sizeof(c->fmt_ctx)); |
|
|
|
pstrcpy(c->fmt_ctx.author, sizeof(c->fmt_ctx.author), |
|
|
|
av_strlcpy(c->fmt_ctx.author, c->stream->author, |
|
|
|
c->stream->author); |
|
|
|
sizeof(c->fmt_ctx.author)); |
|
|
|
pstrcpy(c->fmt_ctx.comment, sizeof(c->fmt_ctx.comment), |
|
|
|
av_strlcpy(c->fmt_ctx.comment, c->stream->comment, |
|
|
|
c->stream->comment); |
|
|
|
sizeof(c->fmt_ctx.comment)); |
|
|
|
pstrcpy(c->fmt_ctx.copyright, sizeof(c->fmt_ctx.copyright), |
|
|
|
av_strlcpy(c->fmt_ctx.copyright, c->stream->copyright, |
|
|
|
c->stream->copyright); |
|
|
|
sizeof(c->fmt_ctx.copyright)); |
|
|
|
pstrcpy(c->fmt_ctx.title, sizeof(c->fmt_ctx.title), |
|
|
|
av_strlcpy(c->fmt_ctx.title, c->stream->title, |
|
|
|
c->stream->title); |
|
|
|
sizeof(c->fmt_ctx.title)); |
|
|
|
|
|
|
|
|
|
|
|
/* open output stream by using specified codecs */ |
|
|
|
/* open output stream by using specified codecs */ |
|
|
|
c->fmt_ctx.oformat = c->stream->fmt; |
|
|
|
c->fmt_ctx.oformat = c->stream->fmt; |
|
|
@ -2586,9 +2587,9 @@ static int rtsp_parse_request(HTTPContext *c) |
|
|
|
get_word(url, sizeof(url), &p); |
|
|
|
get_word(url, sizeof(url), &p); |
|
|
|
get_word(protocol, sizeof(protocol), &p); |
|
|
|
get_word(protocol, sizeof(protocol), &p); |
|
|
|
|
|
|
|
|
|
|
|
pstrcpy(c->method, sizeof(c->method), cmd); |
|
|
|
av_strlcpy(c->method, cmd, sizeof(c->method)); |
|
|
|
pstrcpy(c->url, sizeof(c->url), url); |
|
|
|
av_strlcpy(c->url, url, sizeof(c->url)); |
|
|
|
pstrcpy(c->protocol, sizeof(c->protocol), protocol); |
|
|
|
av_strlcpy(c->protocol, protocol, sizeof(c->protocol)); |
|
|
|
|
|
|
|
|
|
|
|
c->pb = &pb1; |
|
|
|
c->pb = &pb1; |
|
|
|
if (url_open_dyn_buf(c->pb) < 0) { |
|
|
|
if (url_open_dyn_buf(c->pb) < 0) { |
|
|
@ -3073,7 +3074,7 @@ static void rtsp_cmd_teardown(HTTPContext *c, const char *url, RTSPHeader *h) |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pstrcpy(session_id, sizeof(session_id), rtp_c->session_id); |
|
|
|
av_strlcpy(session_id, rtp_c->session_id, sizeof(session_id)); |
|
|
|
|
|
|
|
|
|
|
|
/* abort the session */ |
|
|
|
/* abort the session */ |
|
|
|
close_connection(rtp_c); |
|
|
|
close_connection(rtp_c); |
|
|
@ -3115,7 +3116,7 @@ static HTTPContext *rtp_new_connection(struct sockaddr_in *from_addr, |
|
|
|
goto fail; |
|
|
|
goto fail; |
|
|
|
nb_connections++; |
|
|
|
nb_connections++; |
|
|
|
c->stream = stream; |
|
|
|
c->stream = stream; |
|
|
|
pstrcpy(c->session_id, sizeof(c->session_id), session_id); |
|
|
|
av_strlcpy(c->session_id, session_id, sizeof(c->session_id)); |
|
|
|
c->state = HTTPSTATE_READY; |
|
|
|
c->state = HTTPSTATE_READY; |
|
|
|
c->is_packetized = 1; |
|
|
|
c->is_packetized = 1; |
|
|
|
c->rtp_protocol = rtp_protocol; |
|
|
|
c->rtp_protocol = rtp_protocol; |
|
|
@ -3135,8 +3136,8 @@ static HTTPContext *rtp_new_connection(struct sockaddr_in *from_addr, |
|
|
|
proto_str = "???"; |
|
|
|
proto_str = "???"; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
pstrcpy(c->protocol, sizeof(c->protocol), "RTP/"); |
|
|
|
av_strlcpy(c->protocol, "RTP/", sizeof(c->protocol)); |
|
|
|
pstrcat(c->protocol, sizeof(c->protocol), proto_str); |
|
|
|
av_strlcat(c->protocol, proto_str, sizeof(c->protocol)); |
|
|
|
|
|
|
|
|
|
|
|
current_bandwidth += stream->bandwidth; |
|
|
|
current_bandwidth += stream->bandwidth; |
|
|
|
|
|
|
|
|
|
|
|