Search in sources :

Example 1 with StreamMonitor

use of org.codice.alliance.video.stream.mpegts.StreamMonitor in project alliance by codice.

the class StreamMonitorHelperTest method setUp.

@Before
public void setUp() throws Exception {
    bundleContext = mock(BundleContext.class);
    uri = new URI(TEST_URL);
    List<ServiceReference<StreamMonitor>> serviceReferences = new ArrayList<>();
    udpStreamMonitor = mock(UdpStreamMonitor.class);
    ServiceReference<StreamMonitor> streamMonitorServiceReference = mock(ServiceReference.class);
    serviceReferences.add(streamMonitorServiceReference);
    when(bundleContext.getServiceReferences(eq(StreamMonitor.class), anyString())).thenReturn(serviceReferences);
    when(udpStreamMonitor.getTitle()).thenReturn(Optional.of("test"));
    when(udpStreamMonitor.getStreamUri()).thenReturn(Optional.of(uri));
    // when(udpStreamMonitor.startMonitoring()).thenReturn(Optional.of(uri));
    doAnswer(invocation -> {
        isMonitoring = true;
        return null;
    }).when(udpStreamMonitor).startMonitoring();
    doAnswer(invocation -> {
        isMonitoring = false;
        return null;
    }).when(udpStreamMonitor).stopMonitoring();
    when(bundleContext.getService(any(ServiceReference.class))).thenReturn(udpStreamMonitor);
    when(streamMonitorServiceReference.getProperty(anyString())).thenReturn(StreamMonitorHelper.SERVICE_PID);
    stream = new StreamMonitorHelper();
    stream.setContext(bundleContext);
}
Also used : StreamMonitorHelper(org.codice.alliance.video.ui.service.StreamMonitorHelper) UdpStreamMonitor(org.codice.alliance.video.stream.mpegts.UdpStreamMonitor) ArrayList(java.util.ArrayList) StreamMonitor(org.codice.alliance.video.stream.mpegts.StreamMonitor) UdpStreamMonitor(org.codice.alliance.video.stream.mpegts.UdpStreamMonitor) URI(java.net.URI) BundleContext(org.osgi.framework.BundleContext) ServiceReference(org.osgi.framework.ServiceReference) Before(org.junit.Before)

Example 2 with StreamMonitor

use of org.codice.alliance.video.stream.mpegts.StreamMonitor in project alliance by codice.

the class UdpStreamProcessorTest method testSetStreamEndPlugin.

@Test
public void testSetStreamEndPlugin() throws InterruptedException {
    StreamMonitor streamMonitor = mock(StreamMonitor.class);
    UdpStreamProcessor udpStreamProcessor = new UdpStreamProcessor(streamMonitor);
    RolloverCondition rolloverCondition = mock(RolloverCondition.class);
    when(rolloverCondition.isRolloverReady(any())).thenReturn(true);
    StreamEndPlugin streamEndPlugin = mock(StreamEndPlugin.class);
    udpStreamProcessor.setStreamEndPlugin(streamEndPlugin);
    udpStreamProcessor.setRolloverCondition(rolloverCondition);
    udpStreamProcessor.setRolloverAction(mock(RolloverAction.class));
    udpStreamProcessor.getPacketBuffer().write(new byte[] { 0x00 });
    Thread.sleep(1000);
    udpStreamProcessor.checkForRollover();
    verify(streamEndPlugin).streamEnded(any());
}
Also used : StreamEndPlugin(org.codice.alliance.video.stream.mpegts.plugins.StreamEndPlugin) StreamMonitor(org.codice.alliance.video.stream.mpegts.StreamMonitor) RolloverAction(org.codice.alliance.video.stream.mpegts.rollover.RolloverAction) RolloverCondition(org.codice.alliance.video.stream.mpegts.rollover.RolloverCondition) Test(org.junit.Test)

Example 3 with StreamMonitor

use of org.codice.alliance.video.stream.mpegts.StreamMonitor in project alliance by codice.

