@@ -0,0 +1,1712 @@
+package org.taktik.mpegts.sources;%0A%0Aimport org.taktik.mpegts.MTSPacket;%0A%0Aimport static com.google.common.base.Preconditions.checkArgument;%0Aimport static com.google.common.base.Preconditions.checkNotNull;%0A%0Apublic class LoopingMTSSource implements MTSSource%7B%0A%09private ResettableMTSSource source;%0A%09private boolean fixContinuity;%0A%09private Integer maxLoops;%0A%09private long currentLoop;%0A%0A%09public LoopingMTSSource(ResettableMTSSource source, boolean fixContinuity, Integer maxLoops) %7B%0A%09%09this.source = source;%0A%09%09this.fixContinuity = fixContinuity;%0A%09%09this.maxLoops = maxLoops;%0A%09%09currentLoop = 1;%0A%09%7D%0A%0A%09@Override%0A%09public MTSPacket nextPacket() throws Exception %7B%0A%09%09MTSPacket packet = source.nextPacket();%0A%09%09if (packet == null) %7B%0A%09%09%09currentLoop++;%0A%09%09%09if (maxLoops == null %7C%7C (currentLoop %3C= maxLoops)) %7B%0A%09%09%09%09source.reset();%0A%09%09%09%09packet = source.nextPacket();%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return packet;%0A%09%7D%0A%0A%09public static LoopingMTSSourceBuilder builder() %7B%0A%09%09return new LoopingMTSSourceBuilder();%0A%09%7D%0A%0A%09public static class LoopingMTSSourceBuilder %7B%0A%09%09private ResettableMTSSource source;%0A%09%09private boolean fixContinuity;%0A%09%09private Integer maxLoops;%0A%0A%09%09private LoopingMTSSourceBuilder()%7B%7D%0A%0A%09%09public LoopingMTSSource build() %7B%0A%09%09%09checkNotNull(source);%0A%09%09%09checkArgument(maxLoops == null %7C%7C maxLoops %3E 0);%0A%09%09%09return new LoopingMTSSource(source, fixContinuity, maxLoops);%0A%09%09%7D%0A%0A%09%09public LoopingMTSSourceBuilder setSource(ResettableMTSSource source) %7B%0A%09%09%09this.source = source;%0A%09%09%09return this;%0A%09%09%7D%0A%0A%09%09public LoopingMTSSourceBuilder setFixContinuity(boolean fixContinuity) %7B%0A%09%09%09this.fixContinuity = fixContinuity;%0A%09%09%09return this;%0A%09%09%7D%0A%0A%09%09public LoopingMTSSourceBuilder setMaxLoops(Integer maxLoops) %7B%0A%09%09%09this.maxLoops = maxLoops;%0A%09%09%09return this;%0A%09%09%7D%0A%09%7D%0A%7D%0A

Revert "Removed LoopingMTSSource"