private static DrmInitData getDrmInitData(MediaPresentationDescription manifest, int adaptationSetIndex) { AdaptationSet adaptationSet = manifest.periods.get(0).adaptationSets.get(adaptationSetIndex); String drmInitMimeType = mimeTypeIsWebm(adaptationSet.representations.get(0).format.mimeType) ? MimeTypes.VIDEO_WEBM : MimeTypes.VIDEO_MP4; if (adaptationSet.contentProtections.isEmpty()) { return null; } else { DrmInitData.Mapped drmInitData = null; for (ContentProtection contentProtection : adaptationSet.contentProtections) { if (contentProtection.uuid != null && contentProtection.data != null) { if (drmInitData == null) { drmInitData = new DrmInitData.Mapped(drmInitMimeType); } drmInitData.put(contentProtection.uuid, contentProtection.data); } } return drmInitData; } }
private static DrmInitData getDrmInitData(AdaptationSet adaptationSet) { if (adaptationSet.contentProtections.isEmpty()) { return null; } else { DrmInitData.Mapped drmInitData = null; for (int i = 0; i < adaptationSet.contentProtections.size(); i++) { ContentProtection contentProtection = adaptationSet.contentProtections.get(i); if (contentProtection.uuid != null && contentProtection.data != null) { if (drmInitData == null) { drmInitData = new DrmInitData.Mapped(); } drmInitData.put(contentProtection.uuid, contentProtection.data); } } return drmInitData; } }
private static Map<UUID, byte[]> getPsshInfo(MediaPresentationDescription manifest, int adaptationSetIndex) { AdaptationSet adaptationSet = manifest.periods.get(0).adaptationSets.get(adaptationSetIndex); if (adaptationSet.contentProtections.isEmpty()) { return null; } else { Map<UUID, byte[]> psshInfo = new HashMap<UUID, byte[]>(); for (ContentProtection contentProtection : adaptationSet.contentProtections) { if (contentProtection.uuid != null && contentProtection.data != null) { psshInfo.put(contentProtection.uuid, contentProtection.data); } } return psshInfo.isEmpty() ? null : psshInfo; } }