From 5689e093da93e0c968338d71ba4267aaace07ff0 Mon Sep 17 00:00:00 2001 From: christosts Date: Wed, 4 Aug 2021 13:54:47 +0100 Subject: [PATCH] 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 --- RELEASENOTES.md | 6 ++++++ .../android/exoplayer2/source/hls/HlsMediaPeriod.java | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index ab3989eaef9..fb98ceca1cf 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -144,6 +144,12 @@ * Deprecate `setControlDispatcher` in `MediaSessionConnector`. The `ControlDispatcher` parameter has also been deprecated in all `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) diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaPeriod.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaPeriod.java index a13a7bb3a18..785e7f1d36b 100644 --- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaPeriod.java +++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaPeriod.java @@ -628,9 +628,13 @@ private void buildAndPrepareMainSampleStreamWrapper( numberOfAudioCodecs <= 1 && numberOfVideoCodecs <= 1 && numberOfAudioCodecs + numberOfVideoCodecs > 0; + int trackType = + !useVideoVariantsOnly && numberOfAudioCodecs > 0 + ? C.TRACK_TYPE_AUDIO + : C.TRACK_TYPE_DEFAULT; HlsSampleStreamWrapper sampleStreamWrapper = buildSampleStreamWrapper( - C.TRACK_TYPE_DEFAULT, + trackType, selectedPlaylistUrls, selectedPlaylistFormats, masterPlaylist.muxedAudioFormat,