android.media.MediaDrm Java Examples
The following examples show how to use
android.media.MediaDrm.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FrameworkMediaDrm.java From MediaSDK with Apache License 2.0 | 6 votes |
@Override public void setOnKeyStatusChangeListener( final OnKeyStatusChangeListener<? super FrameworkMediaCrypto> listener) { if (Util.SDK_INT < 23) { throw new UnsupportedOperationException(); } mediaDrm.setOnKeyStatusChangeListener( listener == null ? null : (mediaDrm, sessionId, keyInfo, hasNewUsableKey) -> { List<KeyStatus> exoKeyInfo = new ArrayList<>(); for (MediaDrm.KeyStatus keyStatus : keyInfo) { exoKeyInfo.add(new KeyStatus(keyStatus.getStatusCode(), keyStatus.getKeyId())); } listener.onKeyStatusChange( FrameworkMediaDrm.this, sessionId, exoKeyInfo, hasNewUsableKey); }, null); }
Example #2
Source File: FrameworkMediaDrm.java From Telegram with GNU General Public License v2.0 | 6 votes |
@Override public void setOnKeyStatusChangeListener( final ExoMediaDrm.OnKeyStatusChangeListener<? super FrameworkMediaCrypto> listener) { if (Util.SDK_INT < 23) { throw new UnsupportedOperationException(); } mediaDrm.setOnKeyStatusChangeListener( listener == null ? null : (mediaDrm, sessionId, keyInfo, hasNewUsableKey) -> { List<KeyStatus> exoKeyInfo = new ArrayList<>(); for (MediaDrm.KeyStatus keyStatus : keyInfo) { exoKeyInfo.add(new KeyStatus(keyStatus.getStatusCode(), keyStatus.getKeyId())); } listener.onKeyStatusChange( FrameworkMediaDrm.this, sessionId, exoKeyInfo, hasNewUsableKey); }, null); }
Example #3
Source File: FrameworkMediaDrm.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@Override public void setOnKeyStatusChangeListener( final ExoMediaDrm.OnKeyStatusChangeListener<? super FrameworkMediaCrypto> listener) { if (Util.SDK_INT < 23) { throw new UnsupportedOperationException(); } mediaDrm.setOnKeyStatusChangeListener( listener == null ? null : (mediaDrm, sessionId, keyInfo, hasNewUsableKey) -> { List<KeyStatus> exoKeyInfo = new ArrayList<>(); for (MediaDrm.KeyStatus keyStatus : keyInfo) { exoKeyInfo.add(new KeyStatus(keyStatus.getStatusCode(), keyStatus.getKeyId())); } listener.onKeyStatusChange( FrameworkMediaDrm.this, sessionId, exoKeyInfo, hasNewUsableKey); }, null); }
Example #4
Source File: StreamingDrmSessionManager.java From Exoplayer_VLC with Apache License 2.0 | 6 votes |
@Override public void handleMessage(Message msg) { if (openCount == 0 || (state != STATE_OPENED && state != STATE_OPENED_WITH_KEYS)) { return; } switch (msg.what) { case MediaDrm.EVENT_KEY_REQUIRED: postKeyRequest(); return; case MediaDrm.EVENT_KEY_EXPIRED: state = STATE_OPENED; postKeyRequest(); return; case MediaDrm.EVENT_PROVISION_REQUIRED: state = STATE_OPENED; postProvisionRequest(); return; } }
Example #5
Source File: MediaDrmBridge.java From 365browser with Apache License 2.0 | 6 votes |
@Override public void onResult(Boolean success) { if (!success) { onPromiseRejected(mPromiseId, "failed to update key after response accepted"); return; } Log.d(TAG, "Key successfully %s for session %s", mIsKeyRelease ? "released" : "added", mSessionId.toHexString()); onPromiseResolved(mPromiseId); if (!mIsKeyRelease && Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { onSessionKeysChange(mSessionId, getDummyKeysInfo(MediaDrm.KeyStatus.STATUS_USABLE).toArray(), true, mIsKeyRelease); } }
Example #6
Source File: MediaDrmBridge.java From 365browser with Apache License 2.0 | 6 votes |
@Override public void onExpirationUpdate( MediaDrm md, byte[] drmSessionId, final long expirationTime) { final SessionId sessionId = getSessionIdByDrmId(drmSessionId); assert sessionId != null; deferEventHandleIfNeeded(sessionId, new Runnable() { @Override public void run() { Log.d(TAG, "ExpirationUpdate: " + sessionId.toHexString() + ", " + expirationTime); onSessionExpirationUpdate(sessionId, expirationTime); } }); }
Example #7
Source File: MediaDrmBridge.java From 365browser with Apache License 2.0 | 6 votes |
@Override public void onKeyStatusChange(MediaDrm md, byte[] drmSessionId, final List<MediaDrm.KeyStatus> keyInformation, final boolean hasNewUsableKey) { final SessionId sessionId = getSessionIdByDrmId(drmSessionId); assert sessionId != null; assert mSessionManager.get(sessionId) != null; final boolean isKeyRelease = mSessionManager.get(sessionId).keyType() == MediaDrm.KEY_TYPE_RELEASE; deferEventHandleIfNeeded(sessionId, new Runnable() { @Override public void run() { Log.d(TAG, "KeysStatusChange: " + sessionId.toHexString() + ", " + hasNewUsableKey); onSessionKeysChange(sessionId, getKeysInfo(keyInformation).toArray(), hasNewUsableKey, isKeyRelease); } }); }
Example #8
Source File: MediaDrmBridge.java From 365browser with Apache License 2.0 | 6 votes |
@TargetApi(Build.VERSION_CODES.M) private void onSessionMessage(final SessionId sessionId, final MediaDrm.KeyRequest request) { if (!isNativeMediaDrmBridgeValid()) return; int requestType = MediaDrm.KeyRequest.REQUEST_TYPE_INITIAL; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { requestType = request.getRequestType(); } else { // Prior to M, getRequestType() is not supported. Do our best guess here: Assume // requests with a URL are renewals and all others are initial requests. requestType = request.getDefaultUrl().isEmpty() ? MediaDrm.KeyRequest.REQUEST_TYPE_INITIAL : MediaDrm.KeyRequest.REQUEST_TYPE_RENEWAL; } nativeOnSessionMessage( mNativeMediaDrmBridge, sessionId.emeId(), requestType, request.getData()); }
Example #9
Source File: FrameworkMediaDrm.java From K-Sonic with MIT License | 6 votes |
@Override public KeyRequest getKeyRequest(byte[] scope, byte[] init, String mimeType, int keyType, HashMap<String, String> optionalParameters) throws NotProvisionedException { final MediaDrm.KeyRequest request = mediaDrm.getKeyRequest(scope, init, mimeType, keyType, optionalParameters); return new KeyRequest() { @Override public byte[] getData() { return request.getData(); } @Override public String getDefaultUrl() { return request.getDefaultUrl(); } }; }
Example #10
Source File: DefaultDrmSessionManager.java From K-Sonic with MIT License | 6 votes |
@SuppressWarnings("deprecation") @Override public void handleMessage(Message msg) { if (openCount == 0 || (state != STATE_OPENED && state != STATE_OPENED_WITH_KEYS)) { return; } switch (msg.what) { case MediaDrm.EVENT_KEY_REQUIRED: doLicense(); break; case MediaDrm.EVENT_KEY_EXPIRED: // When an already expired key is loaded MediaDrm sends this event immediately. Ignore // this event if the state isn't STATE_OPENED_WITH_KEYS yet which means we're still // waiting for key response. if (state == STATE_OPENED_WITH_KEYS) { state = STATE_OPENED; onError(new KeysExpiredException()); } break; case MediaDrm.EVENT_PROVISION_REQUIRED: state = STATE_OPENED; postProvisionRequest(); break; } }
Example #11
Source File: DashTest.java From ExoPlayer-Offline with Apache License 2.0 | 6 votes |
@TargetApi(18) @SuppressWarnings("ResourceType") private static boolean isL1WidevineAvailable(String videoMimeType) { try { // Force L3 if secure decoder is not available. if (MediaCodecUtil.getDecoderInfo(videoMimeType, true) == null) { return false; } MediaDrm mediaDrm = new MediaDrm(WIDEVINE_UUID); String securityProperty = mediaDrm.getPropertyString(SECURITY_LEVEL_PROPERTY); mediaDrm.release(); return WIDEVINE_SECURITY_LEVEL_1.equals(securityProperty); } catch (DecoderQueryException | UnsupportedSchemeException e) { throw new IllegalStateException(e); } }
Example #12
Source File: FrameworkMediaDrm.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void setOnKeyStatusChangeListener( final ExoMediaDrm.OnKeyStatusChangeListener<? super FrameworkMediaCrypto> listener) { if (Util.SDK_INT < 23) { throw new UnsupportedOperationException(); } mediaDrm.setOnKeyStatusChangeListener(listener == null ? null : new MediaDrm.OnKeyStatusChangeListener() { @Override public void onKeyStatusChange(@NonNull MediaDrm md, @NonNull byte[] sessionId, @NonNull List<MediaDrm.KeyStatus> keyInfo, boolean hasNewUsableKey) { List<KeyStatus> exoKeyInfo = new ArrayList<>(); for (MediaDrm.KeyStatus keyStatus : keyInfo) { exoKeyInfo.add(new DefaultKeyStatus(keyStatus.getStatusCode(), keyStatus.getKeyId())); } listener.onKeyStatusChange(FrameworkMediaDrm.this, sessionId, exoKeyInfo, hasNewUsableKey); } }, null); }
Example #13
Source File: FrameworkMediaDrm.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void setOnKeyStatusChangeListener( final ExoMediaDrm.OnKeyStatusChangeListener<? super FrameworkMediaCrypto> listener) { if (Util.SDK_INT < 23) { throw new UnsupportedOperationException(); } mediaDrm.setOnKeyStatusChangeListener(listener == null ? null : new MediaDrm.OnKeyStatusChangeListener() { @Override public void onKeyStatusChange(@NonNull MediaDrm md, @NonNull byte[] sessionId, @NonNull List<MediaDrm.KeyStatus> keyInfo, boolean hasNewUsableKey) { List<KeyStatus> exoKeyInfo = new ArrayList<>(); for (MediaDrm.KeyStatus keyStatus : keyInfo) { exoKeyInfo.add(new DefaultKeyStatus(keyStatus.getStatusCode(), keyStatus.getKeyId())); } listener.onKeyStatusChange(FrameworkMediaDrm.this, sessionId, exoKeyInfo, hasNewUsableKey); } }, null); }
Example #14
Source File: StreamingDrmSessionManager.java From Exoplayer_VLC with Apache License 2.0 | 5 votes |
private void postKeyRequest() { KeyRequest keyRequest; try { keyRequest = mediaDrm.getKeyRequest(sessionId, schemePsshData, mimeType, MediaDrm.KEY_TYPE_STREAMING, optionalKeyRequestParameters); postRequestHandler.obtainMessage(MSG_KEYS, keyRequest).sendToTarget(); } catch (NotProvisionedException e) { onKeysError(e); } }
Example #15
Source File: MediaDrmBridge.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void onEvent(MediaDrm mediaDrm, byte[] sessionId, int event, int extra, byte[] data) { switch(event) { case MediaDrm.EVENT_PROVISION_REQUIRED: Log.d(TAG, "MediaDrm.EVENT_PROVISION_REQUIRED."); MediaDrm.ProvisionRequest request = mMediaDrm.getProvisionRequest(); PostRequestTask postTask = new PostRequestTask(request.getData()); postTask.execute(request.getDefaultUrl()); break; case MediaDrm.EVENT_KEY_REQUIRED: Log.d(TAG, "MediaDrm.EVENT_KEY_REQUIRED."); generateKeyRequest(data, mMimeType); break; case MediaDrm.EVENT_KEY_EXPIRED: Log.d(TAG, "MediaDrm.EVENT_KEY_EXPIRED."); onKeyError(); break; case MediaDrm.EVENT_VENDOR_DEFINED: Log.d(TAG, "MediaDrm.EVENT_VENDOR_DEFINED."); assert(false); break; default: Log.e(TAG, "Invalid DRM event " + (int)event); return; } }
Example #16
Source File: MediaDrmBridge.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
/** * Reset the device DRM credentials. */ @CalledByNative private void resetDeviceCredentials() { mResetDeviceCredentialsPending = true; MediaDrm.ProvisionRequest request = mMediaDrm.getProvisionRequest(); PostRequestTask postTask = new PostRequestTask(request.getData()); postTask.execute(request.getDefaultUrl()); }
Example #17
Source File: MediaDrmBridge.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
private MediaDrmBridge(UUID schemeUUID, String securityLevel, int nativeMediaDrmBridge) throws android.media.UnsupportedSchemeException { mSchemeUUID = schemeUUID; mMediaDrm = new MediaDrm(schemeUUID); mHandler = new Handler(); mNativeMediaDrmBridge = nativeMediaDrmBridge; mResetDeviceCredentialsPending = false; mMediaDrm.setOnEventListener(new MediaDrmListener()); mMediaDrm.setPropertyString(PRIVACY_MODE, "enable"); String currentSecurityLevel = mMediaDrm.getPropertyString(SECURITY_LEVEL); Log.e(TAG, "Security level: current " + currentSecurityLevel + ", new " + securityLevel); if (!securityLevel.equals(currentSecurityLevel)) mMediaDrm.setPropertyString(SECURITY_LEVEL, securityLevel); }
Example #18
Source File: MediaDrmBridge.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void onEvent(MediaDrm mediaDrm, byte[] sessionId, int event, int extra, byte[] data) { switch(event) { case MediaDrm.EVENT_PROVISION_REQUIRED: Log.d(TAG, "MediaDrm.EVENT_PROVISION_REQUIRED."); MediaDrm.ProvisionRequest request = mMediaDrm.getProvisionRequest(); PostRequestTask postTask = new PostRequestTask(request.getData()); postTask.execute(request.getDefaultUrl()); break; case MediaDrm.EVENT_KEY_REQUIRED: Log.d(TAG, "MediaDrm.EVENT_KEY_REQUIRED."); generateKeyRequest(data, mMimeType); break; case MediaDrm.EVENT_KEY_EXPIRED: Log.d(TAG, "MediaDrm.EVENT_KEY_EXPIRED."); onKeyError(); break; case MediaDrm.EVENT_VENDOR_DEFINED: Log.d(TAG, "MediaDrm.EVENT_VENDOR_DEFINED."); assert(false); break; default: Log.e(TAG, "Invalid DRM event " + (int)event); return; } }
Example #19
Source File: MediaDrmBridge.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
/** * Reset the device DRM credentials. */ @CalledByNative private void resetDeviceCredentials() { mResetDeviceCredentialsPending = true; MediaDrm.ProvisionRequest request = mMediaDrm.getProvisionRequest(); PostRequestTask postTask = new PostRequestTask(request.getData()); postTask.execute(request.getDefaultUrl()); }
Example #20
Source File: MediaDrmBridge.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
private MediaDrmBridge(UUID schemeUUID, String securityLevel, int nativeMediaDrmBridge) throws android.media.UnsupportedSchemeException { mSchemeUUID = schemeUUID; mMediaDrm = new MediaDrm(schemeUUID); mHandler = new Handler(); mNativeMediaDrmBridge = nativeMediaDrmBridge; mResetDeviceCredentialsPending = false; mMediaDrm.setOnEventListener(new MediaDrmListener()); mMediaDrm.setPropertyString(PRIVACY_MODE, "enable"); String currentSecurityLevel = mMediaDrm.getPropertyString(SECURITY_LEVEL); Log.e(TAG, "Security level: current " + currentSecurityLevel + ", new " + securityLevel); if (!securityLevel.equals(currentSecurityLevel)) mMediaDrm.setPropertyString(SECURITY_LEVEL, securityLevel); }
Example #21
Source File: FrameworkMediaDrm.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public KeyRequest getKeyRequest( byte[] scope, @Nullable List<DrmInitData.SchemeData> schemeDatas, int keyType, @Nullable HashMap<String, String> optionalParameters) throws NotProvisionedException { SchemeData schemeData = null; byte[] initData = null; String mimeType = null; if (schemeDatas != null) { schemeData = getSchemeData(uuid, schemeDatas); initData = adjustRequestInitData(uuid, Assertions.checkNotNull(schemeData.data)); mimeType = adjustRequestMimeType(uuid, schemeData.mimeType); } MediaDrm.KeyRequest request = mediaDrm.getKeyRequest(scope, initData, mimeType, keyType, optionalParameters); byte[] requestData = adjustRequestData(uuid, request.getData()); String licenseServerUrl = request.getDefaultUrl(); if (MOCK_LA_URL_VALUE.equals(licenseServerUrl)) { licenseServerUrl = ""; } if (TextUtils.isEmpty(licenseServerUrl) && schemeData != null && !TextUtils.isEmpty(schemeData.licenseServerUrl)) { licenseServerUrl = schemeData.licenseServerUrl; } return new KeyRequest(requestData, licenseServerUrl); }
Example #22
Source File: FrameworkMediaDrm.java From MediaSDK with Apache License 2.0 | 5 votes |
private FrameworkMediaDrm(UUID uuid) throws UnsupportedSchemeException { Assertions.checkNotNull(uuid); Assertions.checkArgument(!C.COMMON_PSSH_UUID.equals(uuid), "Use C.CLEARKEY_UUID instead"); this.uuid = uuid; this.mediaDrm = new MediaDrm(adjustUuid(uuid)); // Creators of an instance automatically acquire ownership of the created instance. referenceCount = 1; if (C.WIDEVINE_UUID.equals(uuid) && needsForceWidevineL3Workaround()) { forceWidevineL3(mediaDrm); } }
Example #23
Source File: FrameworkMediaDrm.java From Telegram with GNU General Public License v2.0 | 5 votes |
private FrameworkMediaDrm(UUID uuid) throws UnsupportedSchemeException { Assertions.checkNotNull(uuid); Assertions.checkArgument(!C.COMMON_PSSH_UUID.equals(uuid), "Use C.CLEARKEY_UUID instead"); this.uuid = uuid; this.mediaDrm = new MediaDrm(adjustUuid(uuid)); if (C.WIDEVINE_UUID.equals(uuid) && needsForceWidevineL3Workaround()) { forceWidevineL3(mediaDrm); } }
Example #24
Source File: FrameworkMediaDrm.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public KeyRequest getKeyRequest( byte[] scope, @Nullable List<DrmInitData.SchemeData> schemeDatas, int keyType, @Nullable HashMap<String, String> optionalParameters) throws NotProvisionedException { SchemeData schemeData = null; byte[] initData = null; String mimeType = null; if (schemeDatas != null) { schemeData = getSchemeData(uuid, schemeDatas); initData = adjustRequestInitData(uuid, Assertions.checkNotNull(schemeData.data)); mimeType = adjustRequestMimeType(uuid, schemeData.mimeType); } MediaDrm.KeyRequest request = mediaDrm.getKeyRequest(scope, initData, mimeType, keyType, optionalParameters); byte[] requestData = adjustRequestData(uuid, request.getData()); String licenseServerUrl = request.getDefaultUrl(); if (MOCK_LA_URL_VALUE.equals(licenseServerUrl)) { licenseServerUrl = ""; } if (TextUtils.isEmpty(licenseServerUrl) && schemeData != null && !TextUtils.isEmpty(schemeData.licenseServerUrl)) { licenseServerUrl = schemeData.licenseServerUrl; } return new KeyRequest(requestData, licenseServerUrl); }
Example #25
Source File: FrameworkMediaDrm.java From MediaSDK with Apache License 2.0 | 5 votes |
@Override public KeyRequest getKeyRequest( byte[] scope, @Nullable List<SchemeData> schemeDatas, int keyType, @Nullable HashMap<String, String> optionalParameters) throws NotProvisionedException { SchemeData schemeData = null; byte[] initData = null; String mimeType = null; if (schemeDatas != null) { schemeData = getSchemeData(uuid, schemeDatas); initData = adjustRequestInitData(uuid, Assertions.checkNotNull(schemeData.data)); mimeType = adjustRequestMimeType(uuid, schemeData.mimeType); } MediaDrm.KeyRequest request = mediaDrm.getKeyRequest(scope, initData, mimeType, keyType, optionalParameters); byte[] requestData = adjustRequestData(uuid, request.getData()); String licenseServerUrl = request.getDefaultUrl(); if (MOCK_LA_URL_VALUE.equals(licenseServerUrl)) { licenseServerUrl = ""; } if (TextUtils.isEmpty(licenseServerUrl) && schemeData != null && !TextUtils.isEmpty(schemeData.licenseServerUrl)) { licenseServerUrl = schemeData.licenseServerUrl; } return new KeyRequest(requestData, licenseServerUrl); }
Example #26
Source File: FrameworkMediaDrm.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private FrameworkMediaDrm(UUID uuid) throws UnsupportedSchemeException { Assertions.checkNotNull(uuid); Assertions.checkArgument(!C.COMMON_PSSH_UUID.equals(uuid), "Use C.CLEARKEY_UUID instead"); this.uuid = uuid; this.mediaDrm = new MediaDrm(adjustUuid(uuid)); if (C.WIDEVINE_UUID.equals(uuid) && needsForceWidevineL3Workaround()) { forceWidevineL3(mediaDrm); } }
Example #27
Source File: FrameworkMediaDrm.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void setOnEventListener( final ExoMediaDrm.OnEventListener<? super FrameworkMediaCrypto> listener) { mediaDrm.setOnEventListener(listener == null ? null : new MediaDrm.OnEventListener() { @Override public void onEvent(@NonNull MediaDrm md, @Nullable byte[] sessionId, int event, int extra, byte[] data) { listener.onEvent(FrameworkMediaDrm.this, sessionId, event, extra, data); } }); }
Example #28
Source File: StreamingDrmSessionManager.java From Exoplayer_VLC with Apache License 2.0 | 5 votes |
/** * @param uuid The UUID of the drm scheme. * @param playbackLooper The looper associated with the media playback thread. Should usually be * obtained using {@link com.google.android.exoplayer.ExoPlayer#getPlaybackLooper()}. * @param callback Performs key and provisioning requests. * @param optionalKeyRequestParameters An optional map of parameters to pass as the last argument * to {@link MediaDrm#getKeyRequest(byte[], byte[], String, int, HashMap)}. May be null. * @param eventHandler A handler to use when delivering events to {@code eventListener}. May be * null if delivery of events is not required. * @param eventListener A listener of events. May be null if delivery of events is not required. * @throws UnsupportedSchemeException If the specified DRM scheme is not supported. */ public StreamingDrmSessionManager(UUID uuid, Looper playbackLooper, MediaDrmCallback callback, HashMap<String, String> optionalKeyRequestParameters, Handler eventHandler, EventListener eventListener) throws UnsupportedSchemeException { this.uuid = uuid; this.callback = callback; this.optionalKeyRequestParameters = optionalKeyRequestParameters; this.eventHandler = eventHandler; this.eventListener = eventListener; mediaDrm = new MediaDrm(uuid); mediaDrm.setOnEventListener(new MediaDrmEventListener()); mediaDrmHandler = new MediaDrmHandler(playbackLooper); postResponseHandler = new PostResponseHandler(playbackLooper); state = STATE_CLOSED; }
Example #29
Source File: FrameworkMediaDrm.java From K-Sonic with MIT License | 5 votes |
@Override public ProvisionRequest getProvisionRequest() { final MediaDrm.ProvisionRequest provisionRequest = mediaDrm.getProvisionRequest(); return new ProvisionRequest() { @Override public byte[] getData() { return provisionRequest.getData(); } @Override public String getDefaultUrl() { return provisionRequest.getDefaultUrl(); } }; }
Example #30
Source File: FrameworkMediaDrm.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public KeyRequest getKeyRequest(byte[] scope, byte[] init, String mimeType, int keyType, HashMap<String, String> optionalParameters) throws NotProvisionedException { // Prior to L the Widevine CDM required data to be extracted from the PSSH atom. Some Amazon // devices also required data to be extracted from the PSSH atom for PlayReady. if ((Util.SDK_INT < 21 && C.WIDEVINE_UUID.equals(uuid)) || (C.PLAYREADY_UUID.equals(uuid) && "Amazon".equals(Util.MANUFACTURER) && ("AFTB".equals(Util.MODEL) // Fire TV Gen 1 || "AFTS".equals(Util.MODEL) // Fire TV Gen 2 || "AFTM".equals(Util.MODEL)))) { // Fire TV Stick Gen 1 byte[] psshData = PsshAtomUtil.parseSchemeSpecificData(init, uuid); if (psshData == null) { // Extraction failed. schemeData isn't a PSSH atom, so leave it unchanged. } else { init = psshData; } } // Prior to API level 26 the ClearKey CDM only accepted "cenc" as the scheme for MP4. if (Util.SDK_INT < 26 && C.CLEARKEY_UUID.equals(uuid) && (MimeTypes.VIDEO_MP4.equals(mimeType) || MimeTypes.AUDIO_MP4.equals(mimeType))) { mimeType = CENC_SCHEME_MIME_TYPE; } final MediaDrm.KeyRequest request = mediaDrm.getKeyRequest(scope, init, mimeType, keyType, optionalParameters); byte[] requestData = request.getData(); if (C.CLEARKEY_UUID.equals(uuid)) { requestData = ClearKeyUtil.adjustRequestData(requestData); } return new DefaultKeyRequest(requestData, request.getDefaultUrl()); }