+++ /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.io.IOException;
-import java.net.*;
-import java.util.LinkedList;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.swing.JFrame;
-import javax.swing.JOptionPane;
-
-// Referenced classes of package mcsClient:
-// BitMap, SecureDatagramSocket, McsTcpConnection, LiveVideoPanel,
-// McsToolBar
-
-public final class DatagramReader
- implements Runnable {
-
- public boolean videoLostSync;
- private DatagramSocket dgSocket;
- private McsTcpConnection mcsTcpConnection;
- private LiveVideoPanel liveVideoPanel;
- private LinkedList datagramList;
- private static final boolean USE_MULTICAST = false;
- public static final int DEFAULT_DIALIN_BITRATE;
- public static final int DEFAULT_NET_BITRATE;
- private long serverTime;
- private long serverBaseTime;
- private long clientTime;
- private long clientBaseTime;
- private boolean gotBaseTime;
- private long skew;
- private long upperSkew;
- private long lowerSkew;
- private long initialBitRate;
- private long skewTime;
- private boolean gotBeginningOfFrame;
- private boolean gotInitialBitRate;
- private boolean detectedPPP;
- private int frameNumber;
- private int maxSequenceNumber;
- private int lastFrameNumber;
- private long totalFrameSize;
- private BitMap bitmap;
- private boolean initialized;
- private static int nakMessage[] = new int[4];
- private McsToolBar sliderListener;
- private int nakCount;
- private static Logger logger = Logger.getAnonymousLogger();
-
- public DatagramReader(McsTcpConnection mcstcpconnection, LiveVideoPanel livevideopanel, LinkedList linkedlist, String s, int i, boolean flag) {
- videoLostSync = false;
- serverBaseTime = 0L;
- clientTime = 0L;
- clientBaseTime = 0L;
- gotBaseTime = false;
- skew = 0L;
- upperSkew = 150L;
- lowerSkew = -10L;
- initialBitRate = 0L;
- skewTime = 225L;
- gotBeginningOfFrame = false;
- gotInitialBitRate = false;
- detectedPPP = false;
- maxSequenceNumber = 0;
- lastFrameNumber = 0;
- totalFrameSize = 0L;
- bitmap = new BitMap();
- initialized = true;
- sliderListener = null;
- nakCount = 0;
- mcsTcpConnection = mcstcpconnection;
- liveVideoPanel = livevideopanel;
- datagramList = linkedlist;
- logger.setLevel(Level.WARNING);
- String s1 = System.getProperty("mcs.debug");
- if (s1 != null && s1.equalsIgnoreCase("true"))
- logger.setLevel(Level.ALL);
- nakMessage[0] = nakMessage.length * 4;
- nakMessage[1] = 5;
- if (mcstcpconnection.getDetectedPPP() || flag) {
- detectedPPP = true;
- upperSkew = 150L;
- lowerSkew = -30L;
- skewTime = 2000L;
- }
- if (mcstcpconnection.videoEncrypted())
- dgSocket = new SecureDatagramSocket(mcstcpconnection.cipher1, mcstcpconnection.cipher2, mcstcpconnection.getLocalPort());
- else
- dgSocket = new DatagramSocket(mcstcpconnection.getLocalPort());
- dgSocket.setReceiveBufferSize(0x1f400);
- dgSocket.setSoTimeout(500);
- if (flag)
- return;
- try {
- byte abyte0[] = new byte[10];
- DatagramPacket datagrampacket = new DatagramPacket(abyte0, abyte0.length, InetAddress.getByName(s), i);
- for (int j = 0; j < 6; j++) {
- dgSocket.send(datagrampacket);
- try {
- Thread.currentThread();
- Thread.sleep(60L);
- }
- catch (InterruptedException interruptedexception) { }
- }
-
- try {
- Thread.currentThread();
- Thread.sleep(200L);
- }
- catch (InterruptedException interruptedexception1) { }
- }
- catch (Exception exception) {
- logger.severe(exception.toString());
- initialized = false;
- JOptionPane.showMessageDialog(new JFrame(), "Failed to connect. Try again.", "Remote Console Datagram Reader Initialization Error", 0);
- }
- return;
- }
-
- private void cleanupThread() {
- if (dgSocket != null) {
- dgSocket.disconnect();
- dgSocket.close();
- }
- dgSocket = null;
- mcsTcpConnection = null;
- liveVideoPanel = null;
- datagramList = null;
- initialized = false;
- }
-
- private void process() {
- int l;
- Thread thread;
- l = 0;
- boolean flag = false;
- boolean flag1 = false;
- boolean flag2 = false;
- if (!initialized)
- return;
- thread = Thread.currentThread();
- goto _L1
-_L22:
- if (nakCount >= 25) {
- logger.info("25 NAK messages sent");
- nakCount = 0;
- }
- DatagramPacket datagrampacket;
- byte abyte1[] = new byte[1500];
- datagrampacket = new DatagramPacket(abyte1, abyte1.length);
- dgSocket.receive(datagrampacket);
- goto _L2
- SocketTimeoutException sockettimeoutexception;
- sockettimeoutexception;
- goto _L1
- IOException ioexception3;
- ioexception3;
- logger.warning("Datagram Reader - error reading datagram " + ioexception3);
- return;
-_L2:
- byte abyte0[];
- int j;
- abyte0 = datagrampacket.getData();
- j = datagrampacket.getOffset();
- if (datagrampacket.getLength() >= 24) goto _L3; else goto _L1
-_L3:
- if (abyte0[j + 7] != 6) goto _L5; else goto _L4
-_L4:
- videoLostSync = true;
- gotBaseTime = false;
- logger.info("DatagramReader: video lost sync");
- goto _L1
-_L5:
- videoLostSync = false;
- frameNumber = (abyte0[j + 8] & 0xff) << 8 | abyte0[j + 9] & 0xff;
- if (gotBeginningOfFrame) goto _L7; else goto _L6
-_L6:
- if ((abyte0[j + 7] & 0xbf) != 0) goto _L8; else goto _L1
-_L8:
- gotBeginningOfFrame = true;
- lastFrameNumber = frameNumber - 1;
- l = 128;
- bitmap.clear();
- bitmap.setBit(0);
-_L7:
- int i;
- i = (abyte0[j + 10] & 0xff) << 8 | abyte0[j + 11] & 0xff;
- int i1 = (abyte0[j + 2] & 0xff) << 8 | abyte0[j + 3] & 0xff;
- totalFrameSize += i1;
- serverTime = ((long)abyte0[j + 20] & 255L) << 24 | ((long)abyte0[j + 21] & 255L) << 16 | ((long)abyte0[j + 22] & 255L) << 8 | (long)abyte0[j + 23] & 255L;
- clientTime = System.currentTimeMillis();
- if (gotBaseTime) goto _L10; else goto _L9
-_L9:
- gotBaseTime = true;
- serverBaseTime = serverTime;
- clientBaseTime = clientTime;
- totalFrameSize = 0L;
- goto _L11
-_L10:
- long l1;
- skew = clientTime - clientBaseTime - (serverTime - serverBaseTime);
- l1 = (totalFrameSize * 8L * 1000L) / ((clientTime - clientBaseTime) + 50L);
- if (l1 > 0x13880L)
- liveVideoPanel.doPartialScreenUpdates = false;
- else
- liveVideoPanel.doPartialScreenUpdates = true;
- if (skew >= lowerSkew) goto _L13; else goto _L12
-_L12:
- gotBaseTime = false;
- goto _L11
-_L13:
- if (skew <= upperSkew || clientTime - clientBaseTime <= skewTime) goto _L11; else goto _L14
-_L14:
- int ai[];
- if (!gotInitialBitRate) {
- initialBitRate = l1;
- gotInitialBitRate = true;
- if (detectedPPP) {
- if (initialBitRate < (long)DEFAULT_DIALIN_BITRATE)
- initialBitRate = DEFAULT_DIALIN_BITRATE;
- } else
- if (initialBitRate < (long)DEFAULT_NET_BITRATE)
- initialBitRate = DEFAULT_NET_BITRATE;
- if (sliderListener != null)
- sliderListener.setSliderInitialBitRate(initialBitRate);
- } else {
- if (l1 < (initialBitRate * 60L) / 100L)
- l1 = (initialBitRate * 60L) / 100L;
- if (detectedPPP && l1 > initialBitRate)
- l1 = initialBitRate;
- }
- gotBaseTime = false;
- l1 *= 75L;
- l1 /= 100L;
- ai = new int[3];
- ai[0] = ai.length * 4;
- ai[1] = 10;
- ai[2] = (int)l1;
- thread;
- if (Thread.interrupted())
- return;
- try {
- mcsTcpConnection.sendMessage(ai, false);
- }
- catch (IOException ioexception4) {
- logger.severe("Socket exception - DatagramReader exiting");
- return;
- }
-_L11:
- if (frameNumber == lastFrameNumber)
- break MISSING_BLOCK_LABEL_1033;
- if (frameNumber == lastFrameNumber + 1) goto _L16; else goto _L15
-_L15:
- nakMessage[2] = 0;
- nakMessage[3] = frameNumber;
- try {
- mcsTcpConnection.sendMessage(nakMessage, false);
- }
- catch (IOException ioexception) {
- logger.severe("Socket exception - DatagramReader exiting");
- return;
- }
- nakCount++;
- goto _L17
-_L16:
- if ((l & 0x80) != 0) goto _L19; else goto _L18
-_L18:
- nakMessage[2] = 0;
- nakMessage[3] = 0;
- thread;
- if (Thread.interrupted())
- return;
- try {
- mcsTcpConnection.sendMessage(nakMessage, false);
- }
- catch (IOException ioexception1) {
- logger.severe("Socket exception - DatagramReader exiting");
- return;
- }
- nakCount++;
- goto _L17
-_L20:
- int k;
- nakMessage[2] = k;
- nakMessage[3] = frameNumber;
- thread;
- if (Thread.interrupted())
- return;
- try {
- mcsTcpConnection.sendMessage(nakMessage, false);
- }
- catch (IOException ioexception2) {
- logger.severe("Socket exception - DatagramReader exiting");
- return;
- }
- nakCount++;
- break; /* Loop/switch isn't completed */
-_L19:
- if ((k = bitmap.findZeroBit()) <= maxSequenceNumber) goto _L20; else goto _L17
-_L17:
- lastFrameNumber = frameNumber;
- bitmap.clear();
- l = 0;
- maxSequenceNumber = 0;
- bitmap.setBit(i);
- maxSequenceNumber = i <= maxSequenceNumber ? maxSequenceNumber : i;
- l |= abyte0[j + 7];
- abyte0[j + 7] &= 0x3f;
- int j1;
- if ((j1 = datagramList.size()) < 10 || liveVideoPanel.imagesAutomaticallyPaused)
- break MISSING_BLOCK_LABEL_1147;
- thread;
- if (Thread.interrupted())
- return;
- if (liveVideoPanel.pauseVideo() != 1) {
- logger.severe("Socket exception - DatagramReader exiting");
- return;
- }
- liveVideoPanel.imagesAutomaticallyPaused = true;
- long l2 = ((long)abyte0[j] & 255L) << 24 | ((long)abyte0[j + 1] & 255L) << 16 | ((long)abyte0[j + 2] & 255L) << 8 | (long)abyte0[j + 3] & 255L;
- long l3 = ((long)abyte0[j + 12] & 255L) << 24 | ((long)abyte0[j + 13] & 255L) << 16 | ((long)abyte0[j + 14] & 255L) << 8 | (long)abyte0[j + 15] & 255L;
- long l4 = ((long)abyte0[j + 16] & 255L) << 24 | ((long)abyte0[j + 17] & 255L) << 16 | ((long)abyte0[j + 18] & 255L) << 8 | (long)abyte0[j + 19] & 255L;
- if (i >= 0 && i <= 896 && l3 >= 0L && l3 <= 0xc0000L && l4 >= 0L && l3 <= 0xc0000L) {
- if (l2 != 31L)
- synchronized (datagramList) {
- datagramList.addFirst(datagrampacket);
- datagramList.notify();
- }
- } else {
- logger.warning("Bad packet discarded. seq num: " + i + " vid ram offset: " + l3 + " vid ram count: " + l4);
- }
- goto _L1
- ArrayIndexOutOfBoundsException arrayindexoutofboundsexception;
- arrayindexoutofboundsexception;
- logger.warning(arrayindexoutofboundsexception.toString());
-_L1:
- thread;
- if (Thread.interrupted())
- return;
- if (true) goto _L22; else goto _L21
-_L21:
- }
-
- public void run() {
- process();
- cleanupThread();
- }
-
- protected void finalize() throws Throwable {
- cleanupThread();
- }
-
- public boolean initialized() {
- return initialized;
- }
-
- public void addSliderListener(McsToolBar mcstoolbar) {
- sliderListener = mcstoolbar;
- }
-
- public void setInitialBitRate(long l) {
- initialBitRate = l;
- gotInitialBitRate = true;
- int ai[] = new int[3];
- ai[0] = ai.length * 4;
- ai[1] = 10;
- ai[2] = (int)l;
- try {
- mcsTcpConnection.sendMessage(ai, true);
- }
- catch (IOException ioexception) {
- logger.severe("Socket exception - setInitialBitRate");
- return;
- }
- }
-
- static {
- DEFAULT_DIALIN_BITRATE = McsToolBar.BITRATES[2];
- DEFAULT_NET_BITRATE = McsToolBar.BITRATES[7];
- }
-}