[FFmpeg-cvslog] avformat/hlsenc: replace with av_dirname to get the directory

Limin Wang git at videolan.org
Tue Oct 8 09:24:22 EEST 2019


ffmpeg | branch: master | Limin Wang <lance.lmwang at gmail.com> | Tue Sep 24 19:24:00 2019 +0800| [28bb73cee77e209a6445d081e7ea577ede29c50f] | committer: Steven Liu

avformat/hlsenc: replace with av_dirname to get the directory

Signed-off-by: Limin Wang <lance.lmwang at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=28bb73cee77e209a6445d081e7ea577ede29c50f
---

 libavformat/hlsenc.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index e5ccedc792..aefaeacf28 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -486,7 +486,7 @@ static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls,
     float playlist_duration = 0.0f;
     int ret = 0, path_size, sub_path_size;
     int segment_cnt = 0;
-    char *dirname = NULL, *p, *sub_path;
+    char *dirname = NULL, *sub_path;
     char *path = NULL;
     char *vtt_dirname = NULL;
     AVDictionary *options = NULL;
@@ -517,13 +517,8 @@ static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls,
     }
 
     if (segment && !hls->use_localtime_mkdir) {
-        dirname = hls->segment_filename ? av_strdup(hls->segment_filename): av_strdup(vs->avf->url);
-        if (!dirname) {
-            ret = AVERROR(ENOMEM);
-            goto fail;
-        }
-        p = (char *)av_basename(dirname);
-        *p = '\0';
+        char *dirname_r = hls->segment_filename ? av_strdup(hls->segment_filename): av_strdup(vs->avf->url);
+        dirname = (char*)av_dirname(dirname_r);
     }
 
     /* if %v is present in the file's directory
@@ -542,7 +537,7 @@ static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls,
             }
         }
 
-        av_free(dirname);
+        av_freep(&dirname);
         dirname = r_dirname;
     }
 
@@ -578,13 +573,8 @@ static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls,
         }
 
         if ((segment->sub_filename[0] != '\0')) {
-            vtt_dirname = av_strdup(vs->vtt_avf->url);
-            if (!vtt_dirname) {
-                ret = AVERROR(ENOMEM);
-                goto fail;
-            }
-            p = (char *)av_basename(vtt_dirname);
-            *p = '\0';
+            char *vtt_dirname_r = av_strdup(vs->vtt_avf->url);
+            vtt_dirname = (char*)av_dirname(vtt_dirname_r);
             sub_path_size = strlen(segment->sub_filename) + 1 + strlen(vtt_dirname);
             sub_path = av_malloc(sub_path_size);
             if (!sub_path) {



More information about the ffmpeg-cvslog mailing list