Esempio n. 1
0
        public override bool Equals(object o)
        {
            if (!(o is PlaylistData))
            {
                return(false);
            }

            PlaylistData other = (PlaylistData)o;

            return(object.Equals(mUri, other.mUri) && object.Equals(mStreamInfo, other.mStreamInfo));
        }
Esempio n. 2
0
        private static void addPlaylistDataErrors(PlaylistData playlistData, HashSet <PlaylistError> errors)
        {
            if (playlistData.getUri() == null || playlistData.getUri().isEmpty())
            {
                errors.Add(PlaylistError.PLAYLIST_DATA_WITHOUT_URI);
            }


            if (playlistData.hasStreamInfo())
            {
                if (playlistData.getStreamInfo().getBandwidth() == StreamInfo.NO_BANDWIDTH)
                {
                    errors.Add(PlaylistError.STREAM_INFO_WITH_NO_BANDWIDTH);
                }

                if (playlistData.getStreamInfo().getAverageBandwidth() < StreamInfo.NO_BANDWIDTH)
                {
                    errors.Add(PlaylistError.STREAM_INFO_WITH_INVALID_AVERAGE_BANDWIDTH);
                }
            }
        }
Esempio n. 3
0
        public void masterPlaylistWithIFrames()
        {
            Playlist playlist = readPlaylist("masterPlaylistWithIFrames.m3u8");

            Assert.True(playlist.hasMasterPlaylist());

            MasterPlaylist masterPlaylist = playlist.getMasterPlaylist();

            Assert.NotNull(masterPlaylist);

            List <PlaylistData>     playlistDatas = masterPlaylist.getPlaylists();
            List <IFrameStreamInfo> iFrameInfo    = masterPlaylist.getIFramePlaylists();

            Assert.NotNull(playlistDatas);
            Assert.NotNull(iFrameInfo);
            Assert.Equal(4, playlistDatas.Count);
            Assert.Equal(3, iFrameInfo.Count);

            PlaylistData lowXStreamInf = playlistDatas[0];

            Assert.NotNull(lowXStreamInf);
            Assert.NotNull(lowXStreamInf.getStreamInfo());
            Assert.Equal(1280000, lowXStreamInf.getStreamInfo().getBandwidth());
            Assert.Equal("low/audio-video.m3u8", lowXStreamInf.getUri());

            PlaylistData midXStreamInf = playlistDatas[1];

            Assert.NotNull(midXStreamInf);
            Assert.NotNull(midXStreamInf.getStreamInfo());
            Assert.Equal(2560000, midXStreamInf.getStreamInfo().getBandwidth());
            Assert.Equal("mid/audio-video.m3u8", midXStreamInf.getUri());

            PlaylistData hiXStreamInf = playlistDatas[2];

            Assert.NotNull(hiXStreamInf);
            Assert.NotNull(hiXStreamInf.getStreamInfo());
            Assert.Equal(7680000, hiXStreamInf.getStreamInfo().getBandwidth());
            Assert.Equal("hi/audio-video.m3u8", hiXStreamInf.getUri());

            PlaylistData audioXStreamInf = playlistDatas[3];

            Assert.NotNull(audioXStreamInf);
            Assert.NotNull(audioXStreamInf.getStreamInfo());
            Assert.Equal(65000, audioXStreamInf.getStreamInfo().getBandwidth());
            Assert.NotNull(audioXStreamInf.getStreamInfo().getCodecs());
            Assert.Single(audioXStreamInf.getStreamInfo().getCodecs());
            Assert.Equal("mp4a.40.5", audioXStreamInf.getStreamInfo().getCodecs()[0]);
            Assert.Equal("audio-only.m3u8", audioXStreamInf.getUri());

            IFrameStreamInfo lowXIFrameStreamInf = iFrameInfo[0];

            Assert.NotNull(lowXIFrameStreamInf);
            Assert.Equal(86000, lowXIFrameStreamInf.getBandwidth());
            Assert.Equal("low/iframe.m3u8", lowXIFrameStreamInf.getUri());

            IFrameStreamInfo midXIFrameStreamInf = iFrameInfo[1];

            Assert.NotNull(midXIFrameStreamInf);
            Assert.Equal(150000, midXIFrameStreamInf.getBandwidth());
            Assert.Equal("mid/iframe.m3u8", midXIFrameStreamInf.getUri());

            IFrameStreamInfo hiXIFrameStreamInf = iFrameInfo[2];

            Assert.NotNull(hiXIFrameStreamInf);
            Assert.Equal(550000, hiXIFrameStreamInf.getBandwidth());
            Assert.Equal("hi/iframe.m3u8", hiXIFrameStreamInf.getUri());

            String writtenPlaylist = writePlaylist(playlist);

            Assert.Equal(
                "#EXTM3U\n" +
                "#EXT-X-VERSION:1\n" +
                "#EXT-X-STREAM-INF:BANDWIDTH=1280000\n" +
                "low/audio-video.m3u8\n" +
                "#EXT-X-STREAM-INF:BANDWIDTH=2560000\n" +
                "mid/audio-video.m3u8\n" +
                "#EXT-X-STREAM-INF:BANDWIDTH=7680000\n" +
                "hi/audio-video.m3u8\n" +
                "#EXT-X-STREAM-INF:CODECS=\"mp4a.40.5\",BANDWIDTH=65000\n" +
                "audio-only.m3u8\n" +
                "#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=86000,URI=\"low/iframe.m3u8\"\n" +
                "#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=150000,URI=\"mid/iframe.m3u8\"\n" +
                "#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=550000,URI=\"hi/iframe.m3u8\"\n",
                writtenPlaylist);
        }