Java Code Examples for org.kurento.client.Continuation

The following examples show how to use org.kurento.client.Continuation. These examples are extracted from open source projects. 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 Project: openvidu   Source File: KurentoParticipant.java    License: 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 Project: openvidu   Source File: MediaEndpoint.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * If supported, it instructs the internal endpoint to start gathering
 * {@link IceCandidate}s.
 */
protected void gatherCandidates() throws OpenViduException {
	if (!this.isWeb()) {
		return;
	}
	if (webEndpoint == null) {
		throw new OpenViduException(Code.MEDIA_WEBRTC_ENDPOINT_ERROR_CODE,
				"Can't start gathering ICE candidates on null WebRtcEndpoint (ep: " + endpointName + ")");
	}
	webEndpoint.gatherCandidates(new Continuation<Void>() {
		@Override
		public void onSuccess(Void result) throws Exception {
			log.trace("EP {}: Internal endpoint started to gather candidates", endpointName);
		}

		@Override
		public void onError(Throwable cause) throws Exception {
			log.warn("EP {}: Internal endpoint failed to start gathering candidates", endpointName, cause);
		}
	});
}
 
Example 3
Source Project: openvidu   Source File: MediaEndpoint.java    License: Apache License 2.0 6 votes vote down vote up
private void internalAddIceCandidate(IceCandidate candidate) throws OpenViduException {
	if (webEndpoint == null) {
		throw new OpenViduException(Code.MEDIA_WEBRTC_ENDPOINT_ERROR_CODE,
				"Can't add existing ICE candidates to null WebRtcEndpoint (ep: " + endpointName + ")");
	}
	this.receivedCandidateList.add(candidate);
	this.webEndpoint.addIceCandidate(candidate, new Continuation<Void>() {
		@Override
		public void onSuccess(Void result) throws Exception {
			log.trace("Ice candidate \"{}\" added to the internal endpoint", candidate.getCandidate());
		}

		@Override
		public void onError(Throwable cause) throws Exception {
			log.warn("EP {}: Failed to add ice candidate \"{}\" to the internal endpoint: {}", endpointName,
					candidate.getCandidate(), cause.getMessage());
		}
	});
}
 
Example 4
Source Project: openvidu   Source File: PublisherEndpoint.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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 5
Source Project: openmeetings   Source File: KStream.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void release(IStreamProcessor processor, boolean remove) {
	if (outgoingMedia != null) {
		releaseListeners();
		outgoingMedia.release(new Continuation<Void>() {
			@Override
			public void onSuccess(Void result) throws Exception {
				log.trace("PARTICIPANT {}: Released successfully", KStream.this.uid);
			}

			@Override
			public void onError(Throwable cause) throws Exception {
				log.warn("PARTICIPANT {}: Could not release", KStream.this.uid, cause);
			}
		});
		releaseRecorder(false);
		outgoingMedia = null;
	}
	if (remove) {
		processor.release(this, false);
	}
}
 
Example 6
Source Project: kurento-room   Source File: Participant.java    License: 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 7
Source Project: kurento-room   Source File: Room.java    License: Apache License 2.0 6 votes vote down vote up
private void closePipeline() {
  synchronized (pipelineReleaseLock) {
    if (pipeline == null || pipelineReleased) {
      return;
    }
    getPipeline().release(new Continuation<Void>() {

      @Override
      public void onSuccess(Void result) throws Exception {
        log.debug("ROOM {}: Released Pipeline", Room.this.name);
        pipelineReleased = true;
      }

      @Override
      public void onError(Throwable cause) throws Exception {
        log.warn("ROOM {}: Could not successfully release Pipeline", Room.this.name, cause);
        pipelineReleased = true;
      }
    });
  }
}
 
Example 8
Source Project: kurento-room   Source File: MediaEndpoint.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * If supported, it instructs the internal endpoint to start gathering {@link IceCandidate}s.
 */
protected void gatherCandidates() throws RoomException {
  if (!this.isWeb()) {
    return;
  }
  if (webEndpoint == null) {
    throw new RoomException(Code.MEDIA_WEBRTC_ENDPOINT_ERROR_CODE,
        "Can't start gathering ICE candidates on null WebRtcEndpoint (ep: " + endpointName + ")");
  }
  webEndpoint.gatherCandidates(new Continuation<Void>() {
    @Override
    public void onSuccess(Void result) throws Exception {
      log.trace("EP {}: Internal endpoint started to gather candidates", endpointName);
    }

    @Override
    public void onError(Throwable cause) throws Exception {
      log.warn("EP {}: Internal endpoint failed to start gathering candidates", endpointName,
          cause);
    }
  });
}
 
