Example #1
0
    def __init__(self, protocol, supports_mmap, default_quality):
        self.closed = False
        self.ordinary_packets = []
        self.protocol = protocol
        self.supports_rgb24zlib = False
        # mmap:
        self.supports_mmap = supports_mmap
        self.mmap = None
        self.mmap_size = 0

        self.default_quality = default_quality  #default encoding quality for lossless encodings
        self.encoding = None  #the default encoding for all windows
        self.encodings = []  #all the encodings supported by the client
        self.encoding_client_options = False  #does the client support encoding options?
        self.png_window_icons = False
        self.default_batch_config = DamageBatchConfig()
        self.default_damage_options = {}

        self.window_sources = {}  #WindowSource for each Window ID

        self.uuid = None
        # client capabilities/options:
        self.client_type = None
        self.client_version = None
        self.client_platform = None
        self.auto_refresh_delay = 0
        self.server_window_resize = False
        self.send_cursors = False
        self.send_bell = False
        self.send_notifications = False
        self.send_windows = True
        self.randr_notify = False
        self.clipboard_enabled = False
        self.share = False
        self.desktop_size = None
        self.uses_swscale = False

        self.keyboard_config = None

        # the queues of damage requests we work through:
        self.damage_data_queue = Queue(
        )  #holds functions to call to process damage data
        #items placed in this queue are picked off by the "data_to_packet" thread,
        #the functions should add the packets they generate to the 'damage_packet_queue'
        self.damage_packet_queue = deque(
        )  #holds actual packets ready for sending (already encoded)
        #these packets are picked off by the "protocol" via 'next_packet()'
        #format: packet, wid, pixels, start_send_cb, end_send_cb
        #these statistics are shared by all WindowSource instances:
        self.statistics = GlobalPerformanceStatistics()
        # ready for processing:
        protocol.source = self
        self.datapacket_thread = start_daemon_thread(self.data_to_packet,
                                                     "data_to_packet")
Example #2
0
 def parse_hello(self, capabilities):
     #batch options:
     self.default_batch_config = DamageBatchConfig()
     self.default_batch_config.enabled = bool(
         capabilities.get("batch.enabled", DamageBatchConfig.ENABLED))
     self.default_batch_config.always = bool(
         capabilities.get("batch.always", False))
     self.default_batch_config.min_delay = min(
         1000,
         max(
             1,
             capabilities.get("batch.min_delay",
                              DamageBatchConfig.MIN_DELAY)))
     self.default_batch_config.max_delay = min(
         15000,
         max(
             1,
             capabilities.get("batch.max_delay",
                              DamageBatchConfig.MAX_DELAY)))
     self.default_batch_config.delay = min(
         1000,
         max(1,
             capabilities.get("batch.delay",
                              DamageBatchConfig.START_DELAY)))
     #client uuid:
     self.uuid = capabilities.get("uuid", "")
     #general features:
     self.server_window_resize = capabilities.get("server-window-resize",
                                                  False)
     self.send_cursors = capabilities.get("cursors", False)
     self.send_bell = capabilities.get("bell", False)
     self.send_notifications = capabilities.get("notifications", False)
     self.randr_notify = capabilities.get("randr_notify", False)
     self.clipboard_enabled = capabilities.get("clipboard", True)
     self.share = capabilities.get("share", False)
     self.desktop_size = capabilities.get("desktop_size")
     #encodings:
     self.encoding_client_options = capabilities.get(
         "encoding_client_options", False)
     self.encodings = capabilities.get("encodings", [])
     self.set_encoding(capabilities.get("encoding", None), None)
     if "jpeg" in capabilities:
         self.default_damage_options["jpegquality"] = capabilities["jpeg"]
     self.png_window_icons = "png" in self.encodings and "png" in ENCODINGS
     #mmap:
     mmap_file = capabilities.get("mmap_file")
     mmap_token = capabilities.get("mmap_token")
     log("client supplied mmap_file=%s, mmap supported=%s", mmap_file,
         self.supports_mmap)
     if self.supports_mmap and mmap_file and os.path.exists(mmap_file):
         self.init_mmap(mmap_file, mmap_token)
     log("cursors=%s, bell=%s, notifications=%s", self.send_cursors,
         self.send_bell, self.send_notifications)
