@Test public void testToSeconds() { assertEquals(0.985, toSeconds(track(1970), percent(50), 0), 0); assertEquals(0, toSeconds(track(1970), percent(0), 0), 0); assertEquals(1.87, toSeconds(track(1970), percent(100), 100), 0); assertEquals(0, toSeconds(track(100), percent(100), 200), 0); assertEquals(1.77, toSeconds(track(1970), sec(1.970), 200), 0); assertEquals(1.77, toSeconds(track(1970), sec(1.870), 200), 0); assertEquals(1.77, toSeconds(track(1970), sec(1.770), 200), 0); assertEquals(1.769, toSeconds(track(1970), sec(1.769), 200), 0); }
static double toSeconds(Track track, MediaPosition position, double endMarginMs) { final long durationMs = track.getDuration() == null ? 0 : track.getDuration(); final double posMs; switch (position.type) { case Percentage: posMs = durationMs * position.position / 100.0; break; case Seconds: posMs = position.position * 1000.0; break; default: throw unexhaustiveMatchError(); } return Math.abs(durationMs - posMs) >= endMarginMs ? posMs / 1000.0 : Math.max(0, ((double) durationMs - endMarginMs)) / 1000.0; }
ImageWorkflowOperationHandler extends AbstractWorkflowOperationHandler { static double toSeconds(Track track, MediaPosition position, double endMarginMs) { final long durationMs = track.getDuration() == null ? 0 : track.getDuration(); final double posMs; switch (position.type) { case Percentage: posMs = durationMs * position.position / 100.0; break; case Seconds: posMs = position.position * 1000.0; break; default: throw unexhaustiveMatchError(); } return Math.abs(durationMs - posMs) >= endMarginMs ? posMs / 1000.0 : Math.max(0, ((double) durationMs - endMarginMs)) / 1000.0; } }
ImageWorkflowOperationHandler extends AbstractWorkflowOperationHandler { static double toSeconds(Track track, MediaPosition position, double endMarginMs) { final long durationMs = track.getDuration() == null ? 0 : track.getDuration(); final double posMs; switch (position.type) { case Percentage: posMs = durationMs * position.position / 100.0; break; case Seconds: posMs = position.position * 1000.0; break; default: throw unexhaustiveMatchError(); } return Math.abs(durationMs - posMs) >= endMarginMs ? posMs / 1000.0 : Math.max(0, ((double) durationMs - endMarginMs)) / 1000.0; }  }
ImageWorkflowOperationHandler extends AbstractWorkflowOperationHandler { static double toSeconds(Track track, MediaPosition position, double endMarginMs) { final long durationMs = track.getDuration() == null ? 0 : track.getDuration(); final double posMs; switch (position.type) { case Percentage: posMs = durationMs * position.position / 100.0; break; case Seconds: posMs = position.position * 1000.0; break; default: throw unexhaustiveMatchError(); } return Math.abs(durationMs - posMs) >= endMarginMs ? posMs / 1000.0 : Math.max(0, ((double) durationMs - endMarginMs)) / 1000.0; }  void setWorkspace(Workspace workspace); @Override WorkflowOperationResult start(final WorkflowInstance wi, JobContext ctx); static StreamFold<MediaPackageElementFlavor, S> flavorFold(S selector); static StreamFold<String, S> tagFold(S selector); static Fn<String, EncodingProfile> fetchProfile(final ComposerService composerService); }
ImageWorkflowOperationHandler extends AbstractWorkflowOperationHandler { static double toSeconds(Track track, MediaPosition position, double endMarginMs) { final long durationMs = track.getDuration() == null ? 0 : track.getDuration(); final double posMs; switch (position.type) { case Percentage: posMs = durationMs * position.position / 100.0; break; case Seconds: posMs = position.position * 1000.0; break; default: throw unexhaustiveMatchError(); } return Math.abs(durationMs - posMs) >= endMarginMs ? posMs / 1000.0 : Math.max(0, ((double) durationMs - endMarginMs)) / 1000.0; }  void setWorkspace(Workspace workspace); @Override WorkflowOperationResult start(final WorkflowInstance wi, JobContext ctx); static StreamFold<MediaPackageElementFlavor, S> flavorFold(S selector); static StreamFold<String, S> tagFold(S selector); static Fn<String, EncodingProfile> fetchProfile(final ComposerService composerService); static final String OPT_SOURCE_FLAVOR; static final String OPT_SOURCE_FLAVORS; static final String OPT_SOURCE_TAGS; static final String OPT_PROFILES; static final String OPT_POSITIONS; static final String OPT_TARGET_FLAVOR; static final String OPT_TARGET_TAGS; static final String OPT_TARGET_BASE_NAME_FORMAT_SECOND; static final String OPT_TARGET_BASE_NAME_FORMAT_PERCENT; static final String OPT_END_MARGIN; static final double SINGLE_FRAME_POS; }