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

The following examples show how to use org.kurento.client.MediaElement#getId() . 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 kurento-room with Apache License 2.0 5 votes vote down vote up
/**
 * 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 4
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 5
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);
      }
    });
  }
}