1 // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
2 // Jad home page: http://www.kpdus.com/jad.html
3 // Decompiler options: packimports(3) fieldsfirst nonlb space
8 import java.awt.image.*;
10 import java.net.DatagramPacket;
11 import java.util.LinkedList;
12 import java.util.logging.Level;
13 import java.util.logging.Logger;
14 import javax.swing.JPanel;
16 // Referenced classes of package mcsClient:
17 // ColorPalette, Decompress, McsTargetSize, McsTcpConnection,
18 // McsToolBar, LockingKeyStateManager
20 public final class LiveVideoPanel extends JPanel
23 private int targetWidth;
24 private int targetHeight;
25 private boolean initialized;
26 private McsTargetSize targetSize;
27 private ColorPalette colorPalette;
28 private IndexColorModel indexColorModel;
29 private LinkedList datagramList;
30 public static boolean PRINT_HEADER = false;
31 public static boolean MEASURE_PERFORMANCE = false;
32 public boolean SHOW_CURSOR;
33 public static final boolean DEBUG_MOUSE = false;
34 public static final int SUCCESS = 1;
35 public static final int FAILURE = 2;
36 boolean doPartialScreenUpdates;
37 boolean interpolation;
38 Graphics2D graphics2D;
39 RenderingHints renderingHints;
40 private final Toolkit defaultToolkit = Toolkit.getDefaultToolkit();
41 private final Cursor invisibleCursor;
42 private Cursor visibleCursor;
43 private Cursor currentCursor;
44 private byte imageData[];
45 private MemoryImageSource memoryImageSource;
46 private MemoryImageSource memoryImageSource_1024_768;
47 private MemoryImageSource memoryImageSource_800_600;
48 private MemoryImageSource memoryImageSource_640_480;
49 private MemoryImageSource memoryImageSource_640_400;
50 private MemoryImageSource memoryImageSource_656_496;
51 private Image image_1024_768;
52 private Image image_800_600;
53 private Image image_640_480;
54 private Image image_640_400;
55 private Image image_656_496;
57 private int blankImage[];
58 private MemoryImageSource blankMemoryImageSource;
60 private Dimension dimension_1024_768;
61 private Dimension dimension_800_600;
62 private Dimension dimension_640_480;
63 private Dimension dimension_640_400;
64 private Dimension dimension_656_496;
65 private McsTcpConnection mcsTcpConnection;
66 private int frameWidth;
67 private int frameHeight;
68 private int livePanelWait;
69 private boolean livePanelSchedule;
70 private McsToolBar sliderListener;
71 private static int resumeMessage[] = new int[2];
72 private static int pauseMessage[] = new int[2];
73 boolean imagesAutomaticallyPaused;
74 private LockingKeyStateManager lockingKeyStateManager;
75 private static Logger logger = Logger.getAnonymousLogger();
77 public LiveVideoPanel(McsTcpConnection mcstcpconnection, LinkedList linkedlist, McsTargetSize mcstargetsize, LockingKeyStateManager lockingkeystatemanager) {
81 colorPalette = new ColorPalette();
82 indexColorModel = new IndexColorModel(8, colorPalette.hardwareColors.length, colorPalette.hardwareColors, 0, 0, null);
84 doPartialScreenUpdates = true;
85 interpolation = false;
87 renderingHints = null;
88 invisibleCursor = defaultToolkit.createCustomCursor(new BufferedImage(1, 1, 2), new Point(0, 0), "");
89 dimension_1024_768 = new Dimension(1024, 768);
90 dimension_800_600 = new Dimension(800, 600);
91 dimension_640_480 = new Dimension(640, 480);
92 dimension_640_400 = new Dimension(640, 400);
93 dimension_656_496 = new Dimension(656, 496);
94 sliderListener = null;
95 imagesAutomaticallyPaused = false;
96 mcsTcpConnection = mcstcpconnection;
97 datagramList = linkedlist;
98 targetSize = mcstargetsize;
99 lockingKeyStateManager = lockingkeystatemanager;
100 imageData = new byte[targetWidth * targetHeight * 2];
101 memoryImageSource_1024_768 = new MemoryImageSource(1024, 768, indexColorModel, imageData, 0, 1024);
102 memoryImageSource_800_600 = new MemoryImageSource(800, 600, indexColorModel, imageData, 0, 800);
103 memoryImageSource_640_480 = new MemoryImageSource(640, 480, indexColorModel, imageData, 0, 640);
104 memoryImageSource_640_400 = new MemoryImageSource(640, 400, indexColorModel, imageData, 0, 640);
105 memoryImageSource_656_496 = new MemoryImageSource(656, 496, indexColorModel, imageData, 0, 656);
106 memoryImageSource_1024_768.setAnimated(true);
107 memoryImageSource_800_600.setAnimated(true);
108 memoryImageSource_640_480.setAnimated(true);
109 memoryImageSource_640_400.setAnimated(true);
110 memoryImageSource_656_496.setAnimated(true);
111 memoryImageSource = memoryImageSource_1024_768;
112 image_1024_768 = createImage(memoryImageSource_1024_768);
113 image_800_600 = createImage(memoryImageSource_800_600);
114 image_640_480 = createImage(memoryImageSource_640_480);
115 image_640_400 = createImage(memoryImageSource_640_400);
116 image_656_496 = createImage(memoryImageSource_656_496);
117 image = image_1024_768;
118 blankImage = new int[0xc0000];
119 blankMemoryImageSource = new MemoryImageSource(1024, 768, indexColorModel, blankImage, 0, 1024);
120 blank = createImage(blankMemoryImageSource);
121 Cursor cursor = getCursor();
122 Cursor cursor1 = cursor;
124 setCursor(invisibleCursor);
125 Cursor cursor2 = invisibleCursor;
127 resumeMessage[0] = resumeMessage.length * 4;
128 resumeMessage[1] = 8;
129 pauseMessage[0] = pauseMessage.length * 4;
132 livePanelSchedule = true;
133 logger.setLevel(Level.WARNING);
134 String s = System.getProperty("mcs.debug");
135 if (s != null && s.equalsIgnoreCase("true"))
136 logger.setLevel(Level.ALL);
140 public void toggleVisibleCursor() {
141 if (currentCursor.equals(visibleCursor)) {
142 setCursor(invisibleCursor);
143 currentCursor = invisibleCursor;
145 setCursor(visibleCursor);
146 currentCursor = visibleCursor;
150 public boolean initialized() {
154 public boolean isFocusable() {
158 public void addNotify() {
162 public boolean isOpaque() {
166 public void paintComponent(Graphics g) {
167 super.paintComponent(g);
168 Rectangle rectangle = g.getClipBounds();
169 if (rectangle.x >= 0 && rectangle.x < targetWidth && rectangle.y >= 0 && rectangle.y < targetHeight)
170 g.drawImage(image, 0, 0, null);
174 public void update(Graphics g) {
178 public void setInterpolation(boolean flag) {
179 interpolation = flag;
182 private void cleanupThread() {
183 mcsTcpConnection = null;
185 lockingKeyStateManager = null;
189 private void process() {
198 Decompress decompress;
204 boolean flag = false;
206 boolean flag1 = false;
207 boolean flag2 = false;
212 ai[0] = ai.length * 4;
214 setBackground(Color.white);
217 decompress = new Decompress(imageData);
219 l = l1 = System.currentTimeMillis();
220 graphics2D = (Graphics2D)getGraphics();
221 renderingHints = graphics2D.getRenderingHints();
222 logger.info("RenderingHints size = " + renderingHints.size());
223 thread = Thread.currentThread();
224 break MISSING_BLOCK_LABEL_1474;
226 LinkedList linkedlist = datagramList;
227 JVM INSTR monitorenter ;
229 DatagramPacket datagrampacket;
233 if (Thread.interrupted()) {
234 logger.info("Terminating LiveVideoPanel");
238 while ((i = datagramList.size()) == 0)
240 datagrampacket = (DatagramPacket)datagramList.removeLast();
243 catch (InterruptedException interruptedexception1) { }
249 if (i > 2 || !imagesAutomaticallyPaused)
250 break MISSING_BLOCK_LABEL_277;
251 if (resumeVideo() != 1) {
252 logger.severe("Socket exception - LiveVideoPanel exiting");
255 imagesAutomaticallyPaused = false;
256 break MISSING_BLOCK_LABEL_313;
257 if (i < 6 || imagesAutomaticallyPaused)
258 break MISSING_BLOCK_LABEL_313;
259 if (pauseVideo() != 1) {
260 logger.severe("Socket exception - LiveVideoPanel exiting");
263 imagesAutomaticallyPaused = true;
264 DataInputStream datainputstream;
266 datainputstream = new DataInputStream(new ByteArrayInputStream(datagrampacket.getData(), datagrampacket.getOffset(), datagrampacket.getLength()));
268 catch (NullPointerException nullpointerexception) {
269 logger.severe("Data stream has been closed. LiveVideoPanel exiting.");
276 int j = datagrampacket.getLength();
277 i1 = datainputstream.readInt();
278 int j1 = datainputstream.readInt();
279 int k1 = datainputstream.readInt();
280 i2 = datainputstream.readInt();
281 j2 = datainputstream.readInt();
282 int k2 = datainputstream.readInt();
283 if (MEASURE_PERFORMANCE) {
289 System.out.println();
290 System.out.println("dg length: " + i1 + ", vro: " + i2 + ", vrc: " + j2);
295 logger.warning("Bad datagramLength = " + i1);
299 memoryImageSource = memoryImageSource_1024_768;
300 image = image_1024_768;
301 logger.info("Setting to 1024 x 768");
302 setPreferredSize(dimension_1024_768);
305 targetSize.setWidth(1024);
306 targetSize.setHeight(768);
309 memoryImageSource = memoryImageSource_800_600;
310 image = image_800_600;
311 logger.info("Setting to 800 x 600");
312 setPreferredSize(dimension_800_600);
315 targetSize.setWidth(800);
316 targetSize.setHeight(600);
319 memoryImageSource = memoryImageSource_640_480;
320 image = image_640_480;
321 logger.info("Setting to 640 x 480");
322 setPreferredSize(dimension_640_480);
325 targetSize.setWidth(640);
326 targetSize.setHeight(480);
329 memoryImageSource = memoryImageSource_640_400;
330 image = image_640_400;
331 logger.info("Setting to 640 x 400");
332 setPreferredSize(dimension_640_400);
335 targetSize.setWidth(640);
336 targetSize.setHeight(400);
339 memoryImageSource = memoryImageSource_656_496;
340 image = image_656_496;
341 logger.info("Setting to 656 x 496");
342 setPreferredSize(dimension_656_496);
345 targetSize.setWidth(656);
346 targetSize.setHeight(496);
349 logger.warning("Bad messageType = " + j1);
351 java.awt.Container container = getParent();
352 java.awt.Container container1 = container;
355 if (i2 < 0 || i2 > targetWidth * targetHeight) {
357 logger.warning("Bad videoRamOffset = " + i2);
359 if (j2 < 0 || j2 > targetWidth * targetHeight) {
361 logger.warning("Bad videoRamCount = " + j2);
364 catch (IOException ioexception) {
365 logger.warning("LiveVideoPanel: got I/O exception" + ioexception);
366 break; /* Loop/switch isn't completed */
370 decompress.doDecompress(datainputstream, i1 - 24, i2, j2, memoryImageSource, targetWidth, targetHeight);
372 catch (ArrayIndexOutOfBoundsException arrayindexoutofboundsexception) {
373 logger.warning("Decompress failed - " + arrayindexoutofboundsexception.toString());
376 if (i2 + j2 >= targetWidth * targetHeight)
377 break; /* Loop/switch isn't completed */
378 if (doPartialScreenUpdates) {
379 if (!decompress.pixelsInParts)
380 memoryImageSource.newPixels(0, 0, targetWidth, targetHeight, false);
386 if (!Thread.interrupted()) goto _L2; else goto _L1
389 if (Thread.interrupted())
391 if (!decompress.pixelsInParts)
392 memoryImageSource.newPixels(0, 0, targetWidth, targetHeight, false);
397 Thread.currentThread();
398 Thread.sleep(livePanelWait);
400 catch (InterruptedException interruptedexception) { }
402 if (MEASURE_PERFORMANCE) {
404 long l2 = System.currentTimeMillis();
405 if (l2 - l > 10000L) {
406 System.out.println("Datagrams/sec = " + (f3 * 1000F) / (float)(l2 - l));
407 System.out.println("Frames/sec = " + (f2 * 1000F) / (float)(l2 - l));
408 System.out.println("Bit rate = " + (8F * f1) / 10F);
413 l = l2 = System.currentTimeMillis();
415 mcsTcpConnection.sendMessage(ai);
417 catch (IOException ioexception1) {
418 logger.warning("Socket exception - LiveVideoPanel exiting");
424 if (Thread.interrupted())
434 void setFrameSize(int i, int j) {
439 public int resumeVideo() {
441 mcsTcpConnection.sendMessage(resumeMessage);
443 catch (IOException ioexception) {
449 public int pauseVideo() {
450 imagesAutomaticallyPaused = false;
452 mcsTcpConnection.sendMessage(pauseMessage);
454 catch (IOException ioexception) {
460 public void addSliderListener(McsToolBar mcstoolbar) {
461 sliderListener = mcstoolbar;