Revision: 2709
Author: seba.wagner
Date: Tue Nov 24 13:38:11 2009
Log: Part of screen share event handlers
http://code.google.com/p/openmeetings/source/detail?r=2709

Modified:
   
/trunk/singlewebapp/src/app/org/openmeetings/app/hibernate/beans/recording/RoomClient.java
   
/trunk/singlewebapp/src/app/org/openmeetings/app/remote/red5/ScopeApplicationAdapter.java
   
/trunk/singlewebapp/src/red5-screenshare/org/red5/screen/webstart/ScreenShare.java

=======================================
---  
/trunk/singlewebapp/src/app/org/openmeetings/app/hibernate/beans/recording/RoomClient.java
       
Mon Nov  9 10:19:46 2009
+++  
/trunk/singlewebapp/src/app/org/openmeetings/app/hibernate/beans/recording/RoomClient.java
       
Tue Nov 24 13:38:11 2009
@@ -26,6 +26,13 @@

        private String scope = "";

+       private int vWidth = 0;
+       private int vHeight = 0;
+       private int vX = 0;
+       private int vY = 0;
+
+       private String streamPublishName = "";
+
        /*
         * an unique PUBLIC id,
         * this ID is needed as people can reconnect and will get a new
@@ -50,6 +57,8 @@
        private Date connectedSince;
        private String formatedDate;

+       private Boolean isScreenClient = false;
+
        /*
         * the color of the user, only needed in 4x4 Conference, in these rooms 
 
each user has its own
         * color
@@ -565,5 +574,47 @@
        public void setIsSuperModerator(Boolean isSuperModerator) {
                this.isSuperModerator = isSuperModerator;
        }
+
+       public Boolean getIsScreenClient() {
+               return isScreenClient;
+       }
+       public void setIsScreenClient(Boolean isScreenClient) {
+               this.isScreenClient = isScreenClient;
+       }
+
+       public int getVWidth() {
+               return vWidth;
+       }
+       public void setVWidth(int width) {
+               vWidth = width;
+       }
+
+       public int getVHeight() {
+               return vHeight;
+       }
+       public void setVHeight(int height) {
+               vHeight = height;
+       }
+
+       public int getVX() {
+               return vX;
+       }
+       public void setVX(int vx) {
+               vX = vx;
+       }
+
+       public int getVY() {
+               return vY;
+       }
+       public void setVY(int vy) {
+               vY = vy;
+       }
+
+       public String getStreamPublishName() {
+               return streamPublishName;
+       }
+       public void setStreamPublishName(String streamPublishName) {
+               this.streamPublishName = streamPublishName;
+       }

  }
=======================================
---  
/trunk/singlewebapp/src/app/org/openmeetings/app/remote/red5/ScopeApplicationAdapter.java
        
Sat Nov 21 04:39:39 2009
+++  
/trunk/singlewebapp/src/app/org/openmeetings/app/remote/red5/ScopeApplicationAdapter.java
        
Tue Nov 24 13:38:11 2009
@@ -175,13 +175,18 @@
                        String streamId = client.getId();

                        log.debug("### Client connected to OpenMeetings, 
register Client  
StreamId: "
-                                       + streamId + " scope "+ room.getName());
+                                       + streamId + " scope "+ room.getName() 
);

                        //Set StreamId in Client
                        service.invoke("setId", new Object[] { streamId },this);

+                       String swfURL = "";
+                       if (conn.getConnectParams().get("swfUrl") != null) {
+                               swfURL = 
conn.getConnectParams().get("swfUrl").toString();
+                       }
+
                        RoomClient rcm = 
this.clientListManager.addClientListItem(streamId,  
room.getName(), conn.getRemotePort(),
-                                       conn.getRemoteAddress(),  
conn.getConnectParams().get("swfUrl").toString());
+                                       conn.getRemoteAddress(), swfURL);

                        //Log the User
                        
ConferenceLogDaoImpl.getInstance().addConferenceLog("ClientConnect",  
rcm.getUser_id(),
@@ -192,6 +197,37 @@
                }
                return true;
        }
+
+       public synchronized void setConnectionAsSharingClient(Map map) {
+               try {
+
+                       IConnection conn = Red5.getConnectionLocal();
+                       IServiceCapableConnection service = 
(IServiceCapableConnection) conn;
+
+                       log.debug("### setConnectionAsSharingClient: ");
+
+                       RoomClient rcl =  
this.clientListManager.getClientByStreamId(conn.getClient().getId());
+
+                       if (rcl != null) {
+                               rcl.setIsScreenClient(true);
+
+                               
rcl.setVX(Integer.parseInt(map.get("screenX").toString()));
+                               
rcl.setVY(Integer.parseInt(map.get("screenY").toString()));
+                               
rcl.setVWidth(Integer.parseInt(map.get("screenWidth").toString()));
+                               
rcl.setVHeight(Integer.parseInt(map.get("screenHeight").toString()));
+
+                               log.debug("screen  
x,y,width,height "+rcl.getVX()+" "+rcl.getVY()+" "+rcl.getVWidth()+" 
"+rcl.getVHeight());
+
+                                
this.clientListManager.updateClientByStreamId(conn.getClient().getId(),  
rcl);
+
+                       } else {
+                               throw new Exception("Could not find Screen 
Sharing  
Client "+conn.getClient().getId());
+                       }
+
+               } catch (Exception err){
+                       log.error("[setConnectionAsSharingClient]",err);
+               }
+       }

        /**
         * this function is invoked directly after initial connecting
@@ -236,6 +272,35 @@
                        IConnection current = Red5.getConnectionLocal();

                        RoomClient currentClient =  
this.clientListManager.getClientByStreamId(current.getClient().getId());
+
+                       //In case its a screen sharing we start a new Video for 
that
+                       if (currentClient.getIsScreenClient()) {
+
+                               log.debug("start streamPublishStart Is Screen 
Sharing -- Stop ");
+
+                               //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
+                                                                       
IServiceCapableConnection iStream = (IServiceCapableConnection)  
conn;
+                                                                       
//log.info("IServiceCapableConnection ID " +  
iStream.getClient().getId());
+                                                                       
iStream.invoke("stopRed5ScreenSharing",new Object[] {  
currentClient }, this);
+                                                                       
log.debug("send Notification to");
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+
+                       }

                        //The Room Client can be null if the Client left the 
room by using  
logicalRoomLeave
                        if (currentClient != null) {
@@ -400,32 +465,67 @@
                        // Notify all the clients that the stream had been 
started
                        log.debug("start streamPublishStart broadcast start: "+ 
 
stream.getPublishedName() + "CONN " + current);

-                       //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)){
-                                                               RoomClient rcl 
=  
this.clientListManager.getClientByStreamId(conn.getClient().getId());
-                                                               if 
(rcl.getIsRecording()){
-                                                                       
StreamService.addRecordingByStreamId(current, streamid,  
currentClient, rcl.getRoomRecordingName());
-                                                               }
-                                                               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
-                                                               
IServiceCapableConnection iStream = (IServiceCapableConnection)  
conn;
-                                                               
//log.info("IServiceCapableConnection ID " +  
iStream.getClient().getId());
-                                                               
iStream.invoke("newStream",new Object[] { currentClient }, this);
-                                                               if 
(rcl.getIsRecording()){
-                                                                       
StreamService.addRecordingByStreamId(current, streamid,  
currentClient, rcl.getRoomRecordingName());
+                       //In case its a screen sharing we start a new Video for 
that
+                       if (currentClient.getIsScreenClient()) {
+
+                               
currentClient.setStreamPublishName(stream.getPublishedName());
+
+                                
this.clientListManager.updateClientByStreamId(current.getClient().getId(),  
currentClient);
+
+                               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
+                                                                       
IServiceCapableConnection iStream = (IServiceCapableConnection)  
conn;
+                                                                       
//log.info("IServiceCapableConnection ID " +  
iStream.getClient().getId());
+                                                                       
iStream.invoke("newRed5ScreenSharing",new Object[] {  
currentClient }, this);
+                                                                       
log.debug("send Notification to");
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+
+                       } else {
+
+                               //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)){
+                                                                       
RoomClient rcl =  
this.clientListManager.getClientByStreamId(conn.getClient().getId());
+                                                                       if 
(rcl.getIsRecording()){
+                                                                               
StreamService.addRecordingByStreamId(current, streamid,  
currentClient, rcl.getRoomRecordingName());
+                                                                       }
+                                                                       
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
+                                                                       
IServiceCapableConnection iStream = (IServiceCapableConnection)  
conn;
+                                                                       
//log.info("IServiceCapableConnection ID " +  
iStream.getClient().getId());
+                                                                       
iStream.invoke("newStream",new Object[] { currentClient }, this);
+                                                                       if 
(rcl.getIsRecording()){
+                                                                               
StreamService.addRecordingByStreamId(current, streamid,  
currentClient, rcl.getRoomRecordingName());
+                                                                       }
                                                                }
                                                        }
                                                }
                                        }
                                }
+
                        }

                } catch (Exception err) {
@@ -626,6 +726,49 @@
                }
                return -1L;
        }
+
+       public void setNewCursorPosition(Object item) {
+               try {
+
+                       IConnection current = Red5.getConnectionLocal();
+                       String streamid = current.getClient().getId();
+                       RoomClient currentClient =  
this.clientListManager.getClientByStreamId(streamid);
+
+                       log.debug("[setNewCursorPosition]"+item);
+
+                       Map cursor = (Map) item;
+
+                       log.debug("[setNewCursorPosition 
x]"+cursor.get("cursor_x"));
+                       //log.debug("[setNewCursorPosition 
y]"+cursor.get("cursor_y"));
+                       //log.debug("[setNewCursorPosition 
publicSID]"+cursor.get("publicSID"));
+
+                       //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
+                                                               
IServiceCapableConnection iStream = (IServiceCapableConnection)  
conn;
+                                                               
//log.info("IServiceCapableConnection ID " +  
iStream.getClient().getId());
+                                                               
iStream.invoke("newRed5ScreenCursor",new Object[] { cursor },  
this);
+                                                               log.debug("send 
Notification to");
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+
+
+               } catch (Exception err) {
+                       log.error("[setNewCursorPosition]",err);
+               }
+       }

        public synchronized Long removeModerator(String publicSID) {
                try {
=======================================
---  
/trunk/singlewebapp/src/red5-screenshare/org/red5/screen/webstart/ScreenShare.java
       
Tue Nov 24 08:50:19 2009
+++  
/trunk/singlewebapp/src/red5-screenshare/org/red5/screen/webstart/ScreenShare.java
       
Tue Nov 24 13:38:11 2009
@@ -14,10 +14,13 @@
  import org.red5.io.flv.impl.Tag;
  import org.red5.io.IoConstants;
  import org.red5.io.utils.ObjectMap;
+import org.red5.server.api.IConnection;
+import org.red5.server.api.Red5;
  import org.red5.server.api.event.IEvent;
  import org.red5.server.api.event.IEventDispatcher;
  import org.red5.server.api.service.IPendingServiceCall;
  import org.red5.server.api.service.IPendingServiceCallback;
+import org.red5.server.api.service.IServiceCapableConnection;
  import org.red5.server.net.rtmp.Channel;
  import org.red5.server.net.rtmp.RTMPClient;
  import org.red5.server.net.rtmp.INetStreamEventHandler;
@@ -37,6 +40,9 @@
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;

+import java.awt.MouseInfo;
+import java.awt.Point;
+import java.awt.PointerInfo;
  import java.awt.Rectangle;
  import java.awt.Robot;
  import java.awt.image.BufferedImage;
@@ -169,8 +175,8 @@
        {
                try {

-                       UIManager.setLookAndFeel(new  
com.incors.plaf.kunststoff.KunststoffLookAndFeel());
-                       UIManager.getLookAndFeelDefaults().put( "ClassLoader",  
getClass().getClassLoader()  );
+                       //UIManager.setLookAndFeel(new  
com.incors.plaf.kunststoff.KunststoffLookAndFeel());
+                       //UIManager.getLookAndFeelDefaults().put( 
"ClassLoader",  
getClass().getClassLoader()  );

                        t = new JFrame("Desktop Publisher");
                        contentPane = t.getContentPane();
@@ -256,6 +262,51 @@
        {
                textWarningArea.setText(warning);
        }
+
+       synchronized public void sendCursorStatus() {
+               try {
+
+                       PointerInfo a = MouseInfo.getPointerInfo();
+                       Point mouseP = a.getLocation();
+
+                       Integer x = 
Long.valueOf(Math.round(mouseP.getX())).intValue();
+                       Integer y = 
Long.valueOf(Math.round(mouseP.getY())).intValue();
+
+                       HashMap cursorPosition = new HashMap();
+                       cursorPosition.put("publicSID",this.publishName);
+                       cursorPosition.put("cursor_x",x);
+                       cursorPosition.put("cursor_y",y);
+
+                       invoke("setNewCursorPosition",new Object[] { 
cursorPosition }, this);
+
+               } catch (Exception err) {
+                       System.out.println("captureScreenStart Exception: ");
+                       System.err.println(err);
+                       textArea.setText("Exception: "+err);
+                       logger.error("[sendCursorStatus]",err);
+               }
+       }
+
+       synchronized public void setConnectionAsSharingClient() {
+               try {
+
+                       logger.debug("setConnectionAsSharingClient" );
+
+                       HashMap map = new HashMap();
+                       map.put("screenX",VirtualScreenBean.vScreenSpinnerX);
+                       map.put("screenY",VirtualScreenBean.vScreenSpinnerY);
+                       
map.put("screenWidth",VirtualScreenBean.vScreenSpinnerWidth);
+                       
map.put("screenHeight",VirtualScreenBean.vScreenSpinnerHeight);
+
+                       invoke("setConnectionAsSharingClient",new Object[] { 
map }, this);
+
+               } catch (Exception err) {
+                       System.out.println("captureScreenStart Exception: ");
+                       System.err.println(err);
+                       textArea.setText("Exception: "+err);
+                       logger.error("[sendCursorStatus]",err);
+               }
+       }

        private void captureScreenStart()
        {
@@ -294,7 +345,7 @@


      public void startStream( String host, String app, int port, String  
publishName) {
-
+
          System.out.println( "ScreenShare startStream" );
          this.publishName = publishName;

@@ -359,36 +410,47 @@


      public void resultReceived( IPendingServiceCall call ) {
-
-        logger.debug( "service call result: " + call );
-
-        if ( "connect".equals( call.getServiceMethodName() ) )
-        {
-                       createStream( this );
-
-               } else {
-                       publishStreamId = (Integer) call.getResult();
-                       logger.debug( "createPublishStream result stream id: " 
+  
publishStreamId );
-                       logger.debug( "publishing video by name: " + 
publishName );
-                       publish( publishStreamId, publishName, "live", this );
-
-                       logger.debug( "setup capture thread");
-
-                       capture = new 
CaptureScreen(VirtualScreenBean.vScreenSpinnerX,
-                                                                               
VirtualScreenBean.vScreenSpinnerY,
-                                                                               
VirtualScreenBean.vScreenSpinnerWidth,
-                                                                               
VirtualScreenBean.vScreenSpinnerHeight);
-
-                       if (thread == null)
-                       {
-                               thread = new Thread(capture);
-                               thread.start();
-                       }
-                       capture.start();
-
-                       startButton.setEnabled(false);
-                       stopButton.setEnabled(true);
-        }
+       try {
+               logger.debug( "service call result: " + call );
+
+               if ( call.getServiceMethodName().equals("connect") ) {
+
+                       setConnectionAsSharingClient();
+
+               } else if  
(call.getServiceMethodName().equals("setConnectionAsSharingClient")) {
+
+                               logger.debug("call get Method Name 
"+call.getServiceMethodName());
+                               createStream( this );
+
+                       } else if 
(call.getServiceMethodName().equals("createStream")) {
+
+                               publishStreamId = (Integer) call.getResult();
+                               logger.debug( "createPublishStream result 
stream id: " +  
publishStreamId );
+                               logger.debug( "publishing video by name: " + 
publishName );
+                               publish( publishStreamId, publishName, "live", 
this );
+
+                               logger.debug( "setup capture thread");
+
+                               capture = new 
CaptureScreen(VirtualScreenBean.vScreenSpinnerX,
+                                                                               
        VirtualScreenBean.vScreenSpinnerY,
+                                                                               
        VirtualScreenBean.vScreenSpinnerWidth,
+                                                                               
        VirtualScreenBean.vScreenSpinnerHeight);
+
+                               if (thread == null)
+                               {
+                                       thread = new Thread(capture);
+                                       thread.start();
+                               }
+                               capture.start();
+
+                               startButton.setEnabled(false);
+                               stopButton.setEnabled(true);
+
+                       }
+
+       } catch (Exception err) {
+               logger.error("[resultReceived]",err);
+       }
      }


@@ -498,7 +560,7 @@
                        final int blockWidth = 32;
                        final int blockHeight = 32;

-                       final int timeBetweenFrames = 1000; //frameRate
+                       final int timeBetweenFrames = 750; //frameRate

                        int frameCounter = 0;

@@ -533,6 +595,8 @@

                                        final int spent = (int) 
(System.currentTimeMillis() - ctime);

+                                       sendCursorStatus();
+
                                        Thread.sleep(Math.max(0, 
timeBetweenFrames - spent));
                                }
                        }

--

You received this message because you are subscribed to the Google Groups 
"OpenMeetings developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/openmeetings-dev?hl=en.


Reply via email to