Skip to content

Commit

Permalink
#3750 make code reusable
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Jun 9, 2023
1 parent cb89b33 commit 9a1ed42
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
12 changes: 1 addition & 11 deletions xpra/platform/posix/fd_portal_shadow.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@

import os
import random
from time import monotonic
from dbus.types import UInt32
from dbus.types import Dictionary
from typing import Optional, List, Dict, Any

from xpra.exit_codes import ExitCode
from xpra.util import typedict, envbool, ConnectionMessage, NotificationID
from xpra.net.compression import Compressed
from xpra.dbus.helper import dbus_to_native
from xpra.codecs.gstreamer.capture import Capture, CaptureAndEncode
from xpra.gst_common import get_element_str
Expand Down Expand Up @@ -307,12 +305,6 @@ def capture_new_image(self, capture, coding:str, data, client_info:Dict) -> None
return
#this is a frame from a compressed stream,
#send it to all the window sources for this window:
cdata = Compressed(coding, data)
options = {}
x = y = 0
w, h = model.geometry[2:4]
outstride = 0
damage_time = process_damage_time = monotonic()
for ss in tuple(self._server_sources.values()):
if not hasattr(ss, "get_window_source"):
#client is not showing any windows
Expand All @@ -321,9 +313,7 @@ def capture_new_image(self, capture, coding:str, data, client_info:Dict) -> None
if not ws:
#client not showing this window
continue
log(f"sending {len(data)} bytes packet of {coding} stream to {ws} of {ss}")
packet = ws.make_draw_packet(x, y, w, h, coding, cdata, outstride, client_info, options)
ws.queue_damage_packet(packet, damage_time, process_damage_time, options)
ws.direct_queue_draw(coding, data, client_info)


def capture_error(self, capture, message) -> None:
Expand Down
16 changes: 15 additions & 1 deletion xpra/server/window/window_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from xpra.codecs.loader import get_codec
from xpra.codecs.image_wrapper import ImageWrapper
from xpra.codecs.codec_constants import preforder, LOSSY_PIXEL_FORMATS
from xpra.net.compression import use
from xpra.net.compression import use, Compressed
from xpra.log import Logger

log = Logger("window", "encoding")
Expand Down Expand Up @@ -2743,6 +2743,20 @@ def make_draw_packet(self, x : int, y : int, outw : int, outh : int,
return packet


def direct_queue_draw(self, coding:str, data:bytes, client_info:Dict) -> None:
#this is a frame from a compressed stream,
#send it to all the window sources for this window:
cdata = Compressed(coding, data)
options = {}
x = y = 0
w, h = self.window_dimensions
outstride = 0
damage_time = process_damage_time = monotonic()
log(f"direct_queue_draw({coding}, {len(data)} bytes, {client_info})")
packet = self.make_draw_packet(x, y, w, h, coding, cdata, outstride, client_info, options)
self.queue_damage_packet(packet, damage_time, process_damage_time, options)


def mmap_encode(self, coding : str, image : ImageWrapper, _options) -> Tuple:
assert coding=="mmap"
assert self._mmap and self._mmap_size>0
Expand Down

0 comments on commit 9a1ed42

Please sign in to comment.