use of com.google.android.exoplayer2.source.hls.playlist.HlsMediaPlaylist in project ExoPlayer by google.
the class HlsMediaPlaylistSegmentIteratorTest method next_startIteratorAtFirstSegment_correctElements.
@Test
public void next_startIteratorAtFirstSegment_correctElements() {
HlsMediaPlaylist mediaPlaylist = getHlsMediaPlaylist(LOW_LATENCY_SEGMENTS_AND_PARTS);
HlsChunkSource.HlsMediaPlaylistSegmentIterator hlsMediaPlaylistSegmentIterator = new HlsChunkSource.HlsMediaPlaylistSegmentIterator(mediaPlaylist.baseUri, /* startOfPlaylistInPeriodUs= */
0, HlsChunkSource.getSegmentBaseList(mediaPlaylist, /* mediaSequence= */
10, /* partIndex= */
C.INDEX_UNSET));
List<DataSpec> datasSpecs = new ArrayList<>();
while (hlsMediaPlaylistSegmentIterator.next()) {
datasSpecs.add(hlsMediaPlaylistSegmentIterator.getDataSpec());
}
assertThat(datasSpecs).hasSize(9);
// The iterator starts with 6 segments.
assertThat(datasSpecs.get(0).uri.toString()).isEqualTo("fileSequence10.ts");
// Followed by trailing parts.
assertThat(datasSpecs.get(6).uri.toString()).isEqualTo("fileSequence16.0.ts");
// The preload part is the last.
assertThat(Iterables.getLast(datasSpecs).uri.toString()).isEqualTo("fileSequence16.2.ts");
}
use of com.google.android.exoplayer2.source.hls.playlist.HlsMediaPlaylist in project ExoPlayer by google.
the class HlsMediaPlaylistSegmentIteratorTest method create_withPartIndexBeforeLastTrailingPartSegment_isEmpty.
@Test
public void create_withPartIndexBeforeLastTrailingPartSegment_isEmpty() {
HlsMediaPlaylist mediaPlaylist = getHlsMediaPlaylist(LOW_LATENCY_SEGMENTS_AND_PARTS);
HlsChunkSource.HlsMediaPlaylistSegmentIterator hlsMediaPlaylistSegmentIterator = new HlsChunkSource.HlsMediaPlaylistSegmentIterator(mediaPlaylist.baseUri, /* startOfPlaylistInPeriodUs= */
0, HlsChunkSource.getSegmentBaseList(mediaPlaylist, mediaPlaylist.mediaSequence + mediaPlaylist.segments.size(), /* partIndex= */
3));
assertThat(hlsMediaPlaylistSegmentIterator.next()).isFalse();
}
use of com.google.android.exoplayer2.source.hls.playlist.HlsMediaPlaylist in project ExoPlayer by google.
the class HlsMediaPlaylistSegmentIteratorTest method next_conventionalLiveStartIteratorAtSecondSegment_correctElements.
@Test
public void next_conventionalLiveStartIteratorAtSecondSegment_correctElements() {
HlsMediaPlaylist mediaPlaylist = getHlsMediaPlaylist(SEGMENTS_ONLY);
HlsChunkSource.HlsMediaPlaylistSegmentIterator hlsMediaPlaylistSegmentIterator = new HlsChunkSource.HlsMediaPlaylistSegmentIterator(mediaPlaylist.baseUri, /* startOfPlaylistInPeriodUs= */
0, HlsChunkSource.getSegmentBaseList(mediaPlaylist, /* mediaSequence= */
11, /* partIndex= */
C.INDEX_UNSET));
List<DataSpec> datasSpecs = new ArrayList<>();
while (hlsMediaPlaylistSegmentIterator.next()) {
datasSpecs.add(hlsMediaPlaylistSegmentIterator.getDataSpec());
}
assertThat(datasSpecs).hasSize(5);
assertThat(datasSpecs.get(0).uri.toString()).isEqualTo("fileSequence11.ts");
assertThat(Iterables.getLast(datasSpecs).uri.toString()).isEqualTo("fileSequence15.ts");
}
use of com.google.android.exoplayer2.source.hls.playlist.HlsMediaPlaylist in project ExoPlayer by google.
the class HlsMediaPlaylistSegmentIteratorTest method next_startIteratorAtFirstPartInaSegment_usesFullSegment.
@Test
public void next_startIteratorAtFirstPartInaSegment_usesFullSegment() {
HlsMediaPlaylist mediaPlaylist = getHlsMediaPlaylist(LOW_LATENCY_SEGMENTS_AND_PARTS);
HlsChunkSource.HlsMediaPlaylistSegmentIterator hlsMediaPlaylistSegmentIterator = new HlsChunkSource.HlsMediaPlaylistSegmentIterator(mediaPlaylist.baseUri, /* startOfPlaylistInPeriodUs= */
0, HlsChunkSource.getSegmentBaseList(mediaPlaylist, /* mediaSequence= */
14, /* partIndex= */
0));
List<DataSpec> datasSpecs = new ArrayList<>();
while (hlsMediaPlaylistSegmentIterator.next()) {
datasSpecs.add(hlsMediaPlaylistSegmentIterator.getDataSpec());
}
assertThat(datasSpecs).hasSize(5);
// The iterator starts with 6 segments.
assertThat(datasSpecs.get(0).uri.toString()).isEqualTo("fileSequence14.ts");
assertThat(datasSpecs.get(1).uri.toString()).isEqualTo("fileSequence15.ts");
// Followed by trailing parts.
assertThat(datasSpecs.get(2).uri.toString()).isEqualTo("fileSequence16.0.ts");
assertThat(datasSpecs.get(3).uri.toString()).isEqualTo("fileSequence16.1.ts");
// The preload part is the last.
assertThat(Iterables.getLast(datasSpecs).uri.toString()).isEqualTo("fileSequence16.2.ts");
}
use of com.google.android.exoplayer2.source.hls.playlist.HlsMediaPlaylist in project ExoPlayer by google.
the class HlsMediaPlaylistParserTest method encryptedMapTag.
@Test
public void encryptedMapTag() throws IOException {
Uri playlistUri = Uri.parse("https://example.com/test3.m3u8");
String playlistString = "#EXTM3U\n" + "#EXT-X-VERSION:3\n" + "#EXT-X-TARGETDURATION:5\n" + "#EXT-X-MEDIA-SEQUENCE:10\n" + "#EXT-X-KEY:METHOD=AES-128," + "URI=\"https://priv.example.com/key.php?r=2680\",IV=0x1566B\n" + "#EXT-X-MAP:URI=\"init1.ts\"" + "#EXTINF:5.005,\n" + "02/00/32.ts\n" + "#EXT-X-KEY:METHOD=NONE\n" + "#EXT-X-MAP:URI=\"init2.ts\"" + "#EXTINF:5.005,\n" + "02/00/47.ts\n";
InputStream inputStream = new ByteArrayInputStream(Util.getUtf8Bytes(playlistString));
HlsMediaPlaylist playlist = (HlsMediaPlaylist) new HlsPlaylistParser().parse(playlistUri, inputStream);
List<Segment> segments = playlist.segments;
Segment initSegment1 = segments.get(0).initializationSegment;
assertThat(initSegment1.fullSegmentEncryptionKeyUri).isEqualTo("https://priv.example.com/key.php?r=2680");
assertThat(initSegment1.encryptionIV).isEqualTo("0x1566B");
Segment initSegment2 = segments.get(1).initializationSegment;
assertThat(initSegment2.fullSegmentEncryptionKeyUri).isNull();
assertThat(initSegment2.encryptionIV).isNull();
}
Aggregations