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

The following examples show how to use org.kurento.client.MediaElement#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: KurentoParticipant.java    From openvidu with Apache License 2.0 6 votes vote down vote up
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 2
Source File: Participant.java    From kurento-room with Apache License 2.0 6 votes vote down vote up
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 3
Source File: PublisherEndpoint.java    From openvidu with Apache License 2.0 4 votes vote down vote up
public synchronized void revert(MediaElement shaper, boolean releaseElement) throws OpenViduException {
	final String elementId = shaper.getId();
	if (!elements.containsKey(elementId)) {
		throw new OpenViduException(Code.MEDIA_ENDPOINT_ERROR_CODE,
				"This endpoint (" + getEndpointName() + ") has no media element with id " + elementId);
	}

	MediaElement element = elements.remove(elementId);
	unregisterElementErrListener(element, elementsErrorSubscriptions.remove(elementId));

	// careful, the order in the elems list is reverted
	if (connected) {
		String nextId = getNext(elementId);
		String prevId = getPrevious(elementId);
		// next connects to prev
		MediaElement prev = null;
		MediaElement next = null;
		if (nextId != null) {
			next = elements.get(nextId);
		} else {
			next = this.getEndpoint();
		}
		if (prevId != null) {
			prev = elements.get(prevId);
		} else {
			prev = passThru;
		}
		internalSinkConnect(next, prev);
	}
	elementIds.remove(elementId);
	if (releaseElement) {
		element.release(new Continuation<Void>() {
			@Override
			public void onSuccess(Void result) throws Exception {
				log.trace("EP {}: Released media element {}", getEndpointName(), elementId);
			}

			@Override
			public void onError(Throwable cause) throws Exception {
				log.error("EP {}: Failed to release media element {}", getEndpointName(), elementId, cause);
			}
		});
	}
	this.filter = null;
}
 
Example 4
Source File: PublisherEndpoint.java    From kurento-room with Apache License 2.0 4 votes vote down vote up
public synchronized void revert(MediaElement shaper, boolean releaseElement) throws
    RoomException {
  final String elementId = shaper.getId();
  if (!elements.containsKey(elementId)) {
    throw new RoomException(Code.MEDIA_ENDPOINT_ERROR_CODE,
        "This endpoint (" + getEndpointName() + ") has no media element with id " + elementId);
  }

  MediaElement element = elements.remove(elementId);
  unregisterElementErrListener(element, elementsErrorSubscriptions.remove(elementId));

  // careful, the order in the elems list is reverted
  if (connected) {
    String nextId = getNext(elementId);
    String prevId = getPrevious(elementId);
    // next connects to prev
    MediaElement prev = null;
    MediaElement next = null;
    if (nextId != null) {
      next = elements.get(nextId);
    } else {
      next = this.getEndpoint();
    }
    if (prevId != null) {
      prev = elements.get(prevId);
    } else {
      prev = passThru;
    }
    internalSinkConnect(next, prev);
  }
  elementIds.remove(elementId);
  if (releaseElement) {
    element.release(new Continuation<Void>() {
      @Override
      public void onSuccess(Void result) throws Exception {
        log.trace("EP {}: Released media element {}", getEndpointName(), elementId);
      }

      @Override
      public void onError(Throwable cause) throws Exception {
        log.error("EP {}: Failed to release media element {}", getEndpointName(), elementId, cause);
      }
    });
  }
}