Class OfflineLicenseHelper
- java.lang.Object
-
- com.google.android.exoplayer2.drm.OfflineLicenseHelper
-
@RequiresApi(18) public final class OfflineLicenseHelper extends Object
Helper class to download, renew and release offline licenses.
-
-
Constructor Summary
Constructors Constructor Description OfflineLicenseHelper(DefaultDrmSessionManager defaultDrmSessionManager, DrmSessionEventListener.EventDispatcher eventDispatcher)Constructs an instance.OfflineLicenseHelper(UUID uuid, ExoMediaDrm.Provider mediaDrmProvider, MediaDrmCallback callback, Map<String,String> optionalKeyRequestParameters, DrmSessionEventListener.EventDispatcher eventDispatcher)Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]downloadLicense(Format format)Downloads an offline license.Pair<Long,Long>getLicenseDurationRemainingSec(byte[] offlineLicenseKeySetId)Returns the remaining license and playback durations in seconds, for an offline license.static OfflineLicenseHelpernewWidevineInstance(String defaultLicenseUrl, boolean forceDefaultLicenseUrl, HttpDataSource.Factory httpDataSourceFactory, DrmSessionEventListener.EventDispatcher eventDispatcher)Instantiates a new instance which uses Widevine CDM.static OfflineLicenseHelpernewWidevineInstance(String defaultLicenseUrl, boolean forceDefaultLicenseUrl, HttpDataSource.Factory httpDataSourceFactory, Map<String,String> optionalKeyRequestParameters, DrmSessionEventListener.EventDispatcher eventDispatcher)Instantiates a new instance which uses Widevine CDM.static OfflineLicenseHelpernewWidevineInstance(String defaultLicenseUrl, HttpDataSource.Factory httpDataSourceFactory, DrmSessionEventListener.EventDispatcher eventDispatcher)Instantiates a new instance which uses Widevine CDM.voidrelease()Releases the helper.voidreleaseLicense(byte[] offlineLicenseKeySetId)Releases an offline license.byte[]renewLicense(byte[] offlineLicenseKeySetId)Renews an offline license.
-
-
-
Constructor Detail
-
OfflineLicenseHelper
@Deprecated public OfflineLicenseHelper(UUID uuid, ExoMediaDrm.Provider mediaDrmProvider, MediaDrmCallback callback, @Nullable Map<String,String> optionalKeyRequestParameters, DrmSessionEventListener.EventDispatcher eventDispatcher)
Deprecated.
-
OfflineLicenseHelper
public OfflineLicenseHelper(DefaultDrmSessionManager defaultDrmSessionManager, DrmSessionEventListener.EventDispatcher eventDispatcher)
Constructs an instance. Callrelease()when the instance is no longer required.- Parameters:
defaultDrmSessionManager- TheDefaultDrmSessionManagerused to download licenses.eventDispatcher- ADrmSessionEventListener.EventDispatcherused to distribute DRM-related events.
-
-
Method Detail
-
newWidevineInstance
public static OfflineLicenseHelper newWidevineInstance(String defaultLicenseUrl, HttpDataSource.Factory httpDataSourceFactory, DrmSessionEventListener.EventDispatcher eventDispatcher)
Instantiates a new instance which uses Widevine CDM. Callrelease()when the instance is no longer required.- Parameters:
defaultLicenseUrl- The default license URL. Used for key requests that do not specify their own license URL.httpDataSourceFactory- A factory from which to obtainHttpDataSourceinstances.eventDispatcher- ADrmSessionEventListener.EventDispatcherused to distribute DRM-related events.- Returns:
- A new instance which uses Widevine CDM.
-
newWidevineInstance
public static OfflineLicenseHelper newWidevineInstance(String defaultLicenseUrl, boolean forceDefaultLicenseUrl, HttpDataSource.Factory httpDataSourceFactory, DrmSessionEventListener.EventDispatcher eventDispatcher)
Instantiates a new instance which uses Widevine CDM. Callrelease()when the instance is no longer required.- Parameters:
defaultLicenseUrl- The default license URL. Used for key requests that do not specify their own license URL.forceDefaultLicenseUrl- Whether to usedefaultLicenseUrlfor key requests that include their own license URL.httpDataSourceFactory- A factory from which to obtainHttpDataSourceinstances.eventDispatcher- ADrmSessionEventListener.EventDispatcherused to distribute DRM-related events.- Returns:
- A new instance which uses Widevine CDM.
-
newWidevineInstance
public static OfflineLicenseHelper newWidevineInstance(String defaultLicenseUrl, boolean forceDefaultLicenseUrl, HttpDataSource.Factory httpDataSourceFactory, @Nullable Map<String,String> optionalKeyRequestParameters, DrmSessionEventListener.EventDispatcher eventDispatcher)
Instantiates a new instance which uses Widevine CDM. Callrelease()when the instance is no longer required.- Parameters:
defaultLicenseUrl- The default license URL. Used for key requests that do not specify their own license URL.forceDefaultLicenseUrl- Whether to usedefaultLicenseUrlfor key requests that include their own license URL.optionalKeyRequestParameters- An optional map of parameters to pass as the last argument toMediaDrm.getKeyRequest(byte[], byte[], java.lang.String, int, java.util.HashMap<java.lang.String, java.lang.String>). May be null.eventDispatcher- ADrmSessionEventListener.EventDispatcherused to distribute DRM-related events.- Returns:
- A new instance which uses Widevine CDM.
- See Also:
DefaultDrmSessionManager.Builder
-
downloadLicense
public byte[] downloadLicense(Format format) throws DrmSession.DrmSessionException
Downloads an offline license.- Parameters:
format- TheFormatof the content whose license is to be downloaded. Must contain a non-nullFormat.drmInitData.- Returns:
- The key set id for the downloaded license.
- Throws:
DrmSession.DrmSessionException- Thrown when a DRM session error occurs.
-
renewLicense
public byte[] renewLicense(byte[] offlineLicenseKeySetId) throws DrmSession.DrmSessionExceptionRenews an offline license.- Parameters:
offlineLicenseKeySetId- The key set id of the license to be renewed.- Returns:
- The renewed offline license key set id.
- Throws:
DrmSession.DrmSessionException- Thrown when a DRM session error occurs.
-
releaseLicense
public void releaseLicense(byte[] offlineLicenseKeySetId) throws DrmSession.DrmSessionExceptionReleases an offline license.- Parameters:
offlineLicenseKeySetId- The key set id of the license to be released.- Throws:
DrmSession.DrmSessionException- Thrown when a DRM session error occurs.
-
getLicenseDurationRemainingSec
public Pair<Long,Long> getLicenseDurationRemainingSec(byte[] offlineLicenseKeySetId) throws DrmSession.DrmSessionException
Returns the remaining license and playback durations in seconds, for an offline license.- Parameters:
offlineLicenseKeySetId- The key set id of the license.- Returns:
- The remaining license and playback durations, in seconds.
- Throws:
DrmSession.DrmSessionException- Thrown when a DRM session error occurs.
-
release
public void release()
Releases the helper. Should be called when the helper is no longer required.
-
-