lavf/dashenc: Delete HLS manifests on trailer writing if remove_at_exit is set.
authorAndrey Semashev <andrey.semashev@gmail.com>
Wed, 28 Nov 2018 11:36:09 +0000 (14:36 +0300)
committerKarthick J <kjeyapal@akamai.com>
Sun, 2 Dec 2018 13:37:30 +0000 (19:07 +0530)
This fixes HLS manifests being left behind if remove_at_exit is set.

libavformat/dashenc.c

index a7d8c4e..af3f0ee 100644 (file)
@@ -1619,6 +1619,18 @@ static int dash_write_trailer(AVFormatContext *s)
             dashenc_delete_file(s, filename);
         }
         dashenc_delete_file(s, s->url);
+
+        if (c->hls_playlist && c->master_playlist_created) {
+            for (i = 0; i < s->nb_streams; i++) {
+                OutputStream *os = &c->streams[i];
+                if (os->segment_type == SEGMENT_TYPE_MP4) {
+                    get_hls_playlist_name(filename, sizeof(filename), c->dirname, i);
+                    dashenc_delete_file(s, filename);
+                }
+            }
+            snprintf(filename, sizeof(filename), "%smaster.m3u8", c->dirname);
+            dashenc_delete_file(s, filename);
+        }
     }
 
     return 0;