use of org.freedesktop.gstreamer.Pipeline in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class EdgeConnectorForKVSServiceTest method testStopRecordingJob_JobStop.
@Test
public void testStopRecordingJob_JobStop(@TempDir Path tempDir) throws IOException, InterruptedException {
// when
List<EdgeConnectorForKVSConfiguration> edgeConnectorForKVSConfigurationList = new ArrayList();
Pipeline mockedPipeline = Mockito.mock(Pipeline.class);
EdgeConnectorForKVSConfiguration edgeConnectorForKVSConfiguration = EdgeConnectorForKVSConfiguration.builder().kinesisVideoStreamName(MOCK_KINESIS_VIDEO_STREAM_NAME).liveStreamingStartTime(LIVE_STREAMING_START_TIME).liveStreamingDurationInMinutes(LIVE_STREAMING_DURATION_IN_MINUTES).captureStartTime(START_TIME_ALWAYS).videoRecordFolderPath(tempDir).videoRecorder(videoRecorder).build();
edgeConnectorForKVSConfigurationList.add(edgeConnectorForKVSConfiguration);
// Mock for initConfiguration
when(siteWiseManager.initEdgeConnectorForKVSServiceConfiguration(any())).thenReturn(edgeConnectorForKVSConfigurationList);
// Mock for initSecretsManager
when(secretsClient.getSecretValue(any())).thenReturn(gson.toJson(secretMap));
// Mock for videoRecorder status
when(videoRecorder.getStatus()).thenReturn(RecorderStatus.STOPPED);
// Mock for videoRecorder pipeline
when(videoRecorder.getPipeline()).thenReturn(mockedPipeline);
// then
edgeConnectorForKVSService.setUpSharedEdgeConnectorForKVSService();
edgeConnectorForKVSService.setUpCameraLevelEdgeConnectorForKVSService(edgeConnectorForKVSConfiguration);
Thread.sleep(2000);
edgeConnectorForKVSService.schedulerStopTaskCallback(Constants.JobType.LOCAL_VIDEO_CAPTURE, MOCK_KINESIS_VIDEO_STREAM_NAME);
Thread.sleep(1000);
// verify
assertEquals(0, edgeConnectorForKVSConfigurationList.get(0).getRecordingRequestsCount());
}
use of org.freedesktop.gstreamer.Pipeline in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class VideoRecorderUnitTest method registerCustomized_customizedModule_exceptionDoesNotThrow.
@Test
public void registerCustomized_customizedModule_exceptionDoesNotThrow() {
VideoRecorder recorder = null;
VideoRecorderBuilder builder = new VideoRecorderBuilder(mockGst, STATE_CALLBACK);
GstDao dao = builder.getGstDao();
Pipeline pipe = builder.getPipeline();
Assertions.assertNotNull(builder.getPipeline());
RecorderCameraRtsp cameraSrc = new RecorderCameraRtsp(dao, pipe, SRC_URL);
RecorderBranchFile filePath = new RecorderBranchFile(ContainerType.MATROSKA, dao, pipe, "./record");
// Add cam
Assertions.assertThrows(RejectedExecutionException.class, () -> builder.construct());
Assertions.assertTrue(builder.registerCustomCamera(cameraSrc));
Assertions.assertFalse(builder.registerCustomCamera(cameraSrc));
// Add branch
Assertions.assertThrows(RejectedExecutionException.class, () -> builder.construct());
Assertions.assertTrue(builder.registerCustomBranch(filePath, "customBranch"));
Assertions.assertFalse(builder.registerCustomBranch(filePath, "customBranch"));
// Get branch
recorder = builder.construct();
Assertions.assertNotNull(recorder.getBranch("customBranch"));
Assertions.assertTrue(null == recorder.getBranch("NoSuchBranch"));
}
use of org.freedesktop.gstreamer.Pipeline in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class VideoRecorderUnitTest method toggleAppDataAnyTest_notRegistered_returnFalse.
@Test
public void toggleAppDataAnyTest_notRegistered_returnFalse() {
VideoRecorder recorder = null;
VideoRecorderBuilder builder = new VideoRecorderBuilder(mockGst, STATE_CALLBACK);
try {
testOutputStream = new FileOutputStream("/dev/null");
} catch (FileNotFoundException e) {
Assertions.fail();
}
builder.registerCamera(REC_TYPE, SRC_URL);
builder.registerFileSink(CON_TYPE, "./record");
recorder = builder.construct();
// enable/disable invalid pipeline branches should get FALSE
Assertions.assertFalse(recorder.toggleAppDataCallback(true));
Assertions.assertFalse(recorder.toggleAppDataCallback(false));
Assertions.assertFalse(recorder.toggleAppDataOutputStream(true));
Assertions.assertFalse(recorder.toggleAppDataOutputStream(false));
Assertions.assertFalse(recorder.setAppDataCallback((rec, buff) -> {
}));
Assertions.assertFalse(recorder.setAppDataOutputStream(testOutputStream));
}
use of org.freedesktop.gstreamer.Pipeline in project iris by mnit-rtmc.
the class VidStreamMgrGst method closeStream.
/**
* Close the video stream
*/
private synchronized void closeStream() {
Pipeline p = pipe;
if (p != null) {
// NOTE - uncomment the lines below to generate debug DOT files of
// the GStreamer pipeline. You must have the GST_DEBUG_DUMP_DOT_DIR
// environment variable set for this to work.
// pipe.debugToDotFile(Bin.DebugGraphDetails.SHOW_ALL,
// getDOTFileName());
pipe = null;
if (appsink == null)
System.out.println("appsink is null");
else {
appsink.disconnect((AppSink.NEW_SAMPLE) appsinkListener);
appsink.disconnect((AppSink.EOS) appsinkListener);
}
if (bus == null)
System.out.println("bus is null");
else {
bus.disconnect((Bus.ERROR) busListener);
bus.disconnect((Bus.WARNING) busListener);
bus.disconnect((Bus.INFO) busListener);
}
gstComponent.disconnectAll();
gstComponent = null;
try {
p.setState(State.NULL);
p.getState();
System.out.println("CloseStream finished");
} catch (java.lang.IllegalStateException e) {
e.printStackTrace();
}
}
}
use of org.freedesktop.gstreamer.Pipeline in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class GstDaoUnitTest method gstDaoTest_invokeConstructor_noException.
@Test
void gstDaoTest_invokeConstructor_noException() {
// Test: new Pipeline
try (MockedConstruction<Pipeline> mockPipe = mockConstruction(Pipeline.class)) {
Pipeline pipe = mockGst.newPipeline();
Assertions.assertNotNull(pipe);
}
// Test: new EOSEvent
try (MockedConstruction<EOSEvent> mockEosEvent = mockConstruction(EOSEvent.class)) {
EOSEvent event = mockGst.newEosEvent();
Assertions.assertNotNull(event);
}
// Test: new Pipeline
try (MockedConstruction<EOSMessage> mockEosMsg = mockConstruction(EOSMessage.class)) {
EOSMessage msg = mockGst.newEosMessage(null);
Assertions.assertNotNull(msg);
}
}
Aggregations