@Test public void testMinMax() throws IOException, JAXBException { MPDtype mpd = read(new File(ManifestOptimizerTest.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/com/castlabs/dash/dashfragmenter/representation/exampleManifest.mpd")); ManifestOptimizer.adjustMinMax(mpd.getPeriod().get(0).getAdaptationSet().get(0), RepresentationType::getBandwidth, AdaptationSetType::setMinBandwidth, AdaptationSetType::setMaxBandwidth); Assert.assertEquals(new Long(549100), mpd.getPeriod().get(0).getAdaptationSet().get(0).getMinBandwidth()); Assert.assertEquals(new Long(1356600), mpd.getPeriod().get(0).getAdaptationSet().get(0).getMaxBandwidth()); ManifestOptimizer.adjustMinMax(mpd.getPeriod().get(0).getAdaptationSet().get(1), RepresentationType::getBandwidth, AdaptationSetType::setMinBandwidth, AdaptationSetType::setMaxBandwidth); Assert.assertNull(mpd.getPeriod().get(0).getAdaptationSet().get(1).getMinBandwidth()); Assert.assertNull(mpd.getPeriod().get(0).getAdaptationSet().get(1).getMaxBandwidth()); }
public static void adjustMinMax(AdaptationSetType adaptationSetType, Function<RepresentationType, Long> get, ObjLongConsumer<AdaptationSetType> setMin, ObjLongConsumer<AdaptationSetType> setMax) { List<RepresentationType> representations = adaptationSetType.getRepresentation(); long min = Integer.MAX_VALUE, max = Integer.MIN_VALUE; for (RepresentationType representationType : representations) { Long n = get.apply(representationType); if (n != null) { min = Math.min(n, min); max = Math.max(n, max); } } if (min != Integer.MAX_VALUE && min != max) { setMax.accept(adaptationSetType, max); setMin.accept(adaptationSetType, min); } }
ManifestOptimizer { public static void adjustMinMax(AdaptationSetType adaptationSetType, Function<RepresentationType, Long> get, ObjLongConsumer<AdaptationSetType> setMin, ObjLongConsumer<AdaptationSetType> setMax) { List<RepresentationType> representations = adaptationSetType.getRepresentation(); long min = Integer.MAX_VALUE, max = Integer.MIN_VALUE; for (RepresentationType representationType : representations) { Long n = get.apply(representationType); if (n != null) { min = Math.min(n, min); max = Math.max(n, max); } } if (min != Integer.MAX_VALUE && min != max) { setMax.accept(adaptationSetType, max); setMin.accept(adaptationSetType, min); } } }
ManifestOptimizer { public static void adjustMinMax(AdaptationSetType adaptationSetType, Function<RepresentationType, Long> get, ObjLongConsumer<AdaptationSetType> setMin, ObjLongConsumer<AdaptationSetType> setMax) { List<RepresentationType> representations = adaptationSetType.getRepresentation(); long min = Integer.MAX_VALUE, max = Integer.MIN_VALUE; for (RepresentationType representationType : representations) { Long n = get.apply(representationType); if (n != null) { min = Math.min(n, min); max = Math.max(n, max); } } if (min != Integer.MAX_VALUE && min != max) { setMax.accept(adaptationSetType, max); setMin.accept(adaptationSetType, min); } }  }
ManifestOptimizer { public static void adjustMinMax(AdaptationSetType adaptationSetType, Function<RepresentationType, Long> get, ObjLongConsumer<AdaptationSetType> setMin, ObjLongConsumer<AdaptationSetType> setMax) { List<RepresentationType> representations = adaptationSetType.getRepresentation(); long min = Integer.MAX_VALUE, max = Integer.MIN_VALUE; for (RepresentationType representationType : representations) { Long n = get.apply(representationType); if (n != null) { min = Math.min(n, min); max = Math.max(n, max); } } if (min != Integer.MAX_VALUE && min != max) { setMax.accept(adaptationSetType, max); setMin.accept(adaptationSetType, min); } }  static void optimize(MPDtype mpd); static void adjustDuration(MPDtype mpd); static void adjustMinMaxFrameRate(AdaptationSetType adaptationSetType); static void adjustMinMax(AdaptationSetType adaptationSetType, Function<RepresentationType, Long> get, ObjLongConsumer<AdaptationSetType> setMin, ObjLongConsumer<AdaptationSetType> setMax); static void optimize(AdaptationSetType adaptationSetType); static void optimizeContentProtection(AdaptationSetType parent); }
ManifestOptimizer { public static void adjustMinMax(AdaptationSetType adaptationSetType, Function<RepresentationType, Long> get, ObjLongConsumer<AdaptationSetType> setMin, ObjLongConsumer<AdaptationSetType> setMax) { List<RepresentationType> representations = adaptationSetType.getRepresentation(); long min = Integer.MAX_VALUE, max = Integer.MIN_VALUE; for (RepresentationType representationType : representations) { Long n = get.apply(representationType); if (n != null) { min = Math.min(n, min); max = Math.max(n, max); } } if (min != Integer.MAX_VALUE && min != max) { setMax.accept(adaptationSetType, max); setMin.accept(adaptationSetType, min); } }  static void optimize(MPDtype mpd); static void adjustDuration(MPDtype mpd); static void adjustMinMaxFrameRate(AdaptationSetType adaptationSetType); static void adjustMinMax(AdaptationSetType adaptationSetType, Function<RepresentationType, Long> get, ObjLongConsumer<AdaptationSetType> setMin, ObjLongConsumer<AdaptationSetType> setMax); static void optimize(AdaptationSetType adaptationSetType); static void optimizeContentProtection(AdaptationSetType parent);  }