Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sometimes IllegalArgumentException thrown, when parsing DASH manifest file with AC3 stream. #677

Closed
1 task
wndrus opened this issue Sep 26, 2023 · 3 comments
Assignees
Labels

Comments

@wndrus
Copy link

wndrus commented Sep 26, 2023

Version

ExoPlayer 2.19.1

More version details

No response

Devices that reproduce the issue

Android 12 STB

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Yes

Reproduction steps

  1. Play DASH stream with E-AC3-JOC audio or with audio with unknown channel count.

  2. The following exception is thrown during processing of period data:

09-14 20:50:15.735  1515  2397 E ExoPlayerImplInternal: Playback error
09-14 20:50:15.735  1515  2397 E ExoPlayerImplInternal:   com.google.android.exoplayer2.ExoPlaybackException: Unexpected runtime error
09-14 20:50:15.735  1515  2397 E ExoPlayerImplInternal:       at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:668)
09-14 20:50:15.735  1515  2397 E ExoPlayerImplInternal:       at android.os.Handler.dispatchMessage(Handler.java:102)
09-14 20:50:15.735  1515  2397 E ExoPlayerImplInternal:       at android.os.Looper.loopOnce(Looper.java:201)
09-14 20:50:15.735  1515  2397 E ExoPlayerImplInternal:       at android.os.Looper.loop(Looper.java:288)
09-14 20:50:15.735  1515  2397 E ExoPlayerImplInternal:       at android.os.HandlerThread.run(HandlerThread.java:67)
09-14 20:50:15.735  1515  2397 E ExoPlayerImplInternal:   Caused by: java.lang.IllegalArgumentException: Invalid zero channel mask
09-14 20:50:15.735  1515  2397 E ExoPlayerImplInternal:       at android.media.AudioFormat$Builder.setChannelMask(AudioFormat.java:1126)
09-14 20:50:15.735  1515  2397 E ExoPlayerImplInternal:       at com.google.android.exoplayer2.audio.AudioCapabilities$Api29.getMaxSupportedChannelCountForPassthrough(AudioCapabilities.java:419)
09-14 20:50:15.735  1515  2397 E ExoPlayerImplInternal:       at com.google.android.exoplayer2.audio.AudioCapabilities.getMaxSupportedChannelCountForPassthrough(AudioCapabilities.java:302)
09-14 20:50:15.735  1515  2397 E ExoPlayerImplInternal:       at com.google.android.exoplayer2.audio.AudioCapabilities.getEncodingAndChannelConfigForPassthrough(AudioCapabilities.java:240)
09-14 20:50:15.735  1515  2397 E ExoPlayerImplInternal:       at com.google.android.exoplayer2.audio.AudioCapabilities.isPassthroughPlaybackSupported(AudioCapabilities.java:199)
09-14 20:50:15.735  1515  2397 E ExoPlayerImplInternal:       at com.google.android.exoplayer2.audio.DefaultAudioSink.getFormatSupport(DefaultAudioSink.java:620)
09-14 20:50:15.735  1515  2397 E ExoPlayerImplInternal:       at com.google.android.exoplayer2.audio.DefaultAudioSink.supportsFormat(DefaultAudioSink.java:599)
09-14 20:50:15.735  1515  2397 E ExoPlayerImplInternal:       at com.google.android.exoplayer2.audio.MediaCodecAudioRenderer.supportsFormat(MediaCodecAudioRenderer.java:300)
09-14 20:50:15.735  1515  2397 E ExoPlayerImplInternal:       at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.supportsFormat(MediaCodecRenderer.java:459)
09-14 20:50:15.735  1515  2397 E ExoPlayerImplInternal:       at com.google.android.exoplayer2.trackselection.MappingTrackSelector.findRenderer(MappingTrackSelector.java:513)
09-14 20:50:15.735  1515  2397 E ExoPlayerImplInternal:       at com.google.android.exoplayer2.trackselection.MappingTrackSelector.selectTracks(MappingTrackSelector.java:380)
09-14 20:50:15.735  1515  2397 E ExoPlayerImplInternal:       at com.google.android.exoplayer2.MediaPeriodHolder.selectTracks(MediaPeriodHolder.java:246)
09-14 20:50:15.735  1515  2397 E ExoPlayerImplInternal:       at com.google.android.exoplayer2.MediaPeriodHolder.handlePrepared(MediaPeriodHolder.java:194)
09-14 20:50:15.735  1515  2397 E ExoPlayerImplInternal:       at com.google.android.exoplayer2.ExoPlayerImplInternal.handlePeriodPrepared(ExoPlayerImplInternal.java:2327)
09-14 20:50:15.735  1515  2397 E ExoPlayerImplInternal:       at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:541)
09-14 20:50:15.735  1515  2397 E ExoPlayerImplInternal:       ... 4 more

  1. There is an issue in AudioCapabilities.java getMaxSupportedChannelCountForPassthrough().
    The function iterates from DEFAULT_MAX_CHANNEL_COUNT, which now is 10 to 1 and trying to create AudioFormat, setting the channel mask with given channel count, but Util.getAudioTrackChannelConfig() for input parameter 9 returns AudioFormat.CHANNEL_INVALID, which leads to exception.

