org.kurento.client.MediaType Java Examples
The following examples show how to use
org.kurento.client.MediaType.
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: SubscriberEndpoint.java From kurento-room with Apache License 2.0 | 6 votes |
@Override public synchronized void mute(MutedMediaType muteType) { if (this.publisher == null) { throw new RoomException(Code.MEDIA_MUTE_ERROR_CODE, "Publisher endpoint not found"); } switch (muteType) { case ALL : this.publisher.disconnectFrom(this.getEndpoint()); break; case AUDIO : this.publisher.disconnectFrom(this.getEndpoint(), MediaType.AUDIO); break; case VIDEO : this.publisher.disconnectFrom(this.getEndpoint(), MediaType.VIDEO); break; } resolveCurrentMuteType(muteType); }
Example #2
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 #3
Source File: SdpBaseTest.java From kurento-java with Apache License 2.0 | 6 votes |
@Test public void testRtpEndpointSimulatingAndroidSdp() throws InterruptedException { PlayerEndpoint player = new PlayerEndpoint.Builder(pipeline, URL_BARCODES).build(); String requestSdp = "v=0\r\n" + "o=- 12345 12345 IN IP4 95.125.31.136\r\n" + "s=-\r\n" + "c=IN IP4 95.125.31.136\r\n" + "t=0 0\r\n" + "m=video 52126 RTP/AVP 96 97 98\r\n" + "a=rtpmap:96 H264/90000\r\n" + "a=rtpmap:97 MP4V-ES/90000\r\n" + "a=rtpmap:98 H263-1998/90000\r\n" + "a=recvonly\r\n" + "b=AS:384\r\n"; player.connect(sdp, MediaType.VIDEO); sdp.processOffer(requestSdp); player.play(); // just a little bit of time before destroying Thread.sleep(2000); }
Example #4
Source File: RtpEndpointAsyncTest.java From kurento-java with Apache License 2.0 | 6 votes |
@Test public void testRtpEndpointSimulatingAndroidSdp() throws InterruptedException { PlayerEndpoint player = new PlayerEndpoint.Builder(pipeline, URL_BARCODES).build(); RtpEndpoint rtpEndpoint = new RtpEndpoint.Builder(pipeline).build(); String requestSdp = "v=0\r\n" + "o=- 12345 12345 IN IP4 95.125.31.136\r\n" + "s=-\r\n" + "c=IN IP4 95.125.31.136\r\n" + "t=0 0\r\n" + "m=video 52126 RTP/AVP 96 97 98\r\n" + "a=rtpmap:96 H264/90000\r\n" + "a=rtpmap:97 MP4V-ES/90000\r\n" + "a=rtpmap:98 H263-1998/90000\r\n" + "a=recvonly\r\n" + "b=AS:384\r\n"; rtpEndpoint.processOffer(requestSdp); player.connect(rtpEndpoint, MediaType.VIDEO); player.play(); // just a little bit of time before destroying Thread.sleep(2000); }
Example #5
Source File: AgnosticBenchmarkTest.java From kurento-java with Apache License 2.0 | 6 votes |
private double getInputLatency(MediaElement mediaElement, Multimap<String, Object> statTimeMap, String mediaElementName) { long now = System.currentTimeMillis(); Map<String, Stats> filterStats = mediaElement.getStats(MediaType.VIDEO); long time = System.currentTimeMillis() - now; statTimeMap.put(mediaElementName + "MiliSec", time); double inputLatency = 0; for (Stats s : filterStats.values()) { if (s instanceof ElementStats) { List<MediaLatencyStat> inputLatencyList = ((ElementStats) s).getInputLatency(); if (!inputLatencyList.isEmpty()) { inputLatency = inputLatencyList.get(0).getAvg(); } } } return inputLatency; }
Example #6
Source File: PublisherEndpoint.java From kurento-room with Apache License 2.0 | 6 votes |
/** * Same as {@link #internalSinkDisconnect(MediaElement, MediaElement)}, but can specify the type * of the media that will be disconnected. * * @param source * @param sink * @param type if null, {@link #internalSinkConnect(MediaElement, MediaElement)} will be used * instead * @see #internalSinkConnect(MediaElement, MediaElement) */ private void internalSinkDisconnect(final MediaElement source, final MediaElement sink, final MediaType type) { if (type == null) { internalSinkDisconnect(source, sink); } else { source.disconnect(sink, type, new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { log.debug("EP {}: {} media elements have been disconnected (source {} -> sink {})", getEndpointName(), type, source.getId(), sink.getId()); } @Override public void onError(Throwable cause) throws Exception { log.warn("EP {}: Failed to disconnect {} media elements (source {} -> sink {})", getEndpointName(), type, source.getId(), sink.getId(), cause); } }); } }
Example #7
Source File: PublisherEndpoint.java From kurento-room with Apache License 2.0 | 6 votes |
/** * Same as {@link #internalSinkConnect(MediaElement, MediaElement)}, but can specify the type of * the media that will be streamed. * * @param source * @param sink * @param type if null, {@link #internalSinkConnect(MediaElement, MediaElement)} will be used * instead * @see #internalSinkConnect(MediaElement, MediaElement) */ private void internalSinkConnect(final MediaElement source, final MediaElement sink, final MediaType type) { if (type == null) { internalSinkConnect(source, sink); } else { source.connect(sink, type, new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { log.debug("EP {}: {} media elements have been connected (source {} -> sink {})", getEndpointName(), type, source.getId(), sink.getId()); } @Override public void onError(Throwable cause) throws Exception { log.warn("EP {}: Failed to connect {} media elements (source {} -> sink {})", getEndpointName(), type, source.getId(), sink.getId(), cause); } }); } }
Example #8
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 #9
Source File: NotificationRoomManager.java From kurento-room with Apache License 2.0 | 6 votes |
/** * @param request instance of {@link ParticipantRequest} POJO * @see RoomManager#publishMedia(String, boolean, String, MediaElement, MediaType, boolean, * * MediaElement...) */ public void publishMedia(ParticipantRequest request, boolean isOffer, String sdp, MediaElement loopbackAlternativeSrc, MediaType loopbackConnectionType, boolean doLoopback, MediaElement... mediaElements) { String pid = request.getParticipantId(); String userName = null; Set<UserParticipant> participants = null; String sdpAnswer = null; try { userName = internalManager.getParticipantName(pid); sdpAnswer = internalManager .publishMedia(request.getParticipantId(), isOffer, sdp, loopbackAlternativeSrc, loopbackConnectionType, doLoopback, mediaElements); participants = internalManager.getParticipants(internalManager.getRoomName(pid)); } catch (RoomException e) { log.warn("PARTICIPANT {}: Error publishing media", userName, e); notificationRoomHandler.onPublishMedia(request, null, null, null, e); } if (sdpAnswer != null) { notificationRoomHandler.onPublishMedia(request, userName, sdpAnswer, participants, null); } }
Example #10
Source File: PublisherEndpoint.java From openvidu with Apache License 2.0 | 6 votes |
public synchronized void mute(TrackType muteType) { MediaElement sink = passThru; if (!elements.isEmpty()) { String sinkId = elementIds.peekLast(); if (!elements.containsKey(sinkId)) { throw new OpenViduException(Code.MEDIA_ENDPOINT_ERROR_CODE, "This endpoint (" + getEndpointName() + ") has no media element with id " + sinkId + " (should've been connected to the internal ep)"); } sink = elements.get(sinkId); } else { log.debug("Will mute connection of WebRTC and PassThrough (no other elems)"); } switch (muteType) { case ALL: internalSinkDisconnect(this.getEndpoint(), sink); break; case AUDIO: internalSinkDisconnect(this.getEndpoint(), sink, MediaType.AUDIO); break; case VIDEO: internalSinkDisconnect(this.getEndpoint(), sink, MediaType.VIDEO); break; } }
Example #11
Source File: PublisherEndpoint.java From openvidu with Apache License 2.0 | 6 votes |
public synchronized void unmute(TrackType muteType) { MediaElement sink = passThru; if (!elements.isEmpty()) { String sinkId = elementIds.peekLast(); if (!elements.containsKey(sinkId)) { throw new OpenViduException(Code.MEDIA_ENDPOINT_ERROR_CODE, "This endpoint (" + getEndpointName() + ") has no media element with id " + sinkId + " (should've been connected to the internal ep)"); } sink = elements.get(sinkId); } else { log.debug("Will unmute connection of WebRTC and PassThrough (no other elems)"); } switch (muteType) { case ALL: internalSinkConnect(this.getEndpoint(), sink); break; case AUDIO: internalSinkConnect(this.getEndpoint(), sink, MediaType.AUDIO); break; case VIDEO: internalSinkConnect(this.getEndpoint(), sink, MediaType.VIDEO); break; } }
Example #12
Source File: PublisherEndpoint.java From openvidu with Apache License 2.0 | 6 votes |
/** * Same as {@link #internalSinkConnect(MediaElement, MediaElement)}, but can * specify the type of the media that will be streamed. * * @param source * @param sink * @param type if null, * {@link #internalSinkConnect(MediaElement, MediaElement)} will * be used instead * @see #internalSinkConnect(MediaElement, MediaElement) */ private void internalSinkConnect(final MediaElement source, final MediaElement sink, final MediaType type) { if (type == null) { internalSinkConnect(source, sink); } else { source.connect(sink, type, new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { log.debug("EP {}: {} media elements have been connected (source {} -> sink {})", getEndpointName(), type, source.getId(), sink.getId()); } @Override public void onError(Throwable cause) throws Exception { log.warn("EP {}: Failed to connect {} media elements (source {} -> sink {})", getEndpointName(), type, source.getId(), sink.getId(), cause); } }); } }
Example #13
Source File: PublisherEndpoint.java From openvidu with Apache License 2.0 | 6 votes |
/** * Same as {@link #internalSinkDisconnect(MediaElement, MediaElement)}, but can * specify the type of the media that will be disconnected. * * @param source * @param sink * @param type if null, * {@link #internalSinkConnect(MediaElement, MediaElement)} will * be used instead * @see #internalSinkConnect(MediaElement, MediaElement) */ private void internalSinkDisconnect(final MediaElement source, final MediaElement sink, final MediaType type) { if (type == null) { internalSinkDisconnect(source, sink); } else { source.disconnect(sink, type, new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { log.debug("EP {}: {} media elements have been disconnected (source {} -> sink {})", getEndpointName(), type, source.getId(), sink.getId()); } @Override public void onError(Throwable cause) throws Exception { log.warn("EP {}: Failed to disconnect {} media elements (source {} -> sink {})", getEndpointName(), type, source.getId(), sink.getId(), cause); } }); } }
Example #14
Source File: PublisherEndpoint.java From kurento-room with Apache License 2.0 | 5 votes |
/** * Same as {@link #apply(MediaElement)}, can specify the media type that will be streamed through * the shaper element. * * @param shaper {@link MediaElement} that will be linked to the end of the chain (e.g. a filter) * @param type indicates which type of media will be connected to the shaper * ({@link MediaType}), if * null then the connection is mixed * @return the element's id * @throws RoomException if thrown, the media element was not added */ public synchronized String apply(MediaElement shaper, MediaType type) throws RoomException { String id = shaper.getId(); if (id == null) { throw new RoomException(Code.MEDIA_WEBRTC_ENDPOINT_ERROR_CODE, "Unable to connect media element with null id"); } if (elements.containsKey(id)) { throw new RoomException(Code.MEDIA_WEBRTC_ENDPOINT_ERROR_CODE, "This endpoint already has a media element with id " + id); } MediaElement first = null; if (!elementIds.isEmpty()) { first = elements.get(elementIds.getFirst()); } if (connected) { if (first != null) { internalSinkConnect(first, shaper, type); } else { internalSinkConnect(this.getEndpoint(), shaper, type); } internalSinkConnect(shaper, passThru, type); } elementIds.addFirst(id); elements.put(id, shaper); elementsErrorSubscriptions.put(id, registerElemErrListener(shaper)); return id; }
Example #15
Source File: PublisherEndpoint.java From openvidu with Apache License 2.0 | 5 votes |
public synchronized void connect(MediaElement sink, MediaType type) { if (!connected) { innerConnect(); } internalSinkConnect(passThru, sink, type); this.enableIpCameraIfNecessary(); }
Example #16
Source File: PublisherEndpoint.java From openvidu with Apache License 2.0 | 5 votes |
/** * Same as {@link #apply(MediaElement)}, can specify the media type that will be * streamed through the shaper element. * * @param shaper {@link MediaElement} that will be linked to the end of the * chain (e.g. a filter) * @param type indicates which type of media will be connected to the shaper * ({@link MediaType}), if null then the connection is mixed * @return the element's id * @throws OpenViduException if thrown, the media element was not added */ public synchronized String apply(GenericMediaElement shaper, MediaType type) throws OpenViduException { String id = shaper.getId(); if (id == null) { throw new OpenViduException(Code.MEDIA_WEBRTC_ENDPOINT_ERROR_CODE, "Unable to connect media element with null id"); } if (elements.containsKey(id)) { throw new OpenViduException(Code.MEDIA_WEBRTC_ENDPOINT_ERROR_CODE, "This endpoint already has a media element with id " + id); } MediaElement first = null; if (!elementIds.isEmpty()) { first = elements.get(elementIds.getFirst()); } if (connected) { if (first != null) { internalSinkConnect(first, shaper, type); } else { internalSinkConnect(this.getEndpoint(), shaper, type); } internalSinkConnect(shaper, passThru, type); } elementIds.addFirst(id); elements.put(id, shaper); this.filter = shaper; elementsErrorSubscriptions.put(id, registerElemErrListener(shaper)); return id; }
Example #17
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 #18
Source File: WebRtcClient.java From kurento-java with Apache License 2.0 | 5 votes |
private WebRtcEndpointStats getStats(WebRtcEndpoint webRtcEndpoint) { Map<String, Stats> stats = new HashMap<>(); MediaType[] types = { MediaType.VIDEO, MediaType.AUDIO, MediaType.DATA }; for (MediaType type : types) { Map<String, Stats> trackStats = webRtcEndpoint.getStats(type); for (Stats track : trackStats.values()) { stats.put(type.name().toLowerCase() + "_" + getRtcStatsType(track.getClass()), track); } } return new WebRtcEndpointStats(stats); }
Example #19
Source File: PublisherEndpoint.java From kurento-room with Apache License 2.0 | 5 votes |
private void connectAltLoopbackSrc(MediaElement loopbackAlternativeSrc, MediaType loopbackConnectionType) { if (!connected) { innerConnect(); } internalSinkConnect(loopbackAlternativeSrc, this.getEndpoint(), loopbackConnectionType); }
Example #20
Source File: PublisherEndpoint.java From kurento-room with Apache License 2.0 | 5 votes |
@Override public synchronized void mute(MutedMediaType muteType) { MediaElement sink = passThru; if (!elements.isEmpty()) { String sinkId = elementIds.peekLast(); if (!elements.containsKey(sinkId)) { throw new RoomException(Code.MEDIA_ENDPOINT_ERROR_CODE, "This endpoint (" + getEndpointName() + ") has no media element with id " + sinkId + " (should've been connected to the internal ep)"); } sink = elements.get(sinkId); } else { log.debug("Will mute connection of WebRTC and PassThrough (no other elems)"); } switch (muteType) { case ALL: internalSinkDisconnect(this.getEndpoint(), sink); break; case AUDIO: internalSinkDisconnect(this.getEndpoint(), sink, MediaType.AUDIO); break; case VIDEO: internalSinkDisconnect(this.getEndpoint(), sink, MediaType.VIDEO); break; } resolveCurrentMuteType(muteType); }
Example #21
Source File: KStream.java From openmeetings with Apache License 2.0 | 5 votes |
private WebRtcEndpoint getEndpointForUser(final StreamProcessor processor, String sid, String uid) { if (uid.equals(this.uid)) { log.debug("PARTICIPANT {}: configuring loopback", this.uid); return outgoingMedia; } log.debug("PARTICIPANT {}: receiving video from {}", uid, this.uid); WebRtcEndpoint listener = listeners.remove(uid); if (listener != null) { log.debug("PARTICIPANT {}: re-started video receiving, will drop previous endpoint", uid); listener.release(); } log.debug("PARTICIPANT {}: creating new endpoint for {}", uid, this.uid); listener = createEndpoint(processor, sid, uid); listeners.put(uid, listener); log.debug("PARTICIPANT {}: obtained endpoint for {}", uid, this.uid); Client cur = processor.getBySid(this.sid); if (cur == null) { log.warn("Client for endpoint dooesn't exists"); } else { StreamDesc sd = cur.getStream(this.uid); if (sd == null) { log.warn("Stream for endpoint dooesn't exists"); } else { if (sd.hasActivity(Activity.AUDIO)) { outgoingMedia.connect(listener, MediaType.AUDIO); } if (StreamType.SCREEN == streamType || sd.hasActivity(Activity.VIDEO)) { outgoingMedia.connect(listener, MediaType.VIDEO); } } } return listener; }
Example #22
Source File: PublisherEndpoint.java From kurento-room with Apache License 2.0 | 5 votes |
/** * Initializes this media endpoint for publishing media and processes the SDP offer or answer. If * the internal endpoint is an {@link WebRtcEndpoint}, it first registers an event listener for * the ICE candidates and instructs the endpoint to start gathering the candidates. If required, * it connects to itself (after applying the intermediate media elements and the * {@link PassThrough}) to allow loopback of the media stream. * * @param sdpType indicates the type of the sdpString (offer or answer) * @param sdpString offer or answer from the remote peer * @param doLoopback loopback flag * @param loopbackAlternativeSrc alternative loopback source * @param loopbackConnectionType how to connect the loopback source * @return the SDP response (the answer if processing an offer SDP, otherwise is the updated offer * generated previously by this endpoint) */ public synchronized String publish(SdpType sdpType, String sdpString, boolean doLoopback, MediaElement loopbackAlternativeSrc, MediaType loopbackConnectionType) { registerOnIceCandidateEventListener(); if (doLoopback) { if (loopbackAlternativeSrc == null) { connect(this.getEndpoint(), loopbackConnectionType); } else { connectAltLoopbackSrc(loopbackAlternativeSrc, loopbackConnectionType); } } else { innerConnect(); } String sdpResponse = null; switch (sdpType) { case ANSWER: sdpResponse = processAnswer(sdpString); break; case OFFER: sdpResponse = processOffer(sdpString); break; default: throw new RoomException(Code.MEDIA_SDP_ERROR_CODE, "Sdp type not supported: " + sdpType); } gatherCandidates(); return sdpResponse; }
Example #23
Source File: Participant.java From kurento-room with Apache License 2.0 | 5 votes |
public String publishToRoom(SdpType sdpType, String sdpString, boolean doLoopback, MediaElement loopbackAlternativeSrc, MediaType loopbackConnectionType) { log.info("USER {}: Request to publish video in room {} (sdp type {})", this.name, this.room.getName(), sdpType); log.trace("USER {}: Publishing Sdp ({}) is {}", this.name, sdpType, sdpString); String sdpResponse = this.getPublisher() .publish(sdpType, sdpString, doLoopback, loopbackAlternativeSrc, loopbackConnectionType); this.streaming = true; log.trace("USER {}: Publishing Sdp ({}) is {}", this.name, sdpType, sdpResponse); log.info("USER {}: Is now publishing video in room {}", this.name, this.room.getName()); return sdpResponse; }
Example #24
Source File: Participant.java From kurento-room with Apache License 2.0 | 5 votes |
public void shapePublisherMedia(MediaElement element, MediaType type) { if (type == null) { this.publisher.apply(element); } else { this.publisher.apply(element, type); } }
Example #25
Source File: KStream.java From openmeetings with Apache License 2.0 | 5 votes |
public void startRecord(StreamProcessor processor) { log.debug("startRecord outMedia OK ? {}", outgoingMedia != null); if (outgoingMedia == null) { release(processor, true); return; } final String chunkUid = "rec_" + room.getRecordingId() + "_" + randomUUID(); recorder = createRecorderEndpoint(room.getPipeline(), getRecUri(getRecordingChunk(room.getRoomId(), chunkUid)), profile); recorder.addTag("outUid", uid); recorder.addTag("uid", uid); recorder.addRecordingListener(evt -> chunkId = room.getChunkDao().start(room.getRecordingId(), type, chunkUid, sid)); recorder.addStoppedListener(evt -> room.getChunkDao().stop(chunkId)); switch (profile) { case WEBM: outgoingMedia.connect(recorder, MediaType.AUDIO); outgoingMedia.connect(recorder, MediaType.VIDEO); break; case WEBM_VIDEO_ONLY: outgoingMedia.connect(recorder, MediaType.VIDEO); break; case WEBM_AUDIO_ONLY: default: outgoingMedia.connect(recorder, MediaType.AUDIO); break; } recorder.record(new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { log.info("Recording started successfully"); } @Override public void onError(Throwable cause) throws Exception { log.error("Failed to start recording", cause); } }); }
Example #26
Source File: PublisherEndpoint.java From kurento-room with Apache License 2.0 | 4 votes |
public synchronized void disconnectFrom(MediaElement sink, MediaType type) { internalSinkDisconnect(passThru, sink, type); }
Example #27
Source File: PublisherEndpoint.java From kurento-room with Apache License 2.0 | 4 votes |
public synchronized void connect(MediaElement sink, MediaType type) { if (!connected) { innerConnect(); } internalSinkConnect(passThru, sink, type); }
Example #28
Source File: KmsMediaEvent.java From openvidu with Apache License 2.0 | 4 votes |
public KmsMediaEvent(MediaEvent event, Participant participant, String endpointName, MediaType mediaType, long createdAt) { super(event, participant, endpointName, createdAt); this.mediaType = mediaType; }
Example #29
Source File: RoomManagerTest.java From kurento-room with Apache License 2.0 | 4 votes |
@Test public void publishWithAlternativeLoopbackSrcAudioType() { joinManyUsersOneRoom(); Mixer m = new Mixer.Builder(pipeline).build(); assertThat("Mixer returned by the builder is not the same as the mocked one", m, is(mixer)); HubPort hb = new HubPort.Builder(m).build(); assertThat("HubPort returned by the builder is not the same as the mocked one", hb, is(hubPort)); String participantId0 = usersParticipantIds.get(users[0]); assertEquals("SDP answer doesn't match", SDP_WEB_ANSWER, manager.publishMedia(participantId0, true, SDP_WEB_OFFER, hb, MediaType.AUDIO, true)); assertThat(manager.getPublishers(roomx).size(), is(1)); // connected with loopback, so the internal connection is performed // right away verify(endpoint).connect(any(MediaElement.class), webRtcConnectCaptor.capture()); // the loopback is not done using the passThru elem verify(passThru, never()).connect(any(MediaElement.class), passThruConnectCaptor.capture()); // the hubPort is connected to the webrtc endpoint verify(hubPort).connect(any(MediaElement.class), hubPortConnectTypeCaptor.capture(), hubPortConnectCaptor.capture()); assertThat("Connection type is not audio", hubPortConnectTypeCaptor.getValue(), is(MediaType.AUDIO)); for (String pid : usersParticipantIds.values()) { if (!pid.equals(participantId0)) { assertEquals("SDP answer doesn't match", SDP_WEB_ANSWER, manager.subscribe(users[0], SDP_WEB_OFFER, pid)); } } assertThat(manager.getSubscribers(roomx).size(), is(users.length - 1)); // using same endpoint, subscribers connections only verify(passThru, times(users.length - 1)).connect(any(MediaElement.class), passThruConnectCaptor.capture()); Set<UserParticipant> remainingUsers = manager.leaveRoom(participantId0); Set<UserParticipant> roomParticipants = manager.getParticipants(roomx); assertEquals(roomParticipants, remainingUsers); assertThat(roomParticipants, not(hasItem(usersParticipants.get(users[0])))); assertThat(manager.getPublishers(roomx).size(), is(0)); // peers are automatically unsubscribed assertThat(manager.getSubscribers(roomx).size(), is(0)); }
Example #30
Source File: NotificationRoomManager.java From kurento-room with Apache License 2.0 | 4 votes |
/** * @see RoomManager#addMediaElement(String, MediaElement, MediaType) */ public void addMediaElement(String participantId, MediaElement element, MediaType type) throws RoomException { internalManager.addMediaElement(participantId, element, type); }