org.kurento.client.Continuation Java Examples

The following examples show how to use org.kurento.client.Continuation. 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: 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 #2
Source File: PublisherEndpoint.java    From openvidu with 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 #3
Source File: RomManager.java    From kurento-java with 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 #4
Source File: KStream.java    From openmeetings with 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 #5
Source File: MediaEndpoint.java    From openvidu with 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 #6
Source File: MediaEndpoint.java    From openvidu with 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 #7
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 #8
Source File: MediaEndpoint.java    From kurento-room with 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 #9
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 #10
Source File: RemoteObject.java    From kurento-java with 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 #11
Source File: Room.java    From kurento-room with 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 #12
Source File: MediaEndpoint.java    From kurento-room with 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 #13
Source File: PublisherEndpoint.java    From kurento-room with 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 #14
Source File: PublisherEndpoint.java    From kurento-room with 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 #15
Source File: RoomManagerTest.java    From kurento-room with 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 #16
Source File: RemoteObject.java    From kurento-java with 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 #17
Source File: MediaPipelineAsyncBaseTest.java    From kurento-java with 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 #18
Source File: RemoteObjectInvocationHandler.java    From kurento-java with Apache License 2.0 6 votes vote down vote up
@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 #19
Source File: RemoteObjectInvocationHandler.java    From kurento-java with Apache License 2.0 6 votes vote down vote up
@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 #20
Source File: RemoteObjectInvocationHandler.java    From kurento-java with Apache License 2.0 6 votes vote down vote up
@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 #21
Source File: AsyncResultManager.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
public Continuation<E> getContinuation() {
  return new Continuation<E>() {

    @Override
    public void onSuccess(E result) throws Exception {
      addResult(result);
    }

    @Override
    public void onError(Throwable cause) throws Exception {
      addError(cause);
    }
  };
}
 
Example #22
Source File: RomClientJsonRpcClient.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Override
public Object invoke(String objectRef, String operationName, Props operationParams, Type type,
    Continuation<?> cont) {

  RequestAndResponseType reqres = createInvokeRequest(objectRef, operationName, operationParams,
      type, false);

  return sendRequest(reqres.request, reqres.responseType, null, cont);
}
 
Example #23
Source File: PublisherEndpoint.java    From kurento-room with 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 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 #25
Source File: Room.java    From kurento-java with 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 #26
Source File: RemoteObject.java    From kurento-java with 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 #27
Source File: RomClientJsonRpcClient.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Override
public String create(String remoteClassName, Props constructorParams, Props genericProperties,
    Continuation<String> cont) {

  RequestAndResponseType reqres = createCreateRequest(remoteClassName, constructorParams,
      genericProperties, false);

  return this.<String, String> sendRequest(reqres.request, reqres.responseType, null, cont);
}
 
Example #28
Source File: RomClientJsonRpcClient.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("serial")
public void transaction(final List<Operation> operations, final Continuation<Void> continuation) {

  JsonArray opJsons = new JsonArray();
  final List<RequestAndResponseType> opReqres = new ArrayList<>();

  int numReq = 0;
  for (Operation op : operations) {
    RequestAndResponseType reqres = op.createRequest(this);
    opReqres.add(reqres);
    reqres.request.setId(numReq);
    opJsons.add(JsonUtils.toJsonElement(reqres.request));
    numReq++;
  }

  JsonObject params = new JsonObject();
  params.add(TRANSACTION_OPERATIONS, opJsons);

  DefaultContinuation<List<Response<JsonElement>>> wrappedContinuation = null;

  if (continuation != null) {
    wrappedContinuation = new DefaultContinuation<List<Response<JsonElement>>>(continuation) {
      @Override
      public void onSuccess(List<Response<JsonElement>> responses) throws Exception {
        processTransactionResponse(operations, opReqres, responses);
        continuation.onSuccess(null);
      }
    };
  }

  List<Response<JsonElement>> responses = this.sendRequest(
      new Request<>(TRANSACTION_METHOD, params), new TypeToken<List<Response<JsonElement>>>() {
      }.getType(), null, wrappedContinuation);

  if (continuation == null) {
    processTransactionResponse(operations, opReqres, responses);
  }
}
 
Example #29
Source File: CompositeWebRtcRecorderTest.java    From kurento-java with 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 #30
Source File: PublisherEndpoint.java    From openvidu with 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);
		}
	});
}