iheartradio / open-m3u8

Open Source m3u8 Parser
Other
248 stars 94 forks source link

The FORCED attribute present when the TYPE is not SUBTITLES #58

Open aapcuk opened 6 years ago

aapcuk commented 6 years ago

According to the HLS specification, also linked in the documentation, the FORCED attribute should only be present with subtitles: "The FORCED attribute MUST NOT be present unless the TYPE is SUBTITLES." https://tools.ietf.org/html/draft-pantos-http-live-streaming-16

However, when writing an m3u8 file, it is present with audio as well:

EXT-X-MEDIA:LANGUAGE="eng",AUTOSELECT=YES,FORCED=NO,TYPE=AUDIO,URI="...",GROUP-ID="audio_aac",DEFAULT=YES,NAME="eng"

Version: 0.2.6

aapcuk commented 6 years ago

I think the solution is simply changing the containsAttribute() for Constants.FORCED in MasterPlaylistTagWriter.java:

HANDLERS.put(Constants.FORCED, new AttributeWriter<MediaData>() {
    @Override
    public boolean containsAttribute(MediaData mediaData) {
        return mediaData.getType() == MediaType.SUBTITLES;
    }
    // ...
});

(I couldn't yet made a pull request, I'm new here.)