org.kurento.client.ServerManager Java Examples

The following examples show how to use org.kurento.client.ServerManager. 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: IntegrationTestConfiguration.java    From openvidu with Apache License 2.0 5 votes vote down vote up
@Bean
public KmsManager kmsManager() throws Exception {
	final KmsManager spy = Mockito.spy(new FixedOneKmsManager());
	doAnswer(invocation -> {
		List<Kms> successfullyConnectedKmss = new ArrayList<>();
		List<KmsProperties> kmsProperties = invocation.getArgument(0);
		for (KmsProperties kmsProp : kmsProperties) {
			Kms kms = new Kms(kmsProp, spy.getLoadManager());
			KurentoClient kClient = mock(KurentoClient.class);

			doAnswer(i -> {
				Thread.sleep((long) (Math.random() * 1000));
				((Continuation<MediaPipeline>) i.getArgument(0)).onSuccess(mock(MediaPipeline.class));
				return null;
			}).when(kClient).createMediaPipeline((Continuation<MediaPipeline>) any());

			ServerManager serverManagerMock = mock(ServerManager.class);
			when(serverManagerMock.getCpuCount()).thenReturn(new Random().nextInt(32) + 1);
			when(kClient.getServerManager()).thenReturn(serverManagerMock);

			kms.setKurentoClient(kClient);
			kms.setKurentoClientConnected(true);
			kms.setTimeOfKurentoClientConnection(System.currentTimeMillis());

			spy.addKms(kms);
			successfullyConnectedKmss.add(kms);
		}
		return successfullyConnectedKmss;
	}).when(spy).initializeKurentoClients(any(List.class), any(Boolean.class));
	return spy;
}
 
Example #2
Source File: ServerManagerTest.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testSameInstance() throws InterruptedException {

  ServerManager server = kurentoClient.getServerManager();
  ServerManager server2 = kurentoClient.getServerManager();

  assertThat(server, IsSame.sameInstance(server2));
}
 
Example #3
Source File: ServerManagerTest.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Test
public void readPipelines() {

  MediaPipeline pipeline = kurentoClient.createMediaPipeline();

  ServerManager serverManager = kurentoClient.getServerManager();
  List<MediaPipeline> mediaPipelines = serverManager.getPipelines();

  for (MediaPipeline p : mediaPipelines) {
    String gstreamerDot = p.getGstreamerDot();
    System.out.println(p.getId() + ": " + gstreamerDot);
  }

  assertTrue(mediaPipelines.contains(pipeline));
}
 
Example #4
Source File: BasePipeline.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
public ServerManager getServerManager() {
  serverManager = kurentoClient.getServerManager();
  return serverManager;
}
 
Example #5
Source File: ServerManagerTest.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
@Test
public void readPipelineElements() throws IOException {

  MediaPipeline pipeline = kurentoClient.createMediaPipeline();

  new WebRtcEndpoint.Builder(pipeline).build();

  KurentoClient otherKurentoClient = kms.createKurentoClient();

  ServerManager serverManager = otherKurentoClient.getServerManager();

  List<MediaPipeline> mediaPipelines = serverManager.getPipelines();

  for (MediaObject o : mediaPipelines.get(0).getChildren()) {
    if (o.getId().indexOf("WebRtcEndpoint") >= 0) {
      WebRtcEndpoint webRtc = (WebRtcEndpoint) o;

      assertThat(pipeline, is(webRtc.getParent()));
    }
  }
}