public synchronized void streamPublishStart(IBroadcastStream stream) {
try {
log.debug("----------- streamPublishStart");
IConnection current = Red5.getConnectionLocal();
String streamid = current.getClient().getId();
Client currentClient = this.sessionManager
.getClientByStreamId(streamid, null);
//We make a second object the has the reference to the object
//that we will use to send to all participents
Client clientObjectSendToSync = currentClient;
// Notify all the clients that the stream had been started
log.debug("start streamPublishStart broadcast start: "
+ stream.getPublishedName() + " CONN " + current);
// In case its a screen sharing we start a new Video for that
if (currentClient.getIsScreenClient()) {
currentClient.setScreenPublishStarted(true);
this.sessionManager.updateClientByStreamId(current
.getClient().getId(), currentClient, false, null);
}
//If its an audio/video client then send the session object with the full
//data to everybody
else if (currentClient.getIsAVClient()) {
clientObjectSendToSync = this.sessionManager.getClientByPublicSID(
currentClient.getPublicSID(), false, null);
}
log.debug("newStream SEND: "+currentClient);
// Notify all users of the same Scope
// We need to iterate through the streams to catch if anybody is recording
for (Set<IConnection> conset : current.getScope().getConnections()) {
for (IConnection conn : conset) {
if (conn != null) {
if (conn instanceof IServiceCapableConnection) {
Client rcl = this.sessionManager
.getClientByStreamId(conn.getClient()
.getId(), null);
if (rcl == null) {
log.debug("RCL IS NULL newStream SEND");
continue;
}
log.debug("check send to "+rcl);
if (rcl.getPublicSID() == "") {
log.debug("publicSID IS NULL newStream SEND");
continue;
}
if (rcl.getIsRecording()) {
log.debug("RCL getIsRecording newStream SEND");
flvRecorderService.addRecordingByStreamId(current, streamid, currentClient, rcl.getFlvRecordingId());
}
if (rcl.getIsAVClient()) {
log.debug("RCL getIsAVClient newStream SEND");
continue;
}
if (rcl.getIsScreenClient() == null || rcl.getIsScreenClient()) {
log.debug("RCL getIsScreenClient newStream SEND");
continue;
}
if (rcl.getPublicSID().equals(currentClient.getPublicSID())) {
log.debug("RCL publicSID is equal newStream SEND");
continue;
}
log.debug("RCL SEND is equal newStream SEND "+rcl.getPublicSID()+" || "+rcl.getUserport());
((IServiceCapableConnection) conn).invoke("newStream", new Object[] { clientObjectSendToSync }, this);
}
}