Skip to content

Commit

Permalink
max analyze time test
Browse files Browse the repository at this point in the history
  • Loading branch information
burak-58 committed Mar 24, 2021
1 parent a7ad37d commit a64a42c
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/test/java/io/antmedia/test/MuxerUnitTest.java
Expand Up @@ -59,6 +59,7 @@
import java.util.List;
import java.util.Queue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

import org.apache.mina.core.buffer.IoBuffer;
import org.apache.tika.io.IOUtils;
Expand Down Expand Up @@ -2294,4 +2295,42 @@ public void testMp4MuxingWhileTempFileExist() {
assertEquals(nonExistingFile_1, mp4Muxer.getFile());

}

@Test
public void testAnalyzeTime() {
if (appScope == null) {
appScope = (WebScope) applicationContext.getBean("web.scope");
logger.info("Application / web scope: {}", appScope);
assertTrue(appScope.getDepth() == 1);
}

getAppSettings().setDeleteHLSFilesOnEnded(false);

ClientBroadcastStream clientBroadcastStream = new ClientBroadcastStream();
StreamCodecInfo info = new StreamCodecInfo();
clientBroadcastStream.setCodecInfo(info);

assertFalse(clientBroadcastStream.getCodecInfo().hasVideo());
assertFalse(clientBroadcastStream.getCodecInfo().hasAudio());

MuxAdaptor muxAdaptor = MuxAdaptor.initializeMuxAdaptor(clientBroadcastStream, false, appScope);
assertFalse(muxAdaptor.isRecording());

long pollInterval = 1000; //ms
int expectedPollCount = (int)(getAppSettings().getMaxAnalyzeDurationMS()*2 / pollInterval) + 1;
AtomicInteger actualPollCount = new AtomicInteger(0);

Awaitility.await()
.pollInterval(pollInterval , TimeUnit.MILLISECONDS)
.atMost(getAppSettings().getMaxAnalyzeDurationMS()*10, TimeUnit.MILLISECONDS)
.until(() -> {
actualPollCount.incrementAndGet();
muxAdaptor.execute();
return muxAdaptor.isRecording();
});

assertEquals(expectedPollCount, actualPollCount.get());
assertTrue(muxAdaptor.isRecording());

}
}

0 comments on commit a64a42c

Please sign in to comment.