Commit 26e1efb0 authored by Vishwanath Dixit's avatar Vishwanath Dixit Committed by Steven Liu

avformat/hlsenc: revamped master playlist url creation logic

parent 21b5990d
...@@ -1689,28 +1689,30 @@ static int update_variant_stream_info(AVFormatContext *s) { ...@@ -1689,28 +1689,30 @@ static int update_variant_stream_info(AVFormatContext *s) {
static int update_master_pl_info(AVFormatContext *s) { static int update_master_pl_info(AVFormatContext *s) {
HLSContext *hls = s->priv_data; HLSContext *hls = s->priv_data;
int m3u8_name_size, ret; const char *dir;
char *p; char *fn;
int ret = 0;
m3u8_name_size = strlen(s->filename) + strlen(hls->master_pl_name) + 1; fn = av_strdup(s->filename);
hls->master_m3u8_url = av_malloc(m3u8_name_size); if (!fn) {
if (!hls->master_m3u8_url) {
ret = AVERROR(ENOMEM); ret = AVERROR(ENOMEM);
return ret; goto fail;
} }
av_strlcpy(hls->master_m3u8_url, s->filename, m3u8_name_size); dir = av_dirname(fn);
p = strrchr(hls->master_m3u8_url, '/') ? if (dir && strcmp(dir, "."))
strrchr(hls->master_m3u8_url, '/') : hls->master_m3u8_url = av_append_path_component(dir, hls->master_pl_name);
strrchr(hls->master_m3u8_url, '\\'); else
if (p) { hls->master_m3u8_url = av_strdup(hls->master_pl_name);
*(p + 1) = '\0';
av_strlcat(hls->master_m3u8_url, hls->master_pl_name, m3u8_name_size); if (!hls->master_m3u8_url) {
} else { ret = AVERROR(ENOMEM);
av_strlcpy(hls->master_m3u8_url, hls->master_pl_name, m3u8_name_size); goto fail;
} }
return 0; fail:
av_freep(&fn);
return ret;
} }
static int hls_write_header(AVFormatContext *s) static int hls_write_header(AVFormatContext *s)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment