@Override protected DashManifest getManifest(DataSource dataSource, Uri uri) throws IOException { return DashUtil.loadManifest(dataSource, uri); }
/** * Loads {@link DrmInitData} for a given period in a DASH manifest. * * @param dataSource The {@link HttpDataSource} from which data should be loaded. * @param period The {@link Period}. * @return The loaded {@link DrmInitData}, or null if none is defined. * @throws IOException Thrown when there is an error while loading. * @throws InterruptedException Thrown if the thread was interrupted. */ public static @Nullable DrmInitData loadDrmInitData(DataSource dataSource, Period period) throws IOException, InterruptedException { int primaryTrackType = C.TRACK_TYPE_VIDEO; Representation representation = getFirstRepresentation(period, primaryTrackType); if (representation == null) { primaryTrackType = C.TRACK_TYPE_AUDIO; representation = getFirstRepresentation(period, primaryTrackType); if (representation == null) { return null; } } Format manifestFormat = representation.format; Format sampleFormat = DashUtil.loadSampleFormat(dataSource, primaryTrackType, representation); return sampleFormat == null ? manifestFormat.drmInitData : sampleFormat.copyWithManifestFormatInfo(manifestFormat).drmInitData; }
private static @Nullable DashSegmentIndex getSegmentIndex( DataSource dataSource, int trackType, Representation representation) throws IOException, InterruptedException { DashSegmentIndex index = representation.getIndex(); if (index != null) { return index; } ChunkIndex seekMap = DashUtil.loadChunkIndex(dataSource, trackType, representation); return seekMap == null ? null : new DashWrappingSegmentIndex(seekMap, representation.presentationTimeOffsetUs); }
private void downloadLicense() throws InterruptedException, DrmSessionException, IOException { DataSource dataSource = httpDataSourceFactory.createDataSource(); DashManifest dashManifest = DashUtil.loadManifest(dataSource, Uri.parse(DashTestData.WIDEVINE_H264_MANIFEST)); DrmInitData drmInitData = DashUtil.loadDrmInitData(dataSource, dashManifest.getPeriod(0)); offlineLicenseKeySetId = offlineLicenseHelper.downloadLicense(drmInitData); assertThat(offlineLicenseKeySetId).isNotNull(); assertThat(offlineLicenseKeySetId.length).isGreaterThan(0); testRunner.setOfflineLicenseKeySetId(offlineLicenseKeySetId); }
@Test public void testLoadDrmInitDataNoAdaptationSets() throws Exception { Period period = newPeriod(/* no adaptation set */ ); DrmInitData drmInitData = DashUtil.loadDrmInitData(DummyDataSource.INSTANCE, period); assertThat(drmInitData).isNull(); }
return null; ChunkExtractorWrapper extractorWrapper = newWrappedExtractor(trackType, representation.format); RangedUri requestUri; if (loadIndex) { loadInitializationData(dataSource, representation, extractorWrapper, initializationUri); requestUri = indexUri; requestUri = initializationUri; loadInitializationData(dataSource, representation, extractorWrapper, requestUri); return extractorWrapper;
/** * Loads initialization data for the {@code representation} and returns the sample {@link Format}. * * @param dataSource The source from which the data should be loaded. * @param trackType The type of the representation. Typically one of the {@link * com.google.android.exoplayer2.C} {@code TRACK_TYPE_*} constants. * @param representation The representation which initialization chunk belongs to. * @return the sample {@link Format} of the given representation. * @throws IOException Thrown when there is an error while loading. * @throws InterruptedException Thrown if the thread was interrupted. */ public static @Nullable Format loadSampleFormat( DataSource dataSource, int trackType, Representation representation) throws IOException, InterruptedException { ChunkExtractorWrapper extractorWrapper = loadInitializationData(dataSource, trackType, representation, false); return extractorWrapper == null ? null : extractorWrapper.getSampleFormats()[0]; }
@Test public void testLoadDrmInitDataNoRepresentations() throws Exception { Period period = newPeriod(newAdaptationSets(/* no representation */ )); DrmInitData drmInitData = DashUtil.loadDrmInitData(DummyDataSource.INSTANCE, period); assertThat(drmInitData).isNull(); }
/** * Loads initialization and index data for the {@code representation} and returns the {@link * ChunkIndex}. * * @param dataSource The source from which the data should be loaded. * @param trackType The type of the representation. Typically one of the {@link * com.google.android.exoplayer2.C} {@code TRACK_TYPE_*} constants. * @param representation The representation which initialization chunk belongs to. * @return The {@link ChunkIndex} of the given representation, or null if no initialization or * index data exists. * @throws IOException Thrown when there is an error while loading. * @throws InterruptedException Thrown if the thread was interrupted. */ public static @Nullable ChunkIndex loadChunkIndex( DataSource dataSource, int trackType, Representation representation) throws IOException, InterruptedException { ChunkExtractorWrapper extractorWrapper = loadInitializationData(dataSource, trackType, representation, true); return extractorWrapper == null ? null : (ChunkIndex) extractorWrapper.getSeekMap(); }
@Test public void testLoadDrmInitDataMissing() throws Exception { Period period = newPeriod(newAdaptationSets(newRepresentations(null /* no init data */))); DrmInitData drmInitData = DashUtil.loadDrmInitData(DummyDataSource.INSTANCE, period); assertThat(drmInitData).isNull(); }
private DashDownloader downloadContent() throws Exception { DashManifest dashManifest = DashUtil.loadManifest(httpDataSourceFactory.createDataSource(), MANIFEST_URI); ArrayList<StreamKey> keys = new ArrayList<>(); for (int pIndex = 0; pIndex < dashManifest.getPeriodCount(); pIndex++) { List<AdaptationSet> adaptationSets = dashManifest.getPeriod(pIndex).adaptationSets; for (int aIndex = 0; aIndex < adaptationSets.size(); aIndex++) { AdaptationSet adaptationSet = adaptationSets.get(aIndex); List<Representation> representations = adaptationSet.representations; for (int rIndex = 0; rIndex < representations.size(); rIndex++) { String id = representations.get(rIndex).format.id; if (DashTestData.AAC_AUDIO_REPRESENTATION_ID.equals(id) || DashTestData.H264_CDD_FIXED.equals(id)) { keys.add(new StreamKey(pIndex, aIndex, rIndex)); } } } } DownloaderConstructorHelper constructorHelper = new DownloaderConstructorHelper(cache, httpDataSourceFactory); return new DashDownloader(MANIFEST_URI, keys, constructorHelper); }
@Test public void testLoadDrmInitDataFromManifest() throws Exception { Period period = newPeriod(newAdaptationSets(newRepresentations(newDrmInitData()))); DrmInitData drmInitData = DashUtil.loadDrmInitData(DummyDataSource.INSTANCE, period); assertThat(drmInitData).isEqualTo(newDrmInitData()); }