DownloadDistributionServiceImpl extends AbstractDistributionService implements DistributionService, DownloadDistributionService, ManagedService { @Override public Job distribute(String channelId, MediaPackage mediapackage, String elementId) throws DistributionException, MediaPackageException { return distribute(channelId, mediapackage, elementId, true); } DownloadDistributionServiceImpl(); @Override void activate(ComponentContext cc); @Override String getDistributionType(); @Override Job distribute(String channelId, MediaPackage mediapackage, String elementId); @Override Job distribute(String channelId, MediaPackage mediapackage, String elementId, boolean checkAvailability); @Override Job distribute(String channelId, MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability); @Override Job distribute(String channelId, MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability, boolean preserveReference); MediaPackageElement[] distributeElements(String channelId, MediaPackage mediapackage, Set<String> elementIds,
          boolean checkAvailability); MediaPackageElement[] distributeElements(String channelId, MediaPackage mediapackage, Set<String> elementIds,
          boolean checkAvailability, boolean preserveReference); MediaPackageElement distributeElement(String channelId, MediaPackage mediapackage, MediaPackageElement element,
          boolean checkAvailability, boolean preserveReference); Track setUpHLSElementforDistribution(String channelId, MediaPackage mediapackage, Track element,
          boolean preserveReference); Track checkDistributeHLSElement(Track element, boolean checkAvailability); @Override Job retract(String channelId, MediaPackage mediapackage, String elementId); @Override Job retract(String channelId, MediaPackage mediapackage, Set<String> elementIds); @Override List<MediaPackageElement> distributeSync(String channelId, MediaPackage mediapackage, Set<String> elementIds,
                                                  boolean checkAvailability); @Override List<MediaPackageElement> retractSync(String channelId, MediaPackage mediaPackage, Set<String> elementIds); @Override void updated(@SuppressWarnings("rawtypes") Dictionary properties); static final String JOB_TYPE; static final float DEFAULT_DISTRIBUTE_JOB_LOAD; static final float DEFAULT_RETRACT_JOB_LOAD; static final String DISTRIBUTE_JOB_LOAD_KEY; static final String RETRACT_JOB_LOAD_KEY; }
@Test public void testPartialDistribution() throws Exception { Job job1 = service.distribute("engage-player", mp, "track-1"); Job job2 = service.distribute("engage-player", mp, "catalog-1"); Job job3 = service.distribute("oai-pmh", mp, "catalog-1"); JobBarrier jobBarrier = new JobBarrier(null, serviceRegistry, 500, job1, job2, job3); jobBarrier.waitForJobs(); File mpDir = new File(distributionRoot, PathSupport.path(defaultOrganization.getId(), "engage-player", mp.getIdentifier().toString())); Assert.assertTrue(mpDir.exists()); File mediaDir = new File(mpDir, "track-1"); File metadataDir = new File(mpDir, "catalog-1"); File attachmentsDir = new File(mpDir, "notes"); Assert.assertTrue(mediaDir.exists()); Assert.assertTrue(metadataDir.exists()); Assert.assertFalse(attachmentsDir.exists()); Assert.assertTrue(new File(mediaDir, "media.mov").exists()); Assert.assertTrue(new File(metadataDir, "dublincore.xml").exists()); Assert.assertFalse(new File(metadataDir, "mpeg7.xml").exists()); Assert.assertFalse(new File(attachmentsDir, "attachment.txt").exists()); }
@Test public void testHLSDistribution() throws Exception { mp = MediaPackageParser .getFromXml(IOUtils.toString(getClass().getResourceAsStream("/hls_1_var_mediapackage.xml"), "UTF-8")); String[] elementIds = { "master", "variant", "segments", "dublincore", "mpeg7" }; Job job = service.distribute("engage-player", mp, Arrays.stream(elementIds).collect(Collectors.toSet()), true); JobBarrier jobBarrier = new JobBarrier(null, serviceRegistry, 500, job); jobBarrier.waitForJobs(); File mpDir = new File(distributionRoot, PathSupport.path(defaultOrganization.getId(), "engage-player", mp.getIdentifier().toString())); Assert.assertTrue(mpDir.exists()); File mediaDir = new File(mpDir, "master"); File variantDir = new File(mpDir, "variant"); File segmentDir = new File(mpDir, "segments"); File metadataDir = new File(mpDir, "dublincore"); File attachmentsDir = new File(mpDir, "mpeg7"); Assert.assertTrue(mediaDir.exists()); Assert.assertTrue(variantDir.exists()); Assert.assertTrue(segmentDir.exists()); Assert.assertTrue(metadataDir.exists()); Assert.assertTrue(attachmentsDir.exists()); Assert.assertTrue(new File(mediaDir, "master.m3u8").exists()); Assert.assertTrue(new File(variantDir, "variant_0.m3u8").exists()); Assert.assertTrue(new File(segmentDir, "file_0.mp4").exists()); Assert.assertTrue(new File(metadataDir, "dublincore.xml").exists()); Assert.assertTrue(new File(attachmentsDir, "mpeg7.xml").exists()); Assert.assertFalse(new File(metadataDir, "mpeg7.xml").exists()); Assert.assertFalse(new File(attachmentsDir, "attachment.txt").exists()); File playlist = new File(mediaDir, "master.m3u8"); logger.info("Reading playlist " + playlist); Optional<String> hasRelativeLink = Files.lines(playlist.toPath()) .filter(s -> s.contains("../variant/variant_0.m3u8")) .findFirst(); Assert.assertTrue(hasRelativeLink.isPresent()); playlist = new File(variantDir, "variant_0.m3u8"); hasRelativeLink = Files.lines(playlist.toPath()).filter(s -> s.contains("../segments/file_0.mp4")) .findFirst(); Assert.assertTrue(hasRelativeLink.isPresent()); }