Java Code Examples for com.google.android.exoplayer2.drm.DrmInitData.SchemeData#matches()

The following examples show how to use com.google.android.exoplayer2.drm.DrmInitData.SchemeData#matches() . 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: DefaultDrmSessionManager.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Extracts {@link SchemeData} instances suitable for the given DRM scheme {@link UUID}.
 *
 * @param drmInitData The {@link DrmInitData} from which to extract the {@link SchemeData}.
 * @param uuid The UUID.
 * @param allowMissingData Whether a {@link SchemeData} with null {@link SchemeData#data} may be
 *     returned.
 * @return The extracted {@link SchemeData} instances, or an empty list if no suitable data is
 *     present.
 */
private static List<SchemeData> getSchemeDatas(
    DrmInitData drmInitData, UUID uuid, boolean allowMissingData) {
  // Look for matching scheme data (matching the Common PSSH box for ClearKey).
  List<SchemeData> matchingSchemeDatas = new ArrayList<>(drmInitData.schemeDataCount);
  for (int i = 0; i < drmInitData.schemeDataCount; i++) {
    SchemeData schemeData = drmInitData.get(i);
    boolean uuidMatches =
        schemeData.matches(uuid)
            || (C.CLEARKEY_UUID.equals(uuid) && schemeData.matches(C.COMMON_PSSH_UUID));
    if (uuidMatches && (schemeData.data != null || allowMissingData)) {
      matchingSchemeDatas.add(schemeData);
    }
  }
  return matchingSchemeDatas;
}
 
Example 2
Source File: DrmInitData.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieves data for a given DRM scheme, specified by its UUID.
 *
 * @deprecated Use {@link #get(int)} and {@link SchemeData#matches(UUID)} instead.
 * @param uuid The DRM scheme's UUID.
 * @return The initialization data for the scheme, or null if the scheme is not supported.
 */
@Deprecated
@Nullable
public SchemeData get(UUID uuid) {
  for (SchemeData schemeData : schemeDatas) {
    if (schemeData.matches(uuid)) {
      return schemeData;
    }
  }
  return null;
}
 
Example 3
Source File: DrmInitData.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Retrieves data for a given DRM scheme, specified by its UUID.
 *
 * @deprecated Use {@link #get(int)} and {@link SchemeData#matches(UUID)} instead.
 * @param uuid The DRM scheme's UUID.
 * @return The initialization data for the scheme, or null if the scheme is not supported.
 */
@Deprecated
public SchemeData get(UUID uuid) {
  for (SchemeData schemeData : schemeDatas) {
    if (schemeData.matches(uuid)) {
      return schemeData;
    }
  }
  return null;
}
 
Example 4
Source File: DefaultDrmSessionManager.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Extracts {@link SchemeData} suitable for the given DRM scheme {@link UUID}.
 *
 * @param drmInitData The {@link DrmInitData} from which to extract the {@link SchemeData}.
 * @param uuid The UUID.
 * @param allowMissingData Whether a {@link SchemeData} with null {@link SchemeData#data} may be
 *     returned.
 * @return The extracted {@link SchemeData}, or null if no suitable data is present.
 */
private static SchemeData getSchemeData(DrmInitData drmInitData, UUID uuid,
    boolean allowMissingData) {
  // Look for matching scheme data (matching the Common PSSH box for ClearKey).
  List<SchemeData> matchingSchemeDatas = new ArrayList<>(drmInitData.schemeDataCount);
  for (int i = 0; i < drmInitData.schemeDataCount; i++) {
    SchemeData schemeData = drmInitData.get(i);
    boolean uuidMatches = schemeData.matches(uuid)
        || (C.CLEARKEY_UUID.equals(uuid) && schemeData.matches(C.COMMON_PSSH_UUID));
    if (uuidMatches && (schemeData.data != null || allowMissingData)) {
      matchingSchemeDatas.add(schemeData);
    }
  }

  if (matchingSchemeDatas.isEmpty()) {
    return null;
  }

  // For Widevine PSSH boxes, prefer V1 boxes from API 23 and V0 before.
  if (C.WIDEVINE_UUID.equals(uuid)) {
    for (int i = 0; i < matchingSchemeDatas.size(); i++) {
      SchemeData matchingSchemeData = matchingSchemeDatas.get(i);
      int version = matchingSchemeData.hasData()
          ? PsshAtomUtil.parseVersion(matchingSchemeData.data) : -1;
      if (Util.SDK_INT < 23 && version == 0) {
        return matchingSchemeData;
      } else if (Util.SDK_INT >= 23 && version == 1) {
        return matchingSchemeData;
      }
    }
  }

  // If we don't have any special handling, prefer the first matching scheme data.
  return matchingSchemeDatas.get(0);
}
 
Example 5
Source File: DrmInitData.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Retrieves data for a given DRM scheme, specified by its UUID.
 *
 * @deprecated Use {@link #get(int)} and {@link SchemeData#matches(UUID)} instead.
 * @param uuid The DRM scheme's UUID.
 * @return The initialization data for the scheme, or null if the scheme is not supported.
 */
@Deprecated
public SchemeData get(UUID uuid) {
  for (SchemeData schemeData : schemeDatas) {
    if (schemeData.matches(uuid)) {
      return schemeData;
    }
  }
  return null;
}
 
Example 6
Source File: DefaultDrmSessionManager.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Extracts {@link SchemeData} suitable for the given DRM scheme {@link UUID}.
 *
 * @param drmInitData The {@link DrmInitData} from which to extract the {@link SchemeData}.
 * @param uuid The UUID.
 * @param allowMissingData Whether a {@link SchemeData} with null {@link SchemeData#data} may be
 *     returned.
 * @return The extracted {@link SchemeData}, or null if no suitable data is present.
 */
private static SchemeData getSchemeData(DrmInitData drmInitData, UUID uuid,
    boolean allowMissingData) {
  // Look for matching scheme data (matching the Common PSSH box for ClearKey).
  List<SchemeData> matchingSchemeDatas = new ArrayList<>(drmInitData.schemeDataCount);
  for (int i = 0; i < drmInitData.schemeDataCount; i++) {
    SchemeData schemeData = drmInitData.get(i);
    boolean uuidMatches = schemeData.matches(uuid)
        || (C.CLEARKEY_UUID.equals(uuid) && schemeData.matches(C.COMMON_PSSH_UUID));
    if (uuidMatches && (schemeData.data != null || allowMissingData)) {
      matchingSchemeDatas.add(schemeData);
    }
  }

  if (matchingSchemeDatas.isEmpty()) {
    return null;
  }

  // For Widevine PSSH boxes, prefer V1 boxes from API 23 and V0 before.
  if (C.WIDEVINE_UUID.equals(uuid)) {
    for (int i = 0; i < matchingSchemeDatas.size(); i++) {
      SchemeData matchingSchemeData = matchingSchemeDatas.get(i);
      int version = matchingSchemeData.hasData()
          ? PsshAtomUtil.parseVersion(matchingSchemeData.data) : -1;
      if (Util.SDK_INT < 23 && version == 0) {
        return matchingSchemeData;
      } else if (Util.SDK_INT >= 23 && version == 1) {
        return matchingSchemeData;
      }
    }
  }

  // If we don't have any special handling, prefer the first matching scheme data.
  return matchingSchemeDatas.get(0);
}
 
Example 7
Source File: DrmInitData.java    From K-Sonic with MIT License 5 votes vote down vote up
/**
 * Retrieves data for a given DRM scheme, specified by its UUID.
 *
 * @param uuid The DRM scheme's UUID.
 * @return The initialization data for the scheme, or null if the scheme is not supported.
 */
public SchemeData get(UUID uuid) {
  for (SchemeData schemeData : schemeDatas) {
    if (schemeData.matches(uuid)) {
      return schemeData;
    }
  }
  return null;
}
 
Example 8
Source File: DrmInitData.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Retrieves data for a given DRM scheme, specified by its UUID.
 *
 * @deprecated Use {@link #get(int)} and {@link SchemeData#matches(UUID)} instead.
 * @param uuid The DRM scheme's UUID.
 * @return The initialization data for the scheme, or null if the scheme is not supported.
 */
@Deprecated
public @Nullable SchemeData get(UUID uuid) {
  for (SchemeData schemeData : schemeDatas) {
    if (schemeData.matches(uuid)) {
      return schemeData;
    }
  }
  return null;
}
 
Example 9
Source File: DefaultDrmSessionManager.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Extracts {@link SchemeData} instances suitable for the given DRM scheme {@link UUID}.
 *
 * @param drmInitData The {@link DrmInitData} from which to extract the {@link SchemeData}.
 * @param uuid The UUID.
 * @param allowMissingData Whether a {@link SchemeData} with null {@link SchemeData#data} may be
 *     returned.
 * @return The extracted {@link SchemeData} instances, or an empty list if no suitable data is
 *     present.
 */
private static List<SchemeData> getSchemeDatas(
    DrmInitData drmInitData, UUID uuid, boolean allowMissingData) {
  // Look for matching scheme data (matching the Common PSSH box for ClearKey).
  List<SchemeData> matchingSchemeDatas = new ArrayList<>(drmInitData.schemeDataCount);
  for (int i = 0; i < drmInitData.schemeDataCount; i++) {
    SchemeData schemeData = drmInitData.get(i);
    boolean uuidMatches = schemeData.matches(uuid)
        || (C.CLEARKEY_UUID.equals(uuid) && schemeData.matches(C.COMMON_PSSH_UUID));
    if (uuidMatches && (schemeData.data != null || allowMissingData)) {
      matchingSchemeDatas.add(schemeData);
    }
  }
  return matchingSchemeDatas;
}
 
Example 10
Source File: DrmInitData.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Retrieves data for a given DRM scheme, specified by its UUID.
 *
 * @deprecated Use {@link #get(int)} and {@link SchemeData#matches(UUID)} instead.
 * @param uuid The DRM scheme's UUID.
 * @return The initialization data for the scheme, or null if the scheme is not supported.
 */
@Deprecated
public @Nullable SchemeData get(UUID uuid) {
  for (SchemeData schemeData : schemeDatas) {
    if (schemeData.matches(uuid)) {
      return schemeData;
    }
  }
  return null;
}
 
Example 11
Source File: DefaultDrmSessionManager.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Extracts {@link SchemeData} instances suitable for the given DRM scheme {@link UUID}.
 *
 * @param drmInitData The {@link DrmInitData} from which to extract the {@link SchemeData}.
 * @param uuid The UUID.
 * @param allowMissingData Whether a {@link SchemeData} with null {@link SchemeData#data} may be
 *     returned.
 * @return The extracted {@link SchemeData} instances, or an empty list if no suitable data is
 *     present.
 */
private static List<SchemeData> getSchemeDatas(
    DrmInitData drmInitData, UUID uuid, boolean allowMissingData) {
  // Look for matching scheme data (matching the Common PSSH box for ClearKey).
  List<SchemeData> matchingSchemeDatas = new ArrayList<>(drmInitData.schemeDataCount);
  for (int i = 0; i < drmInitData.schemeDataCount; i++) {
    SchemeData schemeData = drmInitData.get(i);
    boolean uuidMatches = schemeData.matches(uuid)
        || (C.CLEARKEY_UUID.equals(uuid) && schemeData.matches(C.COMMON_PSSH_UUID));
    if (uuidMatches && (schemeData.data != null || allowMissingData)) {
      matchingSchemeDatas.add(schemeData);
    }
  }
  return matchingSchemeDatas;
}