org.kurento.client.RecorderEndpoint Java Examples
The following examples show how to use
org.kurento.client.RecorderEndpoint.
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: SingleStreamRecordingService.java From openvidu with Apache License 2.0 | 6 votes |
private void connectAccordingToProfile(PublisherEndpoint publisherEndpoint, RecorderEndpoint recorder, MediaProfileSpecType profile) { switch (profile) { case WEBM: publisherEndpoint.connect(recorder, MediaType.AUDIO); publisherEndpoint.connect(recorder, MediaType.VIDEO); break; case WEBM_AUDIO_ONLY: publisherEndpoint.connect(recorder, MediaType.AUDIO); break; case WEBM_VIDEO_ONLY: publisherEndpoint.connect(recorder, MediaType.VIDEO); break; default: throw new UnsupportedOperationException("Unsupported profile when single stream recording: " + profile); } }
Example #2
Source File: CallMediaPipeline.java From kurento-tutorial-java with Apache License 2.0 | 6 votes |
public CallMediaPipeline(KurentoClient kurento, String from, String to) { // Media pipeline pipeline = kurento.createMediaPipeline(); // Media Elements (WebRtcEndpoint, RecorderEndpoint) webRtcCaller = new WebRtcEndpoint.Builder(pipeline).build(); webRtcCallee = new WebRtcEndpoint.Builder(pipeline).build(); recorderCaller = new RecorderEndpoint.Builder(pipeline, RECORDING_PATH + from + RECORDING_EXT) .build(); recorderCallee = new RecorderEndpoint.Builder(pipeline, RECORDING_PATH + to + RECORDING_EXT) .build(); // Connections webRtcCaller.connect(webRtcCallee); webRtcCaller.connect(recorderCaller); webRtcCallee.connect(webRtcCaller); webRtcCallee.connect(recorderCallee); }
Example #3
Source File: HelloWorldRecHandler.java From kurento-tutorial-java with Apache License 2.0 | 6 votes |
private void connectAccordingToProfile(WebRtcEndpoint webRtcEndpoint, RecorderEndpoint recorder, MediaProfileSpecType profile) { switch (profile) { case WEBM: webRtcEndpoint.connect(recorder, MediaType.AUDIO); webRtcEndpoint.connect(recorder, MediaType.VIDEO); break; case WEBM_AUDIO_ONLY: webRtcEndpoint.connect(recorder, MediaType.AUDIO); break; case WEBM_VIDEO_ONLY: webRtcEndpoint.connect(recorder, MediaType.VIDEO); break; default: throw new UnsupportedOperationException("Unsupported profile for this tutorial: " + profile); } }
Example #4
Source File: RecorderEndpointWrapper.java From openvidu with Apache License 2.0 | 5 votes |
public RecorderEndpointWrapper(RecorderEndpoint recorder, String connectionId, String recordingId, String streamId, String clientData, String serverData, boolean hasAudio, boolean hasVideo, String typeOfVideo) { this.recorder = recorder; this.connectionId = connectionId; this.recordingId = recordingId; this.streamId = streamId; this.clientData = clientData; this.serverData = serverData; this.hasAudio = hasAudio; this.hasVideo = hasVideo; this.typeOfVideo = typeOfVideo; }
Example #5
Source File: CallMediaPipeline.java From kurento-tutorial-java with Apache License 2.0 | 5 votes |
public CallMediaPipeline(KurentoClient kurento, String from, String to) { // Media pipeline pipeline = kurento.createMediaPipeline(); // Media Elements (WebRtcEndpoint, RecorderEndpoint, FaceOverlayFilter) webRtcCaller = new WebRtcEndpoint.Builder(pipeline).build(); webRtcCallee = new WebRtcEndpoint.Builder(pipeline).build(); recorderCaller = new RecorderEndpoint.Builder(pipeline, RECORDING_PATH + from + RECORDING_EXT) .build(); recorderCallee = new RecorderEndpoint.Builder(pipeline, RECORDING_PATH + to + RECORDING_EXT) .build(); // String appServerUrl = System.getProperty("app.server.url", // One2OneCallAdvApp.DEFAULT_APP_SERVER_URL); String appServerUrl = "http://files.openvidu.io"; FaceOverlayFilter faceOverlayFilterCaller = new FaceOverlayFilter.Builder(pipeline).build(); faceOverlayFilterCaller.setOverlayedImage(appServerUrl + "/img/mario-wings.png", -0.35F, -1.2F, 1.6F, 1.6F); FaceOverlayFilter faceOverlayFilterCallee = new FaceOverlayFilter.Builder(pipeline).build(); faceOverlayFilterCallee.setOverlayedImage(appServerUrl + "/img/Hat.png", -0.2F, -1.35F, 1.5F, 1.5F); // Connections webRtcCaller.connect(faceOverlayFilterCaller); faceOverlayFilterCaller.connect(webRtcCallee); faceOverlayFilterCaller.connect(recorderCaller); webRtcCallee.connect(faceOverlayFilterCallee); faceOverlayFilterCallee.connect(webRtcCaller); faceOverlayFilterCallee.connect(recorderCallee); }
Example #6
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 #7
Source File: RepositoryRecorderTest.java From kurento-java with Apache License 2.0 | 5 votes |
private void launchBrowser(WebRtcEndpoint webRtcEp, PlayerEndpoint playerEp, RecorderEndpoint recorderEp) throws InterruptedException { 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 Assert.assertTrue("Not received media (timeout waiting playing event)", getPage().waitForEvent("playing")); Assert.assertTrue("The color of the video should be black", getPage().similarColor(Color.BLACK)); Assert.assertTrue("Not received EOS event in player", eosLatch.await(getPage().getTimeout(), TimeUnit.SECONDS)); double currentTime = getPage().getCurrentTime(); Assert.assertTrue( "Error in play time (expected: " + PLAYTIME + " sec, real: " + currentTime + " sec)", getPage().compare(PLAYTIME, currentTime)); }
Example #8
Source File: TestSetupFlowMocked.java From openmeetings with Apache License 2.0 | 5 votes |
@Test public void testMsgTestRecord1() throws Exception { doReturn(mock(MediaPipeline.class)).when(client).createMediaPipeline(any(Transaction.class)); WebRtcEndpoint.Builder builder = mock(WebRtcEndpoint.Builder.class); whenNew(WebRtcEndpoint.Builder.class).withArguments(any(MediaPipeline.class)).thenReturn(builder); doReturn(mock(WebRtcEndpoint.class)).when(builder).build(); RecorderEndpoint.Builder recBuilder = mock(RecorderEndpoint.Builder.class); whenNew(RecorderEndpoint.Builder.class).withArguments(any(MediaPipeline.class), anyString()).thenReturn(recBuilder); doReturn(recBuilder).when(recBuilder).stopOnEndOfStream(); doReturn(recBuilder).when(recBuilder).withMediaProfile(any(MediaProfileSpecType.class)); doReturn(mock(RecorderEndpoint.class)).when(recBuilder).build(); WsClient c = new WsClient("sessionId", 0); for (boolean audio : new boolean[] {true, false}) { for (boolean video : new boolean[] {true, false}) { JSONObject msg = new JSONObject(MSG_BASE.toString()) .put("id", "record") .put("sdpOffer", "") .put("audio", audio) .put("video", video); handler.onMessage(c, msg); } } JSONObject iceMsg = new JSONObject(MSG_BASE.toString()) .put("id", "iceCandidate") .put(PARAM_CANDIDATE, new JSONObject() .put(PARAM_CANDIDATE, "candidate") .put("sdpMid", "sdpMid") .put("sdpMLineIndex", 1)); handler.onMessage(c, iceMsg); PlayerEndpoint.Builder playBuilder = mock(PlayerEndpoint.Builder.class); whenNew(PlayerEndpoint.Builder.class).withArguments(any(MediaPipeline.class), anyString()).thenReturn(playBuilder); doReturn(mock(PlayerEndpoint.class)).when(playBuilder).build(); handler.onMessage(c, new JSONObject(MSG_BASE.toString()) .put("id", "play") .put("sdpOffer", "sdpOffer")); testProcessor.destroy(); }
Example #9
Source File: CompositeWrapper.java From openvidu with Apache License 2.0 | 5 votes |
public CompositeWrapper(KurentoSession session, String path) { this.session = session; this.composite = new Composite.Builder(session.getPipeline()).build(); this.recorderEndpoint = new RecorderEndpoint.Builder(composite.getMediaPipeline(), path) .withMediaProfile(MediaProfileSpecType.WEBM_AUDIO_ONLY).build(); this.compositeToRecorderHubPort = new HubPort.Builder(composite).build(); this.compositeToRecorderHubPort.connect(recorderEndpoint); }
Example #10
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 #11
Source File: RecorderEndpointWrapper.java From openvidu with Apache License 2.0 | 4 votes |
public RecorderEndpoint getRecorder() { return recorder; }
Example #12
Source File: KStream.java From openmeetings with Apache License 2.0 | 4 votes |
public RecorderEndpoint getRecorder() { return recorder; }
Example #13
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 #14
Source File: RecorderThreeWebRtcSimultaneous.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[NUM_BROWSERS]; final RecorderEndpoint[] recorder = new RecorderEndpoint[NUM_BROWSERS]; final String[] recordingFile = new String[NUM_BROWSERS]; ExecutorService executor = Executors.newFixedThreadPool(NUM_BROWSERS); final CountDownLatch latch = new CountDownLatch(NUM_BROWSERS); final MediaPipeline pipeline = mp; for (int j = 0; j < NUM_BROWSERS; j++) { final int i = j; executor.execute(new Runnable() { @Override public void run() { try { // N viewer webRtcSender[i] = new WebRtcEndpoint.Builder(pipeline).build(); // N recorders recordingFile[i] = getRecordUrl("-receiver" + i + extension); recorder[i] = new RecorderEndpoint.Builder(pipeline, recordingFile[i]) .withMediaProfile(mediaProfileSpecType).build(); // WebRTC receiver negotiation getPage(i).subscribeLocalEvents("playing"); getPage(i).initWebRtc(webRtcSender[i], WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY); Assert.assertTrue("Not received media in sender" + i, getPage(i).waitForEvent("playing")); webRtcSender[i].connect(recorder[i]); // Start record recorder[i].record(); // Wait play time Thread.sleep(RECORD_MS); // Stop record recorder[i].stopAndWait(); // Guard time to stop recording Thread.sleep(4000); getPage(i).reload(); } catch (Throwable e) { log.error("Exception in receiver " + i, e); } finally { latch.countDown(); } } }); } // Wait to finish all recorders latch.await(); // Assessment for (int j = 0; j < NUM_BROWSERS; j++) { AssertMedia.assertCodecs(recordingFile[j], expectedVideoCodec, expectedAudioCodec); AssertMedia.assertDuration(recordingFile[j], RECORD_MS, THRESHOLD_MS); } // Release Media Pipeline if (mp != null) { mp.release(); } }
Example #15
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 #16
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 #17
Source File: RecorderWebRtcOneToManyTest.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(); final WebRtcEndpoint[] webRtcReceiver = new WebRtcEndpoint[numViewers]; final RecorderEndpoint[] recorder = new RecorderEndpoint[numViewers]; final String[] recordingFile = new String[numViewers]; // WebRTC sender negotiation getPage(0).subscribeLocalEvents("playing"); getPage(0).initWebRtc(webRtcSender, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY); Assert.assertTrue("Not received media in sender", getPage(0).waitForEvent("playing")); ExecutorService executor = Executors.newFixedThreadPool(numViewers); final CountDownLatch latch = new CountDownLatch(numViewers); final MediaPipeline pipeline = mp; for (int j = 1; j <= numViewers; j++) { final int i = j; executor.execute(new Runnable() { @Override public void run() { // N Receiver WebRTC and Recorder webRtcReceiver[i - 1] = new WebRtcEndpoint.Builder(pipeline).build(); recordingFile[i - 1] = getRecordUrl("-receiver" + i + extension); recorder[i - 1] = new RecorderEndpoint.Builder(pipeline, recordingFile[i - 1]) .withMediaProfile(mediaProfileSpecType).build(); webRtcSender.connect(webRtcReceiver[i - 1]); webRtcSender.connect(recorder[i - 1]); try { // WebRTC receiver negotiation getPage(i).subscribeEvents("playing"); getPage(i).initWebRtc(webRtcReceiver[i - 1], WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.RCV_ONLY); Assert.assertTrue("Not received media in receiver " + i, getPage(i).waitForEvent("playing")); // Start record recorder[i - 1].record(); // Wait play time Thread.sleep(PLAYTIME_MS); // Stop record recorder[i - 1].stopAndWait(); // Guard time to stop recording Thread.sleep(4000); } catch (InterruptedException e) { log.error("InterruptedException in receiver " + i, e); } latch.countDown(); } }); } // Wait to finish all receivers latch.await(getPage(0).getTimeout(), TimeUnit.SECONDS); // Assessments for (int j = 1; j <= numViewers; j++) { AssertMedia.assertCodecs(recordingFile[j - 1], expectedVideoCodec, expectedAudioCodec); AssertMedia.assertDuration(recordingFile[j - 1], PLAYTIME_MS, THRESHOLD_MS); } // Release Media Pipeline if (mp != null) { mp.release(); } }
Example #18
Source File: RecorderPlayerOneToManyTest.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 PlayerEndpoint playerEp = new PlayerEndpoint.Builder(mp, getPlayerUrl("/video/60sec/ball.webm")).build(); final RecorderEndpoint[] recorder = new RecorderEndpoint[numViewers]; final String[] recordingFile = new String[numViewers]; playerEp.play(); ExecutorService executor = Executors.newFixedThreadPool(numViewers); final CountDownLatch latch = new CountDownLatch(numViewers); final MediaPipeline pipeline = mp; for (int j = 0; j < numViewers; j++) { final int i = j; executor.execute(new Runnable() { @Override public void run() { try { // N recorders recordingFile[i] = getRecordUrl("-recorder" + i + extension); recorder[i] = new RecorderEndpoint.Builder(pipeline, recordingFile[i]) .withMediaProfile(mediaProfileSpecType).build(); playerEp.connect(recorder[i]); // Start record recorder[i].record(); // Wait play time Thread.sleep(PLAYTIME_MS); // Stop record recorder[i].stopAndWait(); // Guard time to stop recording Thread.sleep(4000); } catch (Throwable t) { log.error("Exception in receiver " + i, t); } latch.countDown(); } }); } // Wait to finish all recordings latch.await(); // Assessments for (int j = 0; j < numViewers; j++) { AssertMedia.assertCodecs(recordingFile[j], expectedVideoCodec, expectedAudioCodec); AssertMedia.assertDuration(recordingFile[j], PLAYTIME_MS, THRESHOLD_MS); } // Release Media Pipeline if (mp != null) { mp.release(); } }
Example #19
Source File: RecorderPlayerSwitchSequentialTest.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(); PlayerEndpoint playerEp1 = new PlayerEndpoint.Builder(mp, getPlayerUrl("/video/60sec/ball.webm")).build(); PlayerEndpoint playerEp2 = new PlayerEndpoint.Builder(mp, getPlayerUrl("/video/60sec/smpte.webm")).build(); String recordingFile = getRecordUrl(extension); RecorderEndpoint recorderEp = new RecorderEndpoint.Builder(mp, recordingFile) .withMediaProfile(mediaProfileSpecType).build(); // Start play and record playerEp1.play(); playerEp2.play(); recorderEp.record(); // Switch players for (int i = 0; i < SWITCH_TIMES; i++) { if (i % 2 == 0) { playerEp1.connect(recorderEp); } else { playerEp2.connect(recorderEp); } Thread.sleep(SWITCH_RATE_MS); } // Stop play and record playerEp1.stop(); playerEp2.stop(); recorderEp.stop(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(TIMEOUT, TimeUnit.SECONDS)); // Assessments 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 #20
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 #21
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 #22
Source File: RecorderEndpointTest.java From kurento-java with Apache License 2.0 | 4 votes |
@Before public void setupMediaElements() { recorder = new RecorderEndpoint.Builder(pipeline, URL_SMALL).build(); }
Example #23
Source File: AbstractStream.java From openmeetings with Apache License 2.0 | 4 votes |
public RecorderEndpoint createRecorderEndpoint(MediaPipeline pipeline, String path, MediaProfileSpecType profile) { return new RecorderEndpoint.Builder(pipeline, path) .stopOnEndOfStream() .withMediaProfile(profile).build(); }
Example #24
Source File: UserSession.java From kurento-tutorial-java with Apache License 2.0 | 4 votes |
public void setRecorderEndpoint(RecorderEndpoint recorderEndpoint) { this.recorderEndpoint = recorderEndpoint; }
Example #25
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 #26
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 #27
Source File: RecorderPlayerTest.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(); PlayerEndpoint playerEp = new PlayerEndpoint.Builder(mp, getPlayerUrl("/video/10sec/green.webm")).build(); WebRtcEndpoint webRtcEp1 = new WebRtcEndpoint.Builder(mp).build(); String recordingFile = getRecordUrl(extension); RecorderEndpoint recorderEp = new RecorderEndpoint.Builder(mp, recordingFile) .withMediaProfile(mediaProfileSpecType).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(mp, webRtcEp1, playerEp, recorderEp, expectedVideoCodec, expectedAudioCodec, recordingFile, EXPECTED_COLOR, 0, 0, PLAYTIME); // Wait for EOS Assert.assertTrue("No EOS event", eosLatch.await(getPage().getTimeout(), TimeUnit.SECONDS)); // Release Media Pipeline #1 mp.release(); // 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 launchBrowser(null, webRtcEp2, playerEp2, null, expectedVideoCodec, expectedAudioCodec, recordingFile, EXPECTED_COLOR, 0, 0, PLAYTIME); // Release Media Pipeline #2 mp2.release(); success = true; }
Example #28
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; }
Example #29
Source File: RecorderFaceOverlayTest.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(); PlayerEndpoint playerEp = new PlayerEndpoint.Builder(mp, getPlayerUrl("/video/filter/fiwarecut.mp4")).build(); WebRtcEndpoint webRtcEp1 = new WebRtcEndpoint.Builder(mp).build(); FaceOverlayFilter filter = new FaceOverlayFilter.Builder(mp).build(); filter.setOverlayedImage("http://" + getTestFilesHttpPath() + "/img/red-square.png", -0.2F, -1.2F, 1.6F, 1.6F); String recordingFile = getRecordUrl(extension); RecorderEndpoint recorderEp = new RecorderEndpoint.Builder(mp, recordingFile) .withMediaProfile(mediaProfileSpecType).build(); playerEp.connect(filter); filter.connect(webRtcEp1); filter.connect(recorderEp); // Test execution #1. Play and record getPage().setThresholdTime(THRESHOLD); launchBrowser(mp, webRtcEp1, playerEp, recorderEp, expectedVideoCodec, expectedAudioCodec, recordingFile, EXPECTED_COLOR, EXPECTED_COLOR_X, EXPECTED_COLOR_Y, PLAYTIME); // Release Media Pipeline #1 mp.release(); // 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 launchBrowser(mp, webRtcEp2, playerEp2, null, expectedVideoCodec, expectedAudioCodec, recordingFile, EXPECTED_COLOR, EXPECTED_COLOR_X, EXPECTED_COLOR_Y, PLAYTIME); // Release Media Pipeline #2 mp2.release(); success = true; }
Example #30
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(); }