From 86260468e533a78814fa60af8b86530541c3caf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Koll=C3=A1r?= <10644651+rkollar@users.noreply.github.com> Date: Fri, 20 Sep 2019 13:53:44 +0200 Subject: [PATCH] add INSTREAM-ID attribute for alternative renditions --- reader.go | 2 ++ structure.go | 1 + writer.go | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/reader.go b/reader.go index 86134762..7e670dc6 100644 --- a/reader.go +++ b/reader.go @@ -323,6 +323,8 @@ func decodeLineOfMasterPlaylist(p *MasterPlaylist, state *decodingState, line st alt.Autoselect = v case "FORCED": alt.Forced = v + case "INSTREAM-ID": + alt.InstreamID = v case "CHARACTERISTICS": alt.Characteristics = v case "SUBTITLES": diff --git a/structure.go b/structure.go index ea0d5c85..82bf94a6 100644 --- a/structure.go +++ b/structure.go @@ -192,6 +192,7 @@ type Alternative struct { Default bool Autoselect string Forced string + InstreamID string Characteristics string Subtitles string } diff --git a/writer.go b/writer.go index ae736067..050b5403 100644 --- a/writer.go +++ b/writer.go @@ -140,6 +140,11 @@ func (p *MasterPlaylist) Encode() *bytes.Buffer { p.buf.WriteString(alt.Forced) p.buf.WriteRune('"') } + if alt.Type == "CLOSED-CAPTIONS" && alt.InstreamID != "" { + p.buf.WriteString(",INSTREAM-ID=\"") + p.buf.WriteString(alt.InstreamID) + p.buf.WriteRune('"') + } if alt.Characteristics != "" { p.buf.WriteString(",CHARACTERISTICS=\"") p.buf.WriteString(alt.Characteristics)