aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorStefano Sabatini <stefasab@gmail.com>2012-08-15 23:14:34 +0200
committerStefano Sabatini <stefasab@gmail.com>2012-08-18 11:21:47 +0200
commit4a12d1e8e794059b58718f402c46aed9e2bed458 (patch)
tree60bd3b92f71bdb91321dcd2a91cc961f54a55b94 /libavformat
parent769500c2a35817ef32a60e8d37721d387d94d384 (diff)
downloadffmpeg-4a12d1e8e794059b58718f402c46aed9e2bed458.tar.gz
lavf/segment: compute max list segment duration
This is useful for the M3U8 format incoming patch.
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/segment.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/libavformat/segment.c b/libavformat/segment.c
index ba5718d29f..78b304ae17 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -49,6 +49,7 @@ typedef struct {
char *format; ///< format to use for output segment files
char *list; ///< filename for the segment list file
int list_size; ///< number of entries for the segment list file
+ double list_max_segment_time; ///< max segment time in the current list
ListType list_type; ///< set the list type
AVIOContext *list_pb; ///< list file put-byte context
char *time_str; ///< segment duration specification string
@@ -112,8 +113,14 @@ fail:
static int segment_list_open(AVFormatContext *s)
{
SegmentContext *seg = s->priv_data;
- return avio_open2(&seg->list_pb, seg->list, AVIO_FLAG_WRITE,
- &s->interrupt_callback, NULL);
+ int ret;
+
+ ret = avio_open2(&seg->list_pb, seg->list, AVIO_FLAG_WRITE,
+ &s->interrupt_callback, NULL);
+ if (ret < 0)
+ return ret;
+ seg->list_max_segment_time = 0;
+ return ret;
}
static void segment_list_close(AVFormatContext *s)
@@ -147,6 +154,7 @@ static int segment_end(AVFormatContext *s)
} else if (seg->list_type == LIST_TYPE_EXT) {
avio_printf(seg->list_pb, "%s,%f,%f\n", oc->filename, seg->start_time, seg->end_time);
}
+ seg->list_max_segment_time = FFMAX(seg->end_time - seg->start_time, seg->list_max_segment_time);
avio_flush(seg->list_pb);
}