@@ -259,13 +259,20 @@ public void testVideoStreams() throws Exception {
259259 assertFalse (videoStreams .isEmpty ());
260260
261261 for (final VideoStream stream : videoStreams ) {
262- assertIsSecureUrl (stream .getUrl ());
263- assertFalse (stream .getResolution ().isEmpty ());
264-
265- final int formatId = stream .getFormatId ();
266- // see MediaFormat: video stream formats range from 0 to 0x100
267- assertTrue (0 <= formatId && formatId < 0x100 ,
268- "format id does not fit a video stream: " + formatId );
262+ if (stream .isUrl ()) {
263+ assertIsSecureUrl (stream .getContent ());
264+ }
265+ final StreamType streamType = extractor ().getStreamType ();
266+ // On some video streams, the resolution can be empty and the format be unknown,
267+ // especially on livestreams (like streams with HLS master playlists)
268+ if (streamType != StreamType .LIVE_STREAM
269+ && streamType != StreamType .AUDIO_LIVE_STREAM ) {
270+ assertFalse (stream .getResolution ().isEmpty ());
271+ final int formatId = stream .getFormatId ();
272+ // see MediaFormat: video stream formats range from 0 to 0x100
273+ assertTrue (0 <= formatId && formatId < 0x100 ,
274+ "Format id does not fit a video stream: " + formatId );
275+ }
269276 }
270277 } else {
271278 assertTrue (videoStreams .isEmpty ());
@@ -282,12 +289,17 @@ public void testAudioStreams() throws Exception {
282289 assertFalse (audioStreams .isEmpty ());
283290
284291 for (final AudioStream stream : audioStreams ) {
285- assertIsSecureUrl (stream .getUrl ());
292+ if (stream .isUrl ()) {
293+ assertIsSecureUrl (stream .getContent ());
294+ }
286295
287- final int formatId = stream .getFormatId ();
288- // see MediaFormat: video stream formats range from 0x100 to 0x1000
289- assertTrue (0x100 <= formatId && formatId < 0x1000 ,
290- "format id does not fit an audio stream: " + formatId );
296+ // The media format can be unknown on some audio streams
297+ if (stream .getFormat () != null ) {
298+ final int formatId = stream .getFormat ().id ;
299+ // see MediaFormat: audio stream formats range from 0x100 to 0x1000
300+ assertTrue (0x100 <= formatId && formatId < 0x1000 ,
301+ "Format id does not fit an audio stream: " + formatId );
302+ }
291303 }
292304 } else {
293305 assertTrue (audioStreams .isEmpty ());
@@ -304,12 +316,14 @@ public void testSubtitles() throws Exception {
304316 assertFalse (subtitles .isEmpty ());
305317
306318 for (final SubtitlesStream stream : subtitles ) {
307- assertIsSecureUrl (stream .getUrl ());
319+ if (stream .isUrl ()) {
320+ assertIsSecureUrl (stream .getContent ());
321+ }
308322
309323 final int formatId = stream .getFormatId ();
310324 // see MediaFormat: video stream formats range from 0x1000 to 0x10000
311325 assertTrue (0x1000 <= formatId && formatId < 0x10000 ,
312- "format id does not fit a subtitles stream: " + formatId );
326+ "Format id does not fit a subtitles stream: " + formatId );
313327 }
314328 } else {
315329 assertTrue (subtitles .isEmpty ());
@@ -332,7 +346,8 @@ public void testGetDashMpdUrl() throws Exception {
332346 assertTrue (dashMpdUrl .isEmpty ());
333347 } else {
334348 assertIsSecureUrl (dashMpdUrl );
335- ExtractorAsserts .assertContains (expectedDashMpdUrlContains (), extractor ().getDashMpdUrl ());
349+ ExtractorAsserts .assertContains (expectedDashMpdUrlContains (),
350+ extractor ().getDashMpdUrl ());
336351 }
337352 }
338353
0 commit comments