Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def reset(self):
# mmap state:
self.mmap_size = 0
self.mmap_bytes_sent = 0
self.mmap_free_size = 0 #how much of the mmap space is left (may be negative if we failed to write the last chunk)
# queue statistics:
self.damage_data_qsizes = maxdeque(NRECS) #size of the damage_data_queue before we add a new record to it
#(event_time, size)
self.damage_packet_qsizes = maxdeque(NRECS) #size of the damage_packet_queue before we add a new packet to it
#(event_time, size)
self.damage_packet_qpixels = maxdeque(NRECS) #number of pixels waiting in the damage_packet_queue for a specific window,
#before we add a new packet to it
#(event_time, wid, size)
self.damage_last_events = maxdeque(NRECS) #records the x11 damage requests as they are received:
#(wid, event time, no of pixels)
self.client_decode_time = maxdeque(NRECS) #records how long it took the client to decode frames:
#(wid, event_time, no of pixels, decoding_time*1000*1000)
self.min_client_latency = None #The lowest client latency ever recorded: the time it took
#from the moment the damage packet got sent until we got the ack packet
#(but not including time spent decoding on the client)
self.client_latency = maxdeque(NRECS) #how long it took for a packet to get to the client and get the echo back.
#(wid, event_time, no of pixels, client_latency)
self.avg_client_latency = None
self.client_ping_latency = maxdeque(NRECS) #time it took to get a ping_echo back from the client:
#(event_time, elapsed_time_in_seconds)
self.server_ping_latency = maxdeque(NRECS) #time it took for the client to get a ping_echo back from us:
#(event_time, elapsed_time_in_seconds)
self.readonly = opts.readonly
self.session_name = opts.session_name
self.compression_level = opts.compression_level
self.auto_refresh_delay = opts.auto_refresh_delay
self.max_bandwidth = opts.max_bandwidth
if self.max_bandwidth>0.0 and self.jpegquality==0:
""" jpegquality was not set, use a better start value """
self.jpegquality = 50
self.mmap_enabled = False
self.server_start_time = -1
self.server_platform = ""
self.server_actual_desktop_size = None
self.server_randr = False
self.pixel_counter = maxdeque(maxlen=100)
self.server_latency = maxdeque(maxlen=100)
self.server_load = None
self.client_latency = maxdeque(maxlen=100)
self.toggle_cursors_bell_notify = False
self.toggle_keyboard_sync = False
self.bell_enabled = True
self.cursors_enabled = True
self.notifications_enabled = True
self.clipboard_enabled = False
self.window_configure = False
self.mmap = None
self.mmap_token = None
self.mmap_file = None
self.mmap_size = 0
self.last_ping_echoed_time = 0
self._client_extras = ClientExtras(self, opts)
def reset(self):
# mmap state:
self.mmap_size = 0
self.mmap_bytes_sent = 0
self.mmap_free_size = 0 #how much of the mmap space is left (may be negative if we failed to write the last chunk)
# queue statistics:
self.damage_data_qsizes = maxdeque(NRECS) #size of the damage_data_queue before we add a new record to it
#(event_time, size)
self.damage_packet_qsizes = maxdeque(NRECS) #size of the damage_packet_queue before we add a new packet to it
#(event_time, size)
self.damage_packet_qpixels = maxdeque(NRECS) #number of pixels waiting in the damage_packet_queue for a specific window,
#before we add a new packet to it
#(event_time, wid, size)
self.damage_last_events = maxdeque(NRECS) #records the x11 damage requests as they are received:
#(wid, event time, no of pixels)
self.client_decode_time = maxdeque(NRECS) #records how long it took the client to decode frames:
#(wid, event_time, no of pixels, decoding_time*1000*1000)
self.client_latency = maxdeque(NRECS) #how long it took for a packet to get to the client and get the echo back.
#(wid, event_time, no of pixels, client_latency)
self.client_ping_latency = maxdeque(NRECS) #time it took to get a ping_echo back from the client:
#(event_time, elapsed_time_in_seconds)
self.server_ping_latency = maxdeque(NRECS) #time it took for the client to get a ping_echo back from us:
#(event_time, elapsed_time_in_seconds)
self.client_load = None
self.damage_events_count = 0
self._damage_ack_pending = {} #records when damage packets are sent (per window dict),
#so we can calculate the "client_latency" when the client sends
#the corresponding ack ("damage-sequence" packet - see "client_ack_damage")
self._min_client_latency = None #the lowest client latency ever recorded
self._client_latency = maxdeque(NRECS) #how long it took for a packet to get to the client and get the echo back.
#last NRECS: (echo_time, no of pixels, client_latency)
self._damage_in_latency = maxdeque(NRECS) #records how long it took for a damage request to be sent
#last NRECS: (sent_time, no of pixels, actual batch delay, damage_latency)
self._damage_out_latency = maxdeque(NRECS) #records how long it took for a damage request to be processed
#last NRECS: (processed_time, no of pixels, actual batch delay, damage_latency)
self._damage_send_speed = maxdeque(NRECS) #how long it took to send damage packets (this is not a sustained speed)
#last NRECS: (sent_time, no_of_pixels, elapsed_time)
self._last_packet_send_stats = None #used by _damage_send_speed
self._client_decode_time = {} #records how long it took the client to decode frames:
#last NRECS per window: (ack_time, no of pixels, decoding_time)
self._encoding_stats = maxdeque(NRECS) #encoding statistics
#last NRECS: (wid, coding, pixels, compressed_size, encoding_time)
self._last_client_delta = 0, 0 #records how far behind the client was last time we checked
# (no of packets, no of pixels)
# queue statistics:
self._damage_data_qsizes = maxdeque(NRECS) #size of the damage_data_queue before we add a new record to it
#(event_time, size)
self._damage_packet_qsizes = maxdeque(NRECS)#size of the damage_packet_queue before we add a new packet to it
#(event_time, size)
self._damage_packet_qpixels = maxdeque(NRECS) #number of pixels waiting in the damage_packet_queue for a specific window,
#before we add a new packet to it
#(event_time, wid, size)
if DEBUG_DELAY:
self._debug_delay_messages = []
gobject.timeout_add(30*1000, self.dump_debug_delay_messages)
def client_ack_damage(self, damage_packet_sequence, wid, width, height, decode_time):
"""
The client is acknowledging a damage packet,
we record the 'client decode time' (provided by the client itself)
and the "client latency".
"""
log("packet decoding for window %s %sx%s took %s µs", wid, width, height, decode_time)
if decode_time>0:
client_decode_list = self._client_decode_time.setdefault(wid, maxdeque(maxlen=NRECS))
client_decode_list.append((time.time(), width*height, decode_time))
ack_pending = self._damage_ack_pending.get(wid)
if not ack_pending:
log("cannot find damage_pending list for window %s - already removed?", wid)
return
pending = ack_pending.get(damage_packet_sequence)
if pending is None:
log("cannot find sent time for sequence %s", damage_packet_sequence)
return
del ack_pending[damage_packet_sequence]
if decode_time>0:
sent_at, pixels = pending
now = time.time()
diff = now-sent_at
latency = max(0, diff-decode_time/1000/1000)
log("client_ack_damage: took %s ms round trip, %s for decoding of %s pixels, %s for network", dec1(diff*1000), dec1(decode_time/1000), pixels, dec1(latency*1000))
def do_video_encoder_cleanup(self):
self._video_encoder.clean()
self._video_encoder = None
self._video_encoder_speed = maxdeque(NRECS)
self._video_encoder_quality = maxdeque(NRECS)
the options may get quashed! So, specify a "batching"=False
option to ensure no batching will occur for this request.
"""
def damage_now(reason):
self._sequence += 1
log("damage(%s, %s, %s, %s, %s) %s, sending now with sequence %s", wid, x, y, w, h, reason, self._sequence)
region = gtk.gdk.Region()
region.union_with_rect(gtk.gdk.Rectangle(x, y, w, h))
item = wid, window, region, self._sequence, options
self._damage_request_queue.put(item)
if not self.batch.enabled:
return damage_now("batching disabled")
#record this damage event in the damage_last_events queue:
now = time.time()
last_events = self._damage_last_events.setdefault(wid, maxdeque(maxlen=self.batch.max_events))
last_events.append((now, w*h))
if options and options.get("batching", True) is False:
return damage_now("batching option is off")
delayed = self._damage_delayed.get(wid)
if delayed:
(_, _, region, _, _) = delayed
region.union_with_rect(gtk.gdk.Rectangle(x, y, w, h))
log("damage(%s, %s, %s, %s, %s) using existing delayed region: %s", wid, x, y, w, h, delayed)
return
def update_batch_delay(reason, factor=1, delta=0):
self.batch.delay = max(self.batch.min_delay, min(self.batch.max_delay, int(self.batch.delay*factor-delta)))
log("update_batch_delay: %s, factor=%s, delta=%s, new batch delay=%s", reason, factor, delta, self.batch.delay)
def reset(self):
self.client_decode_time = maxdeque(NRECS) #records how long it took the client to decode frames:
#(ack_time, no of pixels, decoding_time*1000*1000)
self.encoding_stats = maxdeque(NRECS) #encoding: (coding, pixels, compressed_size, encoding_time)
# statistics:
self.damage_in_latency = maxdeque(NRECS) #records how long it took for a damage request to be sent
#last NRECS: (sent_time, no of pixels, actual batch delay, damage_latency)
self.damage_out_latency = maxdeque(NRECS) #records how long it took for a damage request to be processed
#last NRECS: (processed_time, no of pixels, actual batch delay, damage_latency)
self.damage_send_speed = maxdeque(NRECS) #how long it took to send damage packets (this is not a sustained speed)
#last NRECS: (sent_time, no_of_pixels, elapsed_time)
self.damage_ack_pending = {} #records when damage packets are sent
#so we can calculate the "client_latency" when the client sends
#the corresponding ack ("damage-sequence" packet - see "client_ack_damage")
self.encoding_totals = {} #for each encoding, how many frames we sent and how many pixels in total
self.last_damage_event_time = None
#these values are calculated from the values above (see update_averages)
self.target_latency = self.DEFAULT_TARGET_LATENCY
self.avg_damage_in_latency = self.DEFAULT_DAMAGE_LATENCY
self.recent_damage_in_latency = self.DEFAULT_DAMAGE_LATENCY
self.avg_damage_out_latency = self.DEFAULT_DAMAGE_LATENCY + self.DEFAULT_NETWORK_LATENCY
self.recent_damage_out_latency = self.DEFAULT_DAMAGE_LATENCY + self.DEFAULT_NETWORK_LATENCY
self.max_latency = self.DEFAULT_DAMAGE_LATENCY + self.DEFAULT_NETWORK_LATENCY
self.avg_decode_speed = None
self.recent_decode_speed = None
def reset(self):
self.client_decode_time = maxdeque(NRECS) #records how long it took the client to decode frames: (ack_time, no of pixels, decoding_time)
self.encoding_stats = maxdeque(NRECS) #encoding: (coding, pixels, compressed_size, encoding_time)
# statistics:
self.damage_in_latency = maxdeque(NRECS) #records how long it took for a damage request to be sent
#last NRECS: (sent_time, no of pixels, actual batch delay, damage_latency)
self.damage_out_latency = maxdeque(NRECS) #records how long it took for a damage request to be processed
#last NRECS: (processed_time, no of pixels, actual batch delay, damage_latency)
self.damage_send_speed = maxdeque(NRECS) #how long it took to send damage packets (this is not a sustained speed)
#last NRECS: (sent_time, no_of_pixels, elapsed_time)
self.damage_ack_pending = {} #records when damage packets are sent
#so we can calculate the "client_latency" when the client sends
#the corresponding ack ("damage-sequence" packet - see "client_ack_damage")
self.last_packet_send_stats = None #used by _damage_send_speed
self.last_client_delta = 0, 0 #records how far behind the client was last time we checked
def reset(self):
self.client_decode_time = maxdeque(NRECS) #records how long it took the client to decode frames: (ack_time, no of pixels, decoding_time)
self.encoding_stats = maxdeque(NRECS) #encoding: (coding, pixels, compressed_size, encoding_time)
# statistics:
self.damage_in_latency = maxdeque(NRECS) #records how long it took for a damage request to be sent
#last NRECS: (sent_time, no of pixels, actual batch delay, damage_latency)
self.damage_out_latency = maxdeque(NRECS) #records how long it took for a damage request to be processed
#last NRECS: (processed_time, no of pixels, actual batch delay, damage_latency)
self.damage_send_speed = maxdeque(NRECS) #how long it took to send damage packets (this is not a sustained speed)
#last NRECS: (sent_time, no_of_pixels, elapsed_time)
self.damage_ack_pending = {} #records when damage packets are sent
#so we can calculate the "client_latency" when the client sends
#the corresponding ack ("damage-sequence" packet - see "client_ack_damage")
self.last_packet_send_stats = None #used by _damage_send_speed
self.last_client_delta = 0, 0 #records how far behind the client was last time we checked