The issue happened after May 25 2023, when DEFAULT_MAX_CHANNEL_COUNT was changed from 8 to 10.

The possible fix:

diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioCapabilities.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioCapabilities.java
index d384d05fdb..09f0507cf2 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioCapabilities.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioCapabilities.java
@@ -412,11 +412,15 @@ public final class AudioCapabilities {
       // TODO(internal b/234351617): Query supported channel masks directly once it's supported,
       // see also b/25994457.
       for (int channelCount = DEFAULT_MAX_CHANNEL_COUNT; channelCount > 0; channelCount--) {
+        int channelMask = Util.getAudioTrackChannelConfig(channelCount);
+        if(AudioFormat.CHANNEL_INVALID == channelMask) {
+          continue;
+        }
         AudioFormat audioFormat =
             new AudioFormat.Builder()
                 .setEncoding(encoding)
                 .setSampleRate(sampleRate)
-                .setChannelMask(Util.getAudioTrackChannelConfig(channelCount))
+                .setChannelMask(channelMask)
                 .build();
         if (AudioTrack.isDirectPlaybackSupported(audioFormat, DEFAULT_AUDIO_ATTRIBUTES)) {
           return channelCount;

Expected result

Media stream is played correctly.

Actual result

Playback error

Media

<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:cenc="urn:mpeg:cenc:2013" xmlns:scte35="http://www.scte.org/schemas/35/2016" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" availabilityStartTime="2023-08-29T23:50:44Z" maxSegmentDuration="PT4.011S" minBufferTime="PT4S" minimumUpdatePeriod="PT12S" profiles="urn:mpeg:dash:profile:isoff-live:2011" publishTime="2023-09-26T10:57:06Z" timeShiftBufferDepth="PT52.0S" type="dynamic" xsi:schemalocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd">
<Period id="P0" start="PT0S">
<AdaptationSet contentType="video" id="0" maxFrameRate="25" maxHeight="1080" maxWidth="1920" mimeType="video/mp4" minFrameRate="25" minHeight="432" minWidth="640" par="4:3" segmentAlignment="true" startWithSAP="1">
<Role schemeIdUri="urn:mpeg:dash:role:2011" value="main"/>
<Representation bandwidth="500000" codecs="avc1.4d401e" frameRate="25" height="480" id="Video1_1" sar="4:3" scanType="progressive" width="640">
<SegmentTemplate duration="4000000" initialization="video-$RepresentationID$-init.m4i?hw_dash=1&servicetype=1&service_devid=893&mag_hms=893,535&rrsip=31.20.164.84&zoneoffset=0&devkbps=1-30000&accounttype=1&limitflux=-1&limitdur=-1&tenantId=3103&online=1695725830" media="video-$RepresentationID$-$Number$.m4v?hw_dash=1&servicetype=1&service_devid=893&mag_hms=893,535&rrsip=31.20.164.84&zoneoffset=0&devkbps=1-30000&accounttype=1&limitflux=-1&limitdur=-1&tenantId=3103&online=1695725830" startNumber="1" timescale="1000000"/>
</Representation>
<Representation bandwidth="1000000" codecs="avc1.4d401e" frameRate="25" height="432" id="Video1_2" sar="1:1" scanType="progressive" width="768">
<SegmentTemplate duration="4000000" initialization="video-$RepresentationID$-init.m4i?hw_dash=1&servicetype=1&service_devid=893&mag_hms=893,535&rrsip=31.20.164.84&zoneoffset=0&devkbps=1-30000&accounttype=1&limitflux=-1&limitdur=-1&tenantId=3103&online=1695725830" media="video-$RepresentationID$-$Number$.m4v?hw_dash=1&servicetype=1&service_devid=893&mag_hms=893,535&rrsip=31.20.164.84&zoneoffset=0&devkbps=1-30000&accounttype=1&limitflux=-1&limitdur=-1&tenantId=3103&online=1695725830" startNumber="1" timescale="1000000"/>
</Representation>
<Representation bandwidth="1800000" codecs="avc1.4d401f" frameRate="25" height="576" id="Video1_3" sar="1:1" scanType="progressive" width="1024">
<SegmentTemplate duration="4000000" initialization="video-$RepresentationID$-init.m4i?hw_dash=1&servicetype=1&service_devid=893&mag_hms=893,535&rrsip=31.20.164.84&zoneoffset=0&devkbps=1-30000&accounttype=1&limitflux=-1&limitdur=-1&tenantId=3103&online=1695725830" media="video-$RepresentationID$-$Number$.m4v?hw_dash=1&servicetype=1&service_devid=893&mag_hms=893,535&rrsip=31.20.164.84&zoneoffset=0&devkbps=1-30000&accounttype=1&limitflux=-1&limitdur=-1&tenantId=3103&online=1695725830" startNumber="1" timescale="1000000"/>
</Representation>
<Representation bandwidth="2700000" codecs="avc1.4d401f" frameRate="25" height="720" id="Video1_4" sar="1:1" scanType="progressive" width="1280">
<SegmentTemplate duration="4000000" initialization="video-$RepresentationID$-init.m4i?hw_dash=1&servicetype=1&service_devid=893&mag_hms=893,535&rrsip=31.20.164.84&zoneoffset=0&devkbps=1-30000&accounttype=1&limitflux=-1&limitdur=-1&tenantId=3103&online=1695725830" media="video-$RepresentationID$-$Number$.m4v?hw_dash=1&servicetype=1&service_devid=893&mag_hms=893,535&rrsip=31.20.164.84&zoneoffset=0&devkbps=1-30000&accounttype=1&limitflux=-1&limitdur=-1&tenantId=3103&online=1695725830" startNumber="1" timescale="1000000"/>
</Representation>
<Representation bandwidth="4500000" codecs="avc1.4d4028" frameRate="25" height="1080" id="Video1_5" sar="1:1" scanType="progressive" width="1920">
<SegmentTemplate duration="4000000" initialization="video-$RepresentationID$-init.m4i?hw_dash=1&servicetype=1&service_devid=893&mag_hms=893,535&rrsip=31.20.164.84&zoneoffset=0&devkbps=1-30000&accounttype=1&limitflux=-1&limitdur=-1&tenantId=3103&online=1695725830" media="video-$RepresentationID$-$Number$.m4v?hw_dash=1&servicetype=1&service_devid=893&mag_hms=893,535&rrsip=31.20.164.84&zoneoffset=0&devkbps=1-30000&accounttype=1&limitflux=-1&limitdur=-1&tenantId=3103&online=1695725830" startNumber="1" timescale="1000000"/>
</Representation>
</AdaptationSet>
<AdaptationSet contentType="audio" id="1" lang="ger" mimeType="audio/mp4" segmentAlignment="true" startWithSAP="1">
<Role schemeIdUri="urn:mpeg:dash:role:2011" value="main"/>
<Representation audioSamplingRate="48000" bandwidth="128000" codecs="mp4a.40.2" id="Audio2_6">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
<SegmentTemplate duration="4000000" initialization="audio-0-$RepresentationID$-init.m4i?hw_dash=1&servicetype=1&service_devid=893&mag_hms=893,535&rrsip=31.20.164.84&zoneoffset=0&devkbps=1-30000&accounttype=1&limitflux=-1&limitdur=-1&tenantId=3103&online=1695725830" media="audio-0-$RepresentationID$-$Number$.m4a?hw_dash=1&servicetype=1&service_devid=893&mag_hms=893,535&rrsip=31.20.164.84&zoneoffset=0&devkbps=1-30000&accounttype=1&limitflux=-1&limitdur=-1&tenantId=3103&online=1695725830" startNumber="1" timescale="1000000"/>
</Representation>
</AdaptationSet>
<AdaptationSet contentType="audio" id="2" lang="ger" mimeType="audio/mp4" segmentAlignment="true" startWithSAP="1">
<Role schemeIdUri="urn:mpeg:dash:role:2011" value="alternate"/>
<Representation audioSamplingRate="48000" bandwidth="480000" codecs="ac-3" id="Audio3_7">
<AudioChannelConfiguration schemeIdUri="tag:dolby.com,2014:dash:audio_channel_configuration:2011" value="e001"/>
<SegmentTemplate duration="4000000" initialization="audio-1-$Bandwidth$-init.mp4a?hw_dash=1&servicetype=1&service_devid=893&mag_hms=893,535&rrsip=31.20.164.84&zoneoffset=0&devkbps=1-30000&accounttype=1&limitflux=-1&limitdur=-1&tenantId=3103&online=1695725830" media="audio-1-$Bandwidth$-$Number$.mp4a?hw_dash=1&servicetype=1&service_devid=893&mag_hms=893,535&rrsip=31.20.164.84&zoneoffset=0&devkbps=1-30000&accounttype=1&limitflux=-1&limitdur=-1&tenantId=3103&online=1695725830" startNumber="1" timescale="1000000"/>
</Representation>
</AdaptationSet>
<AdaptationSet contentType="text" id="3" lang="und" mimeType="application/mp4" segmentAlignment="true" startWithSAP="1">
<Role schemeIdUri="urn:mpeg:dash:role:2011" value="subtitle"/>
<Representation bandwidth="50000" codecs="stpp" id="Data4_8">
<SegmentTemplate duration="4000000" initialization="data-0-$RepresentationID$-init.m4i?hw_dash=1&servicetype=1&service_devid=893&mag_hms=893,535&rrsip=31.20.164.84&zoneoffset=0&devkbps=1-30000&accounttype=1&limitflux=-1&limitdur=-1&tenantId=3103&online=1695725830" media="data-0-$RepresentationID$-$Number$.m4s?hw_dash=1&servicetype=1&service_devid=893&mag_hms=893,535&rrsip=31.20.164.84&zoneoffset=0&devkbps=1-30000&accounttype=1&limitflux=-1&limitdur=-1&tenantId=3103&online=1695725830" startNumber="1" timescale="1000000"/>
</Representation>
</AdaptationSet>
</Period>
</MPD>

Bug Report

  • You will email the zip file produced by adb bugreport to [email protected] after filing this issue.
@marcbaechinger
Copy link
Contributor

marcbaechinger commented Sep 28, 2023

Thanks for your detailed report.

Can you provide us with a URI to the media so we can provide a fix and test with it?

@Aziz83yahya
Copy link

Support for the story

@wndrus
Copy link
Author

wndrus commented Oct 15, 2023

Thanks for your detailed report.

Can you provide us with a URI to the media so we can provide a fix and test with it?

Hello, unfortunately I can not provide media URI by the security reasons ((

@tonihei tonihei assigned tonihei and unassigned marcbaechinger Oct 19, 2023
@tonihei tonihei closed this as completed Oct 19, 2023
@androidx androidx locked and limited conversation to collaborators Dec 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants