org.kurento.client.KurentoClient Java Examples
The following examples show how to use
org.kurento.client.KurentoClient.
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: FixedOneKmsManager.java From openvidu with Apache License 2.0 | 6 votes |
@Override public List<Kms> initializeKurentoClients(List<KmsProperties> kmsProperties, boolean disconnectUponFailure) throws Exception { KmsProperties firstProps = kmsProperties.get(0); KurentoClient kClient = null; Kms kms = new Kms(firstProps, loadManager); try { kClient = KurentoClient.create(firstProps.getUri(), this.generateKurentoConnectionListener(kms.getId())); this.addKms(kms); kms.setKurentoClient(kClient); // TODO: This should be done in KurentoClient connected event kms.setKurentoClientConnected(true); kms.setTimeOfKurentoClientConnection(System.currentTimeMillis()); } catch (KurentoException e) { log.error("KMS in {} is not reachable by OpenVidu Server", firstProps.getUri()); if (kClient != null) { kClient.destroy(); } throw new Exception(); } return Arrays.asList(kms); }
Example #2
Source File: PlayMediaPipeline.java From kurento-tutorial-java with Apache License 2.0 | 6 votes |
public PlayMediaPipeline(KurentoClient kurento, String user, final WebSocketSession session) { // Media pipeline pipeline = kurento.createMediaPipeline(); // Media Elements (WebRtcEndpoint, PlayerEndpoint) webRtc = new WebRtcEndpoint.Builder(pipeline).build(); player = new PlayerEndpoint.Builder(pipeline, RECORDING_PATH + user + RECORDING_EXT).build(); // Connection player.connect(webRtc); // Player listeners player.addErrorListener(new EventListener<ErrorEvent>() { @Override public void onEvent(ErrorEvent event) { log.info("ErrorEvent: {}", event.getDescription()); sendPlayEnd(session); } }); }
Example #3
Source File: CallMediaPipeline.java From kurento-tutorial-java with Apache License 2.0 | 6 votes |
public CallMediaPipeline(KurentoClient kurento, String from, String to) { // Media pipeline pipeline = kurento.createMediaPipeline(); // Media Elements (WebRtcEndpoint, RecorderEndpoint) webRtcCaller = new WebRtcEndpoint.Builder(pipeline).build(); webRtcCallee = new WebRtcEndpoint.Builder(pipeline).build(); recorderCaller = new RecorderEndpoint.Builder(pipeline, RECORDING_PATH + from + RECORDING_EXT) .build(); recorderCallee = new RecorderEndpoint.Builder(pipeline, RECORDING_PATH + to + RECORDING_EXT) .build(); // Connections webRtcCaller.connect(webRtcCallee); webRtcCaller.connect(recorderCaller); webRtcCallee.connect(webRtcCaller); webRtcCallee.connect(recorderCallee); }
Example #4
Source File: PlayMediaPipeline.java From kurento-tutorial-java with Apache License 2.0 | 6 votes |
public PlayMediaPipeline(KurentoClient kurento, String user, final WebSocketSession session) { // Media pipeline pipeline = kurento.createMediaPipeline(); // Media Elements (WebRtcEndpoint, PlayerEndpoint) webRtc = new WebRtcEndpoint.Builder(pipeline).build(); player = new PlayerEndpoint.Builder(pipeline, RECORDING_PATH + user + RECORDING_EXT).build(); // Connection player.connect(webRtc); // Player listeners player.addErrorListener(new EventListener<ErrorEvent>() { @Override public void onEvent(ErrorEvent event) { log.info("ErrorEvent: {}", event.getDescription()); sendPlayEnd(session); } }); }
Example #5
Source File: ExtraKmsFakeUsers.java From kurento-room with Apache License 2.0 | 6 votes |
protected synchronized KurentoClient getTestExtraFakeKurento() { if (testExtraFakeKurento == null) { testExtraFakeKurento = KurentoClient.create(testExtraFakeKmsWsUri, new KurentoConnectionListener() { @Override public void connected() { } @Override public void connectionFailed() { } @Override public void disconnected() { testExtraFakeKurento = null; } @Override public void reconnected(boolean sameServer) { } }); } return testExtraFakeKurento; }
Example #6
Source File: Room.java From kurento-room with Apache License 2.0 | 5 votes |
public Room(String roomName, KurentoClient kurentoClient, RoomHandler roomHandler, boolean destroyKurentoClient) { this.name = roomName; this.kurentoClient = kurentoClient; this.destroyKurentoClient = destroyKurentoClient; this.roomHandler = roomHandler; log.debug("New ROOM instance, named '{}'", roomName); }
Example #7
Source File: CallMediaPipeline.java From kurento-tutorial-java with Apache License 2.0 | 5 votes |
public CallMediaPipeline(KurentoClient kurento, String from, String to) { // Media pipeline pipeline = kurento.createMediaPipeline(); // Media Elements (WebRtcEndpoint, RecorderEndpoint, FaceOverlayFilter) webRtcCaller = new WebRtcEndpoint.Builder(pipeline).build(); webRtcCallee = new WebRtcEndpoint.Builder(pipeline).build(); recorderCaller = new RecorderEndpoint.Builder(pipeline, RECORDING_PATH + from + RECORDING_EXT) .build(); recorderCallee = new RecorderEndpoint.Builder(pipeline, RECORDING_PATH + to + RECORDING_EXT) .build(); // String appServerUrl = System.getProperty("app.server.url", // One2OneCallAdvApp.DEFAULT_APP_SERVER_URL); String appServerUrl = "http://files.openvidu.io"; FaceOverlayFilter faceOverlayFilterCaller = new FaceOverlayFilter.Builder(pipeline).build(); faceOverlayFilterCaller.setOverlayedImage(appServerUrl + "/img/mario-wings.png", -0.35F, -1.2F, 1.6F, 1.6F); FaceOverlayFilter faceOverlayFilterCallee = new FaceOverlayFilter.Builder(pipeline).build(); faceOverlayFilterCallee.setOverlayedImage(appServerUrl + "/img/Hat.png", -0.2F, -1.35F, 1.5F, 1.5F); // Connections webRtcCaller.connect(faceOverlayFilterCaller); faceOverlayFilterCaller.connect(webRtcCallee); faceOverlayFilterCaller.connect(recorderCaller); webRtcCallee.connect(faceOverlayFilterCallee); faceOverlayFilterCallee.connect(webRtcCaller); faceOverlayFilterCallee.connect(recorderCallee); }
Example #8
Source File: KurentoClientKmsConnectionTest.java From kurento-java with Apache License 2.0 | 5 votes |
@Test public void errorSendingClosedKmsTest() throws Exception { String kmsUrl = kms.getWsUri(); KurentoClient kurento = KurentoClient.create(kmsUrl, new KurentoConnectionListener() { @Override public void reconnected(boolean sameServer) { } @Override public void disconnected() { log.debug("Disconnected"); } @Override public void connectionFailed() { } @Override public void connected() { } }); kurento.createMediaPipeline(); kms.stopKms(); try { kurento.createMediaPipeline(); fail("KurentoException should be thrown"); } catch (KurentoException e) { assertThat(e.getMessage(), containsString("Exception connecting to WebSocket")); } }
Example #9
Source File: CallMediaPipeline.java From kurento-tutorial-java with Apache License 2.0 | 5 votes |
public CallMediaPipeline(KurentoClient kurento) { try { this.pipeline = kurento.createMediaPipeline(); this.callerWebRtcEp = new WebRtcEndpoint.Builder(pipeline).build(); this.calleeWebRtcEp = new WebRtcEndpoint.Builder(pipeline).build(); this.callerWebRtcEp.connect(this.calleeWebRtcEp); this.calleeWebRtcEp.connect(this.callerWebRtcEp); } catch (Throwable t) { if (this.pipeline != null) { pipeline.release(); } } }
Example #10
Source File: KmsManager.java From kurento-room with Apache License 2.0 | 5 votes |
@Override public KurentoClient getKurentoClient(KurentoClientSessionInfo sessionInfo) throws RoomException { if (!(sessionInfo instanceof DefaultKurentoClientSessionInfo)) { throw new RoomException(Code.GENERIC_ERROR_CODE, "Unkown session info bean type (expected " + DefaultKurentoClientSessionInfo.class.getName() + ")"); } return getKms((DefaultKurentoClientSessionInfo) sessionInfo).getKurentoClient(); }
Example #11
Source File: RoomManager.java From kurento-room with Apache License 2.0 | 5 votes |
/** * Creates a room if it doesn't already exist. The room's name will be indicated by the session * info bean. * * @param kcSessionInfo bean that will be passed to the {@link KurentoClientProvider} in order * to obtain the * {@link KurentoClient} that will be used by the room * @throws RoomException in case of error while creating the room */ public void createRoom(KurentoClientSessionInfo kcSessionInfo) throws RoomException { String roomName = kcSessionInfo.getRoomName(); Room room = rooms.get(kcSessionInfo); if (room != null) { throw new RoomException(Code.ROOM_CANNOT_BE_CREATED_ERROR_CODE, "Room '" + roomName + "' already exists"); } KurentoClient kurentoClient = kcProvider.getKurentoClient(kcSessionInfo); room = new Room(roomName, kurentoClient, roomHandler, kcProvider.destroyWhenUnused()); Room oldRoom = rooms.putIfAbsent(roomName, room); if (oldRoom != null) { log.warn("Room '{}' has just been created by another thread", roomName); return; // throw new RoomException( // Code.ROOM_CANNOT_BE_CREATED_ERROR_CODE, // "Room '" // + roomName // + "' already exists (has just been created by another thread)"); } String kcName = "[NAME NOT AVAILABLE]"; if (kurentoClient.getServerManager() != null) { kcName = kurentoClient.getServerManager().getName(); } log.warn("No room '{}' exists yet. Created one " + "using KurentoClient '{}'.", roomName, kcName); }
Example #12
Source File: RoomClientFakeTest.java From kurento-room with Apache License 2.0 | 5 votes |
public CountDownLatch parallelJoinFakeUsers(final List<String> relativePaths, final String room, final KurentoClient kurento) { if (relativePaths == null || relativePaths.isEmpty()) { execExceptions.put("parallelJoinFakeUsers-" + room, new Exception( "Null or empty play paths list")); return null; } int userThreads = relativePaths.size(); log.info("Joining room '{}': {} fake users with relative play paths:\n{}", room, userThreads, relativePaths); final CountDownLatch joinLatch = new CountDownLatch(userThreads); parallelTasks(userThreads, USER_FAKE_PREFIX, "parallelJoinFakeUsers-" + room, new Task() { @Override public void exec(int numTask) throws Exception { try { String userName = getFakeKey(numTask); FakeSession s = createSession(room); String fullPlayPath = getPlaySourcePath(userName, relativePaths.get(numTask)); if (kurento == null) { s.newParticipant(userName, fullPlayPath, true, true); } else { s.newParticipant(userName, fullPlayPath, true, true, kurento); } } finally { joinLatch.countDown(); } } }); return joinLatch; }
Example #13
Source File: FakeSession.java From kurento-room with Apache License 2.0 | 5 votes |
private TestPipeline getOrCreatePipeline(KurentoClient kurento) { TestPipeline pipeline = this.pipelines.get(kurento); if (pipeline == null) { String desc = kurento.getServerManager().getId(); pipeline = this.pipelines.putIfAbsent(kurento, new TestPipeline(kurento, room, desc)); if (pipeline != null) { log.debug("Pipeline already created for room '{}' and kurento '{}'", room, desc); } pipeline = this.pipelines.get(kurento); } return pipeline; }
Example #14
Source File: TestPipeline.java From kurento-room with Apache License 2.0 | 5 votes |
public TestPipeline(KurentoClient kurento, String room, String pipeDescription) { this.kurento = kurento; if (room != null) { this.room = room; } if (pipeDescription != null) { this.description = pipeDescription; } }
Example #15
Source File: IntegrationTestConfiguration.java From openvidu with Apache License 2.0 | 5 votes |
@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 #16
Source File: FixedNKmsManager.java From kurento-room with Apache License 2.0 | 5 votes |
public FixedNKmsManager(List<String> kmsWsUri, int kmsLoadLimit) { for (String uri : kmsWsUri) { Kms kms = new Kms(KurentoClient.create(uri), uri); kms.setLoadManager(new MaxWebRtcLoadManager(kmsLoadLimit)); this.addKms(kms); } }
Example #17
Source File: BaseMockedTest.java From openmeetings with Apache License 2.0 | 5 votes |
@Before public void setup() { MockitoAnnotations.initMocks(this); mockStatic(KurentoClient.class); mockStatic(WebSocketHelper.class); doReturn(kServerManager).when(client).getServerManager(); when(KurentoClient.create(nullable(String.class), any(KurentoConnectionListener.class))).thenReturn(client); doReturn(new TransactionImpl(romManager)).when(client).beginTransaction(); handler.init(); }
Example #18
Source File: FakeSession.java From kurento-room with Apache License 2.0 | 5 votes |
public void newParticipant(String name, String playerUri, boolean autoMedia, boolean loopMedia, KurentoClient kurento) { TestPipeline pipeline = getOrCreatePipeline(kurento); pipeline.createPipeline(); FakeParticipant participant = new FakeParticipant(serviceUrl, name, room, playerUri, pipeline.getPipeline(), autoMedia, loopMedia); participants.put(name, participant); participant.joinRoom(); }
Example #19
Source File: HelloWorldRecApp.java From kurento-tutorial-java with Apache License 2.0 | 4 votes |
@Bean public KurentoClient kurentoClient() { return KurentoClient.create(); }
Example #20
Source File: ChromaApp.java From kurento-tutorial-java with Apache License 2.0 | 4 votes |
@Bean public KurentoClient kurentoClient() { return KurentoClient.create(); }
Example #21
Source File: MagicMirrorApp.java From kurento-tutorial-java with Apache License 2.0 | 4 votes |
@Bean public KurentoClient kurentoClient() { return KurentoClient.create(); }
Example #22
Source File: CrowdDetectorApp.java From kurento-tutorial-java with Apache License 2.0 | 4 votes |
@Bean public KurentoClient kurentoClient() { return KurentoClient.create(); }
Example #23
Source File: Application.java From kurento-tutorial-java with Apache License 2.0 | 4 votes |
@Bean public KurentoClient kurentoClient() { return KurentoClient.create(); }
Example #24
Source File: One2OneCallAdvApp.java From kurento-tutorial-java with Apache License 2.0 | 4 votes |
@Bean public KurentoClient kurentoClient() { return KurentoClient.create(); }
Example #25
Source File: One2OneCallRecApp.java From kurento-tutorial-java with Apache License 2.0 | 4 votes |
@Bean public KurentoClient kurentoClient() { return KurentoClient.create(); }
Example #26
Source File: SendDataChannelApp.java From kurento-tutorial-java with Apache License 2.0 | 4 votes |
@Bean public KurentoClient kurentoClient() { return KurentoClient.create(); }
Example #27
Source File: ShowDataChannelApp.java From kurento-tutorial-java with Apache License 2.0 | 4 votes |
@Bean public KurentoClient kurentoClient() { return KurentoClient.create(); }
Example #28
Source File: Application.java From kurento-tutorial-java with Apache License 2.0 | 4 votes |
@Bean public KurentoClient kurentoClient() { return KurentoClient.create(); }
Example #29
Source File: HelloWorldRecApp.java From kurento-tutorial-java with Apache License 2.0 | 4 votes |
@Bean public KurentoClient kurentoClient() { return KurentoClient.create(); }
Example #30
Source File: One2OneCallApp.java From kurento-tutorial-java with Apache License 2.0 | 4 votes |
@Bean public KurentoClient kurentoClient() { return KurentoClient.create(); }