[FFmpeg-devel] [PATCH] avformat/hlsenc: hold old key info when append list

Steven Liu lq at chinaffmpeg.org
Wed Apr 26 02:30:11 EEST 2017


fix ticket id: #6353

Signed-off-by: Steven Liu <lq at chinaffmpeg.org>
---
 libavformat/hlsenc.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 27c8e3355d..3ec0f330fb 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -810,6 +810,7 @@ static int parse_playlist(AVFormatContext *s, const char *url)
     int64_t new_start_pos;
     char line[1024];
     const char *ptr;
+    const char *end;
 
     if ((ret = ffio_open_whitelist(&in, url, AVIO_FLAG_READ,
                                    &s->interrupt_callback, NULL,
@@ -842,6 +843,29 @@ static int parse_playlist(AVFormatContext *s, const char *url)
         } else if (av_strstart(line, "#EXTINF:", &ptr)) {
             is_segment = 1;
             hls->duration = atof(ptr);
+        } else if (av_stristart(line, "#EXT-X-KEY:", &ptr)) {
+            ptr = av_stristr(line, "URI=\"");
+            if (ptr) {
+                ptr += strlen("URI=\"");
+                end = av_stristr(ptr, ",");
+                if (end) {
+                    av_strlcpy(hls->key_uri, ptr, end - ptr);
+                } else {
+                    av_strlcpy(hls->key_uri, ptr, sizeof(hls->key_uri));
+                }
+            }
+
+            ptr = av_stristr(line, "IV=0x");
+            if (ptr) {
+                ptr += strlen("IV=0x");
+                end = av_stristr(ptr, ",");
+                if (end) {
+                    av_strlcpy(hls->iv_string, ptr, end - ptr);
+                } else {
+                    av_strlcpy(hls->iv_string, ptr, sizeof(hls->iv_string));
+                }
+            }
+
         } else if (av_strstart(line, "#", NULL)) {
             continue;
         } else if (line[0]) {
-- 
2.11.0 (Apple Git-81)





More information about the ffmpeg-devel mailing list