Set HlsSampleStreamWrapper.trackType for audio-only playlists

For audio-only playlists, when formats are communicated to the app with
AnalyticsListener.onDownstreamFormatChanged(), the passed MediaLoadData
do not indicate this is an audio track and therefore the
PlaybackStatsListener cannot derive audio format-related information.

This change sets the main SampleStreamWrappers track type to AUDIO, if
the master playlist contains only audio variants.

Issue: #9175

#minor-release

PiperOrigin-RevId: 388676060
This commit is contained in:
christosts 2021-08-04 13:54:47 +01:00 committed by Christos Tsilopoulos
parent 5b2b882e81
commit 5689e093da
2 changed files with 11 additions and 1 deletions

View File

@ -144,6 +144,12 @@
* Deprecate `setControlDispatcher` in `MediaSessionConnector`. The * Deprecate `setControlDispatcher` in `MediaSessionConnector`. The
`ControlDispatcher` parameter has also been deprecated in all `ControlDispatcher` parameter has also been deprecated in all
`MediaSessionConnector` listener methods. `MediaSessionConnector` listener methods.
* HLS:
* Report audio track type in
`AnalyticsListener.onDownstreamFormatChanged()` for audio-only
playlists, so that the `PlaybackStatsListener` can derive audio
format-related information.
([#9175](https://github.com/google/ExoPlayer/issues/9175)).
### 2.14.2 (2021-07-20) ### 2.14.2 (2021-07-20)

View File

@ -628,9 +628,13 @@ public final class HlsMediaPeriod
numberOfAudioCodecs <= 1 numberOfAudioCodecs <= 1
&& numberOfVideoCodecs <= 1 && numberOfVideoCodecs <= 1
&& numberOfAudioCodecs + numberOfVideoCodecs > 0; && numberOfAudioCodecs + numberOfVideoCodecs > 0;
int trackType =
!useVideoVariantsOnly && numberOfAudioCodecs > 0
? C.TRACK_TYPE_AUDIO
: C.TRACK_TYPE_DEFAULT;
HlsSampleStreamWrapper sampleStreamWrapper = HlsSampleStreamWrapper sampleStreamWrapper =
buildSampleStreamWrapper( buildSampleStreamWrapper(
C.TRACK_TYPE_DEFAULT, trackType,
selectedPlaylistUrls, selectedPlaylistUrls,
selectedPlaylistFormats, selectedPlaylistFormats,
masterPlaylist.muxedAudioFormat, masterPlaylist.muxedAudioFormat,