diff --git a/bigbluebutton-client/html-template/bbb-deskshare-applet-0.64.jar b/bigbluebutton-client/html-template/bbb-deskshare-applet-0.64.jar index 4797cf81576ba9212e9b11cf6a542ee02c6d7f05..4b35cb84124e6dcb54a6694fe24177b08fbae014 100644 Binary files a/bigbluebutton-client/html-template/bbb-deskshare-applet-0.64.jar and b/bigbluebutton-client/html-template/bbb-deskshare-applet-0.64.jar differ diff --git a/deskshare/applet/src/main/java/org/bigbluebutton/deskshare/client/DeskShareApplet.java b/deskshare/applet/src/main/java/org/bigbluebutton/deskshare/client/DeskShareApplet.java index 2f04f67e058aa3872f99974e365ac5dfeb2fdf00..13bd68bef7e05d2ad9f71d64e6a128198d6e286a 100755 --- a/deskshare/applet/src/main/java/org/bigbluebutton/deskshare/client/DeskShareApplet.java +++ b/deskshare/applet/src/main/java/org/bigbluebutton/deskshare/client/DeskShareApplet.java @@ -35,6 +35,7 @@ public class DeskShareApplet extends Applet implements ClientListener { Integer sWidthValue = new Integer(800); Integer sHeightValue = new Integer(600); Boolean qualityValue = false; + Boolean aspectRatioValue = false; Integer xValue = new Integer(0); Integer yValue = new Integer(0); Boolean tunnelValue = true; @@ -59,6 +60,9 @@ public class DeskShareApplet extends Applet implements ClientListener { String qualityCapture = getParameter("SCALE_WITH_QUALITY"); if (qualityCapture != null) qualityValue = Boolean.parseBoolean(qualityCapture); + String aspectRatio = getParameter("MAINTAIN_ASPECT_RATIO"); + if (aspectRatio != null) aspectRatioValue = Boolean.parseBoolean(aspectRatio); + String tunnel = getParameter("HTTP_TUNNEL"); if (tunnel != null) tunnelValue = Boolean.parseBoolean(tunnel); icon = getImage(getCodeBase(), "bbb.gif"); @@ -68,7 +72,8 @@ public class DeskShareApplet extends Applet implements ClientListener { System.out.println("Start"); client = new DeskshareClient.Builder().host(hostValue).port(portValue) .room(roomValue).captureWidth(cWidthValue) - .captureHeight(cHeightValue).scaleWidth(sWidthValue).scaleHeight(sHeightValue).quality(qualityValue) + .captureHeight(cHeightValue).scaleWidth(sWidthValue).scaleHeight(sHeightValue) + .quality(qualityValue).aspectRatio(aspectRatioValue) .x(xValue).y(yValue) .httpTunnel(tunnelValue).trayIcon(icon).enableTrayIconActions(true).build(); client.start(); diff --git a/deskshare/applet/src/main/java/org/bigbluebutton/deskshare/client/DeskshareClient.java b/deskshare/applet/src/main/java/org/bigbluebutton/deskshare/client/DeskshareClient.java index d181021080f57145b2b36363158742fa2950c303..18a181850c4ad3098e4097be7009be69b6eaf19b 100755 --- a/deskshare/applet/src/main/java/org/bigbluebutton/deskshare/client/DeskshareClient.java +++ b/deskshare/applet/src/main/java/org/bigbluebutton/deskshare/client/DeskshareClient.java @@ -45,6 +45,7 @@ class DeskshareClient implements IScreenCaptureListener, ChangedBlocksListener, private int scaleWidth; private int scaleHeight; private boolean quality; + private boolean aspectRatio; private int x; private int y; private boolean httpTunnel; @@ -72,10 +73,18 @@ class DeskshareClient implements IScreenCaptureListener, ChangedBlocksListener, } private void startCapture() { + if (aspectRatio) { + recalculateScaleDimensionsToMaintainAspectRatio(); +// System.out.println("[" + scaleWidth + "x" + scaleHeight + "]"); + } + capture = new ScreenCapture(x, y, captureWidth, captureHeight, scaleWidth, scaleHeight, quality); captureTaker = new ScreenCaptureTaker(capture); - mTaker = new MouseLocationTaker(); + mTaker = new MouseLocationTaker(captureWidth, captureHeight, scaleWidth, scaleHeight); + // Use the scaleWidth and scaleHeight as the dimension we pass to the BlockManager. + // If there is no scaling required, the scaleWidth and scaleHeight will be the same as + // captureWidth and captureHeight (ritzalam 05/27/2010) Dimension screenDim = new Dimension(scaleWidth, scaleHeight); Dimension tileDim = new Dimension(blockWidth, blockHeight); blockManager = new BlockManager(); @@ -101,7 +110,17 @@ class DeskshareClient implements IScreenCaptureListener, ChangedBlocksListener, notifyListener(ExitCode.DESKSHARE_SERVICE_UNAVAILABLE); } } - + + private void recalculateScaleDimensionsToMaintainAspectRatio() { + if (captureWidth < captureHeight) { + double ratio = (double)captureHeight/(double)captureWidth; + scaleHeight = (int)((double)scaleWidth * ratio); + } else { + double ratio = (double)captureWidth/(double)captureHeight; + scaleWidth = (int)((double)scaleHeight * ratio); + } + } + /** * This method is called when the user closes the browser window containing the applet * It is very important that the connection to the server is closed at this point. That way the server knows to @@ -172,6 +191,7 @@ class DeskshareClient implements IScreenCaptureListener, ChangedBlocksListener, scaleWidth = builder.scaleWidth; scaleHeight = builder.scaleHeight; quality = builder.quality; + aspectRatio = builder.aspectRatio; x = builder.x; y = builder.y; httpTunnel = builder.httpTunnel; @@ -193,6 +213,7 @@ class DeskshareClient implements IScreenCaptureListener, ChangedBlocksListener, private int scaleWidth; private int scaleHeight; private boolean quality; + private boolean aspectRatio; private int x; private int y; private boolean httpTunnel; @@ -241,6 +262,11 @@ class DeskshareClient implements IScreenCaptureListener, ChangedBlocksListener, return this; } + public Builder aspectRatio(boolean aspectRatio) { + this.aspectRatio = aspectRatio; + return this; + } + public Builder x(int x) { this.x = x; return this; diff --git a/deskshare/applet/src/main/java/org/bigbluebutton/deskshare/client/DeskshareMain.java b/deskshare/applet/src/main/java/org/bigbluebutton/deskshare/client/DeskshareMain.java index 36e3d632950e7b93da49f9af666fbc42227e1eb2..737852d8d906c42f170cc4e624c4a49746f9578d 100755 --- a/deskshare/applet/src/main/java/org/bigbluebutton/deskshare/client/DeskshareMain.java +++ b/deskshare/applet/src/main/java/org/bigbluebutton/deskshare/client/DeskshareMain.java @@ -40,7 +40,9 @@ public class DeskshareMain implements ClientListener, LifeLineListener { CmdLineParser.Option cHeight = dsMain.addHelp(parser.addIntegerOption('t', "captureHeight"),"Height of the screen capture"); CmdLineParser.Option sWidth = dsMain.addHelp(parser.addIntegerOption('d', "scaleWidth"),"Scale capture width"); CmdLineParser.Option sHeight = dsMain.addHelp(parser.addIntegerOption('g', "scaleHeight"),"Scale capture height"); - CmdLineParser.Option quality = dsMain.addHelp(parser.addBooleanOption('q', "quality"),"Scale with better quality instead of speed"); CmdLineParser.Option xCoord = dsMain.addHelp(parser.addIntegerOption('x', "x"),"Upper-left x coordinate of the screen capture"); + CmdLineParser.Option quality = dsMain.addHelp(parser.addBooleanOption('q', "quality"),"Scale with better quality instead of speed"); + CmdLineParser.Option aspectRatio = dsMain.addHelp(parser.addBooleanOption('a', "aspectRatio"),"Maintain aspect ratio when scaling"); + CmdLineParser.Option xCoord = dsMain.addHelp(parser.addIntegerOption('x', "x"),"Upper-left x coordinate of the screen capture"); CmdLineParser.Option yCoord = dsMain.addHelp(parser.addIntegerOption('y', "y"),"Upper-left y coordinate of the screen capture"); CmdLineParser.Option tryHttpTunnel = dsMain.addHelp(parser.addBooleanOption('n', "httptunnel"),"Http tunnel if direct connection fails"); CmdLineParser.Option icon = dsMain.addHelp(parser.addStringOption('i', "icon"),"Path to system tray icon file"); @@ -73,6 +75,7 @@ public class DeskshareMain implements ClientListener, LifeLineListener { Integer sWidthValue = (Integer)parser.getOptionValue(sWidth, new Integer((int)dim.getWidth())); Integer sHeightValue = (Integer)parser.getOptionValue(sHeight, new Integer((int)dim.getHeight())); Boolean qualityValue = (Boolean)parser.getOptionValue(quality, false); + Boolean aspectValue = (Boolean)parser.getOptionValue(aspectRatio, false); Integer xValue = (Integer)parser.getOptionValue(xCoord, new Integer(0)); Integer yValue = (Integer)parser.getOptionValue(yCoord, new Integer(0)); Boolean tunnelValue = (Boolean)parser.getOptionValue(tryHttpTunnel, false); @@ -85,7 +88,8 @@ public class DeskshareMain implements ClientListener, LifeLineListener { DeskshareClient client = new DeskshareClient.Builder().host(hostValue).port(portValue) .room(roomValue).captureWidth(cWidthValue) - .captureHeight(cHeightValue).scaleWidth(sWidthValue).scaleHeight(sHeightValue).quality(qualityValue) + .captureHeight(cHeightValue).scaleWidth(sWidthValue).scaleHeight(sHeightValue) + .quality(qualityValue).aspectRatio(aspectValue) .x(xValue).y(yValue) .httpTunnel(tunnelValue).trayIcon(image).enableTrayIconActions(true).build(); diff --git a/deskshare/applet/src/main/java/org/bigbluebutton/deskshare/client/MouseLocationTaker.java b/deskshare/applet/src/main/java/org/bigbluebutton/deskshare/client/MouseLocationTaker.java old mode 100644 new mode 100755 index 336796f0d2d011dad025b0595258f968102745a6..0450e2b19cecfeac3a3e4a3a70cabce735b08cef --- a/deskshare/applet/src/main/java/org/bigbluebutton/deskshare/client/MouseLocationTaker.java +++ b/deskshare/applet/src/main/java/org/bigbluebutton/deskshare/client/MouseLocationTaker.java @@ -9,9 +9,22 @@ public class MouseLocationTaker implements Runnable { private MouseLocationListener listeners; private volatile boolean trackMouseLocation = false; + private int captureWidth; + private int captureHeight; + private int scaleWidth; + private int scaleHeight; + + public MouseLocationTaker(int captureWidth, int captureHeight, int scaleWidth, int scaleHeight) { + this.captureWidth = captureWidth; + this.captureHeight = captureHeight; + this.scaleWidth = scaleWidth; + this.scaleHeight = scaleHeight; + } public Point getMouseLocation() { PointerInfo pInfo; + Point pointerLocation = new Point(0,0); + try { pInfo = MouseInfo.getPointerInfo(); } catch (HeadlessException e) { @@ -20,9 +33,24 @@ public class MouseLocationTaker implements Runnable { pInfo = null; } - if (pInfo == null) return new Point(0,0); + if (pInfo == null) return pointerLocation; - return pInfo.getLocation(); + if (adjustPointerLocationDueToScaling()) { + pointerLocation = calculatePointerLocation(pInfo.getLocation()); + } else { + pointerLocation = pInfo.getLocation(); + } + return pointerLocation; + } + + private Point calculatePointerLocation(Point p) { + double mx = ((double)p.x/(double)captureWidth) * (double)scaleWidth; + double my = ((double)p.y/(double)captureHeight) * (double)scaleHeight; + return new Point((int)mx, (int)my); + } + + public boolean adjustPointerLocationDueToScaling() { + return (captureWidth != scaleWidth && captureHeight != scaleHeight); } @Override diff --git a/deskshare/applet/src/main/java/org/bigbluebutton/deskshare/client/ScreenCaptureTaker.java b/deskshare/applet/src/main/java/org/bigbluebutton/deskshare/client/ScreenCaptureTaker.java index 9f19e017a3ed6c40334778172d6028b41b1017c3..27c004dcfdebc910b420ad4b4973b56c027f2cb4 100755 --- a/deskshare/applet/src/main/java/org/bigbluebutton/deskshare/client/ScreenCaptureTaker.java +++ b/deskshare/applet/src/main/java/org/bigbluebutton/deskshare/client/ScreenCaptureTaker.java @@ -39,7 +39,7 @@ public class ScreenCaptureTaker implements Runnable { long start = System.currentTimeMillis(); BufferedImage image = capture.takeSingleSnapshot(); long end = System.currentTimeMillis(); - System.out.println("Capture took " + (end - start) + " millis"); +// System.out.println("Capture took " + (end - start) + " millis"); notifyListeners(image); try{ Thread.sleep(200);