- minimize logging
git-svn-id: http://bigbluebutton.googlecode.com/svn/trunk@2304 af16638f-c34d-0410-8cfa-b39d5352b314
This commit is contained in:
parent
7b6a6a8955
commit
bb885ebd51
@ -30,7 +30,7 @@ build.optimize=false
|
||||
# Change this var to build to a different Java version
|
||||
# Defaults to current version. Valid options are 1.6, or 1.5. Note 1.4 is not supported.
|
||||
#java.target_version=${java.specification.version}
|
||||
java.target_version=1.4
|
||||
java.target_version=1.5
|
||||
|
||||
# jikes options
|
||||
build.compiler.emacs=false
|
||||
|
@ -20,25 +20,32 @@
|
||||
package org.bigbluebutton.deskshare.client;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.JApplet;
|
||||
|
||||
import org.bigbluebutton.deskshare.client.net.HttpScreenCaptureSender;
|
||||
import org.bigbluebutton.deskshare.client.net.ScreenCaptureSender;
|
||||
import org.bigbluebutton.deskshare.client.net.SocketScreenCaptureSender;
|
||||
import org.bigbluebutton.deskshare.client.tiles.ChangedTile;
|
||||
import org.bigbluebutton.deskshare.client.tiles.ChangedTilesListener;
|
||||
import org.bigbluebutton.deskshare.client.tiles.Dimension;
|
||||
import org.bigbluebutton.deskshare.client.tiles.TileManager;
|
||||
|
||||
public class DeskShareApplet extends JApplet implements IScreenCaptureListener {
|
||||
public class DeskShareApplet extends JApplet implements IScreenCaptureListener, ChangedTilesListener {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private ScreenCaptureTaker captureTaker;
|
||||
private ScreenCapture capture;
|
||||
private Thread captureTakerThread;
|
||||
private IScreenCaptureSender captureSender;
|
||||
private ScreenCaptureSender captureSender;
|
||||
|
||||
private int screenWidth = 800;
|
||||
private int screenHeight = 600;
|
||||
private int x = 0;
|
||||
private int y = 0;
|
||||
private boolean httpTunnel = true;
|
||||
private boolean httpTunnel = false;
|
||||
private TileManager tileManager;
|
||||
|
||||
private String room = "f7e8821f-8528-4c28-994e-2db7659f9538";
|
||||
private String host = "192.168.0.136";
|
||||
@ -74,11 +81,16 @@ public class DeskShareApplet extends JApplet implements IScreenCaptureListener {
|
||||
captureSender = new HttpScreenCaptureSender();
|
||||
} else {
|
||||
captureSender = new SocketScreenCaptureSender();
|
||||
|
||||
}
|
||||
|
||||
captureSender.connect(host, room, capture.getVideoWidth(),
|
||||
capture.getVideoHeight(), capture.getProperFrameRate());
|
||||
Dimension screenDim = new Dimension(screenWidth, screenHeight);
|
||||
Dimension tileDim = new Dimension(64, 64);
|
||||
tileManager = new TileManager();
|
||||
tileManager.addListener(this);
|
||||
tileManager.initialize(screenDim, tileDim);
|
||||
|
||||
captureSender.connect(host, room, capture.getWidth(),
|
||||
capture.getHeight(), capture.getProperFrameRate());
|
||||
|
||||
captureTaker.addListener(this);
|
||||
captureTaker.setCapture(true);
|
||||
@ -101,14 +113,17 @@ public class DeskShareApplet extends JApplet implements IScreenCaptureListener {
|
||||
capture.setY(y);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void onScreenCaptured(BufferedImage screen) {
|
||||
captureSender.send(screen);
|
||||
tileManager.processCapturedScreen(screen);
|
||||
}
|
||||
|
||||
static public void main (String argv[]) {
|
||||
final JApplet applet = new DeskShareApplet();
|
||||
applet.start();
|
||||
}
|
||||
|
||||
public void onChangedTiles(ArrayList<ChangedTile> changedTiles) {
|
||||
System.out.println("On ChangedTiles " + changedTiles.size());
|
||||
captureSender.send(changedTiles);
|
||||
}
|
||||
}
|
||||
|
@ -20,9 +20,7 @@
|
||||
package org.bigbluebutton.deskshare.client;
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.Robot;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.image.BufferedImage;
|
||||
@ -36,15 +34,12 @@ import java.awt.image.BufferedImage;
|
||||
* @author Snap
|
||||
*
|
||||
*/
|
||||
public class ScreenCapture {
|
||||
|
||||
public class ScreenCapture {
|
||||
private Robot robot;
|
||||
private Toolkit toolkit;
|
||||
private Rectangle screenBounds;
|
||||
|
||||
private Rectangle screenBounds;
|
||||
private int width, height, x,y, videoWidth, videoHeight;
|
||||
private boolean needScale = true;
|
||||
|
||||
|
||||
public ScreenCapture(int x, int y, int screenWidth, int screenHeight){
|
||||
this.width = screenWidth;
|
||||
this.height = screenHeight;
|
||||
@ -55,16 +50,10 @@ public class ScreenCapture {
|
||||
}
|
||||
this.toolkit = Toolkit.getDefaultToolkit();
|
||||
this.screenBounds = new Rectangle(x, y, this.width, this.height);
|
||||
this.needScale = areDimensionsScaled(this.width, this.height);
|
||||
}
|
||||
|
||||
public BufferedImage takeSingleSnapshot(){
|
||||
if (needScale) {
|
||||
return getScaledImage(robot.createScreenCapture(this.screenBounds));
|
||||
}
|
||||
else {
|
||||
return robot.createScreenCapture(this.screenBounds);
|
||||
}
|
||||
return robot.createScreenCapture(this.screenBounds);
|
||||
}
|
||||
|
||||
public int getScreenshotWidth(){
|
||||
@ -123,43 +112,7 @@ public class ScreenCapture {
|
||||
else if (area > 150000) return 8;
|
||||
else return 10;
|
||||
}
|
||||
|
||||
private boolean areDimensionsScaled(int width, int height){
|
||||
int bigger = Math.max(width, height);
|
||||
if (bigger < 800){
|
||||
videoWidth = width;
|
||||
videoHeight = height;
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
if (width >= height){
|
||||
videoWidth = 800;
|
||||
videoHeight = Math.round(height/(width/800));
|
||||
} else if (height > width){
|
||||
videoHeight = 800;
|
||||
videoWidth = Math.round(width/(height/800));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private BufferedImage getScaledImage(BufferedImage image){
|
||||
BufferedImage scaledImage = new BufferedImage(
|
||||
videoWidth, videoHeight, BufferedImage.TYPE_3BYTE_BGR);
|
||||
|
||||
// Paint scaled version of image to new image
|
||||
Graphics2D graphics2D = scaledImage.createGraphics();
|
||||
graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
|
||||
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||
graphics2D.drawImage(image, 0, 0, videoWidth, videoHeight, null);
|
||||
|
||||
// clean up
|
||||
|
||||
graphics2D.dispose();
|
||||
|
||||
return scaledImage;
|
||||
}
|
||||
|
||||
|
||||
public int getVideoWidth(){
|
||||
return videoWidth;
|
||||
}
|
||||
|
@ -27,13 +27,16 @@ import java.io.UnsupportedEncodingException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.bigbluebutton.deskshare.client.tiles.ChangedTile;
|
||||
|
||||
|
||||
import com.myjavatools.web.ClientHttpRequest;
|
||||
|
||||
public class HttpScreenCaptureSender implements IScreenCaptureSender {
|
||||
public class HttpScreenCaptureSender implements ScreenCaptureSender {
|
||||
private String host = "localhost";
|
||||
private String room;
|
||||
private int videoWidth;
|
||||
@ -99,5 +102,8 @@ public class HttpScreenCaptureSender implements IScreenCaptureSender {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void send(ArrayList<ChangedTile> changedTiles) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -19,12 +19,14 @@
|
||||
*/
|
||||
package org.bigbluebutton.deskshare.client.net;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public interface IScreenCaptureSender {
|
||||
import org.bigbluebutton.deskshare.client.tiles.ChangedTile;
|
||||
|
||||
public interface ScreenCaptureSender {
|
||||
|
||||
public void connect(String host, String room, int videoWidth, int videoHeight, int frameRate);
|
||||
public void send(BufferedImage screenCapture);
|
||||
public void send(ArrayList<ChangedTile> changedTiles);
|
||||
public void disconnect();
|
||||
|
||||
}
|
@ -26,11 +26,14 @@ import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.Socket;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.bigbluebutton.deskshare.client.tiles.ChangedTile;
|
||||
|
||||
public class SocketScreenCaptureSender implements IScreenCaptureSender {
|
||||
|
||||
public class SocketScreenCaptureSender implements ScreenCaptureSender {
|
||||
|
||||
private static final int PORT = 9123;
|
||||
|
||||
@ -45,6 +48,10 @@ public class SocketScreenCaptureSender implements IScreenCaptureSender {
|
||||
private int videoHeight;
|
||||
private int frameRate;
|
||||
|
||||
private static final int CAPTURE_START = 0;
|
||||
private static final int CAPTURE_UPDATE = 1;
|
||||
private static final int CAPTURE_END = 2;
|
||||
|
||||
public void connect(String host, String room, int videoWidth, int videoHeight, int frameRate) {
|
||||
this.room = room;
|
||||
this.videoWidth = videoWidth;
|
||||
@ -52,8 +59,8 @@ public class SocketScreenCaptureSender implements IScreenCaptureSender {
|
||||
this.frameRate = frameRate;
|
||||
try{
|
||||
socket = new Socket(host, PORT);
|
||||
out = new PrintWriter(socket.getOutputStream(), true);
|
||||
outStream = new DataOutputStream(socket.getOutputStream());
|
||||
sendCaptureStartMessage();
|
||||
sendRoom(room);
|
||||
sendScreenCaptureInfo(videoWidth, videoHeight, frameRate);
|
||||
|
||||
@ -64,34 +71,63 @@ public class SocketScreenCaptureSender implements IScreenCaptureSender {
|
||||
}
|
||||
}
|
||||
|
||||
private void sendRoom(String room) {
|
||||
out.println(room);
|
||||
private void sendCaptureStartMessage() throws IOException {
|
||||
outStream.writeInt(CAPTURE_START);
|
||||
}
|
||||
|
||||
private void sendScreenCaptureInfo(int videoWidth, int videoHeight, int frameRate) {
|
||||
out.println(Integer.toString(videoWidth)
|
||||
+ "x" + Integer.toString(videoHeight)
|
||||
+ "x" + Integer.toString(frameRate));
|
||||
private void sendRoom(String room) throws IOException {
|
||||
outStream.writeInt(room.length());
|
||||
outStream.writeBytes(room);
|
||||
}
|
||||
private void sendScreenCaptureInfo(int videoWidth, int videoHeight, int frameRate) throws IOException {
|
||||
String videoInfo = Integer.toString(videoWidth) + "x" + Integer.toString(videoHeight) + "x" + Integer.toString(frameRate);
|
||||
System.out.println("Sending video info " + videoInfo);
|
||||
outStream.writeInt(videoInfo.length());
|
||||
outStream.writeBytes(videoInfo);
|
||||
}
|
||||
|
||||
public void send(BufferedImage screenCapture) {
|
||||
sendRoom(room);
|
||||
sendScreenCaptureInfo(videoWidth, videoHeight, frameRate);
|
||||
try{
|
||||
ByteArrayOutputStream byteConvert = new ByteArrayOutputStream();
|
||||
ImageIO.write(screenCapture, "jpeg", byteConvert);
|
||||
byte[] imageData = byteConvert.toByteArray();
|
||||
outStream.writeInt(imageData.length);
|
||||
//out.println("xxx");
|
||||
outStream.write(imageData);
|
||||
//out.println("vvv");
|
||||
System.out.println("Sent: "+ imageData.length);
|
||||
outStream.flush();
|
||||
} catch(IOException e){
|
||||
System.out.println("IOException while sending screen capture.");
|
||||
public void send(ArrayList<ChangedTile> changedTiles) {
|
||||
for (ChangedTile ct : changedTiles) {
|
||||
sendChangedTileInfo(ct);
|
||||
sendTile(ct);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendCaptureUpdateMessage() throws IOException {
|
||||
outStream.writeInt(CAPTURE_UPDATE);
|
||||
}
|
||||
|
||||
private void sendChangedTileInfo(ChangedTile tile) {
|
||||
String tileInfo = Integer.toString(tile.getWidth())
|
||||
+ "x" + Integer.toString(tile.getHeight())
|
||||
+ "x" + Integer.toString(tile.getX())
|
||||
+ "x" + Integer.toString(tile.getY())
|
||||
+ "x" + Integer.toString(tile.getPosition());
|
||||
try {
|
||||
sendCaptureUpdateMessage();
|
||||
outStream.writeInt(tileInfo.length());
|
||||
outStream.writeBytes(tileInfo);
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void sendTile(ChangedTile tile) {
|
||||
try{
|
||||
ByteArrayOutputStream byteConvert = new ByteArrayOutputStream();
|
||||
ImageIO.write(tile.getImage(), "jpeg", byteConvert);
|
||||
byte[] imageData = byteConvert.toByteArray();
|
||||
outStream.writeInt(imageData.length);
|
||||
outStream.write(imageData);
|
||||
// System.out.println("Sent: tile "+ tile.getPosition() + " with size " + imageData.length);
|
||||
outStream.flush();
|
||||
} catch(IOException e){
|
||||
System.out.println("IOException while sending screen capture.");
|
||||
}
|
||||
}
|
||||
|
||||
public void disconnect(){
|
||||
System.out.println("Closing connection.");
|
||||
try{
|
||||
|
@ -1,20 +1,20 @@
|
||||
package org.bigbluebutton.deskshare.client.tiles;
|
||||
|
||||
final class Dimension {
|
||||
public final class Dimension {
|
||||
|
||||
private final int width;
|
||||
private final int height;
|
||||
|
||||
Dimension(int width, int height) {
|
||||
public Dimension(int width, int height) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
int getWidth() {
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
int getHeight() {
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ class TileFactory {
|
||||
int y = computeTileYLocation(row);
|
||||
int pos = computeTilePosition(row, col);
|
||||
|
||||
System.out.println("Tile dim=" + w + "x" + h + " index=" + row + "," + col + " loc=" + x + "," + y);
|
||||
// System.out.println("Tile dim=" + w + "x" + h + " index=" + row + "," + col + " loc=" + x + "," + y);
|
||||
Tile t = new Tile(new Dimension(w, h), pos, new Point(x,y));
|
||||
|
||||
return t;
|
||||
|
@ -24,8 +24,9 @@ public class TileManager {
|
||||
numRows = factory.getRowCount();
|
||||
tiles = new Tile[numRows][numColumns];
|
||||
|
||||
System.out.println("Setting tiles " + numRows + " " + numColumns);
|
||||
for (int row = 0; row < numRows; row++) {
|
||||
for (int col = 0; col > numColumns; col++) {
|
||||
for (int col = 0; col < numColumns; col++) {
|
||||
if (tiles[row][col] == null) {
|
||||
int position = factory.indexToPosition(row, col);
|
||||
tiles[row][col] = factory.createTile(position);
|
||||
@ -36,18 +37,22 @@ public class TileManager {
|
||||
|
||||
public void processCapturedScreen(BufferedImage capturedSreen)
|
||||
{
|
||||
System.out.println("Processing captured screen.");
|
||||
BufferedImage capturedTile;
|
||||
ArrayList<ChangedTile> changedTiles = new ArrayList<ChangedTile>();
|
||||
|
||||
for (int row = 0; row < numRows; row++) {
|
||||
for (int col = 0; col > numColumns; col++) {
|
||||
for (int col = 0; col < numColumns; col++) {
|
||||
int position = factory.indexToPosition(row, col);
|
||||
Tile tile = getTile(position);
|
||||
capturedTile = capturedSreen.getSubimage(tile.getWidth(), tile.getHeight(), tile.getX(), tile.getY());
|
||||
// System.out.println("Processing tile [" + row + "," + col + "] " + position);
|
||||
// System.out.println("tile [" + tile.getWidth() + "," + tile.getHeight() + "][" + tile.getX() + "," + tile.getY() + "]");
|
||||
capturedTile = capturedSreen.getSubimage(tile.getX(), tile.getY(), tile.getWidth(), tile.getHeight());
|
||||
tile.updateTile(capturedTile);
|
||||
if (tile.isDirty()) {
|
||||
ChangedTileImp ct = new ChangedTileImp(tile.getDimension(), tile.getTilePosition(), tile.getLocation(), tile.getImage());
|
||||
changedTiles.add(ct);
|
||||
// System.out.println("Changed Tile " + tile.getTilePosition());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -58,7 +63,9 @@ public class TileManager {
|
||||
}
|
||||
|
||||
private void notifyChangedTilesListener(ArrayList<ChangedTile> changedTiles) {
|
||||
|
||||
for (ChangedTilesListener ctl : listeners) {
|
||||
ctl.onChangedTiles(changedTiles);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user