--- /dev/null
+// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
+// Jad home page: http://www.kpdus.com/jad.html
+// Decompiler options: packimports(3) fieldsfirst nonlb space
+
+package mcsClient;
+
+import java.awt.*;
+import java.awt.image.*;
+import java.io.*;
+import java.net.DatagramPacket;
+import java.util.LinkedList;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.JPanel;
+
+// Referenced classes of package mcsClient:
+// ColorPalette, Decompress, McsTargetSize, McsTcpConnection,
+// McsToolBar, LockingKeyStateManager
+
+public final class LiveVideoPanel extends JPanel
+ implements Runnable {
+
+ private int targetWidth;
+ private int targetHeight;
+ private boolean initialized;
+ private McsTargetSize targetSize;
+ private ColorPalette colorPalette;
+ private IndexColorModel indexColorModel;
+ private LinkedList datagramList;
+ public static boolean PRINT_HEADER = false;
+ public static boolean MEASURE_PERFORMANCE = false;
+ public boolean SHOW_CURSOR;
+ public static final boolean DEBUG_MOUSE = false;
+ public static final int SUCCESS = 1;
+ public static final int FAILURE = 2;
+ boolean doPartialScreenUpdates;
+ boolean interpolation;
+ Graphics2D graphics2D;
+ RenderingHints renderingHints;
+ private final Toolkit defaultToolkit = Toolkit.getDefaultToolkit();
+ private final Cursor invisibleCursor;
+ private Cursor visibleCursor;
+ private Cursor currentCursor;
+ private byte imageData[];
+ private MemoryImageSource memoryImageSource;
+ private MemoryImageSource memoryImageSource_1024_768;
+ private MemoryImageSource memoryImageSource_800_600;
+ private MemoryImageSource memoryImageSource_640_480;
+ private MemoryImageSource memoryImageSource_640_400;
+ private MemoryImageSource memoryImageSource_656_496;
+ private Image image_1024_768;
+ private Image image_800_600;
+ private Image image_640_480;
+ private Image image_640_400;
+ private Image image_656_496;
+ private Image image;
+ private int blankImage[];
+ private MemoryImageSource blankMemoryImageSource;
+ private Image blank;
+ private Dimension dimension_1024_768;
+ private Dimension dimension_800_600;
+ private Dimension dimension_640_480;
+ private Dimension dimension_640_400;
+ private Dimension dimension_656_496;
+ private McsTcpConnection mcsTcpConnection;
+ private int frameWidth;
+ private int frameHeight;
+ private int livePanelWait;
+ private boolean livePanelSchedule;
+ private McsToolBar sliderListener;
+ private static int resumeMessage[] = new int[2];
+ private static int pauseMessage[] = new int[2];
+ boolean imagesAutomaticallyPaused;
+ private LockingKeyStateManager lockingKeyStateManager;
+ private static Logger logger = Logger.getAnonymousLogger();
+
+ public LiveVideoPanel(McsTcpConnection mcstcpconnection, LinkedList linkedlist, McsTargetSize mcstargetsize, LockingKeyStateManager lockingkeystatemanager) {
+ targetWidth = 1024;
+ targetHeight = 768;
+ initialized = false;
+ colorPalette = new ColorPalette();
+ indexColorModel = new IndexColorModel(8, colorPalette.hardwareColors.length, colorPalette.hardwareColors, 0, 0, null);
+ SHOW_CURSOR = true;
+ doPartialScreenUpdates = true;
+ interpolation = false;
+ graphics2D = null;
+ renderingHints = null;
+ invisibleCursor = defaultToolkit.createCustomCursor(new BufferedImage(1, 1, 2), new Point(0, 0), "");
+ dimension_1024_768 = new Dimension(1024, 768);
+ dimension_800_600 = new Dimension(800, 600);
+ dimension_640_480 = new Dimension(640, 480);
+ dimension_640_400 = new Dimension(640, 400);
+ dimension_656_496 = new Dimension(656, 496);
+ sliderListener = null;
+ imagesAutomaticallyPaused = false;
+ mcsTcpConnection = mcstcpconnection;
+ datagramList = linkedlist;
+ targetSize = mcstargetsize;
+ lockingKeyStateManager = lockingkeystatemanager;
+ imageData = new byte[targetWidth * targetHeight * 2];
+ memoryImageSource_1024_768 = new MemoryImageSource(1024, 768, indexColorModel, imageData, 0, 1024);
+ memoryImageSource_800_600 = new MemoryImageSource(800, 600, indexColorModel, imageData, 0, 800);
+ memoryImageSource_640_480 = new MemoryImageSource(640, 480, indexColorModel, imageData, 0, 640);
+ memoryImageSource_640_400 = new MemoryImageSource(640, 400, indexColorModel, imageData, 0, 640);
+ memoryImageSource_656_496 = new MemoryImageSource(656, 496, indexColorModel, imageData, 0, 656);
+ memoryImageSource_1024_768.setAnimated(true);
+ memoryImageSource_800_600.setAnimated(true);
+ memoryImageSource_640_480.setAnimated(true);
+ memoryImageSource_640_400.setAnimated(true);
+ memoryImageSource_656_496.setAnimated(true);
+ memoryImageSource = memoryImageSource_1024_768;
+ image_1024_768 = createImage(memoryImageSource_1024_768);
+ image_800_600 = createImage(memoryImageSource_800_600);
+ image_640_480 = createImage(memoryImageSource_640_480);
+ image_640_400 = createImage(memoryImageSource_640_400);
+ image_656_496 = createImage(memoryImageSource_656_496);
+ image = image_1024_768;
+ blankImage = new int[0xc0000];
+ blankMemoryImageSource = new MemoryImageSource(1024, 768, indexColorModel, blankImage, 0, 1024);
+ blank = createImage(blankMemoryImageSource);
+ Cursor cursor = getCursor();
+ Cursor cursor1 = cursor;
+ if (!SHOW_CURSOR) {
+ setCursor(invisibleCursor);
+ Cursor cursor2 = invisibleCursor;
+ }
+ resumeMessage[0] = resumeMessage.length * 4;
+ resumeMessage[1] = 8;
+ pauseMessage[0] = pauseMessage.length * 4;
+ pauseMessage[1] = 7;
+ livePanelWait = 0;
+ livePanelSchedule = true;
+ logger.setLevel(Level.WARNING);
+ String s = System.getProperty("mcs.debug");
+ if (s != null && s.equalsIgnoreCase("true"))
+ logger.setLevel(Level.ALL);
+ initialized = true;
+ }
+
+ public void toggleVisibleCursor() {
+ if (currentCursor.equals(visibleCursor)) {
+ setCursor(invisibleCursor);
+ currentCursor = invisibleCursor;
+ } else {
+ setCursor(visibleCursor);
+ currentCursor = visibleCursor;
+ }
+ }
+
+ public boolean initialized() {
+ return initialized;
+ }
+
+ public boolean isFocusable() {
+ return true;
+ }
+
+ public void addNotify() {
+ super.addNotify();
+ }
+
+ public boolean isOpaque() {
+ return false;
+ }
+
+ public void paintComponent(Graphics g) {
+ super.paintComponent(g);
+ Rectangle rectangle = g.getClipBounds();
+ if (rectangle.x >= 0 && rectangle.x < targetWidth && rectangle.y >= 0 && rectangle.y < targetHeight)
+ g.drawImage(image, 0, 0, null);
+ livePanelWait = 0;
+ }
+
+ public void update(Graphics g) {
+ super.update(g);
+ }
+
+ public void setInterpolation(boolean flag) {
+ interpolation = flag;
+ }
+
+ private void cleanupThread() {
+ mcsTcpConnection = null;
+ datagramList = null;
+ lockingKeyStateManager = null;
+ initialized = false;
+ }
+
+ private void process() {
+ float f;
+ float f1;
+ float f2;
+ float f3;
+ long l;
+ int k;
+ boolean flag3;
+ int ai[];
+ Decompress decompress;
+ Thread thread;
+ f = 0.0F;
+ f1 = 0.0F;
+ f2 = 0.0F;
+ f3 = 0.0F;
+ boolean flag = false;
+ k = 2;
+ boolean flag1 = false;
+ boolean flag2 = false;
+ Object obj = null;
+ flag3 = false;
+ Object obj1 = null;
+ ai = new int[2];
+ ai[0] = ai.length * 4;
+ ai[1] = 16;
+ setBackground(Color.white);
+ setEnabled(true);
+ setVisible(true);
+ decompress = new Decompress(imageData);
+ long l1;
+ l = l1 = System.currentTimeMillis();
+ graphics2D = (Graphics2D)getGraphics();
+ renderingHints = graphics2D.getRenderingHints();
+ logger.info("RenderingHints size = " + renderingHints.size());
+ thread = Thread.currentThread();
+ break MISSING_BLOCK_LABEL_1474;
+_L2:
+ LinkedList linkedlist = datagramList;
+ JVM INSTR monitorenter ;
+ int i;
+ DatagramPacket datagrampacket;
+label0:
+ {
+ thread;
+ if (Thread.interrupted()) {
+ logger.info("Terminating LiveVideoPanel");
+ return;
+ }
+ try {
+ while ((i = datagramList.size()) == 0)
+ datagramList.wait();
+ datagrampacket = (DatagramPacket)datagramList.removeLast();
+ break label0;
+ }
+ catch (InterruptedException interruptedexception1) { }
+ return;
+ }
+ Exception exception;
+ exception;
+ throw exception;
+ if (i > 2 || !imagesAutomaticallyPaused)
+ break MISSING_BLOCK_LABEL_277;
+ if (resumeVideo() != 1) {
+ logger.severe("Socket exception - LiveVideoPanel exiting");
+ return;
+ }
+ imagesAutomaticallyPaused = false;
+ break MISSING_BLOCK_LABEL_313;
+ if (i < 6 || imagesAutomaticallyPaused)
+ break MISSING_BLOCK_LABEL_313;
+ if (pauseVideo() != 1) {
+ logger.severe("Socket exception - LiveVideoPanel exiting");
+ return;
+ }
+ imagesAutomaticallyPaused = true;
+ DataInputStream datainputstream;
+ try {
+ datainputstream = new DataInputStream(new ByteArrayInputStream(datagrampacket.getData(), datagrampacket.getOffset(), datagrampacket.getLength()));
+ }
+ catch (NullPointerException nullpointerexception) {
+ logger.severe("Data stream has been closed. LiveVideoPanel exiting.");
+ return;
+ }
+ int i1;
+ int i2;
+ int j2;
+ try {
+ int j = datagrampacket.getLength();
+ i1 = datainputstream.readInt();
+ int j1 = datainputstream.readInt();
+ int k1 = datainputstream.readInt();
+ i2 = datainputstream.readInt();
+ j2 = datainputstream.readInt();
+ int k2 = datainputstream.readInt();
+ if (MEASURE_PERFORMANCE) {
+ f3++;
+ f1 += i1;
+ f += j2;
+ }
+ if (PRINT_HEADER) {
+ System.out.println();
+ System.out.println("dg length: " + i1 + ", vro: " + i2 + ", vrc: " + j2);
+ }
+ flag3 = false;
+ if (i1 > 1458) {
+ flag3 = true;
+ logger.warning("Bad datagramLength = " + i1);
+ }
+ if (j1 != k) {
+ if (j1 == 2) {
+ memoryImageSource = memoryImageSource_1024_768;
+ image = image_1024_768;
+ logger.info("Setting to 1024 x 768");
+ setPreferredSize(dimension_1024_768);
+ targetWidth = 1024;
+ targetHeight = 768;
+ targetSize.setWidth(1024);
+ targetSize.setHeight(768);
+ } else
+ if (j1 == 3) {
+ memoryImageSource = memoryImageSource_800_600;
+ image = image_800_600;
+ logger.info("Setting to 800 x 600");
+ setPreferredSize(dimension_800_600);
+ targetWidth = 800;
+ targetHeight = 600;
+ targetSize.setWidth(800);
+ targetSize.setHeight(600);
+ } else
+ if (j1 == 4) {
+ memoryImageSource = memoryImageSource_640_480;
+ image = image_640_480;
+ logger.info("Setting to 640 x 480");
+ setPreferredSize(dimension_640_480);
+ targetWidth = 640;
+ targetHeight = 480;
+ targetSize.setWidth(640);
+ targetSize.setHeight(480);
+ } else
+ if (j1 == 23) {
+ memoryImageSource = memoryImageSource_640_400;
+ image = image_640_400;
+ logger.info("Setting to 640 x 400");
+ setPreferredSize(dimension_640_400);
+ targetWidth = 640;
+ targetHeight = 400;
+ targetSize.setWidth(640);
+ targetSize.setHeight(400);
+ } else
+ if (j1 == 25) {
+ memoryImageSource = memoryImageSource_656_496;
+ image = image_656_496;
+ logger.info("Setting to 656 x 496");
+ setPreferredSize(dimension_656_496);
+ targetWidth = 656;
+ targetHeight = 496;
+ targetSize.setWidth(656);
+ targetSize.setHeight(496);
+ } else {
+ flag3 = true;
+ logger.warning("Bad messageType = " + j1);
+ }
+ java.awt.Container container = getParent();
+ java.awt.Container container1 = container;
+ k = j1;
+ }
+ if (i2 < 0 || i2 > targetWidth * targetHeight) {
+ flag3 = true;
+ logger.warning("Bad videoRamOffset = " + i2);
+ }
+ if (j2 < 0 || j2 > targetWidth * targetHeight) {
+ flag3 = true;
+ logger.warning("Bad videoRamCount = " + j2);
+ }
+ }
+ catch (IOException ioexception) {
+ logger.warning("LiveVideoPanel: got I/O exception" + ioexception);
+ break; /* Loop/switch isn't completed */
+ }
+ if (!flag3)
+ try {
+ decompress.doDecompress(datainputstream, i1 - 24, i2, j2, memoryImageSource, targetWidth, targetHeight);
+ }
+ catch (ArrayIndexOutOfBoundsException arrayindexoutofboundsexception) {
+ logger.warning("Decompress failed - " + arrayindexoutofboundsexception.toString());
+ flag3 = true;
+ }
+ if (i2 + j2 >= targetWidth * targetHeight)
+ break; /* Loop/switch isn't completed */
+ if (doPartialScreenUpdates) {
+ if (!decompress.pixelsInParts)
+ memoryImageSource.newPixels(0, 0, targetWidth, targetHeight, false);
+ if (!flag3)
+ repaint();
+ }
+_L3:
+ thread;
+ if (!Thread.interrupted()) goto _L2; else goto _L1
+_L1:
+ thread;
+ if (Thread.interrupted())
+ return;
+ if (!decompress.pixelsInParts)
+ memoryImageSource.newPixels(0, 0, targetWidth, targetHeight, false);
+ if (!flag3) {
+ repaint();
+ try {
+ livePanelWait += 2;
+ Thread.currentThread();
+ Thread.sleep(livePanelWait);
+ }
+ catch (InterruptedException interruptedexception) { }
+ }
+ if (MEASURE_PERFORMANCE) {
+ f2++;
+ long l2 = System.currentTimeMillis();
+ if (l2 - l > 10000L) {
+ System.out.println("Datagrams/sec = " + (f3 * 1000F) / (float)(l2 - l));
+ System.out.println("Frames/sec = " + (f2 * 1000F) / (float)(l2 - l));
+ System.out.println("Bit rate = " + (8F * f1) / 10F);
+ f2 = 0.0F;
+ f = 0.0F;
+ f1 = 0.0F;
+ f3 = 0.0F;
+ l = l2 = System.currentTimeMillis();
+ try {
+ mcsTcpConnection.sendMessage(ai);
+ }
+ catch (IOException ioexception1) {
+ logger.warning("Socket exception - LiveVideoPanel exiting");
+ return;
+ }
+ }
+ }
+ thread;
+ if (Thread.interrupted())
+ return;
+ goto _L3
+ }
+
+ public void run() {
+ process();
+ cleanupThread();
+ }
+
+ void setFrameSize(int i, int j) {
+ frameWidth = i;
+ frameHeight = j;
+ }
+
+ public int resumeVideo() {
+ try {
+ mcsTcpConnection.sendMessage(resumeMessage);
+ }
+ catch (IOException ioexception) {
+ return 2;
+ }
+ return 1;
+ }
+
+ public int pauseVideo() {
+ imagesAutomaticallyPaused = false;
+ try {
+ mcsTcpConnection.sendMessage(pauseMessage);
+ }
+ catch (IOException ioexception) {
+ return 2;
+ }
+ return 1;
+ }
+
+ public void addSliderListener(McsToolBar mcstoolbar) {
+ sliderListener = mcstoolbar;
+ }
+
+}