Author: solomax
Date: Sun Jan 19 18:36:40 2014
New Revision: 1559544

URL: http://svn.apache.org/r1559544
Log:
Interview recording is stopped correctly on client disconnect

Modified:
    
openmeetings/trunk/singlewebapp/src/main/java/org/apache/openmeetings/remote/red5/ScopeApplicationAdapter.java

Modified: 
openmeetings/trunk/singlewebapp/src/main/java/org/apache/openmeetings/remote/red5/ScopeApplicationAdapter.java
URL: 
http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/main/java/org/apache/openmeetings/remote/red5/ScopeApplicationAdapter.java?rev=1559544&r1=1559543&r2=1559544&view=diff
==============================================================================
--- 
openmeetings/trunk/singlewebapp/src/main/java/org/apache/openmeetings/remote/red5/ScopeApplicationAdapter.java
 (original)
+++ 
openmeetings/trunk/singlewebapp/src/main/java/org/apache/openmeetings/remote/red5/ScopeApplicationAdapter.java
 Sun Jan 19 18:36:40 2014
@@ -575,8 +575,7 @@ public class ScopeApplicationAdapter ext
 
                        // Remove User from Sync List's
                        if (room_id != null) {
-                               
this.whiteBoardService.removeUserFromAllLists(currentScope,
-                                               currentClient);
+                               
whiteBoardService.removeUserFromAllLists(currentScope, currentClient);
                        }
 
                        log.debug("removing USername " + 
currentClient.getUsername() + " "
@@ -586,14 +585,16 @@ public class ScopeApplicationAdapter ext
                        // stop and save any recordings
                        if (currentClient.getIsRecording()) {
                                log.debug("*** roomLeave Current Client is 
Recording - stop that");
-                               // StreamService.stopRecordAndSave(currentScope,
-                               // currentClient.getRoomRecordingName(), 
currentClient);
-
-                               
flvRecorderService.stopRecordAndSave(currentScope, currentClient, null);
+                               if (currentClient.getInterviewPodId() != null) {
+                                       //interview, TODO need better check
+                                       stopInterviewRecording();
+                               } else {
+                                       
flvRecorderService.stopRecordAndSave(currentScope, currentClient, null);
 
-                               // set to true and overwrite the default one 
cause otherwise no
-                               // notification is send
-                               currentClient.setIsRecording(true);
+                                       // set to true and overwrite the 
default one cause otherwise no
+                                       // notification is send
+                                       currentClient.setIsRecording(true);
+                               }
                        }
 
                        // Notify all clients of the same currentScope (room) 
with domain
@@ -2498,6 +2499,23 @@ public class ScopeApplicationAdapter ext
                }
                return null;
        }
+
+       private Long checkRecordingClient(IConnection conn) {
+               Long flvRecordingId = null;
+               if (conn != null) {
+                       Client rcl = 
sessionManager.getClientByStreamId(conn.getClient().getId(), null);
+                       if (rcl.getIsRecording() != null && 
rcl.getIsRecording()) {
+                               rcl.setIsRecording(false);
+                               flvRecordingId = rcl.getFlvRecordingId();
+                               rcl.setFlvRecordingId(null);
+
+                               // Reset the Recording Flag to Record all
+                               // Participants that enter later
+                               
sessionManager.updateClientByStreamId(conn.getClient().getId(), rcl, false, 
null);
+                       }
+               }
+               return flvRecordingId;
+       }
        
        /**
         * Stop the recording of the streams and send event to connected users 
of scope
@@ -2509,46 +2527,25 @@ public class ScopeApplicationAdapter ext
                        log.debug("-----------  stopInterviewRecording");
                        IConnection current = Red5.getConnectionLocal();
 
-                       boolean found = false;
-                       Long flvRecordingId = null;
+                       Long flvRecordingId = checkRecordingClient(current);
 
                        Collection<Set<IConnection>> concolset = 
current.getScope().getConnections();
                        for (Set<IConnection> conset : concolset) {
-                       for (IConnection conn : conset) {
-                               if (conn != null) {
-
-                                       Client rcl = this.sessionManager
-                                                       
.getClientByStreamId(conn.getClient().getId(), null);
-
-                                       if (rcl.getIsRecording() != null
-                                                       && 
rcl.getIsRecording()) {
-
-                                               rcl.setIsRecording(false);
-
-                                               flvRecordingId = 
rcl.getFlvRecordingId();
-
-                                               rcl.setFlvRecordingId(null);
-
-                                               // Reset the Recording Flag to 
Record all
-                                               // Participants that enter later
-                                               
this.sessionManager.updateClientByStreamId(conn
-                                                               
.getClient().getId(), rcl, false, null);
-
-                                               found = true;
+                               for (IConnection conn : conset) {
+                                       Long recordingId = 
checkRecordingClient(conn);
+                                       if (recordingId != null) {
+                                               flvRecordingId = recordingId;
                                        }
-
                                }
                        }
-                       }
-                       if (!found) {
+                       if (flvRecordingId == null) {
+                               log.debug("stopInterviewRecording:: unable to 
find recording client");
                                return false;
                        }
 
-                       Client currentClient = this.sessionManager
-                                       
.getClientByStreamId(current.getClient().getId(), null);
+                       Client currentClient = 
sessionManager.getClientByStreamId(current.getClient().getId(), null);
 
-                       this.flvRecorderService.stopRecordAndSave(scope, 
currentClient,
-                                       flvRecordingId);
+                       flvRecorderService.stopRecordAndSave(scope, 
currentClient, flvRecordingId);
 
                        Map<String, String> interviewStatus = new 
HashMap<String, String>();
                        interviewStatus.put("action", "stop");


Reply via email to