Example 9
Source Project: kurento-room   Source File: MediaEndpoint.java    License: Apache License 2.0 6 votes vote down vote up
private void internalAddIceCandidate(IceCandidate candidate) throws RoomException {
  if (webEndpoint == null) {
    throw new RoomException(Code.MEDIA_WEBRTC_ENDPOINT_ERROR_CODE,
        "Can't add existing ICE candidates to null WebRtcEndpoint (ep: " + endpointName + ")");
  }
  this.webEndpoint.addIceCandidate(candidate, new Continuation<Void>() {
    @Override
    public void onSuccess(Void result) throws Exception {
      log.trace("Ice candidate added to the internal endpoint");
    }

    @Override
    public void onError(Throwable cause) throws Exception {
      log.warn("EP {}: Failed to add ice candidate to the internal endpoint", endpointName, cause);
    }
  });
}
 
Example 10
Source Project: kurento-room   Source File: PublisherEndpoint.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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 11
Source Project: kurento-room   Source File: PublisherEndpoint.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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 12
Source Project: kurento-room   Source File: RoomManagerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void publishWithLoopbackError() {
  joinManyUsersOneRoom();

  String participantId0 = usersParticipantIds.get(users[0]);

  doThrow(
      new RoomException(Code.MEDIA_WEBRTC_ENDPOINT_ERROR_CODE, "Loopback connection error test"))
      .when(passThru).connect(any(WebRtcEndpoint.class), Matchers.<Continuation<Void>> any());

  exception.expect(RoomException.class);
  exception.expectMessage(containsString("Loopback connection error test"));

  assertEquals("SDP answer doesn't match", SDP_WEB_ANSWER,
      manager.publishMedia(participantId0, true, SDP_WEB_OFFER, true));

  assertThat(manager.getPublishers(roomx).size(), is(0));
  assertThat(manager.getSubscribers(roomx).size(), is(0));
}
 
Example 13
Source Project: kurento-java   Source File: MediaPipelineAsyncBaseTest.java    License: Apache License 2.0 6 votes vote down vote up
protected static void releaseMediaObject(final MediaObject mo) throws InterruptedException {
  final CountDownLatch latch = new CountDownLatch(1);

  if (mo != null) {
    mo.release(new Continuation<Void>() {
      @Override
      public void onSuccess(Void result) {
        latch.countDown();
      }

      @Override
      public void onError(Throwable cause) {
        throw new KurentoException(cause);
      }
    });
    Assert.assertTrue("Timeout of 25s releasing object", latch.await(25, TimeUnit.SECONDS));
  }
}
 
Example 14
@SuppressWarnings("unchecked")
private Object subscribeEventListener(final Object proxy, final Object[] args, String methodName,
    final Class<? extends Event> eventClass, Continuation<?> cont, Transaction tx) {

  String eventName = eventClass.getSimpleName().substring(0,
      eventClass.getSimpleName().length() - "Event".length());

  RemoteObjectEventListener listener = new RemoteObjectEventListener() {
    @Override
    public void onEvent(String eventType, Props data) {
      propagateEventTo(proxy, eventClass, data, (EventListener<?>) args[0]);
    }
  };

  if (cont != null) {
    remoteObject.addEventListener(eventName, listener,
        (Continuation<ListenerSubscriptionImpl>) cont);
    return null;
  } else if (tx != null) {
    return remoteObject.addEventListener(eventName, listener, tx);
  } else {
    return remoteObject.addEventListener(eventName, listener);
  }
}
 
Example 15
@SuppressWarnings("unchecked")
private Object genericSubscribeEventListener(String eventName, final Object proxy, final Object[] args,
		Continuation<?> cont, Transaction tx) {

	RemoteObjectEventListener listener = new RemoteObjectEventListener() {
		@Override
		public void onEvent(String eventType, Props data) {
			propagateEventTo(proxy, GenericMediaEvent.class, data, (EventListener<?>) args[1]);
		}
	};

	if (cont != null) {
		remoteObject.addEventListener(eventName, listener, (Continuation<ListenerSubscriptionImpl>) cont);
		return null;
	} else if (tx != null) {
		return remoteObject.addEventListener(eventName, listener, tx);
	} else {
		return remoteObject.addEventListener(eventName, listener);
	}
}
 
Example 16
@SuppressWarnings("unchecked")
private Object unsubscribeEventListener(final Object proxy, final Object[] args,
    String methodName, final Class<? extends Event> eventClass, Continuation<?> cont,
    Transaction tx) {

  ListenerSubscriptionImpl listenerSubscription = (ListenerSubscriptionImpl) args[0];
  if (cont != null) {
    remoteObject.removeEventListener(listenerSubscription, (Continuation<Void>) cont);
  } else if (tx != null) {
    remoteObject.removeEventListener(listenerSubscription, tx);
  } else {
    remoteObject.removeEventListener(listenerSubscription);
  }

  return null;
}
 
