org.kurento.client.MediaElement Java Examples
The following examples show how to use
org.kurento.client.MediaElement.
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: 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 #2
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 #3
Source File: KurentoParticipant.java From openvidu with Apache License 2.0 | 6 votes |
private void releasePublisherEndpointAux(EndReason reason, long kmsDisconnectionTime) { // Remove streamId from publisher's map this.session.publishedStreamIds.remove(this.getPublisherStreamId()); if (this.openviduConfig.isRecordingModuleEnabled() && this.recordingManager.sessionIsBeingRecorded(session.getSessionId())) { this.recordingManager.stopOneIndividualStreamRecording(session, this.getPublisherStreamId(), kmsDisconnectionTime); } publisher.unregisterErrorListeners(); publisher.cancelStatsLoop.set(true); for (MediaElement el : publisher.getMediaElements()) { releaseElement(getParticipantPublicId(), el); } releaseElement(getParticipantPublicId(), publisher.getEndpoint()); this.streaming = false; this.session.deregisterPublisher(); endpointConfig.getCdr().stopPublisher(this.getParticipantPublicId(), publisher.getStreamId(), reason); publisher = null; }
Example #4
Source File: KurentoParticipant.java From openvidu with Apache License 2.0 | 6 votes |
void releaseElement(final String senderName, final MediaElement element) { final String eid = element.getId(); try { element.release(new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { log.debug("PARTICIPANT {}: Released successfully media element #{} for {}", getParticipantPublicId(), eid, senderName); } @Override public void onError(Throwable cause) throws Exception { log.warn("PARTICIPANT {}: Could not release media element #{} for {}", getParticipantPublicId(), eid, senderName, cause); } }); } catch (Exception e) { log.error("PARTICIPANT {}: Error calling release on elem #{} for {}", getParticipantPublicId(), eid, senderName, e); } }
Example #5
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 #6
Source File: PublisherEndpoint.java From openvidu with Apache License 2.0 | 6 votes |
private void innerConnect() { if (this.getEndpoint() == null) { throw new OpenViduException(Code.MEDIA_ENDPOINT_ERROR_CODE, "Can't connect null endpoint (ep: " + getEndpointName() + ")"); } MediaElement current = this.getEndpoint(); String prevId = elementIds.peekLast(); while (prevId != null) { MediaElement prev = elements.get(prevId); if (prev == null) { throw new OpenViduException(Code.MEDIA_ENDPOINT_ERROR_CODE, "No media element with id " + prevId + " (ep: " + getEndpointName() + ")"); } internalSinkConnect(current, prev); current = prev; prevId = getPrevious(prevId); } internalSinkConnect(current, passThru); connected = true; }
Example #7
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 #8
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 #9
Source File: Participant.java From kurento-room with Apache License 2.0 | 6 votes |
private void releaseElement(final String senderName, final MediaElement element) { final String eid = element.getId(); try { element.release(new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { log.debug("PARTICIPANT {}: Released successfully media element #{} for {}", Participant.this.name, eid, senderName); } @Override public void onError(Throwable cause) throws Exception { log.warn("PARTICIPANT {}: Could not release media element #{} for {}", Participant.this.name, eid, senderName, cause); } }); } catch (Exception e) { log.error("PARTICIPANT {}: Error calling release on elem #{} for {}", name, eid, senderName, e); } }
Example #10
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 #11
Source File: PublisherEndpoint.java From kurento-room with Apache License 2.0 | 6 votes |
@Override public synchronized void unmute() { 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 unmute connection of WebRTC and PassThrough (no other elems)"); } internalSinkConnect(this.getEndpoint(), sink); setMuteType(null); }
Example #12
Source File: PublisherEndpoint.java From kurento-room with Apache License 2.0 | 6 votes |
private void innerConnect() { if (this.getEndpoint() == null) { throw new RoomException(Code.MEDIA_ENDPOINT_ERROR_CODE, "Can't connect null endpoint (ep: " + getEndpointName() + ")"); } MediaElement current = this.getEndpoint(); String prevId = elementIds.peekLast(); while (prevId != null) { MediaElement prev = elements.get(prevId); if (prev == null) { throw new RoomException(Code.MEDIA_ENDPOINT_ERROR_CODE, "No media element with id " + prevId + " (ep: " + getEndpointName() + ")"); } internalSinkConnect(current, prev); current = prev; prevId = getPrevious(prevId); } internalSinkConnect(current, passThru); connected = true; }
Example #13
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 #14
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 #15
Source File: PublisherEndpoint.java From openvidu with Apache License 2.0 | 5 votes |
private void internalSinkDisconnect(final MediaElement source, final MediaElement sink) { source.disconnect(sink, new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { log.debug("EP {}: Elements have been disconnected (source {} -> sink {})", getEndpointName(), source.getId(), sink.getId()); } @Override public void onError(Throwable cause) throws Exception { log.warn("EP {}: Failed to disconnect media elements (source {} -> sink {})", getEndpointName(), source.getId(), sink.getId(), cause); } }); }
Example #16
Source File: RoomManager.java From kurento-room with Apache License 2.0 | 5 votes |
/** * Disconnects and removes media element (filter, recorder, etc.) from a media stream. * * @param participantId identifier of the participant * @param element media element to be removed * @throws RoomException in case the participant doesn't exist, has been closed or on error * when removing the * filter */ public void removeMediaElement(String participantId, MediaElement element) throws RoomException { log.debug("Remove media element {} from participant {}", element.getId(), participantId); Participant participant = getParticipant(participantId); String name = participant.getName(); if (participant.isClosed()) { throw new RoomException(Code.USER_CLOSED_ERROR_CODE, "Participant '" + name + "' has been closed"); } participant.getPublisher().revert(element); }
Example #17
Source File: MediaEndpoint.java From kurento-room with Apache License 2.0 | 5 votes |
/** * Registers a listener for when the {@link MediaElement} triggers an {@link ErrorEvent}. Notifies * the owner with the error. * * @param element * the {@link MediaElement} * @return {@link ListenerSubscription} that can be used to deregister the listener */ protected ListenerSubscription registerElemErrListener(MediaElement element) { return element.addErrorListener(new EventListener<ErrorEvent>() { @Override public void onEvent(ErrorEvent event) { owner.sendMediaError(event); } }); }
Example #18
Source File: PublisherEndpoint.java From kurento-room with Apache License 2.0 | 5 votes |
/** * @return all media elements created for this publisher, except for the main element ( * {@link WebRtcEndpoint}) */ public synchronized Collection<MediaElement> getMediaElements() { if (passThru != null) { elements.put(passThru.getId(), passThru); } return elements.values(); }
Example #19
Source File: PublisherEndpoint.java From openvidu with Apache License 2.0 | 5 votes |
private void internalSinkConnect(final MediaElement source, final MediaElement sink) { source.connect(sink, new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { log.debug("EP {}: Elements have been connected (source {} -> sink {})", getEndpointName(), source.getId(), sink.getId()); } @Override public void onError(Throwable cause) throws Exception { log.warn("EP {}: Failed to connect media elements (source {} -> sink {})", getEndpointName(), source.getId(), sink.getId(), cause); } }); }
Example #20
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 #21
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 #22
Source File: PublisherEndpoint.java From openvidu with Apache License 2.0 | 5 votes |
public synchronized void connect(MediaElement sink) { if (!connected) { innerConnect(); } internalSinkConnect(passThru, sink); this.enableIpCameraIfNecessary(); }
Example #23
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 #24
Source File: PublisherEndpoint.java From openvidu with Apache License 2.0 | 5 votes |
/** * @return all media elements created for this publisher, except for the main * element ( {@link WebRtcEndpoint}) */ public synchronized Collection<MediaElement> getMediaElements() { if (passThru != null) { elements.put(passThru.getId(), passThru); } return elements.values(); }
Example #25
Source File: PublisherEndpoint.java From kurento-room with Apache License 2.0 | 5 votes |
private void internalSinkConnect(final MediaElement source, final MediaElement sink) { source.connect(sink, new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { log.debug("EP {}: Elements have been connected (source {} -> sink {})", getEndpointName(), source.getId(), sink.getId()); } @Override public void onError(Throwable cause) throws Exception { log.warn("EP {}: Failed to connect media elements (source {} -> sink {})", getEndpointName(), source.getId(), sink.getId(), cause); } }); }
Example #26
Source File: PublisherEndpoint.java From kurento-room with Apache License 2.0 | 5 votes |
private void internalSinkDisconnect(final MediaElement source, final MediaElement sink) { source.disconnect(sink, new Continuation<Void>() { @Override public void onSuccess(Void result) throws Exception { log.debug("EP {}: Elements have been disconnected (source {} -> sink {})", getEndpointName(), source.getId(), sink.getId()); } @Override public void onError(Throwable cause) throws Exception { log.warn("EP {}: Failed to disconnect media elements (source {} -> sink {})", getEndpointName(), source.getId(), sink.getId(), cause); } }); }
Example #27
Source File: MediaEndpoint.java From openvidu with Apache License 2.0 | 5 votes |
/** * Registers a listener for when the {@link MediaElement} triggers an * {@link ErrorEvent}. Notifies the owner with the error. * * @param element the {@link MediaElement} * @return {@link ListenerSubscription} that can be used to deregister the * listener */ protected ListenerSubscription registerElemErrListener(MediaElement element) { return element.addErrorListener(new EventListener<ErrorEvent>() { @Override public void onEvent(ErrorEvent event) { owner.sendMediaError(event); } }); }
Example #28
Source File: RoomManagerTest.java From kurento-room with Apache License 2.0 | 5 votes |
@Test public void publishAndLeave() { joinManyUsersOneRoom(); String participantId0 = usersParticipantIds.get(users[0]); assertEquals("SDP answer doesn't match", SDP_WEB_ANSWER, manager.publishMedia(participantId0, true, SDP_WEB_OFFER, false)); assertThat(manager.getPublishers(roomx).size(), is(1)); // connected without loopback, publisher's internal connection verify(endpoint, times(1)).connect(any(MediaElement.class), webRtcConnectCaptor.capture()); // no external connection until someone subscribes verify(passThru, never()).connect(any(MediaElement.class), passThruConnectCaptor.capture()); 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)); // connected without loopback, verify(endpoint, times(1)).connect(any(MediaElement.class), webRtcConnectCaptor.capture()); // using same endpoint, subscribers connections 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 #29
Source File: RoomManagerTest.java From kurento-room with Apache License 2.0 | 5 votes |
@Test public void publishWithLoopback() { joinManyUsersOneRoom(); String participantId0 = usersParticipantIds.get(users[0]); assertEquals("SDP answer doesn't match", SDP_WEB_ANSWER, manager.publishMedia(participantId0, true, SDP_WEB_OFFER, 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()); verify(passThru).connect(any(MediaElement.class), passThruConnectCaptor.capture()); 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 + the internal one verify(passThru, times(users.length)).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: 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; }