}
public synchronized Map setConnectionAsSharingClient(Map map) {
try {
IConnection current = Red5.getConnectionLocal();
//IServiceCapableConnection service = (IServiceCapableConnection) current;
log.debug("### setConnectionAsSharingClient: ");
RoomClient currentClient = this.clientListManager.getClientByStreamId(current.getClient().getId());
if (currentClient != null) {
boolean startRecording = Boolean.valueOf(map.get("startRecording").toString());
boolean startStreaming = Boolean.valueOf(map.get("startStreaming").toString());
currentClient.setRoom_id(Long.parseLong(current.getScope().getName()));
//Set this connection to be a RTMP-Java Client
currentClient.setIsScreenClient(true);
currentClient.setUser_id(Long.parseLong(map.get("user_id").toString()));
if (startStreaming) {
currentClient.setStartStreaming(true);
}
if (startRecording) {
currentClient.setStartRecording(true);
}
currentClient.setOrganization_id(Long.parseLong(map.get("organization_id").toString()));
this.clientListManager.updateClientByStreamId(current.getClient().getId(), currentClient);
Map returnMap = new HashMap();
returnMap.put("alreadyPublished", false);
//if is already started screen sharing, then there is no need to start it again
if (currentClient.getScreenPublishStarted() != null && currentClient.getScreenPublishStarted()) {
returnMap.put("alreadyPublished", true);
}
currentClient.setVX(Integer.parseInt(map.get("screenX").toString()));
currentClient.setVY(Integer.parseInt(map.get("screenY").toString()));
currentClient.setVWidth(Integer.parseInt(map.get("screenWidth").toString()));
currentClient.setVHeight(Integer.parseInt(map.get("screenHeight").toString()));
log.debug("screen x,y,width,height "+currentClient.getVX()+" "+currentClient.getVY()+" "+currentClient.getVWidth()+" "+currentClient.getVHeight());
log.debug("publishName :: "+map.get("publishName"));
currentClient.setStreamPublishName(map.get("publishName").toString());
RoomClient currentScreenUser = this.clientListManager.getClientByPublicSID(currentClient.getStreamPublishName());
currentClient.setFirstname(currentScreenUser.getFirstname());
currentClient.setLastname(currentScreenUser.getLastname());
//This is duplicated, but its not sure that in the meantime somebody requests this Client Object Info
this.clientListManager.updateClientByStreamId(current.getClient().getId(), currentClient);
if (startStreaming) {
returnMap.put("modus", "startStreaming");
log.debug("start streamPublishStart Is Screen Sharing ");
//Notify all users of the same Scope
Collection<Set<IConnection>> conCollection = current.getScope().getConnections();
for (Set<IConnection> conset : conCollection) {
for (IConnection conn : conset) {
if (conn != null) {
if (conn instanceof IServiceCapableConnection) {
if (conn.equals(current)){
continue;
} else {
RoomClient rcl = this.clientListManager.getClientByStreamId(conn.getClient().getId());
//log.debug("is this users still alive? :"+rcl);
//Check if the Client is in the same room and same domain
if (rcl == null) {
//continue;
} else if (rcl.getIsScreenClient() != null && rcl.getIsScreenClient()) {
//continue;
} else {
IServiceCapableConnection iStream = (IServiceCapableConnection) conn;
//log.info("IServiceCapableConnection ID " + iStream.getClient().getId());
iStream.invoke("newRed5ScreenSharing",new Object[] { currentClient }, this);
log.debug("send Notification to");
}
}
}
}
}
}
}
if (startRecording) {
returnMap.put("modus", "startRecording");
String recordingName = "Recording "+CalendarPatterns.getDateWithTimeByMiliSeconds(new Date());
this.flvRecorderService.recordMeetingStream( recordingName, "" ,false);
}
return returnMap;
} else {
throw new Exception("Could not find Screen Sharing Client "+current.getClient().getId());
}
} catch (Exception err){
log.error("[setConnectionAsSharingClient]",err);
}