Example 17
Source Project: kurento-java   Source File: RemoteObject.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("rawtypes")
public void invoke(String method, Props params, final Type type, final Continuation cont) {

  checkCreated();

  Type flattenType = FLATTENER.calculateFlattenType(type);

  manager.invoke(objectRef, method, params, flattenType, new DefaultContinuation<Object>(cont) {
    @SuppressWarnings("unchecked")
    @Override
    public void onSuccess(Object result) {
      try {
        cont.onSuccess(FLATTENER.unflattenValue("return", type, result, manager));
      } catch (Exception e) {
        log.warn("[Continuation] error invoking onSuccess implemented by client", e);
      }
    }
  });
}
 
Example 18
Source Project: kurento-java   Source File: RemoteObject.java    License: Apache License 2.0 6 votes vote down vote up
public void addEventListener(final String eventType, final RemoteObjectEventListener listener,
    final Continuation<ListenerSubscriptionImpl> cont) {

  checkCreated();

  listeners.put(eventType, listener);

  manager.subscribe(objectRef, eventType, new DefaultContinuation<String>(cont) {
    @Override
    public void onSuccess(String subscription) {

      try {
        cont.onSuccess(new ListenerSubscriptionImpl(subscription, eventType, listener));
      } catch (Exception e) {
        log.warn("[Continuation] error invoking onSuccess implemented by client", e);
      }
    }
  });
}
 
Example 19
Source Project: kurento-java   Source File: RomManager.java    License: Apache License 2.0 6 votes vote down vote up
public void transaction(final List<Operation> operations, final Continuation<Void> continuation) {

    for (Operation op : operations) {
      op.setManager(this);
    }

    client.transaction(operations, new Continuation<Void>() {
      @Override
      public void onSuccess(Void result) throws Exception {
        continuation.onSuccess(null);
      }

      @Override
      public void onError(Throwable cause) throws Exception {
        transaction(operations, continuation);
      }
    });
  }
 
Example 20
Source Project: kurento-tutorial-java   Source File: UserSession.java    License: 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 21
Source Project: kurento-java   Source File: CompositeWebRtcRecorderTest.java    License: Apache License 2.0 5 votes vote down vote up
@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 22
Source Project: openvidu   Source File: PublisherEndpoint.java    License: Apache License 2.0 5 votes vote down vote up
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 23
Source Project: openvidu   Source File: PublisherEndpoint.java    License: Apache License 2.0 5 votes vote down vote up
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 24
Source Project: openmeetings   Source File: KStream.java    License: Apache License 2.0 5 votes vote down vote up
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 25
Source Project: kurento-room   Source File: PublisherEndpoint.java    License: Apache License 2.0 5 votes vote down vote up
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 Project: kurento-room   Source File: PublisherEndpoint.java    License: Apache License 2.0 5 votes vote down vote up
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 Project: kurento-java   Source File: RoomParticipant.java    License: 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 28
Source Project: kurento-java   Source File: Room.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void close() {

  if (!closed) {

    executor.shutdown();

    for (final RoomParticipant user : participants.values()) {
      user.close();
    }

    participants.clear();

    if (pipeline != null) {
      pipeline.release(new Continuation<Void>() {

        @Override
        public void onSuccess(Void result) throws Exception {
          log.trace("ROOM {}: Released Pipeline", Room.this.name);
        }

        @Override
        public void onError(Throwable cause) throws Exception {
          log.warn("PARTICIPANT " + Room.this.name + ": Could not release Pipeline", cause);
        }
      });
    }

    log.debug("Room {} closed", this.name);

    this.closed = true;
  } else {
    log.warn("Closing a yet closed room {}", this.name);
  }
}
 
Example 29
Source Project: kurento-java   Source File: RemoteObject.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public synchronized void whenCommited(Continuation<?> continuation, Executor executor) {
  this.whenContinuation = (Continuation<Object>) continuation;
  this.executor = executor;
  if (isCommited()) {
    execWhenCommited();
  }
}
 
Example 30
Source Project: kurento-java   Source File: RemoteObject.java    License: Apache License 2.0 5 votes vote down vote up
public void release(final Continuation<Void> cont) {

    checkCreated();

    manager.release(objectRef, new DefaultContinuation<Void>(cont) {
      @Override
      public void onSuccess(Void result) {
        try {
          cont.onSuccess(null);
        } catch (Exception e) {
          log.warn("[Continuation] error invoking onSuccess implemented by client", e);
        }
      }
    });
  }