public synchronized Map setConnectionAsSharingClient(Map map) {
try {
log.debug("----------- setConnectionAsSharingClient");
IConnection current = Red5.getConnectionLocal();
Client currentClient = sessionManager.getClientByStreamId(current.getClient().getId(), null);
if (currentClient != null) {
boolean startRecording = Boolean.valueOf("" + map.get("startRecording"));
boolean startStreaming = Boolean.valueOf("" + map.get("startStreaming"));
boolean startPublishing = Boolean.valueOf("" + map.get("startPublishing"))
&& (0 == sessionManager.getPublishingCount(currentClient.getRoom_id()));
currentClient.setRoom_id(Long.parseLong(current.getScope().getName()));
// Set this connection to be a RTMP-Java Client
currentClient.setIsScreenClient(true);
SessionVariablesUtil.setIsScreenClient(current.getClient());
currentClient.setUser_id(Long.parseLong(map.get("user_id").toString()));
SessionVariablesUtil.setUserId(current.getClient(), Long.parseLong(map.get("user_id").toString()));
boolean alreadyStreaming = currentClient.isStartStreaming();
if (startStreaming) {
currentClient.setStartStreaming(true);
}
boolean alreadyRecording = currentClient.isStartRecording();
if (startRecording) {
currentClient.setStartRecording(true);
}
if (startPublishing) {
currentClient.setStreamPublishStarted(true);
}
currentClient.setOrganization_id(Long.parseLong(map.get("organization_id").toString()));
sessionManager.updateClientByStreamId(current.getClient().getId(), currentClient, false, null);
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.isScreenPublishStarted()) {
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());
Client currentScreenUser = sessionManager.getClientByPublicSID(currentClient.getStreamPublishName(), false, null);
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
sessionManager.updateClientByStreamId(current.getClient().getId(), currentClient, false, null);