1

I am using the Android NDK MediaDrm API to decrypt video access units with PlayReady.

I have found that certain API calls hang indefinitely. These calls are all successful in this order:

AMediaDrm_createByUUID()
AMediaDrm_openSession()
AMediaDrm_getKeyRequest()
AMediaDrm_provideKeyResponse()

But after the AMediaDrm_provideKeyResponse() call, any call to AMediaDrm_closeSession() or AMediaDrm_decrypt() will hang forever. Looking at the disassembly in both cases, we get stuck at a line jumping to itself such as:

0xf2ea9dec: jmp 0xf2ea9dec

AMediaDrm_closeSession() works when called straight after AMediaDrm_openSession() or AMediaDrm_getKeyRequest().

Has anyone experienced this issue before? Is there something I might be doing wrong with AMediaDrm_provideKeyResponse()?

Jack
  • 2,153
  • 5
  • 28
  • 43

2 Answers2

0

Are you perhaps trying this under an emulator or with a debugger attached? DRM technologies tend to take a very dim view of either of these and disable themselves when such actions are attempted.

Sander
  • 25,685
  • 3
  • 53
  • 85
  • I'm using a Nexus Player. I did have a debugger attached but have rebuilt with `APP_OPTIM := release` and omitting `NDK_DEBUG=1` from my call to `ndk-build`, and I still experience the issue. – Jack Feb 03 '15 at 17:05
0

So I just ran into this myself. I am testing on Android 6 right now, so I hope that this is fixed in A7 or some future release (an API for closing a session that hangs seems like a terrible idea, so I assume it must be a bug).

I did come up with a solution though. I suspect we both weren't using the API like intended, because if I release the keys from the session before closing the drm session, everything works just perfectly. Like so:

AMediaDrm*           mediadrm = NULL;
AMediaDrmKeySetId    keySetId;
AMediaDrmSessionId   drmsessionid;

< ... Code to do everything else that you need to do before you get to this point ... >

AMediaDrm_provideKeyResponse(mediadrm, &drmsessionid, &drmKey[0], drmKey.size(), &keySetId); 

< ... Use your session to playback some DRM protected content ... >

AMediaDrm_removeKeys(mediadrm,&keySetId);
AMediaDrm_closeSession(mediadrm, &drmsessionid);
AMediaDrm_release(mediadrm);

I know this is a bit late, so I hope you found a solution to your issue.

John Bowers
  • 1,695
  • 1
  • 16
  • 26