the class UdpStreamProcessorTest method testCreateChannelHandlers.

@Test
public void testCreateChannelHandlers() {
    StreamMonitor streamMonitor = mock(StreamMonitor.class);
    when(streamMonitor.getTitle()).thenReturn(Optional.of("title"));
    when(streamMonitor.getStreamUri()).thenReturn(Optional.of(URI.create("udp://127.0.0.1:80")));
    RolloverCondition rolloverCondition = mock(RolloverCondition.class);
    String filenameTemplate = "template";
    FilenameGenerator filenameGenerator = mock(FilenameGenerator.class);
    List<MetacardType> metacardTypeList = Collections.singletonList(mock(MetacardType.class));
    CatalogFramework catalogFramework = mock(CatalogFramework.class);
    UdpStreamProcessor udpStreamProcessor = new UdpStreamProcessor(streamMonitor);
    udpStreamProcessor.setRolloverCondition(rolloverCondition);
    udpStreamProcessor.setFilenameTemplate(filenameTemplate);
    udpStreamProcessor.setFilenameGenerator(filenameGenerator);
    udpStreamProcessor.setMetacardTypeList(metacardTypeList);
    udpStreamProcessor.setCatalogFramework(catalogFramework);
    udpStreamProcessor.setStreamCreationPlugin(context -> {
    });
    udpStreamProcessor.setStreamShutdownPlugin(mock(StreamShutdownPlugin.class));
    udpStreamProcessor.setStreamCreationSubject(new SimpleSubject());
    udpStreamProcessor.setParentMetacardUpdater(mock(MetacardUpdater.class));
    udpStreamProcessor.init();
    try {
        assertThat(udpStreamProcessor.createChannelHandlers(), notNullValue());
    } finally {
        udpStreamProcessor.shutdown();
    }
}
Also used : MetacardUpdater(org.codice.alliance.video.stream.mpegts.metacard.MetacardUpdater) StreamShutdownPlugin(org.codice.alliance.video.stream.mpegts.plugins.StreamShutdownPlugin) FilenameGenerator(org.codice.alliance.video.stream.mpegts.filename.FilenameGenerator) StreamMonitor(org.codice.alliance.video.stream.mpegts.StreamMonitor) CatalogFramework(ddf.catalog.CatalogFramework) SimpleSubject(org.codice.alliance.video.stream.mpegts.SimpleSubject) RolloverCondition(org.codice.alliance.video.stream.mpegts.rollover.RolloverCondition) MetacardType(ddf.catalog.data.MetacardType) Test(org.junit.Test)

Aggregations

StreamMonitor (org.codice.alliance.video.stream.mpegts.StreamMonitor)3 RolloverCondition (org.codice.alliance.video.stream.mpegts.rollover.RolloverCondition)2 Test (org.junit.Test)2 CatalogFramework (ddf.catalog.CatalogFramework)1 MetacardType (ddf.catalog.data.MetacardType)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 SimpleSubject (org.codice.alliance.video.stream.mpegts.SimpleSubject)1 UdpStreamMonitor (org.codice.alliance.video.stream.mpegts.UdpStreamMonitor)1 FilenameGenerator (org.codice.alliance.video.stream.mpegts.filename.FilenameGenerator)1 MetacardUpdater (org.codice.alliance.video.stream.mpegts.metacard.MetacardUpdater)1 StreamEndPlugin (org.codice.alliance.video.stream.mpegts.plugins.StreamEndPlugin)1 StreamShutdownPlugin (org.codice.alliance.video.stream.mpegts.plugins.StreamShutdownPlugin)1 RolloverAction (org.codice.alliance.video.stream.mpegts.rollover.RolloverAction)1 StreamMonitorHelper (org.codice.alliance.video.ui.service.StreamMonitorHelper)1 Before (org.junit.Before)1 BundleContext (org.osgi.framework.BundleContext)1 ServiceReference (org.osgi.framework.ServiceReference)1