Example #3
0
 def parse_hello(self, capabilities):
     #batch options:
     self.default_batch_config = DamageBatchConfig()
     self.default_batch_config.always = bool(
         capabilities.get("batch.always", False))
     self.default_batch_config.min_delay = min(
         1000,
         max(
             1,
             capabilities.get("batch.min_delay",
                              DamageBatchConfig.MIN_DELAY)))
     self.default_batch_config.max_delay = min(
         15000,
         max(
             1,
             capabilities.get("batch.max_delay",
                              DamageBatchConfig.MAX_DELAY)))
     self.default_batch_config.delay = min(
         1000,
         max(1,
             capabilities.get("batch.delay",
                              DamageBatchConfig.START_DELAY)))
     #client uuid:
     self.uuid = capabilities.get("uuid", "")
     self.client_type = capabilities.get("client_type", "PyGTK")
     self.client_platform = capabilities.get("platform", "")
     self.client_version = capabilities.get("version", None)
     #general features:
     self.send_windows = capabilities.get("windows", True)
     self.server_window_resize = capabilities.get("server-window-resize",
                                                  False)
     self.send_cursors = self.send_windows and capabilities.get(
         "cursors", False)
     self.send_bell = capabilities.get("bell", False)
     self.send_notifications = capabilities.get("notifications", False)
     self.randr_notify = capabilities.get("randr_notify", False)
     self.clipboard_enabled = capabilities.get("clipboard", True)
     self.share = capabilities.get("share", False)
     self.desktop_size = capabilities.get("desktop_size")
     self.uses_swscale = capabilities.get("uses_swscale", True)
     #encodings:
     self.encoding_client_options = capabilities.get(
         "encoding_client_options", False)
     self.supports_rgb24zlib = capabilities.get("rgb24zlib", False)
     self.encodings = capabilities.get("encodings", [])
     self.set_encoding(capabilities.get("encoding", None), None)
     q = self.default_quality
     if "jpeg" in capabilities:  #pre 0.7 versions
         q = capabilities["jpeg"]
     if "quality" in capabilities:  #0.7 onwards:
         q = capabilities["quality"]
     if q >= 0:
         self.default_damage_options["quality"] = q
     self.png_window_icons = "png" in self.encodings and "png" in ENCODINGS
     self.auto_refresh_delay = int(capabilities.get("auto_refresh_delay",
                                                    0)) / 1000.0
     #keyboard:
     self.keyboard_config = KeyboardConfig()
     self.keyboard_config.enabled = self.send_windows and bool(
         capabilities.get("keyboard", True))
     self.assign_keymap_options(capabilities)
     self.keyboard_config.xkbmap_layout = capabilities.get("xkbmap_layout")
     self.keyboard_config.xkbmap_variant = capabilities.get(
         "xkbmap_variant")
     #mmap:
     if self.send_windows:
         #we don't need mmap if not sending pixels
         mmap_file = capabilities.get("mmap_file")
         mmap_token = capabilities.get("mmap_token")
         log("client supplied mmap_file=%s, mmap supported=%s", mmap_file,
             self.supports_mmap)
         if self.supports_mmap and mmap_file and os.path.exists(mmap_file):
             self.init_mmap(mmap_file, mmap_token)
     log("cursors=%s, bell=%s, notifications=%s", self.send_cursors,
         self.send_bell, self.send_notifications)
     log.info("%s client version %s with uuid %s", self.client_type,
              self.client_version, self.uuid)
     if self.send_windows:
         if self.mmap_size > 0:
             log.info("mmap is enabled using %sBytes area in %s",
                      std_unit(self.mmap_size), mmap_file)
         else:
             log.info("using %s as primary encoding", self.encoding)
     else:
         log.info("windows forwarding is disabled")