You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openmeetings.apache.org by so...@apache.org on 2018/03/23 07:31:15 UTC
[openmeetings] branch master updated: [OPENMEETINGS-1854] video
testing functionality seems to be implemented
This is an automated email from the ASF dual-hosted git repository.
solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openmeetings.git
The following commit(s) were added to refs/heads/master by this push:
new 7a28ed6 [OPENMEETINGS-1854] video testing functionality seems to be implemented
7a28ed6 is described below
commit 7a28ed6a9136a2073b576aab2b62b88d6c6410c7
Author: Maxim Solodovnik <so...@gmail.com>
AuthorDate: Fri Mar 23 14:31:06 2018 +0700
[OPENMEETINGS-1854] video testing functionality seems to be implemented
---
.../apache/openmeetings/core/remote/IKUser.java | 23 ++++++
.../org/apache/openmeetings/core/remote/KRoom.java | 36 ++++-----
.../apache/openmeetings/core/remote/KTestUser.java | 42 +++++++++-
.../org/apache/openmeetings/core/remote/KUser.java | 31 ++++----
.../openmeetings/core/remote/KurentoHandler.java | 34 ++++++--
.../openmeetings/web/common/OmWebSocketPanel.java | 1 +
.../apache/openmeetings/web/room/settings-base.js | 90 +++++++++++-----------
.../apache/openmeetings/web/room/video-manager.js | 4 +-
8 files changed, 173 insertions(+), 88 deletions(-)
diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/IKUser.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/IKUser.java
new file mode 100644
index 0000000..516af37
--- /dev/null
+++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/IKUser.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") + you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openmeetings.core.remote;
+
+public interface IKUser {
+ void release();
+}
diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KRoom.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KRoom.java
index 87060da..360733c 100644
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KRoom.java
+++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KRoom.java
@@ -1,20 +1,24 @@
/*
* (C) Copyright 2014 Kurento (http://kurento.org/)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ */
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") + you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.openmeetings.core.remote;
import static org.apache.openmeetings.core.remote.KurentoHandler.newKurentoMsg;
@@ -56,11 +60,6 @@ public class KRoom implements Closeable {
log.info("ROOM {} has been created", roomId);
}
- @PreDestroy
- private void shutdown() {
- this.close();
- }
-
public KUser addUser(final KurentoHandler h, String uid) {
log.info("ROOM {}: adding participant {}", roomId, uid);
final KUser u = new KUser(h, uid, this.roomId, this.pipeline);
@@ -78,7 +77,7 @@ public class KRoom implements Closeable {
public void leave(final KurentoHandler h, KUser user) {
log.debug("PARTICIPANT {}: Leaving room {}", user.getUid(), this.roomId);
this.removeParticipant(h, user.getUid());
- user.close();
+ user.release();
}
private void removeParticipant(final KurentoHandler h, String name) {
@@ -112,10 +111,11 @@ public class KRoom implements Closeable {
return participants.values();
}
+ @PreDestroy
@Override
public void close() {
for (final KUser user : participants.values()) {
- user.close();
+ user.release();
}
participants.clear();
diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KTestUser.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KTestUser.java
index d9d086d..56ff5d3 100644
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KTestUser.java
+++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KTestUser.java
@@ -19,6 +19,7 @@
package org.apache.openmeetings.core.remote;
import static org.apache.openmeetings.core.remote.KurentoHandler.newTestKurentoMsg;
+import static org.apache.openmeetings.core.remote.KurentoHandler.sendError;
import static org.apache.openmeetings.util.OmFileHelper.TEST_SETUP_PREFIX;
import static org.apache.openmeetings.util.OmFileHelper.getStreamsDir;
@@ -50,10 +51,12 @@ import org.slf4j.LoggerFactory;
import com.github.openjson.JSONObject;
-public class KTestUser {
+public class KTestUser implements IKUser {
private final static Logger log = LoggerFactory.getLogger(KTestUser.class);
private MediaPipeline pipeline;
private WebRtcEndpoint webRtcEndpoint;
+ private PlayerEndpoint player;
+ private RecorderEndpoint recorder;
private String recPath = null;
private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
private ScheduledFuture<?> recHandle;
@@ -67,7 +70,7 @@ public class KTestUser {
MediaProfileSpecType profile = getProfile(msg);
//FIXME TODO generated file uid
initRecPath(_c.getUid());
- final RecorderEndpoint recorder = new RecorderEndpoint.Builder(pipeline, recPath)
+ recorder = new RecorderEndpoint.Builder(pipeline, recPath)
.stopOnEndOfStream()
.withMediaProfile(profile).build();
@@ -126,6 +129,7 @@ public class KTestUser {
@Override
public void onError(Throwable cause) throws Exception {
+ sendError(_c, "Failed to start recording");
log.error("Failed to start recording", cause);
}
});
@@ -135,7 +139,7 @@ public class KTestUser {
// 1. Media logic
this.pipeline = pipeline;
webRtcEndpoint = new WebRtcEndpoint.Builder(pipeline).build();
- PlayerEndpoint player = new PlayerEndpoint.Builder(pipeline, recPath).build();
+ player = new PlayerEndpoint.Builder(pipeline, recPath).build();
player.connect(webRtcEndpoint);
// Player listeners
@@ -220,7 +224,9 @@ public class KTestUser {
}
}
+ @Override
public void release() {
+ //TODO improve this
pipeline.release(new Continuation<Void>() {
@Override
public void onSuccess(Void result) throws Exception {
@@ -234,6 +240,36 @@ public class KTestUser {
cleanup();
}
});
+ if (player != null) {
+ player.release(new Continuation<Void>() {
+ @Override
+ public void onSuccess(Void result) throws Exception {
+ log.info("Pipeline released successfully");
+ player = null;
+ }
+
+ @Override
+ public void onError(Throwable cause) throws Exception {
+ log.info("Error releasing pipeline ", cause);
+ player = null;
+ }
+ });
+ }
+ if (recorder != null) {
+ recorder.release(new Continuation<Void>() {
+ @Override
+ public void onSuccess(Void result) throws Exception {
+ log.info("Pipeline released successfully");
+ recorder = null;
+ }
+
+ @Override
+ public void onError(Throwable cause) throws Exception {
+ log.info("Error releasing pipeline ", cause);
+ recorder = null;
+ }
+ });
+ }
}
private void cleanup() {
diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KUser.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KUser.java
index 7a3b4cb..43f2150 100644
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KUser.java
+++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KUser.java
@@ -1,25 +1,28 @@
/*
* (C) Copyright 2014 Kurento (http://kurento.org/)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ */
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") + you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.openmeetings.core.remote;
import static org.apache.openmeetings.core.remote.KurentoHandler.newKurentoMsg;
-import java.io.Closeable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -42,7 +45,7 @@ import com.github.openjson.JSONObject;
* @author Ivan Gracia (izanmail@gmail.com)
* @since 4.3.1
*/
-public class KUser implements Closeable {
+public class KUser implements IKUser {
private static final Logger log = LoggerFactory.getLogger(KUser.class);
private final String uid;
@@ -175,7 +178,7 @@ public class KUser implements Closeable {
}
@Override
- public void close() {
+ public void release() {
log.debug("PARTICIPANT {}: Releasing resources", this.uid);
for (final String remoteParticipantName : incomingMedia.keySet()) {
diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KurentoHandler.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KurentoHandler.java
index 52750e5..ff46705 100644
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KurentoHandler.java
+++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/KurentoHandler.java
@@ -62,11 +62,15 @@ public class KurentoHandler {
@PreDestroy
private void destroy() {
if (client != null) {
- destroy();
+ client.destroy();
}
}
public void onMessage(IWsClient _c, JSONObject msg) {
+ if (client == null) {
+ sendError(_c, "Multimedia server is inaccessible");
+ return;
+ }
final String cmdId = msg.getString("id");
if ("test".equals(msg.optString("mode"))) {
KTestUser user = getTestByUid(_c.getUid());
@@ -145,6 +149,26 @@ public class KurentoHandler {
WebSocketHelper.sendClient(clientManager.get(uid), msg);
}
+ public static void sendError(IWsClient c, String msg) {
+ WebSocketHelper.sendClient(c, newKurentoMsg()
+ .put("id", "error")
+ .put("message", msg));
+ }
+
+ public void remove(IWsClient c) {
+ final String uid = c.getUid();
+ final boolean test = !(c instanceof Client);
+ IKUser u = test ? getTestByUid(uid) : getByUid(uid);
+ if (u != null) {
+ u.release();
+ if (test) {
+ testsByUid.remove(uid);
+ } else {
+ usersByUid.remove(uid);
+ }
+ }
+ }
+
/**
* Looks for a room in the active room list.
*
@@ -178,18 +202,14 @@ public class KurentoHandler {
log.info("Room {} removed and closed", room.getRoomId());
}
- public KUser getByUid(String uid) {
+ private KUser getByUid(String uid) {
return uid == null ? null : usersByUid.get(uid);
}
- public KTestUser getTestByUid(String uid) {
+ private KTestUser getTestByUid(String uid) {
return uid == null ? null : testsByUid.get(uid);
}
- public boolean exists(String name) {
- return usersByUid.keySet().contains(name);
- }
-
static JSONObject newKurentoMsg() {
return new JSONObject().put("type", KURENTO_TYPE);
}
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/OmWebSocketPanel.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/OmWebSocketPanel.java
index 3f6871c..fb72f0b 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/OmWebSocketPanel.java
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/OmWebSocketPanel.java
@@ -144,6 +144,7 @@ public abstract class OmWebSocketPanel extends Panel {
protected void closeHandler(AbstractClientMessage msg) {
log.debug("WebSocketBehavior::closeHandler {}", msg);
+ kHandler.remove(getWsClient());
}
/**
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/settings-base.js b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/settings-base.js
index 816ddfe..eab8c49 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/settings-base.js
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/settings-base.js
@@ -123,10 +123,7 @@ var VideoSettings = (function() {
.button({icon: "ui-icon-bullet"})
.click(function() {
recBtn.prop('disabled', true).button('refresh');
- playBtn.prop('disabled', true).button('refresh');
- cam.prop('disabled', true);
- mic.prop('disabled', true);
- res.prop('disabled', true);
+ _setEnabled(true);
OmUtil.info('Invoking SDP offer callback function');
const cnts = _constraints();
@@ -142,10 +139,7 @@ var VideoSettings = (function() {
.button({icon: "ui-icon-play"})
.click(function() {
recBtn.prop('disabled', true).button('refresh');
- playBtn.prop('disabled', true).button('refresh');
- cam.prop('disabled', true);
- mic.prop('disabled', true);
- res.prop('disabled', true);
+ _setEnabled(true);
_clear();
rtcPeer = new kurentoUtils.WebRtcPeer.WebRtcPeerRecvonly(
{
@@ -362,12 +356,15 @@ var VideoSettings = (function() {
_load();
_initDevices();
}
+ function _setEnabled(enabled) {
+ playBtn.prop('disabled', enabled).button('refresh');
+ cam.prop('disabled', enabled);
+ mic.prop('disabled', enabled);
+ res.prop('disabled', enabled);
+ }
function _onStop() {
_updateRec();
- playBtn.prop('disabled', false).button('refresh');
- cam.prop('disabled', false);
- mic.prop('disabled', false);
- res.prop('disabled', false);
+ _setEnabled(false);
}
//FIXME TODO, try to unify this
function _onWsMessage(jqEvent, msg) {
@@ -376,43 +373,50 @@ var VideoSettings = (function() {
return; //ping
}
const m = jQuery.parseJSON(msg);
- if (m && 'kurento' === m.type && 'test' === m.mode) {
- OmUtil.info('Received message: ', m);
+ if (m && 'kurento' === m.type) {
+ if ('test' === m.mode) {
+ OmUtil.info('Received message: ', m);
+ switch (m.id) {
+ case 'playResponse':
+ case 'startResponse':
+ OmUtil.log('SDP answer received from server. Processing ...');
+ rtcPeer.processAnswer(m.sdpAnswer, function(error) {
+ if (error) {
+ return OmUtil.error(error);
+ }
+ });
+ break;
+ case 'iceCandidate':
+ rtcPeer.addIceCandidate(m.candidate, function(error) {
+ if (error) {
+ return OmUtil.error('Error adding candidate: ' + error);
+ }
+ });
+ break;
+ case 'recording':
+ timer.show().find('.time').text(m.time);
+ break;
+ case 'recStopped':
+ timer.hide();
+ _onStop()
+ break;
+ case 'playStopped':
+ _onStop();
+ _readValues();
+ break;
+ default:
+ // no-op
+ }
+ }
switch (m.id) {
- case 'playResponse':
- case 'startResponse':
- OmUtil.log('SDP answer received from server. Processing ...');
-
- rtcPeer.processAnswer(m.sdpAnswer, function(error) {
- if (error) {
- return OmUtil.error(error);
- }
- });
- break;
- case 'iceCandidate':
- rtcPeer.addIceCandidate(m.candidate, function(error) {
- if (error) {
- return OmUtil.error('Error adding candidate: ' + error);
- }
- });
- break;
- case 'recording':
- timer.show().find('.time').text(m.time);
- break;
- case 'recStopped':
- timer.hide();
- _onStop()
- break;
- case 'playStopped':
- _onStop();
- _readValues();
+ case 'error':
+ OmUtil.error(m.message);
break;
default:
- OmUtil.error('Unrecognized message: ' + msg);
+ //no-op
}
}
} catch (err) {
- //no-op
OmUtil.error(err);
}
}
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/video-manager.js b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/video-manager.js
index 548e619..b5c6af3 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/video-manager.js
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/video-manager.js
@@ -74,7 +74,6 @@ var VideoManager = (function() {
const m = jQuery.parseJSON(msg);
if (m && 'kurento' === m.type && 'test' !== m.mode) {
OmUtil.info('Received message: ' + m);
-
switch (m.id) {
case 'broadcast':
onBroadcast(m);
@@ -96,11 +95,10 @@ var VideoManager = (function() {
}
break;
default:
- OmUtil.error('Unrecognized message ' + msg);
+ //no-op
}
}
} catch (err) {
- //no-op
OmUtil.error(err);
}
}
--
To stop receiving notification emails like this one, please contact
solomax@apache.org.