aboutsummaryrefslogtreecommitdiffstats
path: root/ffserver.c
diff options
context:
space:
mode:
authorBaptiste Coudurier <baptiste.coudurier@gmail.com>2009-03-21 10:28:49 +0000
committerBaptiste Coudurier <baptiste.coudurier@gmail.com>2009-03-21 10:28:49 +0000
commit861ec13aae31cb59b2d7fe8c0b32d128093c9718 (patch)
tree5a78d525201e58561371de83647e6e8482d6b74e /ffserver.c
parent899a8fa1cb1a102cc0dd3089a870c3af83d3bf81 (diff)
downloadffmpeg-861ec13aae31cb59b2d7fe8c0b32d128093c9718.tar.gz
new Truncate option which will make feeder truncate feed file
Originally committed as revision 18107 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'ffserver.c')
-rw-r--r--ffserver.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/ffserver.c b/ffserver.c
index 279ffaa43f..f84c1a133c 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -237,6 +237,7 @@ typedef struct FFStream {
int feed_opened; /* true if someone is writing to the feed */
int is_feed; /* true if it is a feed */
int readonly; /* True if writing is prohibited to the file */
+ int truncate; /* True if feeder connection truncate the feed file */
int conns_served;
int64_t bytes_served;
int64_t feed_max_size; /* maximum storage size, zero means unlimited */
@@ -2431,10 +2432,18 @@ static int http_start_receive_data(HTTPContext *c)
}
c->feed_fd = fd;
+ if (c->stream->truncate) {
+ /* truncate feed file */
+ ffm_write_write_index(c->feed_fd, FFM_PACKET_SIZE);
+ ftruncate(c->feed_fd, FFM_PACKET_SIZE);
+ http_log("Truncating feed file '%s'\n", c->stream->feed_filename);
+ } else {
if ((c->stream->feed_write_index = ffm_read_write_index(fd)) < 0) {
http_log("Error reading write index from feed file: %s\n", strerror(errno));
return -1;
}
+ }
+
c->stream->feed_write_index = FFMAX(ffm_read_write_index(fd), FFM_PACKET_SIZE);
c->stream->feed_size = lseek(fd, 0, SEEK_END);
@@ -3954,6 +3963,11 @@ static int parse_ffconfig(const char *filename)
get_arg(feed->feed_filename, sizeof(feed->feed_filename), &p);
} else if (stream)
get_arg(stream->feed_filename, sizeof(stream->feed_filename), &p);
+ } else if (!strcasecmp(cmd, "Truncate")) {
+ if (feed) {
+ get_arg(arg, sizeof(arg), &p);
+ feed->truncate = strtod(arg, NULL);
+ }
} else if (!strcasecmp(cmd, "FileMaxSize")) {
if (feed) {
char *p1;