Operation not supported in this configuration exception thrown with Chromecast's secure H264 decoder
- Dominant language
- Java
- Stars
- 21.9k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
### ExoPlayer Version
2.18.2
### Devices that reproduce the issue
* Chromecast with Google TV 4K (2020) - Android 12
### Devices that do not reproduce the issue
* LG G7 ThinQ - Android 10
### Reproducible in the demo app?
Yes
### Reproduction steps
1. Update the demo app to use drm sessions for clear content in createMediaSourceFactory:
``` DataSource.Factory dataSourceFactory = DemoUtil.getHttpDataSourceFactory(/* context= */ this);
DrmSessionManagerProvider drmSessionManagerProvider = new DrmSessionManagerProvider() {
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
@Override
public DrmSessionManager get(MediaItem mediaItem) {
return new DefaultDrmSessionManager.Builder()
.setUseDrmSessionsForClearContent(C.TRACK_TYPE_AUDIO, C.TRACK_TYPE_VIDEO)
.build(new HttpMediaDrmCallback(null, dataSourceFactory));
}
};
```
**Note: This is only required because the content that reproduces the issue with the decoder is clear and could probably happen with encrypted content as well.**
2. Play attached mp4 either by serving it via a local file server or loading it from a local asset in the demo app package.
**Note: Attached asset is originally sourced from a dash stream but has been reduced to just the segments that are causing the issue.**
### Expected result
The asset plays through to the end.
### Actual result
The asset plays for ~2 seconds before an exception is thrown.
```
2022-12-13 08:57:45.575 26645-26645/com.google.android.exoplayer2.demo E/EventLogger: playerFailed [eventTime=2.60, mediaPos=1.76, window=0, period=0, errorCode=ERROR_CODE_DRM_SYSTEM_ERROR
com.google.android.exoplayer2.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(1, null, null, video/avc, avc1.640028, -1, null, [1920, 1080, -1.0], [-1, -1]), format_supported=YES
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:578)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: android.media.MediaCodec$CryptoException: Operation not supported in this configuration
at android.media.MediaCodec.native_queueInputBuffer(Native Method)
at android.media.MediaCodec.queueInputBuffer(MediaCodec.java:2634)
at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter.queueInputBuffer(SynchronousMediaCodecAdapter.java:147)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.feedInputBuffer(MediaCodecRenderer.java:1369)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:794)
at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1001)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:502)
```
This occurs every-time when ExoPlayer is attempting to queue the input buffer for PTS 2252250. At this point the samples are at their largest for the video segment. The input buffer queues when this occurs are as follows:
```
Queue input: 1000001918583 Index: 0 Size: 173
Queue input: 1000001960291 Index: 1 Size: 18868
Queue input: 1000002002000 Index: 2 Size: 46868
Queue input: 1000002043708 Index: 3 Size: 73567
Queue input: 1000002085416 Index: 4 Size: 84631
Queue input: 1000002127125 Index: 5 Size: 153074
Queue input: 1000002168833 Index: 6 Size: 497048
Queue input: 1000002210541 Index: 7 Size: 1000746
Queue input: 1000002252250 Index: 8 Size: 1231366
```
When this occurs the codec also logs the following warning:
```
W/MediaCodec: Log queueSecureInputBuffer error: -2006
```
From investigation there are 2 changes that workaround the issue:
1. Set the `MediaFormat.KEY_MAX_INPUT_SIZE` to 2097153 in `MediaCodecVideoRenderer.getMediaFormat`. Anything lower does not work. It's unclear why this is required because the default that ExoPlayer is providing in this scenario is 1566720 which is larger than the buffer that is being input when the exception is thrown.
2. Force `MediaCodecAdapter.dequeueInputBufferIndex` to only returns input buffers within index < 3.
This issue can be produced when using either `AsynchronousMediaCodecAdapter` or `SynchronousMediaCodecAdapter`.
In testing I was also using https://github.com/taehwandev/MediaCodecExample modified to use the `OMX.amlogic.avc.decoder.awesome2.secure` decoder and it does not exhibit the same issue. The issue does not exist when ExoPlayer is using `OMX.amlogic.avc.decoder.awesome2` (unsecure).
### Media
MP4 is too large to attach, will attach in an email.
### Bug Report
- [X] You will email the zip file produced by `adb bugreport` to dev.exoplayer@gmail.com after filing this issue.
Contributor guide
Assessment
This issue has not been assessed yet.