[FFmpeg-devel] [PATCH] avformat/hlsenc: set default http method to PUT when method is null
Steven Liu
lq at chinaffmpeg.org
Wed Feb 15 17:45:49 EET 2017
When the http method is not set, the method will use POST for ts,
PUT for m3u8, it is not unify, now set it unify.
This ticket id: 5315
Signed-off-by: Steven Liu <lq at chinaffmpeg.org>
---
libavformat/hlsenc.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 930e94b..c2c47c3 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -251,6 +251,7 @@ static int hls_delete_old_segments(HLSContext *hls) {
char *path = NULL;
AVDictionary *options = NULL;
AVIOContext *out = NULL;
+ const char *proto = NULL;
segment = hls->segments;
while (segment) {
@@ -300,7 +301,8 @@ static int hls_delete_old_segments(HLSContext *hls) {
av_strlcat(path, segment->filename, path_size);
}
- if (hls->method) {
+ proto = avio_find_protocol_name(hls->basename);
+ if (hls->method || (proto && !av_strcasecmp(proto, "http"))) {
av_dict_set(&options, "method", "DELETE", 0);
if ((ret = hls->avf->io_open(hls->avf, &out, path, AVIO_FLAG_WRITE, &options)) < 0)
goto fail;
@@ -321,7 +323,7 @@ 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 (hls->method) {
+ if (hls->method || (proto && !av_strcasecmp(proto, "http"))) {
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);
@@ -665,8 +667,14 @@ static void hls_free_segments(HLSSegment *p)
static void set_http_options(AVDictionary **options, HLSContext *c)
{
- if (c->method)
+ const char *proto = avio_find_protocol_name(c->basename);
+
+ if (c->method) {
av_dict_set(options, "method", c->method, 0);
+ } else if (proto && !av_strcasecmp(proto, "http")) {
+ av_log(c, AV_LOG_WARNING, "You forget set http method, hls muxer auto set default method to PUT\n");
+ av_dict_set(options, "method", "PUT", 0);
+ }
}
static void write_m3u8_head_block(HLSContext *hls, AVIOContext *out, int version,
--
2.10.1.382.ga23ca1b.dirty
More information about the ffmpeg-devel
mailing list