Search code examples
androidandroid-mediaplayerhttp-live-streaming

Must EXT-X-MEDIA come before EXT-X-STREAM-INF?


I'm trying to play an HTTP Live Stream I found on the latest Android (Version L) and it's failing. The error Android gives is:

E/M3UParser(152): Undefined media group '600k' referenced in stream info.

Looking into it further, I realized that this specific stream is first listing all the EXT-X-STREAM-INF tags before it goes on to list the matching EXT-X-MEDIA tags. I skinned the example down a bit to illustrate:

#EXT-X-STREAM-INF:AUDIO="600k",BANDWIDTH=1399877,CODECS="avc1.4d401f,mp4a.40.2"
http://example.com/1.m3u8
... [and later on] ...
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="600k",URI="blah",BANDWIDTH=614400

Looking at Android's source code, it appears that no mechanism was put in for Android to "look ahead" in the playlist file, and the code seems to assume that the EXT-X-MEDIA tags are supposed to be listed first.

However, I was reading the IETF draft and it doesn't seem to mention any such restriction on the ordering of these tags.

So I was wondering, is this a bug in the Android implementation? Or am I missing something?

(For the record, Apple's iOS seems to play this stream fine. Looks like they do know how to "look ahead")


Solution

  • Looks like a bug in stagefright. I don't think you're missing anything and probably understand it slightly better than the team that did the Android implementation.