[FFmpeg-cvslog] avformat/hlsenc: Modularized audio rendition playlist write to allow reuse

Karthick Jeyapal git at videolan.org
Fri Dec 29 08:43:27 EET 2017


ffmpeg | branch: master | Karthick Jeyapal <kjeyapal at akamai.com> | Fri Dec 29 13:45:31 2017 +0800| [9e25fe420410c0e1b77cc68f53cc0cd2f79ba30a] | committer: Steven Liu

avformat/hlsenc: Modularized audio rendition playlist write to allow reuse

Reviewed-by: Steven Liu <lq at chinaffmpeg.org>

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

 libavformat/hlsenc.c      | 6 ++----
 libavformat/hlsplaylist.c | 9 +++++++++
 libavformat/hlsplaylist.h | 1 +
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 74f66ce6bd..fe531fb43d 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1169,10 +1169,8 @@ static int create_master_playlist(AVFormatContext *s,
             goto fail;
         }
 
-        avio_printf(hls->m3u8_out, "#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=\"group_%s\"",
-                vs->agroup);
-        avio_printf(hls->m3u8_out, ",NAME=\"audio_0\",DEFAULT=YES,URI=\"%s\"\n",
-                m3u8_rel_name);
+        ff_hls_write_audio_rendition(hls->m3u8_out, vs->agroup, m3u8_rel_name);
+
         av_freep(&m3u8_rel_name);
     }
 
diff --git a/libavformat/hlsplaylist.c b/libavformat/hlsplaylist.c
index 42f059aec9..a065eda59d 100644
--- a/libavformat/hlsplaylist.c
+++ b/libavformat/hlsplaylist.c
@@ -35,6 +35,15 @@ void ff_hls_write_playlist_version(AVIOContext *out, int version) {
     avio_printf(out, "#EXT-X-VERSION:%d\n", version);
 }
 
+void ff_hls_write_audio_rendition(AVIOContext *out, char *agroup,
+                                  char *filename) {
+    if (!out || !agroup || !filename)
+        return;
+
+    avio_printf(out, "#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=\"group_%s\"", agroup);
+    avio_printf(out, ",NAME=\"audio_0\",DEFAULT=YES,URI=\"%s\"\n", filename);
+}
+
 void ff_hls_write_stream_info(AVStream *st, AVIOContext *out,
                               int bandwidth, char *filename, char *agroup) {
     if (!out || !filename)
diff --git a/libavformat/hlsplaylist.h b/libavformat/hlsplaylist.h
index ac03550651..518cfc256b 100644
--- a/libavformat/hlsplaylist.h
+++ b/libavformat/hlsplaylist.h
@@ -37,6 +37,7 @@ typedef enum {
 } PlaylistType;
 
 void ff_hls_write_playlist_version(AVIOContext *out, int version);
+void ff_hls_write_audio_rendition(AVIOContext *out, char *agroup, char *filename);
 void ff_hls_write_stream_info(AVStream *st, AVIOContext *out,
                               int bandwidth, char *filename, char *agroup);
 void ff_hls_write_playlist_header(AVIOContext *out, int version, int allowcache,



More information about the ffmpeg-cvslog mailing list