Hi, every one.

I'm trying something with the java viewer of vnc 4
I'm trying to do an intelligent redirectionner.
So i take the java viwer, and open a socket server on it to accept the
connection of some other java viewer.
I do the init part, and copy on a buffer the rect i receive from the
original server.
I works quite good !

but only for the none compress mode.
I can't make it work's with the ZRLE mode.
in fact if i copy simply the decode stream it doesn't wor because i had to
keep it compressed.

But when i copy the buffer juste before the decompression, and send it  to
the other client, i got a inflate error on the decode.

But i do a lot of test, and compare the buffer of the redirectionner, and
the viewer and it seem's be the same ?
i certainlny don't understand some thing, but i can't find what ???

If someome can help me  PLEASE !!!

My code :
it's on the ZlibStream class.
the rest is not touch.
the "dupMem._dataOutputStream.write(buf_mem[i]);" is the copy.
and the 2 boucle under "**********TRACE***********" are the print on the
console off the stream compressed and uncompressed.
it is the same compress stream for the client, but on the first decode it
does a "java.util.zip.DataFormatException"
so there's certainly a problem ! or something that i don't understand on the
dicodage with ZRLE

CODE :
  protected int overrun(int itemSize, int nItems) {
    if (itemSize > bufSize)
      throw new Exception("ZlibInStream overrun: max itemSize exceeded");
    if (underlying == null)
      throw new Exception("ZlibInStream overrun: no underlying stream");

    if (end - ptr != 0)
      System.arraycopy(b, ptr, b, 0, end - ptr);
    ptrOffset += ptr;
    end -= ptr;
    ptr = 0;
     while (end < itemSize) {
      decompress();
    }

    if (itemSize * nItems > end)
      nItems = end / itemSize;

    return nItems;
  }

  // decompress() calls the decompressor once.  Note that this won't
  // necessarily generate any output data - it may just consume some input
  // data.  Returns false if wait is false and we would block on the
underlying
  // stream.

  private void decompress() {
    try {
      underlying.check(1);
      int avail_in = underlying.getend() - underlying.getptr();
      if (avail_in > bytesIn)
        avail_in = bytesIn;
/**********TRACE**************/
System.err.println("Avail_In ="+avail_in );System.err.flush();
byte[] buf_mem=null;
int ptr_mem=0;
buf_mem=underlying.getbuf();
ptr_mem=underlying.getptr();
int passage;
/*****************************/

      if (inflater.needsInput()) {
          /*******************TRACE***********************/
          DuplicateurMem dupMem = DuplicateurMem.getInstance();// matt
          passage=0;
           for(int i=ptr_mem;i<(ptr_mem+avail_in);i++){
              try{
                  if(passage<20 || passage>(avail_in-20))
                      System.err.println("Data["+i+"] : "+buf_mem[i]
);System.err.flush();

if(passage==20)System.err.println("...");System.err.flush();

                  dupMem._dataOutputStream.write(buf_mem[i]);
                  passage++;
              }catch(java.io.IOException e){}
          }
          saveSecretKey(new File("c:/bufmem.txt"),buf_mem );
          /****************************************************/

        inflater.setInput(underlying.getbuf(), underlying.getptr(),
avail_in);
        //inflater.setInput(buf_mem, ptr_mem, avail_in);
      }

      //System.err.println("ptr="+ptr_mem+" avail_in
"+avail_in);System.err.flush();
      int n=0;
      try{
      n = inflater.inflate(b, end, bufSize - end);
      }catch(java.util.zip.DataFormatException e){}
      /********************TRACE*************************/
        System.err.println("Inflate : end="+end+"
bufSize-end="+(bufSize-end)+" nbUncompress="+n+"
TotalUncompress="+inflater.getTotalIn()+"
Totalinput="+inflater.getTotalOut() );System.err.flush();
         passage=0;
         for(int i=end;i<(n+end);i++){
                 if(passage<20 || passage>(n+end-20))
                     System.err.println("DataUncompress["+i+"] : "+b[i]
);System.err.flush();

if(passage==20)System.err.println("...");System.err.flush();
                 passage++;
          }
         saveSecretKey(new File("c:/b.txt"),b );
          /**************************************************/
      end += n;
      if (inflater.needsInput()) {

        bytesIn -= avail_in;
        underlying.setptr(underlying.getptr() + avail_in);
      }
    } catch (/*java.util.zip.DataFormat*/Exception e) {
      throw new Exception("ZlibInStream: inflate failed");
    }
  }


Thanks a lot for Help !!!
_______________________________________________
VNC-List mailing list
[email protected]
To remove yourself from the list visit:
http://www.realvnc.com/mailman/listinfo/vnc-list

Reply via email to