@Test public void testMinMaxFrameRate() throws IOException, JAXBException { MPDtype mpd = read(new File(ManifestOptimizerTest.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/com/castlabs/dash/dashfragmenter/representation/exampleManifest.mpd")); ManifestOptimizer.adjustMinMaxFrameRate(mpd.getPeriod().get(0).getAdaptationSet().get(0)); Assert.assertEquals("12000/1000", mpd.getPeriod().get(0).getAdaptationSet().get(0).getMinFrameRate()); Assert.assertEquals("24000/1000", mpd.getPeriod().get(0).getAdaptationSet().get(0).getMaxFrameRate()); MPDtype mpd2 = read(new File(ManifestOptimizerTest.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/com/castlabs/dash/dashfragmenter/representation/exampleManifest.mpd")); mpd2.getPeriod().get(0).getAdaptationSet().remove(0); ManifestOptimizer.adjustMinMaxFrameRate(mpd2.getPeriod().get(0).getAdaptationSet().get(0)); Assert.assertEquals(null, mpd2.getPeriod().get(0).getAdaptationSet().get(0).getMinFrameRate()); Assert.assertEquals(null, mpd2.getPeriod().get(0).getAdaptationSet().get(0).getMaxFrameRate()); }
public static void adjustMinMaxFrameRate(AdaptationSetType adaptationSetType) { List<RepresentationType> representations = adaptationSetType.getRepresentation(); Fraction min = null, max = null; for (RepresentationType representationType : representations) { String frameRate = representationType.getFrameRate(); if (frameRate != null) { Fraction f = Fraction.getFraction(frameRate); min = min == null || f.compareTo(min) < 0 ? f : min; max = max == null || f.compareTo(max) > 0 ? f : max; } } if (max != null && !min.equals(max)) { adaptationSetType.setMinFrameRate(min.toString()); adaptationSetType.setMaxFrameRate(max.toString()); } }
ManifestOptimizer { public static void adjustMinMaxFrameRate(AdaptationSetType adaptationSetType) { List<RepresentationType> representations = adaptationSetType.getRepresentation(); Fraction min = null, max = null; for (RepresentationType representationType : representations) { String frameRate = representationType.getFrameRate(); if (frameRate != null) { Fraction f = Fraction.getFraction(frameRate); min = min == null || f.compareTo(min) < 0 ? f : min; max = max == null || f.compareTo(max) > 0 ? f : max; } } if (max != null && !min.equals(max)) { adaptationSetType.setMinFrameRate(min.toString()); adaptationSetType.setMaxFrameRate(max.toString()); } } }
ManifestOptimizer { public static void adjustMinMaxFrameRate(AdaptationSetType adaptationSetType) { List<RepresentationType> representations = adaptationSetType.getRepresentation(); Fraction min = null, max = null; for (RepresentationType representationType : representations) { String frameRate = representationType.getFrameRate(); if (frameRate != null) { Fraction f = Fraction.getFraction(frameRate); min = min == null || f.compareTo(min) < 0 ? f : min; max = max == null || f.compareTo(max) > 0 ? f : max; } } if (max != null && !min.equals(max)) { adaptationSetType.setMinFrameRate(min.toString()); adaptationSetType.setMaxFrameRate(max.toString()); } }  }
ManifestOptimizer { public static void adjustMinMaxFrameRate(AdaptationSetType adaptationSetType) { List<RepresentationType> representations = adaptationSetType.getRepresentation(); Fraction min = null, max = null; for (RepresentationType representationType : representations) { String frameRate = representationType.getFrameRate(); if (frameRate != null) { Fraction f = Fraction.getFraction(frameRate); min = min == null || f.compareTo(min) < 0 ? f : min; max = max == null || f.compareTo(max) > 0 ? f : max; } } if (max != null && !min.equals(max)) { adaptationSetType.setMinFrameRate(min.toString()); adaptationSetType.setMaxFrameRate(max.toString()); } }  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 adjustMinMaxFrameRate(AdaptationSetType adaptationSetType) { List<RepresentationType> representations = adaptationSetType.getRepresentation(); Fraction min = null, max = null; for (RepresentationType representationType : representations) { String frameRate = representationType.getFrameRate(); if (frameRate != null) { Fraction f = Fraction.getFraction(frameRate); min = min == null || f.compareTo(min) < 0 ? f : min; max = max == null || f.compareTo(max) > 0 ? f : max; } } if (max != null && !min.equals(max)) { adaptationSetType.setMinFrameRate(min.toString()); adaptationSetType.setMaxFrameRate(max.toString()); } }  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);  }