Java Code Examples for org.kurento.client.RecorderEndpoint#stopAndWait()
The following examples show how to use
org.kurento.client.RecorderEndpoint#stopAndWait() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CompositeWebRtcRecorderTest.java From kurento-java with Apache License 2.0 | 5 votes |
@Test public void testCompositeRecorder() throws Exception { // MediaPipeline MediaPipeline mp = kurentoClient.createMediaPipeline(); Composite composite = new Composite.Builder(mp).build(); HubPort hubPort1 = new HubPort.Builder(composite).build(); WebRtcEndpoint webRtcEpRed = new WebRtcEndpoint.Builder(mp).build(); webRtcEpRed.connect(hubPort1); HubPort hubPort2 = new HubPort.Builder(composite).build(); WebRtcEndpoint webRtcEpGreen = new WebRtcEndpoint.Builder(mp).build(); webRtcEpGreen.connect(hubPort2, MediaType.AUDIO); HubPort hubPort3 = new HubPort.Builder(composite).build(); WebRtcEndpoint webRtcEpBlue = new WebRtcEndpoint.Builder(mp).build(); webRtcEpBlue.connect(hubPort3, MediaType.AUDIO); HubPort hubPort4 = new HubPort.Builder(composite).build(); WebRtcEndpoint webRtcEpWhite = new WebRtcEndpoint.Builder(mp).build(); webRtcEpWhite.connect(hubPort4, MediaType.AUDIO); String recordingFile = getDefaultOutputFile(EXTENSION_WEBM); RecorderEndpoint recorderEp = new RecorderEndpoint.Builder(mp, Protocol.FILE + recordingFile).build(); HubPort hubPort5 = new HubPort.Builder(composite).build(); hubPort5.connect(recorderEp); // WebRTC browsers getPage(BROWSER2).initWebRtc(webRtcEpRed, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY); getPage(BROWSER3).initWebRtc(webRtcEpGreen, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY); getPage(BROWSER4).initWebRtc(webRtcEpBlue, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY); getPage(BROWSER5).initWebRtc(webRtcEpWhite, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY); recorderEp.record(); Thread.sleep(PLAYTIME * 1000); final CountDownLatch recorderLatch = new CountDownLatch(1); recorderEp.stopAndWait(new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { recorderLatch.countDown(); } @Override public void onError(Throwable cause) throws Exception { recorderLatch.countDown(); } }); Assert.assertTrue("Not stop properly", recorderLatch.await(getPage(BROWSER1).getTimeout(), TimeUnit.SECONDS)); mp.release(); // Media Pipeline #2 MediaPipeline mp2 = kurentoClient.createMediaPipeline(); PlayerEndpoint playerEp2 = new PlayerEndpoint.Builder(mp2, Protocol.FILE + recordingFile).build(); WebRtcEndpoint webRtcEp2 = new WebRtcEndpoint.Builder(mp2).build(); playerEp2.connect(webRtcEp2); // Playing the recorded file launchBrowser(mp2, webRtcEp2, playerEp2, null, EXPECTED_VIDEO_CODEC_WEBM, EXPECTED_AUDIO_CODEC_WEBM, recordingFile, Color.RED, 0, 0, PLAYTIME); // Release Media Pipeline #2 mp2.release(); success = true; }
Example 2
Source File: RecorderMultiSlashesDirectoryTest.java From kurento-java with Apache License 2.0 | 4 votes |
public void doTest(MediaProfileSpecType mediaProfileSpecType, String expectedVideoCodec, String expectedAudioCodec, String extension) throws Exception { String multiSlashses = File.separator + File.separator + File.separator; final CountDownLatch recorderLatch = new CountDownLatch(1); MediaPipeline mp = kurentoClient.createMediaPipeline(); WebRtcEndpoint webRtcEp = new WebRtcEndpoint.Builder(mp).build(); String recordingFile = getRecordUrl(extension).replace(getSimpleTestName(), new Date().getTime() + File.separator + getSimpleTestName()); String recordingFileWithMultiSlashes = recordingFile.replace(File.separator, multiSlashses); log.debug("The path with multi slash is {} ", recordingFileWithMultiSlashes); RecorderEndpoint recorderEp = new RecorderEndpoint.Builder(mp, recordingFileWithMultiSlashes) .withMediaProfile(mediaProfileSpecType).build(); webRtcEp.connect(webRtcEp); webRtcEp.connect(recorderEp); getPage().subscribeEvents("playing"); getPage().initWebRtc(webRtcEp, AUDIO_AND_VIDEO, WebRtcMode.SEND_RCV); recorderEp.record(); // Wait until event playing in the remote stream Assert.assertTrue("Not received media (timeout waiting playing event)", getPage().waitForEvent("playing")); Thread.sleep(SECONDS.toMillis(PLAYTIME)); recorderEp.stopAndWait(new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { recorderLatch.countDown(); } @Override public void onError(Throwable cause) throws Exception { recorderLatch.countDown(); } }); Assert.assertTrue("Not stop properly", recorderLatch.await(getPage().getTimeout(), TimeUnit.SECONDS)); // Wait until file exists waitForFileExists(recordingFile); AssertMedia.assertCodecs(recordingFile, expectedVideoCodec, expectedAudioCodec); mp.release(); }
Example 3
Source File: LongStabilityRecorderS3Test.java From kurento-java with Apache License 2.0 | 4 votes |
public void doTest(final MediaProfileSpecType mediaProfileSpecType, String expectedAudioCodec, final String extension) throws Exception { long testDurationMillis = PropertiesManager.getProperty(TEST_DURATION_PROPERTY, DEFAULT_TEST_DURATION); MediaPipeline mp = kurentoClient.createMediaPipeline(); final CountDownLatch errorPipelinelatch = new CountDownLatch(1); mp.addErrorListener(new EventListener<ErrorEvent>() { @Override public void onEvent(ErrorEvent event) { msgError = "Description:" + event.getDescription() + "; Error code:" + event.getType(); log.error(msgError); errorPipelinelatch.countDown(); } }); final WebRtcEndpoint webRtcSender = new WebRtcEndpoint.Builder(mp).build(); // WebRTC sender negotiation getPage().subscribeLocalEvents("playing"); getPage().initWebRtc(webRtcSender, WebRtcChannel.AUDIO_ONLY, WebRtcMode.SEND_ONLY); Assert.assertTrue("Not received media in sender webrtc", getPage().waitForEvent("playing")); // Recorder String recordingFile = getRecordUrl(extension); RecorderEndpoint recorder = new RecorderEndpoint.Builder(mp, recordingFile) .withMediaProfile(mediaProfileSpecType).build(); webRtcSender.connect(recorder); // Start recorder recorder.record(); // Wait recording time Thread.sleep(testDurationMillis); // Stop recorder final CountDownLatch recorderLatch = new CountDownLatch(1); recorder.stopAndWait(new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { recorderLatch.countDown(); } @Override public void onError(Throwable cause) throws Exception { recorderLatch.countDown(); } }); // Release Media Pipeline Assert.assertTrue("Not stop properly", recorderLatch.await(getPage().getTimeout(), TimeUnit.SECONDS)); if (mp != null) { mp.release(); } Assert.assertTrue(msgError, errorPipelinelatch.getCount() == 1); waitForFileExists(recordingFile); // Assessments AssertMedia.assertDuration(recordingFile, testDurationMillis, THRESHOLD_MS); }
Example 4
Source File: RecorderWebRtcLongFileTest.java From kurento-java with Apache License 2.0 | 4 votes |
public void doTest(final MediaProfileSpecType mediaProfileSpecType, String expectedVideoCodec, String expectedAudioCodec, final String extension) throws Exception { MediaPipeline mp = null; // Media Pipeline mp = kurentoClient.createMediaPipeline(); final WebRtcEndpoint webRtcSender = new WebRtcEndpoint.Builder(mp).build(); // WebRTC sender negotiation getPage().subscribeLocalEvents("playing"); getPage().initWebRtc(webRtcSender, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY); Assert.assertTrue("Not received media in sender webrtc", getPage().waitForEvent("playing")); // Recorder String recordingFile = getRecordUrl(extension); RecorderEndpoint recorder = new RecorderEndpoint.Builder(mp, recordingFile) .withMediaProfile(mediaProfileSpecType).build(); webRtcSender.connect(recorder); // Start recorder recorder.record(); // Wait recording time Thread.sleep(RECORD_MS); // Stop recorder recorder.stopAndWait(); // Guard time to stop recording Thread.sleep(4000); // Assessments AssertMedia.assertCodecs(recordingFile, expectedVideoCodec, expectedAudioCodec); AssertMedia.assertDuration(recordingFile, RECORD_MS, THRESHOLD_MS); // Release Media Pipeline if (mp != null) { mp.release(); } }
Example 5
Source File: RecorderWebRtcSwitchSequentialTest.java From kurento-java with Apache License 2.0 | 4 votes |
public void doTest(MediaProfileSpecType mediaProfileSpecType, String expectedVideoCodec, String expectedAudioCodec, String extension) throws Exception { final CountDownLatch recorderLatch = new CountDownLatch(1); MediaPipeline mp = null; // Media Pipeline mp = kurentoClient.createMediaPipeline(); WebRtcEndpoint webRtcEp1 = new WebRtcEndpoint.Builder(mp).build(); WebRtcEndpoint webRtcEp2 = new WebRtcEndpoint.Builder(mp).build(); // WebRTC negotiation getPage(0).subscribeLocalEvents("playing"); getPage(0).initWebRtc(webRtcEp1, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY); getPage(1).subscribeLocalEvents("playing"); getPage(1).initWebRtc(webRtcEp2, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY); // Start record String recordingFile = getRecordUrl(extension); RecorderEndpoint recorderEp = new RecorderEndpoint.Builder(mp, recordingFile) .withMediaProfile(mediaProfileSpecType).build(); recorderEp.record(); // Switch webrtcs for (int i = 0; i < SWITCH_TIMES; i++) { if (i % 2 == 0) { webRtcEp1.connect(recorderEp); } else { webRtcEp2.connect(recorderEp); } Thread.sleep(SWITCH_RATE_MS); } // Stop record recorderEp.stopAndWait(new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { recorderLatch.countDown(); } @Override public void onError(Throwable cause) throws Exception { recorderLatch.countDown(); } }); // Assessment Assert.assertTrue("Not received media in browser 1", getPage(0).waitForEvent("playing")); Assert.assertTrue("Not received media in browser 2", getPage(1).waitForEvent("playing")); Assert.assertTrue("Not stop properly", recorderLatch.await(getPage().getTimeout(), TimeUnit.SECONDS)); long expectedTimeMs = SWITCH_TIMES * SWITCH_RATE_MS; AssertMedia.assertCodecs(recordingFile, expectedVideoCodec, expectedAudioCodec); AssertMedia.assertDuration(recordingFile, expectedTimeMs, THRESHOLD_MS); // Release Media Pipeline if (mp != null) { mp.release(); } }
Example 6
Source File: RecorderWebRtcShortFileTest.java From kurento-java with Apache License 2.0 | 4 votes |
public void doTest(final MediaProfileSpecType mediaProfileSpecType, String expectedVideoCodec, String expectedAudioCodec, final String extension) throws Exception { final CountDownLatch recorderLatch = new CountDownLatch(1); long testDurationMillis = PropertiesManager.getProperty(TEST_DURATION_PROPERTY, DEFAULT_TEST_DURATION); endTestTime = System.currentTimeMillis() + testDurationMillis; MediaPipeline pipeline = kurentoClient.createMediaPipeline(); final WebRtcEndpoint webRtcSender = new WebRtcEndpoint.Builder(pipeline).build(); final String recordingFile = getRecordUrl(extension); final RecorderEndpoint recorder = new RecorderEndpoint.Builder(pipeline, recordingFile) .withMediaProfile(mediaProfileSpecType).build(); // WebRTC sender negotiation getPage().subscribeLocalEvents("playing"); getPage().initWebRtc(webRtcSender, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY); Assert.assertTrue("Not received media in sender", getPage().waitForEvent("playing")); webRtcSender.connect(recorder); while (!isTimeToFinishTest()) { // Start record recorder.record(); // Wait play time Thread.sleep(RECORD_MS); // Pause record recorder.pause(); Thread.sleep(RECORD_MS); } // Stop record recorder.stopAndWait(new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { recorderLatch.countDown(); } @Override public void onError(Throwable cause) throws Exception { recorderLatch.countDown(); } }); Assert.assertTrue("Not stop properly", recorderLatch.await(getPage().getTimeout(), TimeUnit.SECONDS)); AssertMedia.assertCodecs(recordingFile, expectedVideoCodec, expectedAudioCodec); AssertMedia.assertDuration(recordingFile, testDurationMillis / 2, (testDurationMillis / 2) + THRESHOLD_MS); // Release Media Pipeline if (pipeline != null) { pipeline.release(); } }
Example 7
Source File: CompositeAudioRecorderTest.java From kurento-java with Apache License 2.0 | 4 votes |
@Test public void testCompositeRecorder() throws Exception { // MediaPipeline MediaPipeline mp = kurentoClient.createMediaPipeline(); PlayerEndpoint playerRed = new PlayerEndpoint.Builder(mp, "http://" + getTestFilesHttpPath() + "/video/30sec/red.webm") .build(); PlayerEndpoint playerGreen = new PlayerEndpoint.Builder(mp, "http://" + getTestFilesHttpPath() + "/video/30sec/green.webm").build(); PlayerEndpoint playerBlue = new PlayerEndpoint.Builder(mp, "http://" + getTestFilesHttpPath() + "/video/30sec/blue.webm").build(); Composite composite = new Composite.Builder(mp).build(); HubPort hubPort1 = new HubPort.Builder(composite).build(); HubPort hubPort2 = new HubPort.Builder(composite).build(); HubPort hubPort3 = new HubPort.Builder(composite).build(); playerRed.connect(hubPort1); playerGreen.connect(hubPort2, MediaType.AUDIO); playerBlue.connect(hubPort3, MediaType.AUDIO); PlayerEndpoint playerWhite = new PlayerEndpoint.Builder(mp, "http://" + getTestFilesHttpPath() + "/video/30sec/white.webm").build(); HubPort hubPort4 = new HubPort.Builder(composite).build(); playerWhite.connect(hubPort4, MediaType.AUDIO); HubPort hubPort5 = new HubPort.Builder(composite).build(); String recordingFile = getDefaultOutputFile(EXTENSION_WEBM); RecorderEndpoint recorderEp = new RecorderEndpoint.Builder(mp, Protocol.FILE + recordingFile).build(); hubPort5.connect(recorderEp); playerRed.play(); playerGreen.play(); playerBlue.play(); playerWhite.play(); recorderEp.record(); Thread.sleep(RECORDTIME * 1000); final CountDownLatch recorderLatch = new CountDownLatch(1); recorderEp.stopAndWait(new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { recorderLatch.countDown(); } @Override public void onError(Throwable cause) throws Exception { recorderLatch.countDown(); } }); Assert.assertTrue("Not stop properly", recorderLatch.await(getPage().getTimeout(), TimeUnit.SECONDS)); playerRed.stop(); playerGreen.stop(); playerBlue.stop(); playerWhite.stop(); mp.release(); // Media Pipeline #2 MediaPipeline mp2 = kurentoClient.createMediaPipeline(); PlayerEndpoint playerEp2 = new PlayerEndpoint.Builder(mp2, Protocol.FILE + recordingFile).build(); WebRtcEndpoint webRtcEp2 = new WebRtcEndpoint.Builder(mp2).build(); playerEp2.connect(webRtcEp2); // Playing the recording launchBrowser(mp, webRtcEp2, playerEp2, null, EXPECTED_VIDEO_CODEC_WEBM, EXPECTED_AUDIO_CODEC_WEBM, recordingFile, Color.RED, 0, 0, PLAYTIME); // Release Media Pipeline #2 mp2.release(); success = true; }
Example 8
Source File: CompositeRecorderTest.java From kurento-java with Apache License 2.0 | 4 votes |
@Test public void testCompositeRecorder() throws Exception { // MediaPipeline MediaPipeline mp = kurentoClient.createMediaPipeline(); PlayerEndpoint playerRed = new PlayerEndpoint.Builder(mp, "http://" + getTestFilesHttpPath() + "/video/30sec/red.webm") .build(); PlayerEndpoint playerGreen = new PlayerEndpoint.Builder(mp, "http://" + getTestFilesHttpPath() + "/video/30sec/green.webm").build(); PlayerEndpoint playerBlue = new PlayerEndpoint.Builder(mp, "http://" + getTestFilesHttpPath() + "/video/30sec/blue.webm").build(); Composite composite = new Composite.Builder(mp).build(); HubPort hubPort1 = new HubPort.Builder(composite).build(); HubPort hubPort2 = new HubPort.Builder(composite).build(); HubPort hubPort3 = new HubPort.Builder(composite).build(); playerRed.connect(hubPort1); playerGreen.connect(hubPort2); playerBlue.connect(hubPort3); PlayerEndpoint playerWhite = new PlayerEndpoint.Builder(mp, "http://" + getTestFilesHttpPath() + "/video/30sec/white.webm").build(); HubPort hubPort4 = new HubPort.Builder(composite).build(); playerWhite.connect(hubPort4); HubPort hubPort5 = new HubPort.Builder(composite).build(); String recordingFile = getDefaultOutputFile(EXTENSION_WEBM); RecorderEndpoint recorderEp = new RecorderEndpoint.Builder(mp, Protocol.FILE + recordingFile).build(); hubPort5.connect(recorderEp); playerRed.play(); playerGreen.play(); playerBlue.play(); playerWhite.play(); recorderEp.record(); Thread.sleep(RECORDTIME * 1000); final CountDownLatch recorderLatch = new CountDownLatch(1); recorderEp.stopAndWait(new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { recorderLatch.countDown(); } @Override public void onError(Throwable cause) throws Exception { recorderLatch.countDown(); } }); Assert.assertTrue("Not stop properly", recorderLatch.await(getPage().getTimeout(), TimeUnit.SECONDS)); playerRed.stop(); playerGreen.stop(); playerBlue.stop(); playerWhite.stop(); mp.release(); // Media Pipeline #2 MediaPipeline mp2 = kurentoClient.createMediaPipeline(); PlayerEndpoint playerEp2 = new PlayerEndpoint.Builder(mp2, Protocol.FILE + recordingFile).build(); WebRtcEndpoint webRtcEp2 = new WebRtcEndpoint.Builder(mp2).build(); playerEp2.connect(webRtcEp2); // Playing the recording launchBrowser(mp, webRtcEp2, playerEp2, null, EXPECTED_VIDEO_CODEC_WEBM, EXPECTED_AUDIO_CODEC_WEBM, recordingFile, Color.RED, 0, 0, PLAYTIME); // Assertions Assert.assertTrue("Upper left part of the video must be red", getPage().similarColorAt(Color.RED, 0, 0)); Assert.assertTrue("Upper right part of the video must be green", getPage().similarColorAt(Color.GREEN, 450, 0)); Assert.assertTrue("Lower left part of the video must be blue", getPage().similarColorAt(Color.BLUE, 0, 450)); Assert.assertTrue("Lower right part of the video must be white", getPage().similarColorAt(Color.WHITE, 450, 450)); // Release Media Pipeline #2 mp2.release(); success = true; }
Example 9
Source File: RecorderSwitchPlayerWithPassThroughTest.java From kurento-java with Apache License 2.0 | 4 votes |
public void doTest(MediaProfileSpecType mediaProfileSpecType, String expectedVideoCodec, String expectedAudioCodec, String extension, String[] mediaUrls, Color[] expectedColors) throws Exception { MediaPipeline mp = kurentoClient.createMediaPipeline(); final CountDownLatch errorPipelinelatch = new CountDownLatch(1); mp.addErrorListener(new EventListener<ErrorEvent>() { @Override public void onEvent(ErrorEvent event) { msgError = "Description:" + event.getDescription() + "; Error code:" + event.getType(); errorPipelinelatch.countDown(); } }); int numPlayers = mediaUrls.length; PlayerEndpoint[] players = new PlayerEndpoint[numPlayers]; for (int i = 0; i < numPlayers; i++) { players[i] = new PlayerEndpoint.Builder(mp, mediaUrls[i]).build(); } WebRtcEndpoint webRtcEp = new WebRtcEndpoint.Builder(mp).build(); String recordingFile = getRecordUrl(extension); RecorderEndpoint recorderEp = new RecorderEndpoint.Builder(mp, recordingFile) .withMediaProfile(mediaProfileSpecType).build(); PassThrough passThrough = new PassThrough.Builder(mp).build(); passThrough.connect(recorderEp); // Test execution getPage().subscribeEvents("playing"); getPage().initWebRtc(webRtcEp, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.RCV_ONLY); final CountDownLatch recorderLatch = new CountDownLatch(1); boolean startRecord = false; for (int i = 0; i < numPlayers; i++) { players[i].connect(webRtcEp); players[i].connect(passThrough); players[i].play(); if (!startRecord) { Assert.assertTrue("Not received media (timeout waiting playing event)", getPage().waitForEvent("playing")); recorderEp.record(); startRecord = true; } waitSeconds(PLAYTIME / numPlayers); } saveGstreamerDot(mp); recorderEp.stopAndWait(new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { recorderLatch.countDown(); } @Override public void onError(Throwable cause) throws Exception { recorderLatch.countDown(); } }); Assert.assertTrue("Not stop properly", recorderLatch.await(getPage().getTimeout(), TimeUnit.SECONDS)); mp.release(); Assert.assertTrue(msgError, errorPipelinelatch.getCount() == 1); // Reloading browser getPage().reload(); checkRecordingFile(recordingFile, "browser", expectedColors, PLAYTIME, expectedVideoCodec, expectedAudioCodec); success = true; }
Example 10
Source File: BaseRecorder.java From kurento-java with Apache License 2.0 | 4 votes |
protected void launchBrowser(MediaPipeline mp, WebRtcEndpoint webRtcEp, PlayerEndpoint playerEp, RecorderEndpoint recorderEp, String expectedVideoCodec, String expectedAudioCodec, String recordingFile, Color expectedColor, int xColor, int yColor, int playTime) throws InterruptedException { Timer gettingStats = new Timer(); final CountDownLatch errorContinuityAudiolatch = new CountDownLatch(1); getPage().subscribeEvents("playing"); getPage().initWebRtc(webRtcEp, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.RCV_ONLY); playerEp.play(); final CountDownLatch eosLatch = new CountDownLatch(1); playerEp.addEndOfStreamListener(new EventListener<EndOfStreamEvent>() { @Override public void onEvent(EndOfStreamEvent event) { eosLatch.countDown(); } }); if (recorderEp != null) { recorderEp.record(); } // Assertions String inRecording = recorderEp == null ? " in the recording" : ""; Assert.assertTrue("Not received media (timeout waiting playing event)" + inRecording, getPage().waitForEvent("playing")); if (recorderEp == null) { // Checking continuity of the audio getPage().activatePeerConnectionInboundStats("webRtcPeer.peerConnection"); gettingStats.schedule(new CheckAudioTimerTask(errorContinuityAudiolatch, getPage()), 100, 200); } Assert.assertTrue( "Color at coordinates " + xColor + "," + yColor + " must be " + expectedColor + inRecording, getPage().similarColorAt(expectedColor, xColor, yColor)); Assert.assertTrue("Not received EOS event in player" + inRecording, eosLatch.await(getPage().getTimeout(), TimeUnit.SECONDS)); final CountDownLatch recorderLatch = new CountDownLatch(1); if (recorderEp != null) { saveGstreamerDot(mp); recorderEp.stopAndWait(new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { recorderLatch.countDown(); } @Override public void onError(Throwable cause) throws Exception { recorderLatch.countDown(); } }); Assert.assertTrue("Not stop properly", recorderLatch.await(getPage().getTimeout(), TimeUnit.SECONDS)); // Wait until file exists waitForFileExists(recordingFile); AssertMedia.assertCodecs(recordingFile, expectedVideoCodec, expectedAudioCodec); AssertMedia.assertDuration(recordingFile, TimeUnit.SECONDS.toMillis(playTime), TimeUnit.SECONDS.toMillis(getPage().getThresholdTime())); } else { gettingStats.cancel(); getPage().stopPeerConnectionInboundStats("webRtcPeer.peerConnection"); double currentTime = getPage().getCurrentTime(); Assert.assertTrue("Error in play time in the recorded video (expected: " + playTime + " sec, real: " + currentTime + " sec) " + inRecording, getPage().compare(playTime, currentTime)); if (recorderEp == null) { Assert.assertTrue("Check audio. There were more than 2 seconds without receiving packets", errorContinuityAudiolatch.getCount() == 1); } } }
Example 11
Source File: RepositoryRecorderTest.java From kurento-java with Apache License 2.0 | 4 votes |
@Test public void testRepositoryRecorder() throws Exception { final CountDownLatch recorderLatch = new CountDownLatch(1); // Media Pipeline MediaPipeline mp = kurentoClient.createMediaPipeline(); PlayerEndpoint playerEp = new PlayerEndpoint.Builder(mp, "http://" + getTestFilesHttpPath() + "/video/10sec/ball.webm").build(); WebRtcEndpoint webRtcEp1 = new WebRtcEndpoint.Builder(mp).build(); RepositoryItem repositoryItem = repository.createRepositoryItem(); RepositoryHttpRecorder recorder = repositoryItem.createRepositoryHttpRecorder(); RecorderEndpoint recorderEp = new RecorderEndpoint.Builder(mp, recorder.getURL()).build(); playerEp.connect(webRtcEp1); playerEp.connect(recorderEp); final CountDownLatch eosLatch = new CountDownLatch(1); playerEp.addEndOfStreamListener(new EventListener<EndOfStreamEvent>() { @Override public void onEvent(EndOfStreamEvent event) { eosLatch.countDown(); } }); // Test execution #1. Play the video while it is recorded launchBrowser(webRtcEp1, playerEp, recorderEp); // Wait for EOS Assert.assertTrue("Not received EOS event in player", eosLatch.await(getPage().getTimeout(), TimeUnit.SECONDS)); // Release Media Pipeline #1 recorderEp.stopAndWait(new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { recorderLatch.countDown(); } @Override public void onError(Throwable cause) throws Exception { recorderLatch.countDown(); } }); Assert.assertTrue("Not stop properly", recorderLatch.await(getPage().getTimeout(), TimeUnit.SECONDS)); mp.release(); Thread.sleep(500); }
Example 12
Source File: RecorderSwitchPlayerWebRtcTest.java From kurento-java with Apache License 2.0 | 4 votes |
public void doTest(MediaProfileSpecType mediaProfileSpecType, String expectedVideoCodec, String expectedAudioCodec, String extension) throws Exception { // Media Pipeline #1 MediaPipeline mp = kurentoClient.createMediaPipeline(); WebRtcEndpoint webRtcEp = new WebRtcEndpoint.Builder(mp).build(); PlayerEndpoint playerRed = new PlayerEndpoint.Builder(mp, getPlayerUrl("/video/10sec/red.webm")).build(); playerRed.connect(webRtcEp); // Test execution getPage(0).subscribeLocalEvents("playing"); getPage(0).initWebRtc(webRtcEp, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY); playerRed.play(); // red Assert.assertTrue("Not received media (timeout waiting playing event)", getPage(0).waitForEvent("playing")); PlayerEndpoint playerGreen = new PlayerEndpoint.Builder(mp, getPlayerUrl("/video/10sec/green.webm")).build(); String recordingFile = getRecordUrl(extension); RecorderEndpoint recorderEp = new RecorderEndpoint.Builder(mp, recordingFile) .withMediaProfile(mediaProfileSpecType).build(); playerGreen.play(); recorderEp.record(); for (int i = 0; i < NUM_SWAPS; i++) { if (i % 2 == 0) { playerRed.connect(recorderEp); } else { playerGreen.connect(recorderEp); } Thread.sleep(TimeUnit.SECONDS.toMillis(PLAYTIME) / NUM_SWAPS); } // Release Media Pipeline #1 saveGstreamerDot(mp); final CountDownLatch recorderLatch = new CountDownLatch(1); recorderEp.stopAndWait(new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { recorderLatch.countDown(); } @Override public void onError(Throwable cause) throws Exception { recorderLatch.countDown(); } }); Assert.assertTrue("Not stop properly", recorderLatch.await(getPage(0).getTimeout(), TimeUnit.SECONDS)); mp.release(); // Reloading browser getPage(0).close(); checkRecordingFile(recordingFile, "browser1", EXPECTED_COLORS, PLAYTIME, expectedVideoCodec, expectedAudioCodec); success = true; }
Example 13
Source File: RecorderSwitchWebRtcWebRtcAndPlayerTest.java From kurento-java with Apache License 2.0 | 4 votes |
public void doTest(MediaProfileSpecType mediaProfileSpecType, String expectedVideoCodec, String expectedAudioCodec, String extension) throws Exception { // Media Pipeline #1 MediaPipeline mp = kurentoClient.createMediaPipeline(); final CountDownLatch errorPipelinelatch = new CountDownLatch(1); mp.addErrorListener(new EventListener<ErrorEvent>() { @Override public void onEvent(ErrorEvent event) { msgError = "Description:" + event.getDescription() + "; Error code:" + event.getType(); errorPipelinelatch.countDown(); } }); WebRtcEndpoint webRtcEpRed = new WebRtcEndpoint.Builder(mp).build(); WebRtcEndpoint webRtcEpGreen = new WebRtcEndpoint.Builder(mp).build(); String recordingFile = getRecordUrl(extension); RecorderEndpoint recorderEp = new RecorderEndpoint.Builder(mp, recordingFile) .withMediaProfile(mediaProfileSpecType).build(); // Test execution getPage(BROWSER1).subscribeLocalEvents("playing"); long startWebrtc = System.currentTimeMillis(); getPage(BROWSER1).initWebRtc(webRtcEpRed, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY); webRtcEpRed.connect(recorderEp); recorderEp.record(); Assert.assertTrue("Not received media (timeout waiting playing event)", getPage(BROWSER1).waitForEvent("playing")); long webrtcRedConnectionTime = System.currentTimeMillis() - startWebrtc; Thread.sleep(TimeUnit.SECONDS.toMillis(PLAYTIME) / N_PLAYER); getPage(BROWSER2).subscribeLocalEvents("playing"); startWebrtc = System.currentTimeMillis(); getPage(BROWSER2).initWebRtc(webRtcEpGreen, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY); // green webRtcEpGreen.connect(recorderEp); Assert.assertTrue("Not received media (timeout waiting playing event)", getPage(BROWSER2).waitForEvent("playing")); long webrtcGreenConnectionTime = System.currentTimeMillis() - startWebrtc; Thread.sleep(TimeUnit.SECONDS.toMillis(PLAYTIME) / N_PLAYER); webRtcEpRed.connect(recorderEp); startWebrtc = System.currentTimeMillis(); Thread.sleep(TimeUnit.SECONDS.toMillis(PLAYTIME) / N_PLAYER); // Release Media Pipeline #1 saveGstreamerDot(mp); final CountDownLatch recorderLatch = new CountDownLatch(1); recorderEp.stopAndWait(new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { recorderLatch.countDown(); } @Override public void onError(Throwable cause) throws Exception { recorderLatch.countDown(); } }); Assert.assertTrue("Not stop properly", recorderLatch.await(getPage(BROWSER2).getTimeout(), TimeUnit.SECONDS)); mp.release(); Assert.assertTrue(msgError, errorPipelinelatch.getCount() == 1); final long playtime = PLAYTIME + TimeUnit.MILLISECONDS .toSeconds((2 * webrtcRedConnectionTime) + webrtcGreenConnectionTime); checkRecordingFile(recordingFile, BROWSER3, EXPECTED_COLORS, playtime, expectedVideoCodec, expectedAudioCodec); success = true; }
Example 14
Source File: RecorderSwitchWebRtcWebRtcAndPlayerTest.java From kurento-java with Apache License 2.0 | 4 votes |
public void doTestWithPlayer(MediaProfileSpecType mediaProfileSpecType, String expectedVideoCodec, String expectedAudioCodec, String extension, String mediaUrlPlayer) throws Exception { // Media Pipeline #1 getPage(BROWSER2).close(); MediaPipeline mp = kurentoClient.createMediaPipeline(); final CountDownLatch errorPipelinelatch = new CountDownLatch(1); mp.addErrorListener(new EventListener<ErrorEvent>() { @Override public void onEvent(ErrorEvent event) { msgError = "Description:" + event.getDescription() + "; Error code:" + event.getType(); errorPipelinelatch.countDown(); } }); WebRtcEndpoint webRtcEpRed = new WebRtcEndpoint.Builder(mp).build(); PlayerEndpoint playerEp = new PlayerEndpoint.Builder(mp, mediaUrlPlayer).build(); String recordingFile = getRecordUrl(extension); RecorderEndpoint recorderEp = new RecorderEndpoint.Builder(mp, recordingFile) .withMediaProfile(mediaProfileSpecType).build(); // Test execution getPage(BROWSER1).subscribeLocalEvents("playing"); long startWebrtc = System.currentTimeMillis(); getPage(BROWSER1).initWebRtc(webRtcEpRed, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY); webRtcEpRed.connect(recorderEp); recorderEp.record(); Assert.assertTrue("Not received media (timeout waiting playing event)", getPage(BROWSER1).waitForEvent("playing")); long webrtcRedConnectionTime = System.currentTimeMillis() - startWebrtc; Thread.sleep(TimeUnit.SECONDS.toMillis(PLAYTIME) / N_PLAYER); startWebrtc = System.currentTimeMillis(); playerEp.play(); playerEp.connect(recorderEp); long playerEpConnectionTime = System.currentTimeMillis() - startWebrtc; Thread.sleep(TimeUnit.SECONDS.toMillis(PLAYTIME) / N_PLAYER); webRtcEpRed.connect(recorderEp); Thread.sleep(TimeUnit.SECONDS.toMillis(PLAYTIME) / N_PLAYER); // Release Media Pipeline #1 saveGstreamerDot(mp); final CountDownLatch recorderLatch = new CountDownLatch(1); recorderEp.stopAndWait(new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { recorderLatch.countDown(); } @Override public void onError(Throwable cause) throws Exception { recorderLatch.countDown(); } }); Assert.assertTrue("Not stop properly", recorderLatch.await(getPage(BROWSER1).getTimeout(), TimeUnit.SECONDS)); mp.release(); Assert.assertTrue(msgError, errorPipelinelatch.getCount() == 1); final long playtime = PLAYTIME + TimeUnit.MILLISECONDS.toSeconds((2 * webrtcRedConnectionTime) + playerEpConnectionTime); checkRecordingFile(recordingFile, BROWSER3, EXPECTED_COLORS, playtime, expectedVideoCodec, expectedAudioCodec); success = true; }
Example 15
Source File: RecorderPlayerDisconnectTest.java From kurento-java with Apache License 2.0 | 4 votes |
public void doTest(MediaProfileSpecType mediaProfileSpecType, String expectedVideoCodec, String expectedAudioCodec, String extension) throws Exception { final CountDownLatch recorderLatch = new CountDownLatch(1); // Media Pipeline #1 MediaPipeline mp = kurentoClient.createMediaPipeline(); PlayerEndpoint playerGreen = new PlayerEndpoint.Builder(mp, getPlayerUrl("/video/10sec/green.webm")).build(); String recordingFile = getRecordUrl(extension); RecorderEndpoint recorderEp = new RecorderEndpoint.Builder(mp, recordingFile) .withMediaProfile(mediaProfileSpecType).build(); playerGreen.play(); recorderEp.record(); for (int i = 0; i < NUM_SWAPS; i++) { if (i % 2 == 0) { playerGreen.connect(recorderEp); } else { playerGreen.disconnect(recorderEp); } Thread.sleep(TimeUnit.SECONDS.toMillis(PLAYTIME) / NUM_SWAPS); } // Release Media Pipeline #1 saveGstreamerDot(mp); recorderEp.stopAndWait(new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { recorderLatch.countDown(); } @Override public void onError(Throwable cause) throws Exception { recorderLatch.countDown(); } }); Assert.assertTrue("Not stop properly", recorderLatch.await(getPage().getTimeout(), TimeUnit.SECONDS)); mp.release(); // Wait until file exists waitForFileExists(recordingFile); // Reloading browser getPage().reload(); // Media Pipeline #2 MediaPipeline mp2 = kurentoClient.createMediaPipeline(); PlayerEndpoint playerEp2 = new PlayerEndpoint.Builder(mp2, recordingFile).build(); WebRtcEndpoint webRtcEp2 = new WebRtcEndpoint.Builder(mp2).build(); playerEp2.connect(webRtcEp2); // Playing the recording getPage().subscribeEvents("playing"); getPage().initWebRtc(webRtcEp2, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.RCV_ONLY); final CountDownLatch eosLatch = new CountDownLatch(1); playerEp2.addEndOfStreamListener(new EventListener<EndOfStreamEvent>() { @Override public void onEvent(EndOfStreamEvent event) { eosLatch.countDown(); } }); playerEp2.play(); // Assertions in recording final String messageAppend = "[played file with media pipeline]"; final int playtime = PLAYTIME; Assert.assertTrue( "Not received media in the recording (timeout waiting playing event) " + messageAppend, getPage().waitForEvent("playing")); for (Color color : EXPECTED_COLORS) { Assert.assertTrue("The color of the recorded video should be " + color + " " + messageAppend, getPage().similarColor(color)); } Assert.assertTrue("Not received EOS event in player", eosLatch.await(getPage().getTimeout(), TimeUnit.SECONDS)); double currentTime = getPage().getCurrentTime(); Assert.assertTrue("Error in play time in the recorded video (expected: " + playtime + " sec, real: " + currentTime + " sec) " + messageAppend, getPage().compare(playtime, currentTime)); AssertMedia.assertCodecs(recordingFile, expectedVideoCodec, expectedAudioCodec); AssertMedia.assertDuration(recordingFile, TimeUnit.SECONDS.toMillis(playtime), TimeUnit.SECONDS.toMillis(getPage().getThresholdTime())); // Release Media Pipeline #2 mp2.release(); success = true; }
Example 16
Source File: RecorderSwitchWebRtcWebRtcPlayerWithPassThroughTest.java From kurento-java with Apache License 2.0 | 4 votes |
public void doTest(MediaProfileSpecType mediaProfileSpecType, String expectedVideoCodec, String expectedAudioCodec, String extension) throws Exception { // Media Pipeline #1 MediaPipeline mp = kurentoClient.createMediaPipeline(); final CountDownLatch errorPipelinelatch = new CountDownLatch(1); mp.addErrorListener(new EventListener<ErrorEvent>() { @Override public void onEvent(ErrorEvent event) { msgError = "Description:" + event.getDescription() + "; Error code:" + event.getType(); errorPipelinelatch.countDown(); } }); WebRtcEndpoint webRtcEpRed = new WebRtcEndpoint.Builder(mp).build(); WebRtcEndpoint webRtcEpGreen = new WebRtcEndpoint.Builder(mp).build(); String recordingFile = getRecordUrl(extension); RecorderEndpoint recorderEp = new RecorderEndpoint.Builder(mp, recordingFile) .withMediaProfile(mediaProfileSpecType).build(); PassThrough passThrough = new PassThrough.Builder(mp).build(); passThrough.connect(recorderEp); // Test execution getPage(BROWSER1).subscribeLocalEvents("playing"); long startWebrtc = System.currentTimeMillis(); getPage(BROWSER1).initWebRtc(webRtcEpRed, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY); webRtcEpRed.connect(passThrough); recorderEp.record(); Assert.assertTrue("Not received media (timeout waiting playing event)", getPage(BROWSER1).waitForEvent("playing")); long webrtcRedConnectionTime = System.currentTimeMillis() - startWebrtc; Thread.sleep(TimeUnit.SECONDS.toMillis(PLAYTIME) / N_PLAYER); getPage(BROWSER2).subscribeLocalEvents("playing"); startWebrtc = System.currentTimeMillis(); getPage(BROWSER2).initWebRtc(webRtcEpGreen, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY); // green webRtcEpGreen.connect(passThrough); Assert.assertTrue("Not received media (timeout waiting playing event)", getPage(BROWSER2).waitForEvent("playing")); long webrtcGreenConnectionTime = System.currentTimeMillis() - startWebrtc; Thread.sleep(TimeUnit.SECONDS.toMillis(PLAYTIME) / N_PLAYER); webRtcEpRed.connect(passThrough); startWebrtc = System.currentTimeMillis(); Thread.sleep(TimeUnit.SECONDS.toMillis(PLAYTIME) / N_PLAYER); // Release Media Pipeline #1 saveGstreamerDot(mp); final CountDownLatch recorderLatch = new CountDownLatch(1); recorderEp.stopAndWait(new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { recorderLatch.countDown(); } @Override public void onError(Throwable cause) throws Exception { recorderLatch.countDown(); } }); Assert.assertTrue("Not stop properly", recorderLatch.await(getPage(BROWSER2).getTimeout(), TimeUnit.SECONDS)); mp.release(); Assert.assertTrue(msgError, errorPipelinelatch.getCount() == 1); final long playtime = PLAYTIME + TimeUnit.MILLISECONDS .toSeconds((2 * webrtcRedConnectionTime) + webrtcGreenConnectionTime); checkRecordingFile(recordingFile, BROWSER3, EXPECTED_COLORS, playtime, expectedVideoCodec, expectedAudioCodec); success = true; }
Example 17
Source File: RecorderSwitchWebRtcWebRtcPlayerWithPassThroughTest.java From kurento-java with Apache License 2.0 | 4 votes |
public void doTestWithPlayer(MediaProfileSpecType mediaProfileSpecType, String expectedVideoCodec, String expectedAudioCodec, String extension, String mediaUrlPlayer) throws Exception { // Media Pipeline #1 getPage(BROWSER2).close(); MediaPipeline mp = kurentoClient.createMediaPipeline(); final CountDownLatch errorPipelinelatch = new CountDownLatch(1); mp.addErrorListener(new EventListener<ErrorEvent>() { @Override public void onEvent(ErrorEvent event) { msgError = "Description:" + event.getDescription() + "; Error code:" + event.getType(); errorPipelinelatch.countDown(); } }); WebRtcEndpoint webRtcEpRed = new WebRtcEndpoint.Builder(mp).build(); PlayerEndpoint playerEp = new PlayerEndpoint.Builder(mp, mediaUrlPlayer).build(); String recordingFile = getRecordUrl(extension); RecorderEndpoint recorderEp = new RecorderEndpoint.Builder(mp, recordingFile) .withMediaProfile(mediaProfileSpecType).build(); PassThrough passThrough = new PassThrough.Builder(mp).build(); passThrough.connect(recorderEp); // Test execution getPage(BROWSER1).subscribeLocalEvents("playing"); long startWebrtc = System.currentTimeMillis(); getPage(BROWSER1).initWebRtc(webRtcEpRed, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY); webRtcEpRed.connect(passThrough); recorderEp.record(); Assert.assertTrue("Not received media (timeout waiting playing event)", getPage(BROWSER1).waitForEvent("playing")); long webrtcRedConnectionTime = System.currentTimeMillis() - startWebrtc; Thread.sleep(TimeUnit.SECONDS.toMillis(PLAYTIME) / N_PLAYER); startWebrtc = System.currentTimeMillis(); playerEp.play(); playerEp.connect(passThrough); long playerEpConnectionTime = System.currentTimeMillis() - startWebrtc; Thread.sleep(TimeUnit.SECONDS.toMillis(PLAYTIME) / N_PLAYER); webRtcEpRed.connect(passThrough); Thread.sleep(TimeUnit.SECONDS.toMillis(PLAYTIME) / N_PLAYER); // Release Media Pipeline #1 saveGstreamerDot(mp); final CountDownLatch recorderLatch = new CountDownLatch(1); recorderEp.stopAndWait(new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { recorderLatch.countDown(); } @Override public void onError(Throwable cause) throws Exception { recorderLatch.countDown(); } }); Assert.assertTrue("Not stop properly", recorderLatch.await(getPage(BROWSER1).getTimeout(), TimeUnit.SECONDS)); mp.release(); Assert.assertTrue(msgError, errorPipelinelatch.getCount() == 1); final long playtime = PLAYTIME + TimeUnit.MILLISECONDS.toSeconds((2 * webrtcRedConnectionTime) + playerEpConnectionTime); checkRecordingFile(recordingFile, BROWSER3, EXPECTED_COLORS, playtime, expectedVideoCodec, expectedAudioCodec); success = true; }
Example 18
Source File: RecorderSwitchPlayerTest.java From kurento-java with Apache License 2.0 | 4 votes |
public void doTest(MediaProfileSpecType mediaProfileSpecType, String expectedVideoCodec, String expectedAudioCodec, String extension, String[] mediaUrls, Color[] expectedColors) throws Exception { // Media Pipeline #1 MediaPipeline mp = kurentoClient.createMediaPipeline(); final CountDownLatch errorPipelinelatch = new CountDownLatch(1); mp.addErrorListener(new EventListener<ErrorEvent>() { @Override public void onEvent(ErrorEvent event) { msgError = "Description:" + event.getDescription() + "; Error code:" + event.getType(); errorPipelinelatch.countDown(); } }); int numPlayers = mediaUrls.length; PlayerEndpoint[] players = new PlayerEndpoint[numPlayers]; for (int i = 0; i < numPlayers; i++) { players[i] = new PlayerEndpoint.Builder(mp, mediaUrls[i]).build(); } WebRtcEndpoint webRtcEp = new WebRtcEndpoint.Builder(mp).build(); final CountDownLatch recorderLatch = new CountDownLatch(1); String recordingFile = getRecordUrl(extension); RecorderEndpoint recorderEp = new RecorderEndpoint.Builder(mp, recordingFile) .withMediaProfile(mediaProfileSpecType).build(); // Test execution getPage().subscribeEvents("playing"); getPage().initWebRtc(webRtcEp, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.RCV_ONLY); boolean startRecord = false; for (int i = 0; i < numPlayers; i++) { players[i].connect(webRtcEp); players[i].connect(recorderEp); players[i].play(); if (!startRecord) { Assert.assertTrue("Not received media (timeout waiting playing event)", getPage().waitForEvent("playing")); recorderEp.record(); startRecord = true; } waitSeconds(PLAYTIME / numPlayers); } // Release Media Pipeline #1 saveGstreamerDot(mp); recorderEp.stopAndWait(new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { recorderLatch.countDown(); } @Override public void onError(Throwable cause) throws Exception { recorderLatch.countDown(); } }); Assert.assertTrue("Not stop properly", recorderLatch.await(getPage().getTimeout(), TimeUnit.SECONDS)); mp.release(); Assert.assertTrue(msgError, errorPipelinelatch.getCount() == 1); // Reloading browser getPage().reload(); checkRecordingFile(recordingFile, "browser", expectedColors, PLAYTIME, expectedVideoCodec, expectedAudioCodec); success = true; }
Example 19
Source File: RecorderNonExistingDirectoryTest.java From kurento-java with Apache License 2.0 | 4 votes |
public void doTest(MediaProfileSpecType mediaProfileSpecType, String expectedVideoCodec, String expectedAudioCodec, String extension) throws Exception { final CountDownLatch recorderLatch = new CountDownLatch(1); MediaPipeline mp = kurentoClient.createMediaPipeline(); WebRtcEndpoint webRtcEp = new WebRtcEndpoint.Builder(mp).build(); String recordingFile = getRecordUrl(extension); recordingFile = recordingFile.replace(getSimpleTestName(), new Date().getTime() + File.separator + getSimpleTestName()); log.debug("The path non existing is {} ", recordingFile); RecorderEndpoint recorderEp = new RecorderEndpoint.Builder(mp, recordingFile) .withMediaProfile(mediaProfileSpecType).build(); webRtcEp.connect(webRtcEp); webRtcEp.connect(recorderEp); getPage().subscribeEvents("playing"); getPage().initWebRtc(webRtcEp, AUDIO_AND_VIDEO, WebRtcMode.SEND_RCV); recorderEp.record(); // Wait until event playing in the remote stream Assert.assertTrue("Not received media (timeout waiting playing event)", getPage().waitForEvent("playing")); Thread.sleep(SECONDS.toMillis(PLAYTIME)); recorderEp.stopAndWait(new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { recorderLatch.countDown(); } @Override public void onError(Throwable cause) throws Exception { recorderLatch.countDown(); } }); Assert.assertTrue("Not stop properly", recorderLatch.await(getPage().getTimeout(), TimeUnit.SECONDS)); // Wait until file exists waitForFileExists(recordingFile); AssertMedia.assertCodecs(recordingFile, expectedVideoCodec, expectedAudioCodec); mp.release(); }
Example 20
Source File: RecorderSwitchWebrtcTest.java From kurento-java with Apache License 2.0 | 4 votes |
public void doTest(MediaProfileSpecType mediaProfileSpecType, String expectedVideoCodec, String expectedAudioCodec, String extension) throws Exception { // Media Pipeline #1 MediaPipeline mp = kurentoClient.createMediaPipeline(); WebRtcEndpoint webRtcEpRed = new WebRtcEndpoint.Builder(mp).build(); WebRtcEndpoint webRtcEpGreen = new WebRtcEndpoint.Builder(mp).build(); WebRtcEndpoint webRtcEpBlue = new WebRtcEndpoint.Builder(mp).build(); String recordingFile = getRecordUrl(extension); RecorderEndpoint recorderEp = new RecorderEndpoint.Builder(mp, recordingFile) .withMediaProfile(mediaProfileSpecType).build(); // Test execution getPage(BROWSER1).subscribeLocalEvents("playing"); long startWebrtc = System.currentTimeMillis(); getPage(BROWSER1).initWebRtc(webRtcEpRed, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY); getPage(BROWSER2).subscribeLocalEvents("playing"); getPage(BROWSER2).initWebRtc(webRtcEpGreen, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY); getPage(BROWSER3).subscribeLocalEvents("playing"); getPage(BROWSER3).initWebRtc(webRtcEpBlue, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY); webRtcEpRed.connect(recorderEp); recorderEp.record(); Assert.assertTrue("Not received media (timeout waiting playing event)", getPage(BROWSER1).waitForEvent("playing")); long webrtcRedConnectionTime = System.currentTimeMillis() - startWebrtc; Thread.sleep(TimeUnit.SECONDS.toMillis(PLAYTIME) / N_PLAYER); startWebrtc = System.currentTimeMillis(); // green webRtcEpGreen.connect(recorderEp); Assert.assertTrue("Not received media (timeout waiting playing event)", getPage(BROWSER2).waitForEvent("playing")); long webrtcGreenConnectionTime = System.currentTimeMillis() - startWebrtc; Thread.sleep(TimeUnit.SECONDS.toMillis(PLAYTIME) / N_PLAYER); startWebrtc = System.currentTimeMillis(); // blue webRtcEpBlue.connect(recorderEp); Assert.assertTrue("Not received media (timeout waiting playing event)", getPage(BROWSER3).waitForEvent("playing")); long webrtcBlueConnectionTime = System.currentTimeMillis() - startWebrtc; Thread.sleep(TimeUnit.SECONDS.toMillis(PLAYTIME) / N_PLAYER); // Release Media Pipeline #1 saveGstreamerDot(mp); final CountDownLatch recorderLatch = new CountDownLatch(1); recorderEp.stopAndWait(new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { recorderLatch.countDown(); } @Override public void onError(Throwable cause) throws Exception { recorderLatch.countDown(); } }); Assert.assertTrue("Not stop properly", recorderLatch.await(getPage(BROWSER3).getTimeout(), TimeUnit.SECONDS)); mp.release(); // Reloading browser getPage(BROWSER3).close(); long playtime = PLAYTIME + TimeUnit.MILLISECONDS .toSeconds(webrtcRedConnectionTime + webrtcGreenConnectionTime + webrtcBlueConnectionTime); checkRecordingFile(recordingFile, BROWSER4, EXPECTED_COLORS, playtime, expectedVideoCodec, expectedAudioCodec); success = true; }