Java Code Examples for org.kurento.client.WebRtcEndpoint#release()

The following examples show how to use org.kurento.client.WebRtcEndpoint#release() . 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: FakeParticipant.java    From kurento-room with Apache License 2.0 6 votes vote down vote up
public synchronized void unsubscribe(String remoteName) {
  WebRtcEndpoint peer = null;
  try {
    peer = peerEndpoints.get(remoteName);
    if (peer == null) {
      log.warn("No local peer found for remote {}", remoteName);
    }
    jsonRpcClient.unsubscribeFromVideo(peerStreams.get(remoteName));
    log.debug("Unsubscribed from {}", peerStreams.get(remoteName));
  } catch (IOException e) {
    log.warn("Unable to unsubscribe in room '{}' from '{}'", room, remoteName, e);
    Assert.fail("Unable to unsubscribe: " + e.getMessage());
  } finally {
    if (peer != null) {
      peer.release();
    }
    peerEndpoints.remove(remoteName);
    peerLatches.remove(remoteName);
  }
}
 
Example 2
Source File: FakeKmsService.java    From kurento-java with Apache License 2.0 6 votes vote down vote up
public void releaseAllFakePipelines(long timeBetweenClientMs, SystemMonitorManager monitor) {
  for (int i = 0; i < fakeWebRtcList.size(); i++) {
    monitor.decrementNumClients();
    waitMs(timeBetweenClientMs);
  }
  for (WebRtcEndpoint fakeBrowser : fakeBrowserList) {
    fakeBrowser.release();
    waitMs(timeBetweenClientMs);
  }
  for (MediaPipeline fakeMediaPipeline : fakeMediaPipelineList) {
    fakeMediaPipeline.release();
  }
  fakeWebRtcList = new ArrayList<>();
  fakeBrowserList = new ArrayList<>();
  fakeMediaPipelineList = new ArrayList<MediaPipeline>();
}
 
Example 3
Source File: UserSession.java    From kurento-tutorial-java with Apache License 2.0 6 votes vote down vote up
public void cancelVideoFrom(final String senderName) {
  log.debug("PARTICIPANT {}: canceling video reception from {}", this.name, senderName);
  final WebRtcEndpoint incoming = incomingMedia.remove(senderName);

  log.debug("PARTICIPANT {}: removing endpoint for {}", this.name, senderName);
  incoming.release(new Continuation<Void>() {
    @Override
    public void onSuccess(Void result) throws Exception {
      log.trace("PARTICIPANT {}: Released successfully incoming EP for {}",
          UserSession.this.name, senderName);
    }

    @Override
    public void onError(Throwable cause) throws Exception {
      log.warn("PARTICIPANT {}: Could not release incoming EP for {}", UserSession.this.name,
          senderName);
    }
  });
}
 
Example 4
Source File: KStream.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
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 5
Source File: FakeParticipant.java    From kurento-room with Apache License 2.0 5 votes vote down vote up
private void releaseRemote(String remote) {
  WebRtcEndpoint peer = peerEndpoints.get(remote);
  if (peer != null) {
    peer.release();
  }
  peerEndpoints.remove(remote);
}
 
Example 6
Source File: RoomParticipant.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
private void releaseEndpoint(final String senderName, final WebRtcEndpoint sendingEndpoint) {
  sendingEndpoint.release(new Continuation<Void>() {
    @Override
    public void onSuccess(Void result) throws Exception {
      log.debug("PARTICIPANT {}: Released successfully incoming EP for {}",
          RoomParticipant.this.name, senderName);
    }

    @Override
    public void onError(Throwable cause) throws Exception {
      log.warn("PARTICIPANT " + RoomParticipant.this.name
          + ": Could not release sending endpoint for user " + senderName, cause);
    }
  });
}
 
Example 7
Source File: FakeKmsService.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
public void releaseAllFakeClients(long timeBetweenClientMs, WebRtcEndpoint inputWebRtc,
    SystemMonitorManager monitor) {
  for (WebRtcEndpoint fakeWebRtc : fakeWebRtcList) {
    fakeWebRtc.release();
    monitor.decrementNumClients();

    waitMs(timeBetweenClientMs);
  }
  for (WebRtcEndpoint fakeBrowser : fakeBrowserList) {
    fakeBrowser.release();
    waitMs(timeBetweenClientMs);
  }
  fakeWebRtcList = new ArrayList<>();
  fakeBrowserList = new ArrayList<>();
}
 
Example 8
Source File: KStream.java    From openmeetings with Apache License 2.0 4 votes vote down vote up
public void remove(final Client c) {
	WebRtcEndpoint point = listeners.remove(c.getUid());
	if (point != null) {
		point.release();
	}
}
 
Example 9
Source File: RoomParticipant.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
private String createSdpResponseForUser(RoomParticipant sender, String sdpOffer) {

    WebRtcEndpoint receivingEndpoint = sender.getReceivingEndpoint();
    if (receivingEndpoint == null) {
      log.warn("PARTICIPANT {}: Trying to connect to a user without receiving endpoint "
          + "(it seems is not yet fully connected)", this.name);
      return null;
    }

    if (sender.getName().equals(name)) {
      // FIXME: Use another message type for receiving sdp offer
      log.debug("PARTICIPANT {}: configuring loopback", this.name);
      return receivingEndpoint.processOffer(sdpOffer);
    }

    if (sendingEndpoints.get(sender.getName()) != null) {
      log.warn("PARTICIPANT {}: There is a sending endpoint to user {} "
          + "when trying to create another one", this.name, sender.getName());
      return null;
    }

    log.debug("PARTICIPANT {}: Creating a sending endpoint to user {}", this.name,
        sender.getName());

    WebRtcEndpoint sendingEndpoint = new WebRtcEndpoint.Builder(pipeline).build();
    WebRtcEndpoint oldSendingEndpoint =
        sendingEndpoints.putIfAbsent(sender.getName(), sendingEndpoint);

    if (oldSendingEndpoint != null) {
      log.warn(
          "PARTICIPANT {}: 2 threads have simultaneously created a sending endpoint for user {}",
          this.name, sender.getName());
      return null;
    }

    log.debug("PARTICIPANT {}: Created sending endpoint for user {}", this.name, sender.getName());
    try {
      receivingEndpoint = sender.getReceivingEndpoint();
      if (receivingEndpoint != null) {
        receivingEndpoint.connect(sendingEndpoint);
        return sendingEndpoint.processOffer(sdpOffer);
      }

    } catch (KurentoServerException e) {

      // TODO Check object status when KurentoClient set this info in the
      // object
      if (e.getCode() == 40101) {
        log.warn("Receiving endpoint is released when trying to connect a sending endpoint to it",
            e);
      } else {
        log.error("Exception connecting receiving endpoint to sending endpoint", e);
        sendingEndpoint.release(new Continuation<Void>() {
          @Override
          public void onSuccess(Void result) throws Exception {

          }

          @Override
          public void onError(Throwable cause) throws Exception {
            log.error("Exception releasing WebRtcEndpoint", cause);
          }
        });
      }

      sendingEndpoints.remove(sender.getName());

      releaseEndpoint(sender.getName(), sendingEndpoint);
    }

    return null;
  }