Skip to content

Commit

Permalink
rdpproxy: break dependency to ffmpeg. Used only with libredrec
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanpoelen committed Mar 15, 2024
1 parent 04213f4 commit 2e3d7d8
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 47 deletions.
5 changes: 5 additions & 0 deletions src/capture/capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ class SequencedVideoCaptureImpl {};

using std::begin;
using std::end;

REDEMPTION_DIAGNOSTIC_PUSH()
// skip warning because capture.cpp is included by capture_without_ffmpeg.cpp
REDEMPTION_DIAGNOSTIC_CLANG_IGNORE("-Wheader-hygiene")
using namespace std::chrono_literals;
REDEMPTION_DIAGNOSTIC_POP()

namespace
{
Expand Down
7 changes: 7 additions & 0 deletions src/capture/capture_without_ffmpeg.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
SPDX-FileCopyrightText: 2024 Wallix Proxies Team
SPDX-License-Identifier: GPL-2.0-or-later
*/

#include "capture/capture_without_ffmpeg.hpp"
#include "capture/capture.cpp" // NOLINT(bugprone-suspicious-include)
13 changes: 13 additions & 0 deletions src/capture/capture_without_ffmpeg.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
SPDX-FileCopyrightText: 2024 Wallix Proxies Team
SPDX-License-Identifier: GPL-2.0-or-later
*/

#pragma once

#ifdef REDEMPTION_NO_FFMPEG
# undef REDEMPTION_NO_FFMPEG
#endif

#define REDEMPTION_NO_FFMPEG 1
#include "capture/capture.hpp"
2 changes: 1 addition & 1 deletion src/front/front.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#pragma once

#include "core/log_id.hpp"
#include "capture/capture.hpp"
#include "capture/capture_without_ffmpeg.hpp"
#include "capture/params_from_ini.hpp"
#include "capture/capture_params.hpp"
#include "capture/drawable_params.hpp"
Expand Down
27 changes: 7 additions & 20 deletions targets.jam
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ exe rdpproxy :
:
<library>app_path_exe.o
<library>crypto
<library>ffmpeg
<library>gssapi_krb5
<library>hyperscan
<library>krb5
Expand All @@ -29,7 +28,7 @@ exe rdpproxy :
<library>src/acl/module_manager/mod_factory.o
<library>src/acl/session_logfile.o
<library>src/capture/agent_data_extractor.o
<library>src/capture/capture.o
<library>src/capture/capture_without_ffmpeg.o
<library>src/capture/fdx_capture.o
<library>src/capture/file_to_graphic.o
<library>src/capture/ocr/locale/latin_to_cyrillic.o
Expand All @@ -41,8 +40,6 @@ exe rdpproxy :
<library>src/capture/session_update_buffer.o
<library>src/capture/utils/pattern_searcher.o
<library>src/capture/utils/pattutils.o
<library>src/capture/video_capture.o
<library>src/capture/video_recorder.o
<library>src/core/RDP/RDPDrawable.o
<library>src/core/RDP/dwt.o
<library>src/core/RDP/mppc.o
Expand Down Expand Up @@ -2094,7 +2091,6 @@ test-run tests/front/test_front :
:
<library>app_path_test.o
<library>crypto
<library>ffmpeg
<library>gssapi_krb5
<library>hyperscan
<library>krb5
Expand All @@ -2105,7 +2101,7 @@ test-run tests/front/test_front :
<library>snappy
<library>src/RAIL/client_execute.o
<library>src/acl/kv_list_from_strings.o
<library>src/capture/capture.o
<library>src/capture/capture_without_ffmpeg.o
<library>src/capture/fdx_capture.o
<library>src/capture/ocr/locale/latin_to_cyrillic.o
<library>src/capture/params_from_ini.o
Expand All @@ -2116,8 +2112,6 @@ test-run tests/front/test_front :
<library>src/capture/session_update_buffer.o
<library>src/capture/utils/pattern_searcher.o
<library>src/capture/utils/pattutils.o
<library>src/capture/video_capture.o
<library>src/capture/video_recorder.o
<library>src/client/common/new_mod_rdp.o
<library>src/core/RDP/RDPDrawable.o
<library>src/core/RDP/dwt.o
Expand Down Expand Up @@ -4008,7 +4002,6 @@ test-run tests/server/test_mstsc_client :
:
<library>app_path_test.o
<library>crypto
<library>ffmpeg
<library>gssapi_krb5
<library>hyperscan
<library>krb5
Expand All @@ -4017,7 +4010,7 @@ test-run tests/server/test_mstsc_client :
<library>ppocr
<library>projects/redemption_configs/redemption_src/configs/config.o
<library>snappy
<library>src/capture/capture.o
<library>src/capture/capture_without_ffmpeg.o
<library>src/capture/ocr/locale/latin_to_cyrillic.o
<library>src/capture/params_from_ini.o
<library>src/capture/rail_screen_computation.o
Expand All @@ -4027,8 +4020,6 @@ test-run tests/server/test_mstsc_client :
<library>src/capture/session_update_buffer.o
<library>src/capture/utils/pattern_searcher.o
<library>src/capture/utils/pattutils.o
<library>src/capture/video_capture.o
<library>src/capture/video_recorder.o
<library>src/core/RDP/RDPDrawable.o
<library>src/core/RDP/mppc.o
<library>src/core/RDP/nego.o
Expand Down Expand Up @@ -4084,7 +4075,6 @@ test-run tests/server/test_mstsc_client_rdp50bulk :
:
<library>app_path_test.o
<library>crypto
<library>ffmpeg
<library>gssapi_krb5
<library>hyperscan
<library>krb5
Expand All @@ -4093,7 +4083,7 @@ test-run tests/server/test_mstsc_client_rdp50bulk :
<library>ppocr
<library>projects/redemption_configs/redemption_src/configs/config.o
<library>snappy
<library>src/capture/capture.o
<library>src/capture/capture_without_ffmpeg.o
<library>src/capture/ocr/locale/latin_to_cyrillic.o
<library>src/capture/params_from_ini.o
<library>src/capture/rail_screen_computation.o
Expand All @@ -4103,8 +4093,6 @@ test-run tests/server/test_mstsc_client_rdp50bulk :
<library>src/capture/session_update_buffer.o
<library>src/capture/utils/pattern_searcher.o
<library>src/capture/utils/pattutils.o
<library>src/capture/video_capture.o
<library>src/capture/video_recorder.o
<library>src/core/RDP/RDPDrawable.o
<library>src/core/RDP/mppc.o
<library>src/core/RDP/nego.o
Expand Down Expand Up @@ -4160,7 +4148,6 @@ test-run tests/server/test_rdesktop_client :
:
<library>app_path_test.o
<library>crypto
<library>ffmpeg
<library>gssapi_krb5
<library>hyperscan
<library>krb5
Expand All @@ -4169,7 +4156,7 @@ test-run tests/server/test_rdesktop_client :
<library>ppocr
<library>projects/redemption_configs/redemption_src/configs/config.o
<library>snappy
<library>src/capture/capture.o
<library>src/capture/capture_without_ffmpeg.o
<library>src/capture/ocr/locale/latin_to_cyrillic.o
<library>src/capture/params_from_ini.o
<library>src/capture/rail_screen_computation.o
Expand All @@ -4179,8 +4166,6 @@ test-run tests/server/test_rdesktop_client :
<library>src/capture/session_update_buffer.o
<library>src/capture/utils/pattern_searcher.o
<library>src/capture/utils/pattutils.o
<library>src/capture/video_capture.o
<library>src/capture/video_recorder.o
<library>src/core/RDP/RDPDrawable.o
<library>src/core/RDP/mppc.o
<library>src/core/RDP/nego.o
Expand Down Expand Up @@ -4954,6 +4939,7 @@ obj src/acl/module_manager/mod_factory.o : $(REDEMPTION_SRC_PATH)/acl/module_man
obj src/acl/session_logfile.o : $(REDEMPTION_SRC_PATH)/acl/session_logfile.cpp ;
obj src/capture/agent_data_extractor.o : $(REDEMPTION_SRC_PATH)/capture/agent_data_extractor.cpp ;
obj src/capture/capture.o : $(REDEMPTION_SRC_PATH)/capture/capture.cpp : $(FFMPEG_CXXFLAGS) <define>ZLIB_CONST ;
obj src/capture/capture_without_ffmpeg.o : $(REDEMPTION_SRC_PATH)/capture/capture_without_ffmpeg.cpp : <define>ZLIB_CONST ;
obj src/capture/fdx_capture.o : $(REDEMPTION_SRC_PATH)/capture/fdx_capture.cpp ;
obj src/capture/file_to_graphic.o : $(REDEMPTION_SRC_PATH)/capture/file_to_graphic.cpp : <define>ZLIB_CONST ;
obj src/capture/ocr/locale/latin_to_cyrillic.o : $(REDEMPTION_SRC_PATH)/capture/ocr/locale/latin_to_cyrillic.cpp ;
Expand Down Expand Up @@ -6053,6 +6039,7 @@ explicit
src/acl/session_logfile.o
src/capture/agent_data_extractor.o
src/capture/capture.o
src/capture/capture_without_ffmpeg.o
src/capture/fdx_capture.o
src/capture/file_to_graphic.o
src/capture/ocr/locale/latin_to_cyrillic.o
Expand Down
69 changes: 43 additions & 26 deletions tools/bjam/gen_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import glob
import os
import sys
from collections import OrderedDict
from collections import OrderedDict, defaultdict

includes = set((
'src/',
Expand Down Expand Up @@ -68,9 +68,23 @@ def union(self, other):
))

# because include a .cpp file...
remove_requirements = dict((
# ('tests/capture/test_capture.cpp', ['<library>src/capture/capture.o']),
))
remove_requirements = defaultdict(set, {
# 'tests/capture/test_capture.cpp': {'<library>src/capture/capture.o'}
})

# because include a .cpp file with special macro...
remove_incompatible_requirements = {
'src/capture/capture_without_ffmpeg.cpp': {
'$(FFMPEG_CXXFLAGS)'
},
'<library>src/capture/capture_without_ffmpeg.o': {
'<library>src/capture/capture.o',
'<library>src/capture/video_capture.o',
'<library>src/capture/video_recorder.o',
'<library>ffmpeg'
},
}
remove_incompatible_requirements_keys = set(remove_incompatible_requirements)

# This is usefull if several source files have the same name to disambiguate tests
target_pre_renames = dict((
Expand Down Expand Up @@ -448,10 +462,11 @@ def get_includes(path):
f.user_includes, f.system_includes, f.unknown_user_includes = get_includes(f.path)

# remove .cpp include from user_includes
for f in tests:
l = ['<library>{fp}o'.format(fp=finc.path[:-3]) for finc in f.user_includes if finc.path.endswith('.cpp')]
if l:
remove_requirements.setdefault(f.path, []).extend(l)
for fgroup in (sources, exes, mains, libs, tests):
for f in fgroup:
l = ['<library>{fp}o'.format(fp=finc.path[:-3]) for finc in f.user_includes if finc.path.endswith('.cpp')]
if l:
remove_requirements[f.path].update(l)

#for f in sources:
#print("--", f.path, [a.path for a in f.user_includes], f.system_includes, f.unknown_user_includes)
Expand Down Expand Up @@ -543,6 +558,11 @@ def compute_all_source_deps(f):

for f in all_files.values():
compute_all_source_deps(f)
remove = remove_incompatible_requirements.get(f.path)
if remove:
f.all_source_deps -= remove
f.all_link_deps -= remove
f.all_cxx_deps -= remove


###
Expand Down Expand Up @@ -578,16 +598,16 @@ def cpp_to_obj(f):
#log_hpp = all_files['src/utils/log.hpp']

def get_sources_deps(f, cat, exclude):
a = []
a = set()
for pf in f.all_source_deps:
pf.used = True
if pf == app_path_cpp:
if cat == 'test-run':
a.append('<library>app_path_test.o')
a.add('<library>app_path_test.o')
else:
a.append('<library>app_path_exe.o')
a.add('<library>app_path_exe.o')
elif pf != exclude:
a.append('<library>'+cpp_to_obj(pf))
a.add('<library>'+cpp_to_obj(pf))
return a

def generate(type, files, requirements, get_target_cb = get_target):
Expand All @@ -596,11 +616,11 @@ def generate(type, files, requirements, get_target_cb = get_target):
src = f.path
target = get_target_cb(f)
deps = get_sources_deps(f, type, f)
deps += f.all_link_deps
deps += f.all_cxx_deps
deps += requirements
deps.update(f.all_link_deps)
deps.update(f.all_cxx_deps)
deps.update(requirements)
if target in target_requirements:
deps += target_requirements[target]
deps.update(target_requirements[target])

if type == 'test-run':
iright = len(f.root)
Expand All @@ -613,17 +633,14 @@ def generate(type, files, requirements, get_target_cb = get_target):

print(type, ' ', target, ' :\n ', src, '\n:', sep='')

# <library> following by <...other...>
deps = sorted(set(deps), key=lambda s: s if s.startswith('<library>') else 'Z'+s)
deps -= remove_requirements[f.path]
for k in deps & remove_incompatible_requirements_keys:
deps -= remove_incompatible_requirements[k]

if f.path in remove_requirements:
l = remove_requirements[f.path]
for s in deps:
if s not in l:
print(' ', s)
else:
for s in deps:
print(' ', s)
if deps:
# <library> following by <...other...>
ordered_deps = sorted(deps, key=lambda s: s if s.startswith('<library>') else 'Z'+s)
print(' ', '\n '.join(ordered_deps), sep='')
print(';')

def inject_variable_prefix(path):
Expand Down

0 comments on commit 2e3d7d8

Please sign in to comment.