diff --git a/packager/app/test/testdata/bear-640x360-av-ac3-master-golden.m3u8 b/packager/app/test/testdata/bear-640x360-av-ac3-master-golden.m3u8 index 055c6b17fc..6267ceef0d 100644 --- a/packager/app/test/testdata/bear-640x360-av-ac3-master-golden.m3u8 +++ b/packager/app/test/testdata/bear-640x360-av-ac3-master-golden.m3u8 @@ -1,5 +1,5 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- -#EXT-X-MEDIA:TYPE=AUDIO,URI="audio.m3u8",GROUP-ID="audio",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" -#EXT-X-STREAM-INF:BANDWIDTH=1242703,CODECS="avc1.64001e,ac-3",RESOLUTION=640x360,AUDIO="audio" +#EXT-X-MEDIA:TYPE=AUDIO,URI="audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" +#EXT-X-STREAM-INF:BANDWIDTH=1242703,CODECS="avc1.64001e,ac-3",RESOLUTION=640x360,AUDIO="default-audio-group" video.m3u8 diff --git a/packager/app/test/testdata/bear-640x360-av-ac3-ts-to-mp4-master-golden.m3u8 b/packager/app/test/testdata/bear-640x360-av-ac3-ts-to-mp4-master-golden.m3u8 index f26320f415..5f76149de8 100644 --- a/packager/app/test/testdata/bear-640x360-av-ac3-ts-to-mp4-master-golden.m3u8 +++ b/packager/app/test/testdata/bear-640x360-av-ac3-ts-to-mp4-master-golden.m3u8 @@ -1,5 +1,5 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- -#EXT-X-MEDIA:TYPE=AUDIO,URI="audio.m3u8",GROUP-ID="audio",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" -#EXT-X-STREAM-INF:BANDWIDTH=1168277,CODECS="avc1.64001e,ac-3",RESOLUTION=640x360,AUDIO="audio" +#EXT-X-MEDIA:TYPE=AUDIO,URI="audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" +#EXT-X-STREAM-INF:BANDWIDTH=1168277,CODECS="avc1.64001e,ac-3",RESOLUTION=640x360,AUDIO="default-audio-group" video.m3u8 diff --git a/packager/app/test/testdata/bear-640x360-av-master-golden.m3u8 b/packager/app/test/testdata/bear-640x360-av-master-golden.m3u8 index 2f4d6c0850..a535ebf18f 100644 --- a/packager/app/test/testdata/bear-640x360-av-master-golden.m3u8 +++ b/packager/app/test/testdata/bear-640x360-av-master-golden.m3u8 @@ -1,5 +1,5 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- -#EXT-X-MEDIA:TYPE=AUDIO,URI="audio.m3u8",GROUP-ID="audio",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" -#EXT-X-STREAM-INF:BANDWIDTH=1217518,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,AUDIO="audio" +#EXT-X-MEDIA:TYPE=AUDIO,URI="audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" +#EXT-X-STREAM-INF:BANDWIDTH=1217518,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,AUDIO="default-audio-group" video.m3u8 diff --git a/packager/app/test/testdata/bear-640x360-av-mp4-master-cenc-golden.m3u8 b/packager/app/test/testdata/bear-640x360-av-mp4-master-cenc-golden.m3u8 index f6568c261f..e98c91a8b9 100644 --- a/packager/app/test/testdata/bear-640x360-av-mp4-master-cenc-golden.m3u8 +++ b/packager/app/test/testdata/bear-640x360-av-mp4-master-cenc-golden.m3u8 @@ -1,5 +1,5 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- -#EXT-X-MEDIA:TYPE=AUDIO,URI="audio.m3u8",GROUP-ID="audio",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" -#EXT-X-STREAM-INF:BANDWIDTH=1111340,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,AUDIO="audio" +#EXT-X-MEDIA:TYPE=AUDIO,URI="audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" +#EXT-X-STREAM-INF:BANDWIDTH=1111340,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,AUDIO="default-audio-group" video.m3u8 diff --git a/packager/app/test/testdata/bear-640x360-av-mp4-master-golden.m3u8 b/packager/app/test/testdata/bear-640x360-av-mp4-master-golden.m3u8 index 670498660f..698fb25f6a 100644 --- a/packager/app/test/testdata/bear-640x360-av-mp4-master-golden.m3u8 +++ b/packager/app/test/testdata/bear-640x360-av-mp4-master-golden.m3u8 @@ -1,5 +1,5 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- -#EXT-X-MEDIA:TYPE=AUDIO,URI="audio/audio.m3u8",GROUP-ID="audio",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" -#EXT-X-STREAM-INF:BANDWIDTH=1105163,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,AUDIO="audio" +#EXT-X-MEDIA:TYPE=AUDIO,URI="audio/audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" +#EXT-X-STREAM-INF:BANDWIDTH=1105163,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,AUDIO="default-audio-group" video/video.m3u8 diff --git a/packager/app/test/testdata/bear-640x360-ec3-av-mp4-master-cenc-golden.m3u8 b/packager/app/test/testdata/bear-640x360-ec3-av-mp4-master-cenc-golden.m3u8 index 0da6f74e0d..61b927c4f9 100644 --- a/packager/app/test/testdata/bear-640x360-ec3-av-mp4-master-cenc-golden.m3u8 +++ b/packager/app/test/testdata/bear-640x360-ec3-av-mp4-master-cenc-golden.m3u8 @@ -1,5 +1,5 @@ #EXTM3U ## Generated with https://github.com/google/shaka-packager version -- -#EXT-X-MEDIA:TYPE=AUDIO,URI="audio.m3u8",GROUP-ID="audio",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" -#EXT-X-STREAM-INF:BANDWIDTH=1174135,CODECS="avc1.64001e,ec-3",RESOLUTION=640x360,AUDIO="audio" +#EXT-X-MEDIA:TYPE=AUDIO,URI="audio.m3u8",GROUP-ID="default-audio-group",NAME="stream_0",AUTOSELECT=YES,CHANNELS="2" +#EXT-X-STREAM-INF:BANDWIDTH=1174135,CODECS="avc1.64001e,ec-3",RESOLUTION=640x360,AUDIO="default-audio-group" video.m3u8 diff --git a/packager/hls/base/master_playlist.cc b/packager/hls/base/master_playlist.cc index 85783c5494..1994961cc6 100644 --- a/packager/hls/base/master_playlist.cc +++ b/packager/hls/base/master_playlist.cc @@ -20,8 +20,9 @@ namespace shaka { namespace hls { - namespace { +const char* kDefaultAudioGroupId = "default-audio-group"; + struct Variant { std::string audio_codec; const std::string* audio_group_id = nullptr; @@ -64,6 +65,13 @@ std::list AudioGroupsToVariants( return variants; } +const char* GetGroupId(const MediaPlaylist& playlist) { + // TODO(vaage): Add support to get a subtitle group id when text support + // is added. + const std::string& group_id = playlist.group_id(); + return group_id.empty() ? kDefaultAudioGroupId : group_id.c_str(); +} + void BuildAudioTag(const std::string& base_url, const std::string& group_id, const MediaPlaylist& audio_playlist, @@ -136,7 +144,7 @@ void MasterPlaylist::AddMediaPlaylist(MediaPlaylist* media_playlist) { DCHECK(media_playlist); switch (media_playlist->stream_type()) { case MediaPlaylist::MediaPlaylistStreamType::kAudio: { - const std::string& group_id = media_playlist->group_id(); + std::string group_id = GetGroupId(*media_playlist); audio_playlist_groups_[group_id].push_back(media_playlist); break; } diff --git a/packager/media/event/muxer_listener_factory.cc b/packager/media/event/muxer_listener_factory.cc index f559b101b1..6b1b8a19ce 100644 --- a/packager/media/event/muxer_listener_factory.cc +++ b/packager/media/event/muxer_listener_factory.cc @@ -44,16 +44,10 @@ std::unique_ptr CreateHlsListenerInternal( DCHECK(notifier); DCHECK_GE(stream_index, 0); - // TODO(rkuroiwa): Do some smart stuff to group the audios, e.g. detect - // languages. std::string group_id = stream.hls_group_id; std::string name = stream.hls_name; std::string hls_playlist_name = stream.hls_playlist_name; - if (group_id.empty()) { - group_id = "audio"; - } - if (name.empty()) { name = base::StringPrintf("stream_%d", stream_index); }