- fred fixed it
git-svn-id: http://bigbluebutton.googlecode.com/svn/trunk@2308 af16638f-c34d-0410-8cfa-b39d5352b314
This commit is contained in:
parent
0dad357828
commit
d40e146dd6
@ -19,10 +19,10 @@
|
||||
*/
|
||||
package org.bigbluebutton.deskshare.client;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.applet.Applet;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import javax.swing.JApplet;
|
||||
|
||||
import org.bigbluebutton.deskshare.client.net.HttpScreenCaptureSender;
|
||||
import org.bigbluebutton.deskshare.client.net.ScreenCaptureSender;
|
||||
@ -30,9 +30,10 @@ 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.Tile;
|
||||
import org.bigbluebutton.deskshare.client.tiles.TileManager;
|
||||
|
||||
public class DeskShareApplet extends JApplet implements IScreenCaptureListener, ChangedTilesListener {
|
||||
public class DeskShareApplet extends Applet implements IScreenCaptureListener, ChangedTilesListener {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private ScreenCaptureTaker captureTaker;
|
||||
@ -40,8 +41,8 @@ public class DeskShareApplet extends JApplet implements IScreenCaptureListener,
|
||||
private Thread captureTakerThread;
|
||||
private ScreenCaptureSender captureSender;
|
||||
|
||||
private int screenWidth = 800;
|
||||
private int screenHeight = 600;
|
||||
private int screenWidth = 1400;
|
||||
private int screenHeight = 1000;
|
||||
private int x = 0;
|
||||
private int y = 0;
|
||||
private boolean httpTunnel = false;
|
||||
@ -51,7 +52,8 @@ public class DeskShareApplet extends JApplet implements IScreenCaptureListener,
|
||||
private String host = "192.168.0.136";
|
||||
|
||||
public void init(){
|
||||
System.out.println("Applet built july 20, 2009 at 3:03PM");
|
||||
|
||||
System.out.println("Applet built aug 20, 2009 at 11:50AM");
|
||||
screenWidth = Integer.parseInt(getParameter("CAPTURE_WIDTH"));
|
||||
screenHeight = Integer.parseInt(getParameter("CAPTURE_HEIGHT"));
|
||||
x = Integer.parseInt(getParameter("X"));
|
||||
@ -84,7 +86,7 @@ public class DeskShareApplet extends JApplet implements IScreenCaptureListener,
|
||||
}
|
||||
|
||||
Dimension screenDim = new Dimension(screenWidth, screenHeight);
|
||||
Dimension tileDim = new Dimension(64, 64);
|
||||
Dimension tileDim = new Dimension(256, 256);
|
||||
tileManager = new TileManager();
|
||||
tileManager.addListener(this);
|
||||
tileManager.initialize(screenDim, tileDim);
|
||||
@ -95,7 +97,7 @@ public class DeskShareApplet extends JApplet implements IScreenCaptureListener,
|
||||
captureTaker.addListener(this);
|
||||
captureTaker.setCapture(true);
|
||||
|
||||
captureTakerThread = new Thread(captureTaker);
|
||||
captureTakerThread = new Thread(captureTaker, "ScreenCapture");
|
||||
captureTakerThread.start();
|
||||
}
|
||||
|
||||
@ -118,12 +120,12 @@ public class DeskShareApplet extends JApplet implements IScreenCaptureListener,
|
||||
}
|
||||
|
||||
static public void main (String argv[]) {
|
||||
final JApplet applet = new DeskShareApplet();
|
||||
final Applet applet = new DeskShareApplet();
|
||||
applet.start();
|
||||
}
|
||||
|
||||
public void onChangedTiles(ArrayList<ChangedTile> changedTiles) {
|
||||
System.out.println("On ChangedTiles " + changedTiles.size());
|
||||
captureSender.send(changedTiles);
|
||||
public void onChangedTiles(Tile changedTile) {
|
||||
// System.out.println("On ChangedTiles " + changedTiles.size());
|
||||
captureSender.send(changedTile);
|
||||
}
|
||||
}
|
||||
|
@ -42,9 +42,11 @@ public class ScreenCaptureTaker implements Runnable {
|
||||
while (startCapture){
|
||||
BufferedImage image = capture.takeSingleSnapshot();
|
||||
notifyListeners(image);
|
||||
|
||||
image = null;
|
||||
System.gc();
|
||||
try{
|
||||
Thread.sleep(timeBase);
|
||||
//Thread.sleep(timeBase);
|
||||
Thread.sleep(1000);
|
||||
} catch (Exception e){
|
||||
System.out.println("Exception sleeping.");
|
||||
System.exit(0);
|
||||
|
@ -32,6 +32,7 @@ import java.util.ArrayList;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.bigbluebutton.deskshare.client.tiles.ChangedTile;
|
||||
import org.bigbluebutton.deskshare.client.tiles.Tile;
|
||||
|
||||
|
||||
import com.myjavatools.web.ClientHttpRequest;
|
||||
@ -102,7 +103,7 @@ public class HttpScreenCaptureSender implements ScreenCaptureSender {
|
||||
}
|
||||
}
|
||||
|
||||
public void send(ArrayList<ChangedTile> changedTiles) {
|
||||
public void send(Tile changedTile) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
@ -22,11 +22,12 @@ package org.bigbluebutton.deskshare.client.net;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bigbluebutton.deskshare.client.tiles.ChangedTile;
|
||||
import org.bigbluebutton.deskshare.client.tiles.Tile;
|
||||
|
||||
public interface ScreenCaptureSender {
|
||||
|
||||
public void connect(String host, String room, int videoWidth, int videoHeight, int frameRate);
|
||||
public void send(ArrayList<ChangedTile> changedTiles);
|
||||
public void send(Tile changedTile);
|
||||
public void disconnect();
|
||||
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ import java.util.ArrayList;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.bigbluebutton.deskshare.client.tiles.ChangedTile;
|
||||
import org.bigbluebutton.deskshare.client.tiles.Tile;
|
||||
|
||||
|
||||
public class SocketScreenCaptureSender implements ScreenCaptureSender {
|
||||
@ -42,7 +43,6 @@ public class SocketScreenCaptureSender implements ScreenCaptureSender {
|
||||
private Socket socket = null;
|
||||
|
||||
private DataOutputStream outStream = null;
|
||||
private PrintWriter out;
|
||||
private String room;
|
||||
private int videoWidth;
|
||||
private int videoHeight;
|
||||
@ -61,8 +61,8 @@ public class SocketScreenCaptureSender implements ScreenCaptureSender {
|
||||
socket = new Socket(host, PORT);
|
||||
outStream = new DataOutputStream(socket.getOutputStream());
|
||||
sendCaptureStartMessage();
|
||||
sendRoom(room);
|
||||
sendScreenCaptureInfo(videoWidth, videoHeight, frameRate);
|
||||
sendRoom(this.room);
|
||||
sendScreenCaptureInfo(this.videoWidth, this.videoHeight, this.frameRate);
|
||||
|
||||
} catch(UnknownHostException e){
|
||||
System.out.println("Unknow host: " + host);
|
||||
@ -86,23 +86,25 @@ public class SocketScreenCaptureSender implements ScreenCaptureSender {
|
||||
outStream.writeBytes(videoInfo);
|
||||
}
|
||||
|
||||
public void send(ArrayList<ChangedTile> changedTiles) {
|
||||
for (ChangedTile ct : changedTiles) {
|
||||
sendChangedTileInfo(ct);
|
||||
sendTile(ct);
|
||||
}
|
||||
public void send(Tile changedTile) {
|
||||
// for (ChangedTile ct : changedTiles) {
|
||||
sendChangedTileInfo(changedTile);
|
||||
sendTile(changedTile);
|
||||
// }
|
||||
System.out.println("NULLing changedTiles");
|
||||
changedTile = null;
|
||||
}
|
||||
|
||||
private void sendCaptureUpdateMessage() throws IOException {
|
||||
outStream.writeInt(CAPTURE_UPDATE);
|
||||
}
|
||||
|
||||
private void sendChangedTileInfo(ChangedTile tile) {
|
||||
private void sendChangedTileInfo(Tile 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());
|
||||
+ "x" + Integer.toString(tile.getTilePosition());
|
||||
try {
|
||||
sendCaptureUpdateMessage();
|
||||
outStream.writeInt(tileInfo.length());
|
||||
@ -114,10 +116,10 @@ public class SocketScreenCaptureSender implements ScreenCaptureSender {
|
||||
|
||||
}
|
||||
|
||||
private void sendTile(ChangedTile tile) {
|
||||
private void sendTile(Tile tile) {
|
||||
try{
|
||||
ByteArrayOutputStream byteConvert = new ByteArrayOutputStream();
|
||||
ImageIO.write(tile.getImage(), "jpeg", byteConvert);
|
||||
ImageIO.write(tile.getImage(), "png", byteConvert);
|
||||
byte[] imageData = byteConvert.toByteArray();
|
||||
outStream.writeInt(imageData.length);
|
||||
outStream.write(imageData);
|
||||
@ -125,7 +127,9 @@ public class SocketScreenCaptureSender implements ScreenCaptureSender {
|
||||
outStream.flush();
|
||||
} catch(IOException e){
|
||||
System.out.println("IOException while sending screen capture.");
|
||||
}
|
||||
} finally {
|
||||
tile.imageSent();
|
||||
}
|
||||
}
|
||||
|
||||
public void disconnect(){
|
||||
|
@ -4,5 +4,5 @@ import java.util.ArrayList;
|
||||
|
||||
public interface ChangedTilesListener {
|
||||
|
||||
public void onChangedTiles(ArrayList<ChangedTile> changedTiles);
|
||||
public void onChangedTiles(Tile changedTile);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import java.awt.image.ImageObserver;
|
||||
import java.awt.image.PixelGrabber;
|
||||
import java.util.zip.Adler32;
|
||||
|
||||
final class Tile {
|
||||
public final class Tile {
|
||||
private final Adler32 checksum;
|
||||
private final Dimension dim;
|
||||
private final int position;
|
||||
@ -26,17 +26,21 @@ final class Tile {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
void updateTile(BufferedImage tile)
|
||||
void updateTile(BufferedImage capturedSreen)
|
||||
{
|
||||
BufferedImage tile = capturedSreen.getSubimage(getX(), getY(), getWidth(), getHeight());
|
||||
|
||||
long oldsum;
|
||||
oldsum = checksum.getValue();
|
||||
calcChecksum(tile);
|
||||
if (oldsum != checksum.getValue()) {
|
||||
image = null;
|
||||
this.image = tile;
|
||||
version++;
|
||||
dirty = true;
|
||||
}
|
||||
else {
|
||||
tile = null;
|
||||
dirty = false;
|
||||
}
|
||||
}
|
||||
@ -89,37 +93,41 @@ final class Tile {
|
||||
}
|
||||
}
|
||||
|
||||
BufferedImage getImage() {
|
||||
return image;
|
||||
public BufferedImage getImage() {
|
||||
return image.getSubimage(0, 0, getWidth(), getHeight());
|
||||
}
|
||||
|
||||
int getWidth()
|
||||
public int getWidth()
|
||||
{
|
||||
return dim.getWidth();
|
||||
return new Integer(dim.getWidth()).intValue();
|
||||
}
|
||||
|
||||
int getHeight()
|
||||
public int getHeight()
|
||||
{
|
||||
return dim.getHeight();
|
||||
return new Integer(dim.getHeight()).intValue();
|
||||
}
|
||||
|
||||
int getTilePosition() {
|
||||
return position;
|
||||
public int getTilePosition() {
|
||||
return new Integer(position).intValue();
|
||||
}
|
||||
|
||||
int getX() {
|
||||
return location.x;
|
||||
public int getX() {
|
||||
return new Integer(location.x).intValue();
|
||||
}
|
||||
|
||||
int getY() {
|
||||
return location.y;
|
||||
public int getY() {
|
||||
return new Integer(location.y).intValue();
|
||||
}
|
||||
|
||||
Dimension getDimension() {
|
||||
return dim;
|
||||
return new Dimension(dim.getWidth(), dim.getHeight());
|
||||
}
|
||||
|
||||
Point getLocation() {
|
||||
return location;
|
||||
return new Point(location.x, location.y);
|
||||
}
|
||||
|
||||
public void imageSent() {
|
||||
image = null;
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,8 @@ public class TileManager {
|
||||
private int numRows;
|
||||
|
||||
private TileFactory factory;
|
||||
private Set<ChangedTilesListener> listeners = new HashSet<ChangedTilesListener>();
|
||||
private ChangedTilesListener listeners;
|
||||
//private Set<ChangedTilesListener> listeners = new HashSet<ChangedTilesListener>();
|
||||
|
||||
public TileManager() {}
|
||||
|
||||
@ -35,47 +36,44 @@ public class TileManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void processCapturedScreen(BufferedImage capturedSreen)
|
||||
public void processCapturedScreen(BufferedImage capturedScreen)
|
||||
{
|
||||
System.out.println("Processing captured screen.");
|
||||
BufferedImage capturedTile;
|
||||
ArrayList<ChangedTile> changedTiles = new ArrayList<ChangedTile>();
|
||||
|
||||
System.out.println("Processing captured screen.");
|
||||
for (int row = 0; row < numRows; row++) {
|
||||
for (int col = 0; col < numColumns; col++) {
|
||||
int position = factory.indexToPosition(row, col);
|
||||
Tile tile = getTile(position);
|
||||
// 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);
|
||||
tile.updateTile(capturedScreen);
|
||||
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());
|
||||
//ChangedTileImp ct = new ChangedTileImp(tile.getDimension(), tile.getTilePosition(), tile.getLocation(), tile.getImage());
|
||||
notifyChangedTilesListener(tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (changedTiles.size() > 0) {
|
||||
notifyChangedTilesListener(changedTiles);
|
||||
}
|
||||
// if (changedTiles.size() > 0) {
|
||||
// notifyChangedTilesListener(changedTiles);
|
||||
// }
|
||||
|
||||
// capturedScreen = null;
|
||||
}
|
||||
|
||||
private void notifyChangedTilesListener(ArrayList<ChangedTile> changedTiles) {
|
||||
for (ChangedTilesListener ctl : listeners) {
|
||||
ctl.onChangedTiles(changedTiles);
|
||||
}
|
||||
private void notifyChangedTilesListener(Tile changedTile) {
|
||||
// for (ChangedTilesListener ctl : listeners) {
|
||||
// ctl.onChangedTiles(changedTile);
|
||||
// }
|
||||
listeners.onChangedTiles(changedTile);
|
||||
}
|
||||
|
||||
|
||||
public void addListener(ChangedTilesListener listener) {
|
||||
listeners.add(listener);
|
||||
listeners = listener;
|
||||
}
|
||||
|
||||
|
||||
public void removeListener(ChangedTilesListener listener) {
|
||||
listeners.remove(listener);
|
||||
//listeners.remove(listener);
|
||||
listeners = null;
|
||||
}
|
||||
|
||||
void createTile(int position) {
|
||||
|
Loading…
Reference in New Issue
Block a user