--
You received this message because you are subscribed to the Google Groups "kurento" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kurento+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Luis,it's interesting to read about your good experience with videos using 300Kbps of upload link. Just for curiosity: which hosting provider have you used?
I'll run tutorial 3 again and collect the Chrome statistics with slow videos.
Your investigation about Kurento running on EC2 will be very valuable.
--
You received this message because you are subscribed to a topic in the Google Groups "kurento" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kurento/edxdtUDovyc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kurento+u...@googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "kurento" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kurento/edxdtUDovyc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kurento+u...@googlegroups.com.
private void setBandwidth(String sdp) {
sdp = sdp.replace(/a=mid:audio\r\n/g, 'a=mid:audio\r\nb=AS:50\r\n');
sdp = sdp.replace(/a=mid:video\r\n/g, 'a=mid:video\r\nb=AS:400\r\n');
return sdp;
}/*
* (C) Copyright 2014 Kurento (http://kurento.org/)
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser General Public License
* (LGPL) version 2.1 which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-2.1.html
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*/
package org.kurento.tutorial.one2manycall;
import java.io.IOException;
import java.util.concurrent.ConcurrentHashMap;
import org.kurento.client.MediaPipeline;
import org.kurento.client.WebRtcEndpoint;
import org.kurento.client.factory.KurentoClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.handler.TextWebSocketHandler;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
/**
* Protocol handler for 1 to N video call communication.
*
* @author Boni Garcia (bga...@gsyc.es)
* @since 5.0.0
*/
public class CallHandler extends TextWebSocketHandler {
private static final Logger log = LoggerFactory
.getLogger(CallHandler.class);
private static final Gson gson = new GsonBuilder().create();
private ConcurrentHashMap<String, UserSession> viewers = new ConcurrentHashMap<String, UserSession>();
@Autowired
private KurentoClient kurento;
private MediaPipeline pipeline;
private UserSession masterUserSession;
private String limitBandwidth(String sdp) {
String sep = "\\r\\n";
String audioMark = "a=mid:audio";
String videoMark = "a=mid:video";
return sdp
.replace(audioMark, audioMark + sep + "b=AS:50")
.replace(videoMark, videoMark + sep + "b=AS:300");
}
@Override
public void handleTextMessage(WebSocketSession session, TextMessage message)
throws Exception {
JsonObject jsonMessage = gson.fromJson(message.getPayload(),
JsonObject.class);
log.debug("Incoming message from session '{}': {}", session.getId(),
jsonMessage);
switch (jsonMessage.get("id").getAsString()) {
case "master":
try {
master(session, jsonMessage);
} catch (Throwable t) {
stop(session);
log.error(t.getMessage(), t);
JsonObject response = new JsonObject();
response.addProperty("id", "masterResponse");
response.addProperty("response", "rejected");
response.addProperty("message", t.getMessage());
session.sendMessage(new TextMessage(response.toString()));
}
break;
case "viewer":
try {
viewer(session, jsonMessage);
} catch (Throwable t) {
stop(session);
log.error(t.getMessage(), t);
JsonObject response = new JsonObject();
response.addProperty("id", "viewerResponse");
response.addProperty("response", "rejected");
response.addProperty("message", t.getMessage());
session.sendMessage(new TextMessage(response.toString()));
}
break;
case "stop":
stop(session);
break;
default:
break;
}
}
private synchronized void master(WebSocketSession session,
JsonObject jsonMessage) throws IOException {
if (masterUserSession == null) {
masterUserSession = new UserSession(session);
pipeline = kurento.createMediaPipeline();
masterUserSession.setWebRtcEndpoint(new WebRtcEndpoint.Builder(
pipeline).build());
WebRtcEndpoint masterWebRtc = masterUserSession.getWebRtcEndpoint();
String sdpOffer = jsonMessage.getAsJsonPrimitive("sdpOffer")
.getAsString();
String sdpAnswer = masterWebRtc.processOffer(limitBandwidth(sdpOffer));
JsonObject response = new JsonObject();
response.addProperty("id", "masterResponse");
response.addProperty("response", "accepted");
response.addProperty("sdpAnswer", limitBandwidth(sdpAnswer));
masterUserSession.sendMessage(response);
} else {
JsonObject response = new JsonObject();
response.addProperty("id", "masterResponse");
response.addProperty("response", "rejected");
response.addProperty("message",
"Another user is currently acting as sender. Try again later ...");
session.sendMessage(new TextMessage(response.toString()));
}
}
private synchronized void viewer(WebSocketSession session,
JsonObject jsonMessage) throws IOException {
if (masterUserSession == null
|| masterUserSession.getWebRtcEndpoint() == null) {
JsonObject response = new JsonObject();
response.addProperty("id", "viewerResponse");
response.addProperty("response", "rejected");
response.addProperty("message",
"No active sender now. Become sender or . Try again later ...");
session.sendMessage(new TextMessage(response.toString()));
} else {
if (viewers.containsKey(session.getId())) {
JsonObject response = new JsonObject();
response.addProperty("id", "viewerResponse");
response.addProperty("response", "rejected");
response.addProperty(
"message",
"You are already viewing in this session. Use a different browser to add additional viewers.");
session.sendMessage(new TextMessage(response.toString()));
return;
}
UserSession viewer = new UserSession(session);
viewers.put(session.getId(), viewer);
String sdpOffer = jsonMessage.getAsJsonPrimitive("sdpOffer")
.getAsString();
WebRtcEndpoint nextWebRtc = new WebRtcEndpoint.Builder(pipeline)
.build();
viewer.setWebRtcEndpoint(nextWebRtc);
masterUserSession.getWebRtcEndpoint().connect(nextWebRtc);
String sdpAnswer = nextWebRtc.processOffer(limitBandwidth(sdpOffer));
JsonObject response = new JsonObject();
response.addProperty("id", "viewerResponse");
response.addProperty("response", "accepted");
response.addProperty("sdpAnswer", limitBandwidth(sdpAnswer));
viewer.sendMessage(response);
}
}
private synchronized void stop(WebSocketSession session) throws IOException {
String sessionId = session.getId();
if (masterUserSession != null
&& masterUserSession.getSession().getId().equals(sessionId)) {
for (UserSession viewer : viewers.values()) {
JsonObject response = new JsonObject();
response.addProperty("id", "stopCommunication");
viewer.sendMessage(response);
}
log.info("Releasing media pipeline");
if (pipeline != null) {
pipeline.release();
}
pipeline = null;
masterUserSession = null;
} else if (viewers.containsKey(sessionId)) {
if (viewers.get(sessionId).getWebRtcEndpoint() != null) {
viewers.get(sessionId).getWebRtcEndpoint().release();
}
viewers.remove(sessionId);
}
}
@Override
public void afterConnectionClosed(WebSocketSession session,
CloseStatus status) throws Exception {
stop(session);
}
}...
viewers.put(session<span style="color:#6
...