google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.74k stars 6.03k forks source link

Retry DRM license refreshes #8241

Open zgzong opened 3 years ago

zgzong commented 3 years ago

[REQUIRED] Searched documentation and issues

Widevine have a feature, during a playback, it can initially reponse a short period license, and client need to renew the license periodically during the playback.

[REQUIRED] Issue description

When widevine fail to renew license during playback, there is no retry happens.

[REQUIRED] Reproduction steps

When play a stream with widevine encryption and the license require the client periodically renew the license. When renew license failed or timeout due to network issue,

Expect: the exoplayer can automatically retry the renew license request as it is the first time license request.

Actual: there is no renew happening.

[REQUIRED] Link to test content

NA

[REQUIRED] A full bug report captured from the device

I think the following function limit the retry only handle for first license request

  private void onKeysRequired() {
    if (mode == DefaultDrmSessionManager.MODE_PLAYBACK && state == STATE_OPENED_WITH_KEYS) {
      Util.castNonNull(sessionId);
      doLicense(/* allowRetry= */ false);
    }
  }

[REQUIRED] Version of ExoPlayer being used

2.12.0 2.11.4

[REQUIRED] Device(s) and version(s) of Android being used

Any android device os above os 5.0

icbaker commented 3 years ago

That code you highlighted is deliberate - we expect MediaDrm to trigger retries by emitting additional EVENT_KEY_REQUIRED events.

This is typically part of the license config, e.g. license duration of 5 minutes with a refresh period of 1 minute, naturally giving 3 retries.

You should be able to get the retry behaviour you need by changing the duration and refresh rate in your license configuration.

zgzong commented 3 years ago

Thank @icbaker your reply.

The license refresh means renew license, if the license configured as refresh 1 minute, every one minute the renew license will be triggered no matter the renew license request success or fail.

Our license server configured with 7 minutes license duration with a refresh period of 5 minutes.

It would be better user experience that the player client could handle the renew license exception, such as network timeout, or temporary server error. That behaviour will be aligned with the first time license request.

icbaker commented 3 years ago

Thanks for the details - your reasoning makes sense.

I'll mark this as an enhancement to enable retries for license refreshes.