Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URI is OPTIONAL in EXT-X-MEDIA tag #104

Merged
merged 3 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions client_downloader_primary.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,27 +209,29 @@
return fmt.Errorf("audio playlist with id \"%s\" not found", leadingPlaylist.Audio)
}

u, err := clientAbsoluteURL(d.primaryPlaylistURL, audioPlaylist.URI)
if err != nil {
return err
if audioPlaylist.URI != "" {
u, err := clientAbsoluteURL(d.primaryPlaylistURL, audioPlaylist.URI)
if err != nil {
return err
}

Check warning on line 216 in client_downloader_primary.go

View check run for this annotation

Codecov / codecov/patch

client_downloader_primary.go#L212-L216

Added lines #L212 - L216 were not covered by tests

ds := newClientDownloaderStream(
false,
d.httpClient,
d.onDownloadStreamPlaylist,
d.onDownloadSegment,
d.onDecodeError,
u,
nil,
d.rp,
d.onStreamTracks,
d.onSetLeadingTimeSync,
d.onGetLeadingTimeSync,
d.onData,
)
d.rp.add(ds)
streamCount++

Check warning on line 233 in client_downloader_primary.go

View check run for this annotation

Codecov / codecov/patch

client_downloader_primary.go#L218-L233

Added lines #L218 - L233 were not covered by tests
}

ds := newClientDownloaderStream(
false,
d.httpClient,
d.onDownloadStreamPlaylist,
d.onDownloadSegment,
d.onDecodeError,
u,
nil,
d.rp,
d.onStreamTracks,
d.onSetLeadingTimeSync,
d.onGetLeadingTimeSync,
d.onData,
)
d.rp.add(ds)
streamCount++
}

default:
Expand Down
34 changes: 24 additions & 10 deletions pkg/playlist/multivariant_rendition.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,32 @@
return fmt.Errorf("GROUP-ID missing")
}

if t.Type != MultivariantRenditionTypeClosedCaptions {
if t.URI == "" {
return fmt.Errorf("missing URI")
}

if t.InstreamID != "" {
return fmt.Errorf("INSTREAM-ID is forbidden with type %s", t.Type)
}
} else {
// If the TYPE is CLOSED-CAPTIONS, the URI
// attribute MUST NOT be present.
// The URI attribute of the EXT-X-MEDIA tag is REQUIRED if the media
// type is SUBTITLES, but OPTIONAL if the media type is VIDEO or AUDIO.
switch t.Type {
case MultivariantRenditionTypeClosedCaptions:
if t.URI != "" {
return fmt.Errorf("URI is forbidden for type CLOSED-CAPTIONS")
}

case MultivariantRenditionTypeSubtitles:
if t.URI == "" {
return fmt.Errorf("URI is required for type SUBTITLES")
}

Check warning on line 127 in pkg/playlist/multivariant_rendition.go

View check run for this annotation

Codecov / codecov/patch

pkg/playlist/multivariant_rendition.go#L126-L127

Added lines #L126 - L127 were not covered by tests

default:
}

// This attribute is REQUIRED if the TYPE attribute is CLOSED-CAPTIONS
// For all other TYPE values, the INSTREAM-ID MUST NOT be specified.
if t.Type == MultivariantRenditionTypeClosedCaptions {
if t.InstreamID == "" {
return fmt.Errorf("missing INSTREAM-ID")
}
} else if t.InstreamID != "" {
return fmt.Errorf("INSTREAM-ID is forbidden with type %s", t.Type)
}

return nil
Expand Down Expand Up @@ -164,7 +174,11 @@
ret += ",CHANNELS=\"" + t.Channels + "\""
}

ret += ",URI=\"" + t.URI + "\"\n"
if t.URI != "" {
ret += ",URI=\"" + t.URI + "\""
}

ret += "\n"

return ret
}
2 changes: 1 addition & 1 deletion pkg/playlist/multivariant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ v2/prog_index.m3u8
#EXT-X-MEDIA:TYPE="AUDIO",GROUP-ID="aud1",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,CHANNELS="2",URI="a1/prog_index.m3u8"
#EXT-X-MEDIA:TYPE="AUDIO",GROUP-ID="aud2",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,CHANNELS="6",URI="a2/prog_index.m3u8"
#EXT-X-MEDIA:TYPE="AUDIO",GROUP-ID="aud3",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,CHANNELS="6",URI="a3/prog_index.m3u8"
#EXT-X-MEDIA:TYPE="CLOSED-CAPTIONS",GROUP-ID="cc1",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,URI=""
#EXT-X-MEDIA:TYPE="CLOSED-CAPTIONS",GROUP-ID="cc1",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES
#EXT-X-MEDIA:TYPE="SUBTITLES",GROUP-ID="sub1",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,FORCED=NO,URI="s1/en/prog_index.m3u8"
`,
Multivariant{
Expand Down
Loading