/** * Returns a copy with the specified protection scheme type. * * @param schemeType A protection scheme type. May be null. * @return A copy with the specified protection scheme type. */ public DrmInitData copyWithSchemeType(@Nullable String schemeType) { if (Util.areEqual(this.schemeType, schemeType)) { return this; } return new DrmInitData(schemeType, false, schemeDatas); }
protected Representation buildRepresentation(RepresentationInfo representationInfo, String contentId, String extraDrmSchemeType, ArrayList<SchemeData> extraDrmSchemeDatas, ArrayList<Descriptor> extraInbandEventStreams) { Format format = representationInfo.format; String drmSchemeType = representationInfo.drmSchemeType != null ? representationInfo.drmSchemeType : extraDrmSchemeType; ArrayList<SchemeData> drmSchemeDatas = representationInfo.drmSchemeDatas; drmSchemeDatas.addAll(extraDrmSchemeDatas); if (!drmSchemeDatas.isEmpty()) { filterRedundantIncompleteSchemeDatas(drmSchemeDatas); DrmInitData drmInitData = new DrmInitData(drmSchemeType, drmSchemeDatas); format = format.copyWithDrmInitData(drmInitData); } ArrayList<Descriptor> inbandEventStreams = representationInfo.inbandEventStreams; inbandEventStreams.addAll(extraInbandEventStreams); return Representation.newInstance(contentId, representationInfo.revisionId, format, representationInfo.baseUrl, representationInfo.segmentBase, inbandEventStreams); }
/** Returns DrmInitData from leaf atoms. */ private static DrmInitData getDrmInitDataFromAtoms(List<Atom.LeafAtom> leafChildren) { ArrayList<SchemeData> schemeDatas = null; int leafChildrenSize = leafChildren.size(); for (int i = 0; i < leafChildrenSize; i++) { LeafAtom child = leafChildren.get(i); if (child.type == Atom.TYPE_pssh) { if (schemeDatas == null) { schemeDatas = new ArrayList<>(); } byte[] psshData = child.data.data; UUID uuid = PsshAtomUtil.parseUuid(psshData); if (uuid == null) { Log.w(TAG, "Skipped pssh atom (failed to extract uuid)"); } else { schemeDatas.add(new SchemeData(uuid, MimeTypes.VIDEO_MP4, psshData)); } } } return schemeDatas == null ? null : new DrmInitData(schemeDatas); }
return result.isEmpty() ? null : new DrmInitData(schemeType, result);
@Override public Object build() { StreamElement[] streamElementArray = new StreamElement[streamElements.size()]; streamElements.toArray(streamElementArray); if (protectionElement != null) { DrmInitData drmInitData = new DrmInitData(new SchemeData(protectionElement.uuid, MimeTypes.VIDEO_MP4, protectionElement.data)); for (StreamElement streamElement : streamElementArray) { int type = streamElement.type; if (type == C.TRACK_TYPE_VIDEO || type == C.TRACK_TYPE_AUDIO) { Format[] formats = streamElement.formats; for (int i = 0; i < formats.length; i++) { formats[i] = formats[i].copyWithDrmInitData(drmInitData); } } } } return new SsManifest(majorVersion, minorVersion, timescale, duration, dvrWindowLength, lookAheadCount, isLive, protectionElement, streamElementArray); }
private static DrmInitData newDrmInitData() { return new DrmInitData( new SchemeData(C.WIDEVINE_UUID, "mimeType", new byte[] {1, 4, 7, 0, 3, 6})); } }
private static DrmInitData newDrmInitData() { return new DrmInitData( new SchemeData(C.WIDEVINE_UUID, "mimeType", new byte[] {1, 4, 7, 0, 3, 6})); } }
@Test public void testGetByIndex() { DrmInitData testInitData = new DrmInitData(DATA_1, DATA_2); assertThat(getAllSchemeData(testInitData)).containsAllOf(DATA_1, DATA_2); }
cachedDrmInitData = new DrmInitData(encryptionScheme, schemeDatas); if (playlistProtectionSchemes == null) { SchemeData[] playlistSchemeDatas = new SchemeData[schemeDatas.length]; playlistSchemeDatas[i] = schemeDatas[i].copyWithData(null); playlistProtectionSchemes = new DrmInitData(encryptionScheme, playlistSchemeDatas);
@Test public void testEquals() { DrmInitData drmInitData = new DrmInitData(DATA_1, DATA_2); // Basic non-referential equality test. DrmInitData testInitData = new DrmInitData(DATA_1, DATA_2); assertThat(testInitData).isEqualTo(drmInitData); assertThat(testInitData.hashCode()).isEqualTo(drmInitData.hashCode()); // Basic non-referential equality test with non-referential scheme data. testInitData = new DrmInitData(DATA_1B, DATA_2B); assertThat(testInitData).isEqualTo(drmInitData); assertThat(testInitData.hashCode()).isEqualTo(drmInitData.hashCode()); // Passing the scheme data in reverse order shouldn't affect equality. testInitData = new DrmInitData(DATA_2, DATA_1); assertThat(testInitData).isEqualTo(drmInitData); assertThat(testInitData.hashCode()).isEqualTo(drmInitData.hashCode()); // Ditto. testInitData = new DrmInitData(DATA_2B, DATA_1B); assertThat(testInitData).isEqualTo(drmInitData); assertThat(testInitData.hashCode()).isEqualTo(drmInitData.hashCode()); // Different number of tuples should affect equality. testInitData = new DrmInitData(DATA_1); assertThat(drmInitData).isNotEqualTo(testInitData); // Different data in one of the tuples should affect equality. testInitData = new DrmInitData(DATA_1, DATA_UNIVERSAL); assertThat(testInitData).isNotEqualTo(drmInitData); }
@Test @SuppressWarnings("deprecation") public void testSchemeDatasWithSameUuid() { DrmInitData testInitData = new DrmInitData(DATA_1, DATA_1B); assertThat(testInitData.schemeDataCount).isEqualTo(2); // Deprecated get method should return first entry. assertThat(testInitData.get(WIDEVINE_UUID)).isEqualTo(DATA_1); // Test retrieval of first and second entry. assertThat(testInitData.get(0)).isEqualTo(DATA_1); assertThat(testInitData.get(1)).isEqualTo(DATA_1B); }
@Test @SuppressWarnings("deprecation") public void testGetByUuid() { // Basic matching. DrmInitData testInitData = new DrmInitData(DATA_1, DATA_2); assertThat(testInitData.get(WIDEVINE_UUID)).isEqualTo(DATA_1); assertThat(testInitData.get(PLAYREADY_UUID)).isEqualTo(DATA_2); assertThat(testInitData.get(UUID_NIL)).isNull(); // Basic matching including universal data. testInitData = new DrmInitData(DATA_1, DATA_2, DATA_UNIVERSAL); assertThat(testInitData.get(WIDEVINE_UUID)).isEqualTo(DATA_1); assertThat(testInitData.get(PLAYREADY_UUID)).isEqualTo(DATA_2); assertThat(testInitData.get(UUID_NIL)).isEqualTo(DATA_UNIVERSAL); // Passing the scheme data in reverse order shouldn't affect equality. testInitData = new DrmInitData(DATA_UNIVERSAL, DATA_2, DATA_1); assertThat(testInitData.get(WIDEVINE_UUID)).isEqualTo(DATA_1); assertThat(testInitData.get(PLAYREADY_UUID)).isEqualTo(DATA_2); assertThat(testInitData.get(UUID_NIL)).isEqualTo(DATA_UNIVERSAL); // Universal data should be returned in the absence of a specific match. testInitData = new DrmInitData(DATA_1, DATA_UNIVERSAL); assertThat(testInitData.get(WIDEVINE_UUID)).isEqualTo(DATA_1); assertThat(testInitData.get(PLAYREADY_UUID)).isEqualTo(DATA_UNIVERSAL); assertThat(testInitData.get(UUID_NIL)).isEqualTo(DATA_UNIVERSAL); }
@Test public void testParcelable() { DrmInitData drmInitDataToParcel = new DrmInitData(DATA_1, DATA_2); Parcel parcel = Parcel.obtain(); drmInitDataToParcel.writeToParcel(parcel, 0); parcel.setDataPosition(0); DrmInitData drmInitDataFromParcel = DrmInitData.CREATOR.createFromParcel(parcel); assertThat(drmInitDataFromParcel).isEqualTo(drmInitDataToParcel); parcel.recycle(); }
throw new ParserException("Encrypted Track found but ContentEncKeyID was not found"); currentTrack.drmInitData = new DrmInitData(new SchemeData(C.UUID_NIL, MimeTypes.VIDEO_WEBM, currentTrack.cryptoData.encryptionKey));
DrmInitData.SchemeData drmData2 = new DrmInitData.SchemeData(C.UUID_NIL, VIDEO_WEBM, TestUtil.buildTestData(128, 1 /* data seed */)); DrmInitData drmInitData = new DrmInitData(drmData1, drmData2); byte[] projectionData = new byte[] {1, 2, 3}; Metadata metadata = new Metadata(
@Test public void givenDrmDataDoesNotContainDrmScheme_whenCheckingCanAcquireSession_thenReturnsFalse() { DrmInitData.SchemeData unrecognisedSchemeData = new DrmInitData.SchemeData( UUID.randomUUID(), "ANY_MIME_TYPE", new byte[]{} ); DrmInitData drmInitData = new DrmInitData(Collections.singletonList(unrecognisedSchemeData)); boolean canAcquireSession = localDrmSessionManager.canAcquireSession(drmInitData); assertThat(canAcquireSession).isFalse(); }
@Test public void givenDrmDataContainsDrmScheme_whenCheckingCanAcquireSession_thenReturnsTrue() { DrmInitData.SchemeData recognisedSchemeData = new DrmInitData.SchemeData( DRM_SCHEME, "ANY_MIME_TYPE", new byte[]{} ); DrmInitData drmInitData = new DrmInitData(Collections.singletonList(recognisedSchemeData)); boolean canAcquireSession = localDrmSessionManager.canAcquireSession(drmInitData); assertThat(canAcquireSession).isTrue(); }