Originally committed as revision 577 to svn://svn.ffmpeg.org/ffmpeg/trunk
Philip Gladstone authored on 2002/05/24 10:18:19... | ... |
@@ -95,6 +95,7 @@ typedef struct HTTPContext { |
95 | 95 |
int last_packet_sent; /* true if last data packet was sent */ |
96 | 96 |
int suppress_log; |
97 | 97 |
int bandwidth; |
98 |
+ time_t start_time; |
|
98 | 99 |
char protocol[16]; |
99 | 100 |
char method[16]; |
100 | 101 |
char url[128]; |
... | ... |
@@ -116,6 +117,7 @@ typedef struct FFStream { |
116 | 116 |
AVOutputFormat *fmt; |
117 | 117 |
int nb_streams; |
118 | 118 |
int prebuffer; /* Number of millseconds early to start */ |
119 |
+ time_t max_time; |
|
119 | 120 |
int send_on_key; |
120 | 121 |
AVStream *streams[MAX_STREAMS]; |
121 | 122 |
int feed_streams[MAX_STREAMS]; /* index of streams in the feed */ |
... | ... |
@@ -559,7 +561,7 @@ static int http_parse_request(HTTPContext *c) |
559 | 559 |
c->bandwidth += st->codec.bit_rate; |
560 | 560 |
break; |
561 | 561 |
default: |
562 |
- abort(); |
|
562 |
+ av_abort(); |
|
563 | 563 |
} |
564 | 564 |
} |
565 | 565 |
} |
... | ... |
@@ -636,7 +638,7 @@ static int http_parse_request(HTTPContext *c) |
636 | 636 |
q += sprintf(q, "http://%s/%s%s\r\n", |
637 | 637 |
hostbuf, filename, info); |
638 | 638 |
} else |
639 |
- abort(); |
|
639 |
+ av_abort(); |
|
640 | 640 |
|
641 | 641 |
/* prepare output buffer */ |
642 | 642 |
c->buffer_ptr = c->buffer; |
... | ... |
@@ -829,7 +831,7 @@ static void compute_stats(HTTPContext *c) |
829 | 829 |
} |
830 | 830 |
break; |
831 | 831 |
default: |
832 |
- abort(); |
|
832 |
+ av_abort(); |
|
833 | 833 |
} |
834 | 834 |
} |
835 | 835 |
q += sprintf(q, "<TD align=center> %s <TD align=right> %d <TD align=right> %d <TD> %s %s <TD align=right> %d <TD> %s %s", |
... | ... |
@@ -873,7 +875,7 @@ static void compute_stats(HTTPContext *c) |
873 | 873 |
type = "video"; |
874 | 874 |
break; |
875 | 875 |
default: |
876 |
- abort(); |
|
876 |
+ av_abort(); |
|
877 | 877 |
} |
878 | 878 |
q += sprintf(q, "<tr><td align=right>%d<td>%s<td align=right>%d<td>%s\n", |
879 | 879 |
i, type, st->codec.bit_rate/1000, codec ? codec->name : ""); |
... | ... |
@@ -960,7 +962,7 @@ static void http_write_packet(void *opaque, |
960 | 960 |
c->buffer_ptr = c->buffer_end = c->buffer; |
961 | 961 |
|
962 | 962 |
if (c->buffer_end - c->buffer + size > IOBUFFER_MAX_SIZE) |
963 |
- abort(); |
|
963 |
+ av_abort(); |
|
964 | 964 |
|
965 | 965 |
memcpy(c->buffer_end, buf, size); |
966 | 966 |
c->buffer_end += size; |
... | ... |
@@ -1127,8 +1129,12 @@ static int http_prepare_data(HTTPContext *c) |
1127 | 1127 |
c->stream->feed->feed_write_index, |
1128 | 1128 |
c->stream->feed->feed_size); |
1129 | 1129 |
} |
1130 |
- |
|
1131 |
- if (av_read_packet(c->fmt_in, &pkt) < 0) { |
|
1130 |
+ |
|
1131 |
+ if (c->stream->max_time && |
|
1132 |
+ c->stream->max_time + c->start_time > time(0)) { |
|
1133 |
+ /* We have timed out */ |
|
1134 |
+ c->state = HTTPSTATE_SEND_DATA_TRAILER; |
|
1135 |
+ } else if (av_read_packet(c->fmt_in, &pkt) < 0) { |
|
1132 | 1136 |
if (c->stream->feed && c->stream->feed->feed_opened) { |
1133 | 1137 |
/* if coming from feed, it means we reached the end of the |
1134 | 1138 |
ffm file, so must wait for more data */ |
... | ... |
@@ -1326,18 +1332,25 @@ static int http_receive_data(HTTPContext *c) |
1326 | 1326 |
if (!fmt_in) |
1327 | 1327 |
goto fail; |
1328 | 1328 |
|
1329 |
+ s.priv_data = av_mallocz(fmt_in->priv_data_size); |
|
1330 |
+ if (!s.priv_data) |
|
1331 |
+ goto fail; |
|
1332 |
+ |
|
1329 | 1333 |
if (fmt_in->read_header(&s, 0) < 0) { |
1334 |
+ av_freep(&s.priv_data); |
|
1330 | 1335 |
goto fail; |
1331 | 1336 |
} |
1332 | 1337 |
|
1333 | 1338 |
/* Now we have the actual streams */ |
1334 | 1339 |
if (s.nb_streams != feed->nb_streams) { |
1340 |
+ av_freep(&s.priv_data); |
|
1335 | 1341 |
goto fail; |
1336 | 1342 |
} |
1337 | 1343 |
for (i = 0; i < s.nb_streams; i++) { |
1338 | 1344 |
memcpy(&feed->streams[i]->codec, |
1339 | 1345 |
&s.streams[i]->codec, sizeof(AVCodecContext)); |
1340 | 1346 |
} |
1347 |
+ av_freep(&s.priv_data); |
|
1341 | 1348 |
} |
1342 | 1349 |
c->buffer_ptr = c->buffer; |
1343 | 1350 |
} |
... | ... |
@@ -1379,7 +1392,7 @@ int add_av_stream(FFStream *feed, |
1379 | 1379 |
goto found; |
1380 | 1380 |
break; |
1381 | 1381 |
default: |
1382 |
- abort(); |
|
1382 |
+ av_abort(); |
|
1383 | 1383 |
} |
1384 | 1384 |
} |
1385 | 1385 |
} |
... | ... |
@@ -1530,7 +1543,7 @@ void add_codec(FFStream *stream, AVCodecContext *av) |
1530 | 1530 |
|
1531 | 1531 |
break; |
1532 | 1532 |
default: |
1533 |
- abort(); |
|
1533 |
+ av_abort(); |
|
1534 | 1534 |
} |
1535 | 1535 |
|
1536 | 1536 |
st = av_mallocz(sizeof(AVStream)); |
... | ... |
@@ -1807,6 +1820,11 @@ int parse_ffconfig(const char *filename) |
1807 | 1807 |
filename, line_num, arg); |
1808 | 1808 |
errors++; |
1809 | 1809 |
} |
1810 |
+ } else if (!strcasecmp(cmd, "MaxTime")) { |
|
1811 |
+ get_arg(arg, sizeof(arg), &p); |
|
1812 |
+ if (stream) { |
|
1813 |
+ stream->max_time = atoi(arg); |
|
1814 |
+ } |
|
1810 | 1815 |
} else if (!strcasecmp(cmd, "AudioBitRate")) { |
1811 | 1816 |
get_arg(arg, sizeof(arg), &p); |
1812 | 1817 |
if (stream) { |