Skip to content

Commit

Permalink
#3964 make it possible to honour the encoding specified
Browse files Browse the repository at this point in the history
(not done yet for x11 server since we currently require encoding=stream
  • Loading branch information
totaam committed Mar 26, 2024
1 parent 0acc578 commit 31f1590
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion xpra/codecs/gstreamer/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# later version. See the file COPYING for details.

from queue import Queue, Empty, Full
from collections.abc import Iterable
from typing import Any

from xpra.os_util import gi_import
Expand Down Expand Up @@ -137,7 +138,7 @@ def get_type(self) -> str:
}


def choose_video_encoder(encodings: tuple[str, ...]) -> str:
def choose_video_encoder(encodings: Iterable[str]) -> str:
log(f"choose_video_encoder({encodings})")
for encoding in encodings:
element = ENCODER_ELEMENTS.get(encoding, "")
Expand All @@ -146,6 +147,7 @@ def choose_video_encoder(encodings: tuple[str, ...]) -> str:
if element not in get_all_plugin_names():
log(f"skipped {encoding!r} due to missing {element!r}")
continue
log(f"selected {encoding!r}")
return encoding
return ""

Expand Down
4 changes: 3 additions & 1 deletion xpra/platform/posix/fd_portal_shadow.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,10 @@ def create_capture_pipeline(self, fd: int, node_id: int, w: int, h: int) -> Capt
})
c = self.authenticating_client
if VIDEO_MODE:
encoding = getattr(c, "encoding", "")
encs = getattr(c, "core_encodings", ())
common_video = tuple(x for x in VIDEO_MODE_ENCODINGS if x in encs)
options = [encoding] + VIDEO_MODE_ENCODINGS
common_video = set(options) & set(encs)
log(f"core_encodings({c})={encs}, common video encodings={common_video}")
encoding = choose_video_encoder(common_video)
if encoding:
Expand Down
5 changes: 4 additions & 1 deletion xpra/server/window/video_compress.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,10 @@ def start_gstreamer_pipeline(self) -> bool:
if xid:
attrs["xid"] = xid
element = plugin_str("ximagesrc", attrs)
encoding = choose_video_encoder(self.common_video_encodings)
# for now this doesn't do anything as we require `encoding="stream"`
# options = [self.encoding] + list(self.common_encodings)
options = self.common_encodings
encoding = choose_video_encoder(options)
if not encoding:
return False
w, h = self.window_dimensions
Expand Down

0 comments on commit 31f1590

Please sign in to comment.