Skip to content

Commit

Permalink
Merge pull request #3942 from goekce/fix-immutable-packet-modification
Browse files Browse the repository at this point in the history
Fix immutable packet modifications
  • Loading branch information
totaam authored Jul 26, 2023
2 parents 1a81bb4 + 3ffba49 commit 1f49935
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions xpra/server/proxy/proxy_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def replace_packet_item(self, packet : PacketType, index:int, new_value:Any) ->
# make the packet data mutable and replace the contents at `index`:
assert index>0
lpacket = list(packet)
list_packet[index] = Compressed("file-data", packet[index])
lpacket[index] = Compressed("file-data", packet[index])
# noinspection PyTypeChecker
return tuple(lpacket)

Expand Down Expand Up @@ -641,7 +641,7 @@ def process_draw(self, packet : PacketType) -> bool:
#we can only use video encoders on RGB data:
if encoding not in ("rgb24", "rgb32", "r210", "BGR565"):
#this prevents compression and inlining of pixel data:
packet[7] = Compressed(f"{encoding} pixels", pixels)
packet = self.replace_packet_item(packet, 7, Compressed(f"{encoding} pixels", pixels))
return True
client_options = typedict(client_options)
#we have a proxy video packet:
Expand All @@ -650,9 +650,9 @@ def process_draw(self, packet : PacketType) -> bool:

def send_updated(encoding, compressed_data, updated_client_options) -> bool:
#update the packet with actual encoding data used:
packet[6] = encoding
packet[7] = compressed_data
packet[10] = updated_client_options
packet = self.replace_packet_item(packet, 6, encoding)
packet = self.replace_packet_item(packet, 7, compressed_data)
packet = self.replace_packet_item(packet, 10, updated_client_options)
enclog("returning %s bytes from %s, options=%s", len(compressed_data), len(pixels), updated_client_options)
return wid not in self.lost_windows

Expand All @@ -668,7 +668,7 @@ def passthrough(strip_alpha=True) -> bool:
c = chr(255)
for i in range(len(pixels)//4):
newdata[i*4+Xindex] = c
packet[9] = client_options.intget("rowstride", 0)
packet = self.replace_packet_item(packet, 9, client_options.intget("rowstride", 0))
cdata = bytes(newdata)
else:
cdata = pixels
Expand All @@ -688,7 +688,7 @@ def passthrough(strip_alpha=True) -> bool:
if not self.video_encoder_types or not client_options or not proxy_video:
#ensure we don't try to re-compress the pixel data in the network layer:
#(re-add the "compressed" marker that gets lost when we re-assemble packets)
packet[7] = Compressed(f"{encoding} pixels", packet[7])
packet = self.replace_packet_item(packet, 7, Compressed(f"{encoding} pixels", packet[7]))
return True

#video encoding: find existing encoder
Expand Down

0 comments on commit 1f49935

Please sign in to comment.