// JUnit specific setUp method... should be fine done as above... I think //protected override void setUp() //{ // mParseState = new ParseState(Encoding.UTF_8); //} protected void assertParseThrows(IExtTagParser handler, String line, ParseExceptionType exceptionType) { try { handler.parse(line, mParseState); Assert.False(true); } catch (ParseException exception) { Assert.Equal(exceptionType, exception.type); } }
public void testEXTINF() { IExtTagParser handler = MediaPlaylistLineParser.EXTINF; String tag = Constants.EXTINF_TAG; String line = "#" + tag + ":-1,TOP 100"; Assert.Equal(tag, handler.getTag()); handler.parse(line, mParseState); Assert.Equal(-1f, mParseState.getMedia().trackInfo.duration); Assert.Equal("TOP 100", mParseState.getMedia().trackInfo.title); }
public void testEXT_X_TARGETDURATION() { IExtTagParser handler = MediaPlaylistLineParser.EXT_X_TARGETDURATION; String tag = Constants.EXT_X_TARGETDURATION_TAG; String line = "#" + tag + ":60"; Assert.Equal(tag, handler.getTag()); handler.parse(line, mParseState); Assert.Equal(60, (int)mParseState.getMedia().targetDuration); assertParseThrows(handler, line, ParseExceptionType.MULTIPLE_EXT_TAG_INSTANCES); }
public void testEXTM3U() { IExtTagParser handler = ExtLineParser.EXTM3U_HANDLER; String tag = Constants.EXTM3U_TAG; String line = "#" + tag; Assert.Equal(tag, handler.getTag()); handler.parse(line, mParseState); Assert.True(mParseState.isExtended()); assertParseThrows(handler, line, ParseExceptionType.MULTIPLE_EXT_TAG_INSTANCES); }
public void testEXT_X_VERSION() { IExtTagParser handler = ExtLineParser.EXT_X_VERSION_HANDLER; String tag = Constants.EXT_X_VERSION_TAG; String line = "#" + tag + ":2"; Assert.Equal(tag, handler.getTag()); assertParseThrows(handler, line + ".", ParseExceptionType.BAD_EXT_TAG_FORMAT); handler.parse(line, mParseState); Assert.Equal(2, mParseState.getCompatibilityVersion()); assertParseThrows(handler, line, ParseExceptionType.MULTIPLE_EXT_TAG_INSTANCES); }
public void testEXT_X_BYTERANGE() { IExtTagParser handler = MediaPlaylistLineParser.EXT_X_BYTERANGE; String tag = Constants.EXT_X_BYTERANGE_TAG; long subRangeLength = 350; long offset = 70L; String line = "#" + tag + ":" + subRangeLength + "@" + offset; Assert.Equal(tag, handler.getTag()); handler.parse(line, mParseState); ByteRange byteRange = mParseState.getMedia().byteRange; Assert.Equal(subRangeLength, byteRange.getSubRangeLength()); Assert.Equal(offset, byteRange.getOffset()); }
public void testEXT_X_START() { IExtTagParser parser = ExtLineParser.EXT_X_START; String tag = Constants.EXT_X_START_TAG; String line = "#" + tag + ":TIME-OFFSET=-4.5" + ",PRECISE=YES"; Assert.Equal(tag, parser.getTag()); assertParseThrows(parser, line + ".", ParseExceptionType.NOT_YES_OR_NO); parser.parse(line, mParseState); Assert.Equal(-4.5, mParseState.startData.getTimeOffset(), 12); Assert.True(mParseState.startData.isPrecise()); assertParseThrows(parser, line, ParseExceptionType.MULTIPLE_EXT_TAG_INSTANCES); }
public void testEXT_X_MEDIA() { List <MediaData> expectedMediaData = new List <MediaData>(); IExtTagParser handler = MasterPlaylistLineParser.EXT_X_MEDIA; String tag = Constants.EXT_X_MEDIA_TAG; String groupId = "1234"; String language = "lang"; String associatedLanguage = "assoc-lang"; String name = "Foo"; String inStreamId = "SERVICE1"; expectedMediaData.Add(new MediaData.Builder() .withType(MediaType.CLOSED_CAPTIONS) .withGroupId(groupId) .withLanguage(language) .withAssociatedLanguage(associatedLanguage) .withName(name) .withAutoSelect(true) .withInStreamId(inStreamId) .withCharacteristics(new List <string>() { "char1", "char2" }) .build()); String line = "#" + tag + ":TYPE=CLOSED-CAPTIONS" + ",GROUP-ID=\"" + groupId + "\"" + ",LANGUAGE=\"" + language + "\"" + ",ASSOC-LANGUAGE=\"" + associatedLanguage + "\"" + ",NAME=\"" + name + "\"" + ",DEFAULT=NO" + ",AUTOSELECT=YES" + ",INSTREAM-ID=\"" + inStreamId + "\"" + ",CHARACTERISTICS=\"char1,char2\""; Assert.Equal(tag, handler.getTag()); handler.parse(line, mParseState); var actualMediaData = mParseState.getMaster().mediaData; Assert.Equal(expectedMediaData, actualMediaData); }
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 testEXT_X_MAP() { IExtTagParser handler = MediaPlaylistLineParser.EXT_X_MAP; String tag = Constants.EXT_X_MAP; String uri = "init.mp4"; long subRangeLength = 350; long offset = 76L; String line = "#" + tag + ":URI=\"" + uri + "\"" + ",BYTERANGE=\"" + subRangeLength + "@" + offset + "\""; Assert.Equal(tag, handler.getTag()); handler.parse(line, mParseState); MapInfo mapInfo = mParseState.getMedia().mapInfo; Assert.Equal(uri, mapInfo.getUri()); Assert.NotNull(mapInfo.getByteRange()); Assert.Equal(subRangeLength, mapInfo.getByteRange().getSubRangeLength()); Assert.Equal(offset, mapInfo.getByteRange().getOffset()); }
public void testEXT_X_KEY() { IExtTagParser handler = MediaPlaylistLineParser.EXT_X_KEY; String tag = Constants.EXT_X_KEY_TAG; String uri = "http://foo.bar.com/"; String format = "format"; String line = "#" + tag + ":METHOD=AES-128" + ",URI=\"" + uri + "\"" + ",IV=0x1234abcd5678EF90aabbccddeeff0011" + ",KEYFORMAT=\"" + format + "\"" + ",KEYFORMATVERSIONS=\"1/2/3\""; Assert.Equal(tag, handler.getTag()); handler.parse(line, mParseState); EncryptionData encryptionData = mParseState.getMedia().encryptionData; Assert.Equal(EncryptionMethod.AES, encryptionData.getMethod()); Assert.Equal(uri, encryptionData.getUri()); Assert.Equal( new List <byte>() { (byte)0x12, (byte)0x34, (byte)0xAB, (byte)0xCD, (byte)0x56, (byte)0x78, (byte)0xEF, (byte)0x90, (byte)0xAA, (byte)0xBB, (byte)0xCC, (byte)0xDD, (byte)0xEE, (byte)0xFF, (byte)0x00, (byte)0x11 }, encryptionData.getInitializationVector()); Assert.Equal(format, encryptionData.getKeyFormat()); Assert.Equal(new List <int>() { 1, 2, 3 }, encryptionData.getKeyFormatVersions()); }
MediaPlaylistLineParser(IExtTagParser tagParser, LineParser lineParser) { this.tagParser = tagParser; this.lineParser = lineParser; }
MediaPlaylistLineParser(IExtTagParser parser) : this(parser, new ExtLineParser(parser)) { }
MasterPlaylistLineParser(IExtTagParser tagParser, LineParser lineParser) { mTagParser = tagParser; mLineParser = lineParser; }
public ExtLineParser(IExtTagParser tagParser) { mTagParser = tagParser; }