Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* port nvfbc capture code to linux - use a completely separate source file since the headers are completely different
* use a pkg-config file instead of hard-coded paths

git-svn-id: https://xpra.org/svn/Xpra/trunk@15787 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed May 2, 2017
1 parent 6100d3b commit b83782f
Show file tree
Hide file tree
Showing 5 changed files with 754 additions and 25 deletions.
20 changes: 6 additions & 14 deletions src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def is_RH():
# * wheezy: 53.35
csc_swscale_ENABLED = DEFAULT and pkg_config_ok("--exists", "libswscale")
nvenc7_ENABLED = DEFAULT and BITS==64 and pkg_config_ok("--exists", "nvenc7")
nvfbc_ENABLED = DEFAULT and BITS==64 and WIN32
nvfbc_ENABLED = DEFAULT and BITS==64 and pkg_config_ok("--exists", "nvfbc")
cuda_kernels_ENABLED = DEFAULT
cuda_rebuild_ENABLED = DEFAULT
csc_libyuv_ENABLED = DEFAULT and pkg_config_ok("--exists", "libyuv")
Expand Down Expand Up @@ -250,11 +250,10 @@ def is_RH():
rpath = None
ssl_cert = None
ssl_key = None
nvfbc_path = "E:\\NVIDIA Capture SDK\\"
filtered_args = []
for arg in sys.argv:
matched = False
for x in ("rpath", "ssl-cert", "ssl-key", "install", "nvfbc_path"):
for x in ("rpath", "ssl-cert", "ssl-key", "install"):
varg = "--%s=" % x
if arg.startswith(varg):
value = arg[len(varg):]
Expand Down Expand Up @@ -326,11 +325,6 @@ def is_RH():
if not enc_x264_ENABLED and not vpx_ENABLED:
print("Warning: no x264 and no vpx support!")
print(" you should enable at least one of these two video encodings")
if nvfbc_ENABLED and not os.path.exists(nvfbc_path):
print("Warning: cannot find NvFBC SDK in")
print(" %s" % nvfbc_path)
print(" nvfbc codec disabled")
nvfbc_ENABLED = False


#*******************************************************************************
Expand Down Expand Up @@ -1872,12 +1866,10 @@ def osx_pkgconfig(*pkgs_options, **ekw):

toggle_packages(nvfbc_ENABLED, "xpra.codecs.nvfbc")
if nvfbc_ENABLED:
nvfbc_pkgconfig = pkgconfig()
nvfbc_inc = os.path.join(nvfbc_path, "inc")
add_to_keywords(nvfbc_pkgconfig, 'extra_compile_args', "-I%s" % nvfbc_inc)
add_to_keywords(nvfbc_pkgconfig, 'extra_compile_args', "-Wno-endif-labels")
cython_add(Extension("xpra.codecs.nvfbc.fbc_capture",
["xpra/codecs/nvfbc/fbc_capture.pyx"],
nvfbc_pkgconfig = pkgconfig("nvfbc")
#add_to_keywords(nvfbc_pkgconfig, 'extra_compile_args', "-Wno-endif-labels")
cython_add(Extension("xpra.codecs.nvfbc.fbc_capture_%s" % sys.platform,
["xpra/codecs/nvfbc/fbc_capture_%s.pyx" % sys.platform],
language="c++",
**nvfbc_pkgconfig))

Expand Down
24 changes: 16 additions & 8 deletions src/xpra/codecs/nvfbc/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,33 @@
import time
import os.path

from xpra.log import Logger
from xpra.log import Logger, add_debug_category
log = Logger("encoder", "nvfbc")

def main():
if "-v" in sys.argv or "--verbose" in sys.argv:
log.enable_debug()
add_debug_category("nvfbc")

from xpra.platform import program_context
with program_context("NvFBC-Capture", "NvFBC Capture"):
from xpra.platform.paths import get_download_dir
from xpra.util import print_nested_dict
from xpra.codecs.nvfbc.fbc_capture import NvFBC_SysCapture, init_nvfbc_library, get_info, get_status #@UnresolvedImport
init_nvfbc_library()
from xpra.os_util import WIN32, LINUX
if WIN32:
from xpra.codecs.nvfbc import fbc_capture_win32 as fbc_capture #@UnresolvedImport @UnusedImport
elif LINUX:
from xpra.codecs.nvfbc import fbc_capture_linux2 as fbc_capture #@UnresolvedImport @Reimport
else:
raise Exception("nvfbc is not support on %s" % sys.platform)
fbc_capture.init_module()
log.info("Info:")
print_nested_dict(get_info(), print_fn=log.info)
print_nested_dict(fbc_capture.get_info(), print_fn=log.info)
log.info("Status:")
print_nested_dict(get_status(), print_fn=log.info)
print_nested_dict(fbc_capture.get_status(), print_fn=log.info)
try:
log("creating test capture class")
c = NvFBC_SysCapture()
c = fbc_capture.NvFBC_SysCapture()
log("Capture=%s", c)
c.init_context()
except Exception as e:
Expand All @@ -45,12 +52,13 @@ def main():
rgb_format = image.get_pixel_format()
try:
img = Image.frombuffer("RGB", (w, h), pixels, "raw", rgb_format, stride, 1)
filename = os.path.join(get_download_dir(), "screenshot-%s-%i.png" % (rgb_format, time.time()))
filename = os.path.join(os.path.expanduser(get_download_dir()), "screenshot-%s-%i.png" % (rgb_format, time.time()))
img.save(filename, "png")
log.info("screenshot saved to %s", filename)
return 0
except Exception as e:
log.warn("not saved %s: %s", rgb_format, e)
log.warn("Error: not saved %s:", rgb_format)
log.warn(" %s", e)
return 1


Expand Down
Loading

0 comments on commit b83782f

Please sign in to comment.