List of usage examples for android.media NotProvisionedException toString
public String toString()
From source file:org.chromium.media.MediaDrmBridge.java
/** * Open a new session and return the sessionId. * * @return false if unexpected error happens. Return true if a new session * is successfully opened, or if provisioning is required to open a session. *///from w w w . ja va 2 s. c om private boolean openSession() { assert (mSessionId == null); if (mMediaDrm == null) { return false; } try { final byte[] sessionId = mMediaDrm.openSession(); mSessionId = new String(sessionId, "UTF-8"); } catch (android.media.NotProvisionedException e) { Log.e(TAG, "Cannot open a new session: " + e.toString()); return true; } catch (Exception e) { Log.e(TAG, "Cannot open a new session: " + e.toString()); return false; } assert (mSessionId != null); return createMediaCrypto(); }
From source file:org.chromium.media.MediaDrmBridge.java
/** * Generate a key request and post an asynchronous task to the native side * with the response message.//from ww w. j a v a2 s .c o m * * @param initData Data needed to generate the key request. * @param mime Mime type. */ @CalledByNative private void generateKeyRequest(byte[] initData, String mime) { Log.d(TAG, "generateKeyRequest()."); if (mMimeType == null) { mMimeType = mime; } else if (!mMimeType.equals(mime)) { onKeyError(); return; } if (mSessionId == null) { if (!openSession()) { onKeyError(); return; } // NotProvisionedException happened during openSession(). if (mSessionId == null) { if (mPendingInitData != null) { Log.e(TAG, "generateKeyRequest called when another call is pending."); onKeyError(); return; } // We assume MediaDrm.EVENT_PROVISION_REQUIRED is always fired if // NotProvisionedException is throwed in openSession(). // generateKeyRequest() will be resumed after provisioning is finished. // TODO(xhwang): Double check if this assumption is true. Otherwise we need // to handle the exception in openSession more carefully. mPendingInitData = initData; return; } } try { final byte[] session = mSessionId.getBytes("UTF-8"); HashMap<String, String> optionalParameters = new HashMap<String, String>(); final MediaDrm.KeyRequest request = mMediaDrm.getKeyRequest(session, initData, mime, MediaDrm.KEY_TYPE_STREAMING, optionalParameters); mHandler.post(new Runnable() { public void run() { nativeOnKeyMessage(mNativeMediaDrmBridge, mSessionId, request.getData(), request.getDefaultUrl()); } }); return; } catch (android.media.NotProvisionedException e) { // MediaDrm.EVENT_PROVISION_REQUIRED is also fired in this case. // Provisioning is handled in the handler of that event. Log.e(TAG, "Cannot get key request: " + e.toString()); return; } catch (java.io.UnsupportedEncodingException e) { Log.e(TAG, "Cannot get key request: " + e.toString()); } onKeyError(); }