public void parse(String line, ParseState state) { mLineParser.parse(line, state); StreamInfo.Builder builder = new StreamInfo.Builder(); ParseUtil.parseAttributes(line, builder, state, HANDLERS, getTag()); state.getMaster().streamInfo = builder.build(); }
public void testEXT_X_STREAM_INF() { IExtTagParser handler = MasterPlaylistLineParser.EXT_X_STREAM_INF; String tag = Constants.EXT_X_STREAM_INF_TAG; int bandwidth = 10000; int averageBandwidth = 5000; List <String> codecs = new List <String>() { "h.263", "h.264" }; Resolution resolution = new Resolution(800, 600); String audio = "foo"; String video = "bar"; String subtitles = "titles"; String closedCaptions = "captions"; StreamInfo expectedStreamInfo = new StreamInfo.Builder() .withBandwidth(bandwidth) .withAverageBandwidth(averageBandwidth) .withCodecs(codecs) .withResolution(resolution) .withAudio(audio) .withVideo(video) .withSubtitles(subtitles) .withClosedCaptions(closedCaptions) .build(); String line = "#" + tag + ":BANDWIDTH=" + bandwidth + ",AVERAGE-BANDWIDTH=" + averageBandwidth + ",CODECS=\"" + codecs[0] + "," + codecs[1] + "\"" + ",RESOLUTION=" + resolution.width + "x" + resolution.height + ",AUDIO=\"" + audio + "\"" + ",VIDEO=\"" + video + "\"" + ",SUBTITLES=\"" + subtitles + "\"" + ",CLOSED-CAPTIONS=\"" + closedCaptions + "\""; Assert.Equal(tag, handler.getTag()); handler.parse(line, mParseState); Assert.Equal(expectedStreamInfo, mParseState.getMaster().streamInfo); }
public void testParseMaster() { List <MediaData> expectedMediaData = new List <MediaData>(); expectedMediaData.Add(new MediaData.Builder() .withType(MediaType.AUDIO) .withGroupId("1234") .withName("Foo") .build()); StreamInfo expectedStreamInfo = new StreamInfo.Builder() .withBandwidth(500) .build(); String validData = "#EXTM3U\n" + "#EXT-X-VERSION:2\n" + "#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=\"1234\",NAME=\"Foo\"\n" + "#EXT-X-STREAM-INF:BANDWIDTH=500\n" + "http://foo.bar.com/\n" + "\n"; Stream inputStream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(validData)); ExtendedM3uParser parser = new ExtendedM3uParser(inputStream, Encoding.UTF_8, ParsingMode.STRICT); Assert.True(parser.isAvailable()); Playlist playlist = parser.parse(); Assert.False(parser.isAvailable()); Assert.True(playlist.isExtended()); Assert.Equal(2, playlist.getCompatibilityVersion()); Assert.True(playlist.hasMasterPlaylist()); Assert.Equal(expectedMediaData, playlist.getMasterPlaylist().getMediaData()); Assert.Equal(expectedStreamInfo, playlist.getMasterPlaylist().getPlaylists()[0].getStreamInfo()); }