Class MemoryHlsClearKeyCache

java.lang.Object
com.castlabs.android.player.HlsClearKeyCache
com.castlabs.android.player.MemoryHlsClearKeyCache
All Implemented Interfaces:
Parcelable

public class MemoryHlsClearKeyCache extends HlsClearKeyCache implements Parcelable
Cache for Drm.Clearkey which stores keys in memory.

Can be gotten or PlayerController.setHlsKeyCache(HlsClearKeyCache) set} in the PlayerController.

  • Field Details

    • DEFAULT_CACHE_SIZE

      public static final int DEFAULT_CACHE_SIZE
      Default maximum cache size
      See Also:
    • CREATOR

      public static final Parcelable.Creator<MemoryHlsClearKeyCache> CREATOR
      Creator for Parcelable implementation. This creator is used to create instances of MemoryHlsClearKeyCache from a Parcel.
  • Constructor Details

    • MemoryHlsClearKeyCache

      public MemoryHlsClearKeyCache()
      Create an empty cache with a size of DEFAULT_CACHE_SIZE
    • MemoryHlsClearKeyCache

      public MemoryHlsClearKeyCache(@Nullable Map<Uri,byte[]> cache)
      Create a cache with a size of DEFAULT_CACHE_SIZE and pre-filled with the provided Map.
      Parameters:
      cache - Existing entries to pre-fill the cache with
    • MemoryHlsClearKeyCache

      public MemoryHlsClearKeyCache(int maxCacheSize, @Nullable Map<Uri,byte[]> cache)
      Creates a cache with a size of maxCacheSize and pre-filled with the provided Map.
      Parameters:
      maxCacheSize - Maximum size of the cache
      cache - Existing entries to pre-fill the cache with
  • Method Details

    • writeToParcel

      public void writeToParcel(Parcel dest, int flags)
      Specified by:
      writeToParcel in interface Parcelable
    • describeContents

      public int describeContents()
      Specified by:
      describeContents in interface Parcelable
    • get

      @Nullable public byte[] get(@Nullable Uri uri)
      Description copied from class: HlsClearKeyCache
      Returns the encryption key cached against the given URI.
      Specified by:
      get in class HlsClearKeyCache
      Parameters:
      uri - The URI to look up in the cache
      Returns:
      The cached encryption key, or null if the URI is not in the cache
    • put

      @Nullable public byte[] put(@NonNull Uri uri, @NonNull byte[] encryptionKey)
      Description copied from class: HlsClearKeyCache
      Inserts an entry into the cache.
      Specified by:
      put in class HlsClearKeyCache
      Parameters:
      uri - The URI to cache the encryption key against
      encryptionKey - The encryption key to cache
      Returns:
      The previous encryption key associated with the URI, or null if there was none
    • containsUri

      public boolean containsUri(@NonNull Uri uri)
      Description copied from class: HlsClearKeyCache
      Checks if a URI is present in the cache.
      Specified by:
      containsUri in class HlsClearKeyCache
      Parameters:
      uri - The URI to check
      Returns:
      true if the URI is present in the cache, false otherwise
    • remove

      @Nullable public byte[] remove(@NonNull Uri uri)
      Description copied from class: HlsClearKeyCache
      Removes a URI from the cache.
      Specified by:
      remove in class HlsClearKeyCache
      Parameters:
      uri - The URI to remove from the cache
      Returns:
      The encryption key that was associated with the URI, or null if the URI was not in the cache