import sys, os, os.path, time, socket, re

sys.path.append("./pyvnc2swf")

from rfb import RFBError, RFBNetworkClient, RFBStreamConverter
from movie import SWFInfo
from image import IMG_RAW, IMG_SOLID

import sys 

class VideoStream:
	def __init__(self,*args):
		print "__init__(%s)" % str(args)
	def open(self, *args):
		pass
	def paint_frame(self, (images, othertags, cursor_info)):
		for ((x0,y0), (w,h,(format, data))) in images:
			print "update(%d,%d [%d, %d])" % (x0, y0 , w, h)
			if(format == IMG_SOLID):
				# solid colour
				print "solid colour"
			elif (format == IMG_RAW):
				# rgb [len(data) == 3 * w * h]
				# or rgba [4 * w * h]
				print "raw image"
				
	def next_frame(self):
		print "next_frame()"

class VideoInfo:
	def __init__(self):
	 	self.compression = 0
		self.clipping = None
	 	self.framerate = 3
		self.scalable = False

	def set_defaults(self, w, h):
		self.w = w
		self.h = h
		self.clipping = (0,0,w,h)

stream = VideoStream()
converter = RFBStreamConverter(VideoInfo(), stream, debug=1)
client = RFBNetworkClient("127.0.0.1", 5900, converter)

client.init().auth().start()
client.loop()
## $Id: rfbdump.py,v 1.3 2007/04/05 05:15:29 gopalv Exp $ ##
