diff options
author | Steven Liu <lq@chinaffmpeg.org> | 2017-01-19 07:06:50 +0800 |
---|---|---|
committer | Steven Liu <lq@chinaffmpeg.org> | 2017-01-19 07:06:50 +0800 |
commit | b05d0274ce7dca3d9b3efd9258b46c7a898f04a9 (patch) | |
tree | 392a127a23303e6e1c22ebe828237492ed1ec597 /libavformat/hlsenc.c | |
parent | c3050fcbdcb2dbaecab662836afd0d1b7badbf10 (diff) | |
download | ffmpeg-streaming-b05d0274ce7dca3d9b3efd9258b46c7a898f04a9.zip ffmpeg-streaming-b05d0274ce7dca3d9b3efd9258b46c7a898f04a9.tar.gz |
avformat/hlsenc: fix bug of hlsenc http delete old segments
when push hls to http server, the old segemnts can not delete by hls formats.
so add the http option into hls_delete_old_segments
Reported-by: Yin Jiaoyuan <yinjiaoyuan@163.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
Diffstat (limited to 'libavformat/hlsenc.c')
-rw-r--r-- | libavformat/hlsenc.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 28ac447..1f4bf8b 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -245,6 +245,8 @@ static int hls_delete_old_segments(HLSContext *hls) { int ret = 0, path_size, sub_path_size; char *dirname = NULL, *p, *sub_path; char *path = NULL; + AVDictionary *options = NULL; + AVIOContext *out = NULL; segment = hls->segments; while (segment) { @@ -294,7 +296,11 @@ static int hls_delete_old_segments(HLSContext *hls) { av_strlcat(path, segment->filename, path_size); } - if (unlink(path) < 0) { + if (hls->method) { + av_dict_set(&options, "method", "DELETE", 0); + if ((ret = hls->avf->io_open(hls->avf, &out, path, AVIO_FLAG_WRITE, &options)) < 0) + goto fail; + } else if (unlink(path) < 0) { av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: %s\n", path, strerror(errno)); } @@ -309,7 +315,14 @@ static int hls_delete_old_segments(HLSContext *hls) { av_strlcpy(sub_path, dirname, sub_path_size); av_strlcat(sub_path, segment->sub_filename, sub_path_size); - if (unlink(sub_path) < 0) { + + if (hls->method) { + av_dict_set(&options, "method", "DELETE", 0); + if ((ret = hls->avf->io_open(hls->avf, &out, sub_path, AVIO_FLAG_WRITE, &options)) < 0) { + av_free(sub_path); + goto fail; + } + } else if (unlink(sub_path) < 0) { av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: %s\n", sub_path, strerror(errno)); } |