2

I keep getting an error when pausing ExoPlayer and putting my app in the background. The stream contains Widevine protected content and ads that are inserted on the server side. I suspect this mixture of protected and unprotected content to be causing the error but have no idea where to start. Putting the app in the background and resuming it actually works once during the unprotected preroll ad but fails when trying it a second time in the main content.

SurfaceUtils logs the following message: native window cannot handle protected buffers: the consumer should either be a hardware composer or support hardware protection.

Does someone know what this actually means? Unfortunately I am not too familiar with the inner workings of ExoPlayer.

The code in SurfaceUtils.cpp that returns the error might be helpful here:

// Make sure to check whether either Stagefright or the video decoder
// requested protected buffers.
if (usage & GRALLOC_USAGE_PROTECTED) {
    // Check if the ANativeWindow sends images directly to SurfaceFlinger.
    int queuesToNativeWindow = 0;
    err = nativeWindow->query(
            nativeWindow, NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER, &queuesToNativeWindow);
    if (err != NO_ERROR) {
        ALOGE("error authenticating native window: %s (%d)", strerror(-err), -err);
        return err;
    }
    // Check if the consumer end of the ANativeWindow can handle protected content.
    int isConsumerProtected = 0;
    err = nativeWindow->query(
            nativeWindow, NATIVE_WINDOW_CONSUMER_IS_PROTECTED, &isConsumerProtected);
    if (err != NO_ERROR) {
        ALOGE("error query native window: %s (%d)", strerror(-err), -err);
        return err;
    }
    // Deny queuing into native window if neither condition is satisfied.
    if (queuesToNativeWindow != 1 && isConsumerProtected != 1) {
        ALOGE("native window cannot handle protected buffers: the consumer should either be a hardware composer or support hardware protection");
        return PERMISSION_DENIED;
    }
}
wkarl
  • 781
  • 1
  • 8
  • 19
  • The error comes because you are trying to post the protected media contents on to the surface directly and not using a surfaceview. – blganesh101 Aug 14 '19 at 13:19
  • @blganesh101 is it possible to use surface directly? Any solution will be appreciated. – Tina Lu Mar 03 '21 at 10:53

0 Answers0