Skip to content

Commit

Permalink
Set HlsSampleStreamWrapper.trackType for audio-only playlists
Browse files Browse the repository at this point in the history
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
  • Loading branch information
christosts committed Aug 4, 2021
1 parent 07c49cd commit 4b1609d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:/google/ExoPlayer/issues/9175)).

### 2.14.2 (2021-07-20)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 4b1609d

Please sign in to comment.