|
|
@ -592,7 +592,7 @@ static void start_multicast(void) |
|
|
|
int default_port, stream_index; |
|
|
|
int default_port, stream_index; |
|
|
|
|
|
|
|
|
|
|
|
default_port = 6000; |
|
|
|
default_port = 6000; |
|
|
|
for(stream = first_stream; stream != NULL; stream = stream->next) { |
|
|
|
for(stream = first_stream; stream; stream = stream->next) { |
|
|
|
if (stream->is_multicast) { |
|
|
|
if (stream->is_multicast) { |
|
|
|
unsigned random0 = av_lfg_get(&random_state); |
|
|
|
unsigned random0 = av_lfg_get(&random_state); |
|
|
|
unsigned random1 = av_lfg_get(&random_state); |
|
|
|
unsigned random1 = av_lfg_get(&random_state); |
|
|
@ -696,7 +696,7 @@ static int http_server(void) |
|
|
|
/* wait for events on each HTTP handle */ |
|
|
|
/* wait for events on each HTTP handle */ |
|
|
|
c = first_http_ctx; |
|
|
|
c = first_http_ctx; |
|
|
|
delay = 1000; |
|
|
|
delay = 1000; |
|
|
|
while (c != NULL) { |
|
|
|
while (c) { |
|
|
|
int fd; |
|
|
|
int fd; |
|
|
|
fd = c->fd; |
|
|
|
fd = c->fd; |
|
|
|
switch(c->state) { |
|
|
|
switch(c->state) { |
|
|
@ -763,7 +763,7 @@ static int http_server(void) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* now handle the events */ |
|
|
|
/* now handle the events */ |
|
|
|
for(c = first_http_ctx; c != NULL; c = c_next) { |
|
|
|
for(c = first_http_ctx; c; c = c_next) { |
|
|
|
c_next = c->next; |
|
|
|
c_next = c->next; |
|
|
|
if (handle_connection(c) < 0) { |
|
|
|
if (handle_connection(c) < 0) { |
|
|
|
log_connection(c); |
|
|
|
log_connection(c); |
|
|
@ -881,7 +881,7 @@ static void close_connection(HTTPContext *c) |
|
|
|
|
|
|
|
|
|
|
|
/* remove connection from list */ |
|
|
|
/* remove connection from list */ |
|
|
|
cp = &first_http_ctx; |
|
|
|
cp = &first_http_ctx; |
|
|
|
while ((*cp) != NULL) { |
|
|
|
while (*cp) { |
|
|
|
c1 = *cp; |
|
|
|
c1 = *cp; |
|
|
|
if (c1 == c) |
|
|
|
if (c1 == c) |
|
|
|
*cp = c->next; |
|
|
|
*cp = c->next; |
|
|
@ -890,7 +890,7 @@ static void close_connection(HTTPContext *c) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* remove references, if any (XXX: do it faster) */ |
|
|
|
/* remove references, if any (XXX: do it faster) */ |
|
|
|
for(c1 = first_http_ctx; c1 != NULL; c1 = c1->next) { |
|
|
|
for(c1 = first_http_ctx; c1; c1 = c1->next) { |
|
|
|
if (c1->rtsp_c == c) |
|
|
|
if (c1->rtsp_c == c) |
|
|
|
c1->rtsp_c = NULL; |
|
|
|
c1->rtsp_c = NULL; |
|
|
|
} |
|
|
|
} |
|
|
@ -1486,7 +1486,7 @@ static void compute_real_filename(char *filename, int max_size) |
|
|
|
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; stream = stream->next) { |
|
|
|
av_strlcpy(file2, stream->filename, sizeof(file2)); |
|
|
|
av_strlcpy(file2, stream->filename, sizeof(file2)); |
|
|
|
p = strrchr(file2, '.'); |
|
|
|
p = strrchr(file2, '.'); |
|
|
|
if (p) |
|
|
|
if (p) |
|
|
@ -1595,7 +1595,7 @@ static int http_parse_request(HTTPContext *c) |
|
|
|
av_strlcpy(filename, "index.html", sizeof(filename) - 1); |
|
|
|
av_strlcpy(filename, "index.html", sizeof(filename) - 1); |
|
|
|
|
|
|
|
|
|
|
|
stream = first_stream; |
|
|
|
stream = first_stream; |
|
|
|
while (stream != NULL) { |
|
|
|
while (stream) { |
|
|
|
if (!strcmp(stream->filename, filename) && validate_acl(stream, c)) |
|
|
|
if (!strcmp(stream->filename, filename) && validate_acl(stream, c)) |
|
|
|
break; |
|
|
|
break; |
|
|
|
stream = stream->next; |
|
|
|
stream = stream->next; |
|
|
@ -1974,7 +1974,7 @@ static void compute_status(HTTPContext *c) |
|
|
|
avio_printf(pb, "<table cellspacing=0 cellpadding=4>\n"); |
|
|
|
avio_printf(pb, "<table cellspacing=0 cellpadding=4>\n"); |
|
|
|
avio_printf(pb, "<tr><th valign=top>Path<th align=left>Served<br>Conns<th><br>bytes<th valign=top>Format<th>Bit rate<br>kbits/s<th align=left>Video<br>kbits/s<th><br>Codec<th align=left>Audio<br>kbits/s<th><br>Codec<th align=left valign=top>Feed\n"); |
|
|
|
avio_printf(pb, "<tr><th valign=top>Path<th align=left>Served<br>Conns<th><br>bytes<th valign=top>Format<th>Bit rate<br>kbits/s<th align=left>Video<br>kbits/s<th><br>Codec<th align=left>Audio<br>kbits/s<th><br>Codec<th align=left valign=top>Feed\n"); |
|
|
|
stream = first_stream; |
|
|
|
stream = first_stream; |
|
|
|
while (stream != NULL) { |
|
|
|
while (stream) { |
|
|
|
char sfilename[1024]; |
|
|
|
char sfilename[1024]; |
|
|
|
char *eosf; |
|
|
|
char *eosf; |
|
|
|
|
|
|
|
|
|
|
@ -2063,7 +2063,7 @@ static void compute_status(HTTPContext *c) |
|
|
|
avio_printf(pb, "</table>\n"); |
|
|
|
avio_printf(pb, "</table>\n"); |
|
|
|
|
|
|
|
|
|
|
|
stream = first_stream; |
|
|
|
stream = first_stream; |
|
|
|
while (stream != NULL) { |
|
|
|
while (stream) { |
|
|
|
if (stream->feed == stream) { |
|
|
|
if (stream->feed == stream) { |
|
|
|
avio_printf(pb, "<h2>Feed %s</h2>", stream->filename); |
|
|
|
avio_printf(pb, "<h2>Feed %s</h2>", stream->filename); |
|
|
|
if (stream->pid) { |
|
|
|
if (stream->pid) { |
|
|
@ -2141,7 +2141,7 @@ static void compute_status(HTTPContext *c) |
|
|
|
avio_printf(pb, "<tr><th>#<th>File<th>IP<th>Proto<th>State<th>Target bits/sec<th>Actual bits/sec<th>Bytes transferred\n"); |
|
|
|
avio_printf(pb, "<tr><th>#<th>File<th>IP<th>Proto<th>State<th>Target bits/sec<th>Actual bits/sec<th>Bytes transferred\n"); |
|
|
|
c1 = first_http_ctx; |
|
|
|
c1 = first_http_ctx; |
|
|
|
i = 0; |
|
|
|
i = 0; |
|
|
|
while (c1 != NULL) { |
|
|
|
while (c1) { |
|
|
|
int bitrate; |
|
|
|
int bitrate; |
|
|
|
int j; |
|
|
|
int j; |
|
|
|
|
|
|
|
|
|
|
@ -2785,7 +2785,7 @@ static int http_receive_data(HTTPContext *c) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* wake up any waiting connections */ |
|
|
|
/* wake up any waiting connections */ |
|
|
|
for(c1 = first_http_ctx; c1 != NULL; c1 = c1->next) { |
|
|
|
for(c1 = first_http_ctx; c1; c1 = c1->next) { |
|
|
|
if (c1->state == HTTPSTATE_WAIT_FEED && |
|
|
|
if (c1->state == HTTPSTATE_WAIT_FEED && |
|
|
|
c1->stream->feed == c->stream->feed) |
|
|
|
c1->stream->feed == c->stream->feed) |
|
|
|
c1->state = HTTPSTATE_SEND_DATA; |
|
|
|
c1->state = HTTPSTATE_SEND_DATA; |
|
|
@ -2841,7 +2841,7 @@ static int http_receive_data(HTTPContext *c) |
|
|
|
c->stream->feed_opened = 0; |
|
|
|
c->stream->feed_opened = 0; |
|
|
|
close(c->feed_fd); |
|
|
|
close(c->feed_fd); |
|
|
|
/* wake up any waiting connections to stop waiting for feed */ |
|
|
|
/* wake up any waiting connections to stop waiting for feed */ |
|
|
|
for(c1 = first_http_ctx; c1 != NULL; c1 = c1->next) { |
|
|
|
for(c1 = first_http_ctx; c1; c1 = c1->next) { |
|
|
|
if (c1->state == HTTPSTATE_WAIT_FEED && |
|
|
|
if (c1->state == HTTPSTATE_WAIT_FEED && |
|
|
|
c1->stream->feed == c->stream->feed) |
|
|
|
c1->stream->feed == c->stream->feed) |
|
|
|
c1->state = HTTPSTATE_SEND_DATA_TRAILER; |
|
|
|
c1->state = HTTPSTATE_SEND_DATA_TRAILER; |
|
|
@ -3043,7 +3043,7 @@ static void rtsp_cmd_describe(HTTPContext *c, const char *url) |
|
|
|
if (*path == '/') |
|
|
|
if (*path == '/') |
|
|
|
path++; |
|
|
|
path++; |
|
|
|
|
|
|
|
|
|
|
|
for(stream = first_stream; stream != NULL; stream = stream->next) { |
|
|
|
for(stream = first_stream; stream; stream = stream->next) { |
|
|
|
if (!stream->is_feed && |
|
|
|
if (!stream->is_feed && |
|
|
|
stream->fmt && !strcmp(stream->fmt->name, "rtp") && |
|
|
|
stream->fmt && !strcmp(stream->fmt->name, "rtp") && |
|
|
|
!strcmp(path, stream->filename)) { |
|
|
|
!strcmp(path, stream->filename)) { |
|
|
@ -3081,7 +3081,7 @@ static HTTPContext *find_rtp_session(const char *session_id) |
|
|
|
if (session_id[0] == '\0') |
|
|
|
if (session_id[0] == '\0') |
|
|
|
return NULL; |
|
|
|
return NULL; |
|
|
|
|
|
|
|
|
|
|
|
for(c = first_http_ctx; c != NULL; c = c->next) { |
|
|
|
for(c = first_http_ctx; c; c = c->next) { |
|
|
|
if (!strcmp(c->session_id, session_id)) |
|
|
|
if (!strcmp(c->session_id, session_id)) |
|
|
|
return c; |
|
|
|
return c; |
|
|
|
} |
|
|
|
} |
|
|
@ -3121,7 +3121,7 @@ static void rtsp_cmd_setup(HTTPContext *c, const char *url, |
|
|
|
path++; |
|
|
|
path++; |
|
|
|
|
|
|
|
|
|
|
|
/* now check each stream */ |
|
|
|
/* now check each stream */ |
|
|
|
for(stream = first_stream; stream != NULL; stream = stream->next) { |
|
|
|
for(stream = first_stream; stream; stream = stream->next) { |
|
|
|
if (!stream->is_feed && |
|
|
|
if (!stream->is_feed && |
|
|
|
stream->fmt && !strcmp(stream->fmt->name, "rtp")) { |
|
|
|
stream->fmt && !strcmp(stream->fmt->name, "rtp")) { |
|
|
|
/* accept aggregate filenames only if single stream */ |
|
|
|
/* accept aggregate filenames only if single stream */ |
|
|
@ -3582,7 +3582,7 @@ static void remove_stream(FFStream *stream) |
|
|
|
{ |
|
|
|
{ |
|
|
|
FFStream **ps; |
|
|
|
FFStream **ps; |
|
|
|
ps = &first_stream; |
|
|
|
ps = &first_stream; |
|
|
|
while (*ps != NULL) { |
|
|
|
while (*ps) { |
|
|
|
if (*ps == stream) |
|
|
|
if (*ps == stream) |
|
|
|
*ps = (*ps)->next; |
|
|
|
*ps = (*ps)->next; |
|
|
|
else |
|
|
|
else |
|
|
@ -3648,7 +3648,7 @@ static void build_file_streams(void) |
|
|
|
int i, ret; |
|
|
|
int i, ret; |
|
|
|
|
|
|
|
|
|
|
|
/* gather all streams */ |
|
|
|
/* gather all streams */ |
|
|
|
for(stream = first_stream; stream != NULL; stream = stream_next) { |
|
|
|
for(stream = first_stream; stream; stream = stream_next) { |
|
|
|
AVFormatContext *infile = NULL; |
|
|
|
AVFormatContext *infile = NULL; |
|
|
|
stream_next = stream->next; |
|
|
|
stream_next = stream->next; |
|
|
|
if (stream->stream_type == STREAM_TYPE_LIVE && |
|
|
|
if (stream->stream_type == STREAM_TYPE_LIVE && |
|
|
@ -3700,7 +3700,7 @@ static void build_feed_streams(void) |
|
|
|
int i; |
|
|
|
int i; |
|
|
|
|
|
|
|
|
|
|
|
/* gather all streams */ |
|
|
|
/* gather all streams */ |
|
|
|
for(stream = first_stream; stream != NULL; stream = stream->next) { |
|
|
|
for(stream = first_stream; stream; stream = stream->next) { |
|
|
|
feed = stream->feed; |
|
|
|
feed = stream->feed; |
|
|
|
if (feed) { |
|
|
|
if (feed) { |
|
|
|
if (stream->is_feed) { |
|
|
|
if (stream->is_feed) { |
|
|
@ -3715,7 +3715,7 @@ static void build_feed_streams(void) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* create feed files if needed */ |
|
|
|
/* create feed files if needed */ |
|
|
|
for(feed = first_feed; feed != NULL; feed = feed->next_feed) { |
|
|
|
for(feed = first_feed; feed; feed = feed->next_feed) { |
|
|
|
int fd; |
|
|
|
int fd; |
|
|
|
|
|
|
|
|
|
|
|
if (avio_check(feed->feed_filename, AVIO_FLAG_READ) > 0) { |
|
|
|
if (avio_check(feed->feed_filename, AVIO_FLAG_READ) > 0) { |
|
|
@ -3847,7 +3847,7 @@ static void compute_bandwidth(void) |
|
|
|
int i; |
|
|
|
int i; |
|
|
|
FFStream *stream; |
|
|
|
FFStream *stream; |
|
|
|
|
|
|
|
|
|
|
|
for(stream = first_stream; stream != NULL; stream = stream->next) { |
|
|
|
for(stream = first_stream; stream; stream = stream->next) { |
|
|
|
bandwidth = 0; |
|
|
|
bandwidth = 0; |
|
|
|
for(i=0;i<stream->nb_streams;i++) { |
|
|
|
for(i=0;i<stream->nb_streams;i++) { |
|
|
|
AVStream *st = stream->streams[i]; |
|
|
|
AVStream *st = stream->streams[i]; |
|
|
@ -4294,7 +4294,7 @@ static int parse_ffconfig(const char *filename) |
|
|
|
FFStream *sfeed; |
|
|
|
FFStream *sfeed; |
|
|
|
|
|
|
|
|
|
|
|
sfeed = first_feed; |
|
|
|
sfeed = first_feed; |
|
|
|
while (sfeed != NULL) { |
|
|
|
while (sfeed) { |
|
|
|
if (!strcmp(sfeed->filename, arg)) |
|
|
|
if (!strcmp(sfeed->filename, arg)) |
|
|
|
break; |
|
|
|
break; |
|
|
|
sfeed = sfeed->next_feed; |
|
|
|
sfeed = sfeed->next_feed; |
|
|
|