2017-12-12 22:12:07 +08:00
|
|
|
src = [
|
2018-01-23 23:32:29 +08:00
|
|
|
'src/main.c',
|
2021-01-03 21:55:15 +08:00
|
|
|
'src/adb.c',
|
2019-12-09 04:35:19 +08:00
|
|
|
'src/cli.c',
|
2021-07-04 21:24:51 +08:00
|
|
|
'src/clock.c',
|
2021-01-17 21:11:59 +08:00
|
|
|
'src/compat.c',
|
2019-05-31 20:55:11 +08:00
|
|
|
'src/control_msg.c',
|
2018-02-08 18:26:31 +08:00
|
|
|
'src/controller.c',
|
2017-12-12 22:12:07 +08:00
|
|
|
'src/decoder.c',
|
2019-05-31 20:55:11 +08:00
|
|
|
'src/device_msg.c',
|
2021-10-23 00:51:20 +08:00
|
|
|
'src/icon.c',
|
2018-08-12 10:13:49 +08:00
|
|
|
'src/file_handler.c',
|
2018-08-15 23:01:54 +08:00
|
|
|
'src/fps_counter.c',
|
2021-07-04 18:39:03 +08:00
|
|
|
'src/frame_buffer.c',
|
2018-08-15 23:01:54 +08:00
|
|
|
'src/input_manager.c',
|
2021-10-03 23:11:20 +08:00
|
|
|
'src/keyboard_inject.c',
|
2021-10-03 23:44:14 +08:00
|
|
|
'src/mouse_inject.c',
|
2020-04-11 22:08:23 +08:00
|
|
|
'src/opengl.c',
|
2019-05-30 06:25:37 +08:00
|
|
|
'src/receiver.c',
|
2018-11-09 19:21:17 +08:00
|
|
|
'src/recorder.c',
|
2018-01-23 23:32:29 +08:00
|
|
|
'src/scrcpy.c',
|
2018-02-08 18:14:13 +08:00
|
|
|
'src/screen.c',
|
2018-01-22 18:22:31 +08:00
|
|
|
'src/server.c',
|
2019-03-02 23:43:43 +08:00
|
|
|
'src/stream.c',
|
2019-03-02 22:16:55 +08:00
|
|
|
'src/video_buffer.c',
|
2021-06-20 18:46:41 +08:00
|
|
|
'src/util/log.c',
|
2019-11-24 18:53:00 +08:00
|
|
|
'src/util/net.c',
|
2021-01-03 21:55:15 +08:00
|
|
|
'src/util/process.c',
|
2021-02-01 01:24:35 +08:00
|
|
|
'src/util/str_util.c',
|
|
|
|
'src/util/thread.c',
|
2021-07-04 22:50:19 +08:00
|
|
|
'src/util/tick.c',
|
2017-12-12 22:12:07 +08:00
|
|
|
]
|
|
|
|
|
2021-01-03 22:09:01 +08:00
|
|
|
if host_machine.system() == 'windows'
|
|
|
|
src += [ 'src/sys/win/process.c' ]
|
|
|
|
else
|
|
|
|
src += [ 'src/sys/unix/process.c' ]
|
|
|
|
endif
|
|
|
|
|
2021-04-04 06:10:44 +08:00
|
|
|
v4l2_support = host_machine.system() == 'linux'
|
|
|
|
if v4l2_support
|
|
|
|
src += [ 'src/v4l2_sink.c' ]
|
|
|
|
endif
|
|
|
|
|
2021-01-17 21:11:59 +08:00
|
|
|
check_functions = [
|
|
|
|
'strdup'
|
|
|
|
]
|
|
|
|
|
2021-01-09 02:13:53 +08:00
|
|
|
cc = meson.get_compiler('c')
|
|
|
|
|
2018-06-06 02:43:47 +08:00
|
|
|
if not get_option('crossbuild_windows')
|
2018-05-13 22:03:39 +08:00
|
|
|
|
|
|
|
# native build
|
|
|
|
dependencies = [
|
|
|
|
dependency('libavformat'),
|
|
|
|
dependency('libavcodec'),
|
|
|
|
dependency('libavutil'),
|
|
|
|
dependency('sdl2'),
|
|
|
|
]
|
|
|
|
|
2021-04-04 06:10:44 +08:00
|
|
|
if v4l2_support
|
|
|
|
dependencies += dependency('libavdevice')
|
|
|
|
endif
|
|
|
|
|
2018-05-13 22:03:39 +08:00
|
|
|
else
|
|
|
|
|
|
|
|
# cross-compile mingw32 build (from Linux to Windows)
|
|
|
|
prebuilt_sdl2 = meson.get_cross_property('prebuilt_sdl2')
|
|
|
|
sdl2_bin_dir = meson.current_source_dir() + '/../prebuilt-deps/' + prebuilt_sdl2 + '/bin'
|
|
|
|
sdl2_lib_dir = meson.current_source_dir() + '/../prebuilt-deps/' + prebuilt_sdl2 + '/lib'
|
|
|
|
sdl2_include_dir = '../prebuilt-deps/' + prebuilt_sdl2 + '/include'
|
|
|
|
|
|
|
|
sdl2 = declare_dependency(
|
|
|
|
dependencies: [
|
|
|
|
cc.find_library('SDL2', dirs: sdl2_bin_dir),
|
|
|
|
cc.find_library('SDL2main', dirs: sdl2_lib_dir),
|
|
|
|
],
|
|
|
|
include_directories: include_directories(sdl2_include_dir)
|
|
|
|
)
|
|
|
|
|
|
|
|
prebuilt_ffmpeg_shared = meson.get_cross_property('prebuilt_ffmpeg_shared')
|
|
|
|
prebuilt_ffmpeg_dev = meson.get_cross_property('prebuilt_ffmpeg_dev')
|
|
|
|
ffmpeg_bin_dir = meson.current_source_dir() + '/../prebuilt-deps/' + prebuilt_ffmpeg_shared + '/bin'
|
|
|
|
ffmpeg_include_dir = '../prebuilt-deps/' + prebuilt_ffmpeg_dev + '/include'
|
|
|
|
ffmpeg = declare_dependency(
|
|
|
|
dependencies: [
|
|
|
|
cc.find_library('avcodec-58', dirs: ffmpeg_bin_dir),
|
|
|
|
cc.find_library('avformat-58', dirs: ffmpeg_bin_dir),
|
|
|
|
cc.find_library('avutil-56', dirs: ffmpeg_bin_dir),
|
|
|
|
],
|
|
|
|
include_directories: include_directories(ffmpeg_include_dir)
|
|
|
|
)
|
|
|
|
|
|
|
|
dependencies = [
|
|
|
|
ffmpeg,
|
|
|
|
sdl2,
|
|
|
|
cc.find_library('mingw32')
|
|
|
|
]
|
|
|
|
|
|
|
|
endif
|
2017-12-12 22:12:07 +08:00
|
|
|
|
Replace SDL_net by custom implementation
SDL_net is not very suitable for scrcpy.
For example, SDLNet_TCP_Accept() is non-blocking, so we have to wrap it
by calling many SDL_Net-specific functions to make it blocking.
But above all, SDLNet_TCP_Open() is a server socket only when no IP is
provided; otherwise, it's a client socket. Therefore, it is not possible
to create a server socket bound to localhost, so it accepts connections
from anywhere.
This is a problem for scrcpy, because on start, the application listens
for nearly 1 second until it accepts the first connection, supposedly
from the device. If someone on the local network manages to connect to
the server socket first, then they can stream arbitrary H.264 video.
This may be troublesome, for example during a public presentation ;-)
Provide our own simplified API (net.h) instead, implemented for the
different platforms.
2018-02-16 05:59:21 +08:00
|
|
|
if host_machine.system() == 'windows'
|
|
|
|
dependencies += cc.find_library('ws2_32')
|
|
|
|
endif
|
|
|
|
|
2018-02-07 19:02:15 +08:00
|
|
|
conf = configuration_data()
|
|
|
|
|
2021-01-17 21:11:59 +08:00
|
|
|
foreach f : check_functions
|
|
|
|
if cc.has_function(f)
|
|
|
|
define = 'HAVE_' + f.underscorify().to_upper()
|
|
|
|
conf.set(define, true)
|
|
|
|
endif
|
|
|
|
endforeach
|
|
|
|
|
2018-02-07 19:37:53 +08:00
|
|
|
# the version, updated on release
|
2018-11-12 21:09:11 +08:00
|
|
|
conf.set_quoted('SCRCPY_VERSION', meson.project_version())
|
2018-02-07 19:37:53 +08:00
|
|
|
|
2018-02-13 18:55:12 +08:00
|
|
|
# the prefix used during configuration (meson --prefix=PREFIX)
|
2018-02-14 20:37:01 +08:00
|
|
|
conf.set_quoted('PREFIX', get_option('prefix'))
|
2018-02-13 18:55:12 +08:00
|
|
|
|
2019-10-31 06:40:10 +08:00
|
|
|
# build a "portable" version (with scrcpy-server accessible from the same
|
2019-06-10 21:14:10 +08:00
|
|
|
# directory as the executable)
|
2019-06-09 01:03:22 +08:00
|
|
|
conf.set('PORTABLE', get_option('portable'))
|
2018-02-13 18:55:12 +08:00
|
|
|
|
2019-12-10 04:16:09 +08:00
|
|
|
# the default client TCP port range for the "adb reverse" tunnel
|
2018-02-07 19:02:15 +08:00
|
|
|
# overridden by option --port
|
2019-12-10 04:16:09 +08:00
|
|
|
conf.set('DEFAULT_LOCAL_PORT_RANGE_FIRST', '27183')
|
|
|
|
conf.set('DEFAULT_LOCAL_PORT_RANGE_LAST', '27199')
|
2018-02-07 19:02:15 +08:00
|
|
|
|
|
|
|
# the default video bitrate, in bits/second
|
|
|
|
# overridden by option --bit-rate
|
2018-03-02 01:52:43 +08:00
|
|
|
conf.set('DEFAULT_BIT_RATE', '8000000') # 8Mbps
|
2018-02-07 19:02:15 +08:00
|
|
|
|
2019-11-04 02:31:56 +08:00
|
|
|
# run a server debugger and wait for a client to be attached
|
|
|
|
conf.set('SERVER_DEBUGGER', get_option('server_debugger'))
|
|
|
|
|
2020-03-20 02:15:43 +08:00
|
|
|
# select the debugger method ('old' for Android < 9, 'new' for Android >= 9)
|
|
|
|
conf.set('SERVER_DEBUGGER_METHOD_NEW', get_option('server_debugger_method') == 'new')
|
|
|
|
|
2021-04-04 06:10:44 +08:00
|
|
|
# enable V4L2 support (linux only)
|
|
|
|
conf.set('HAVE_V4L2', v4l2_support)
|
|
|
|
|
2018-02-14 20:37:01 +08:00
|
|
|
configure_file(configuration: conf, output: 'config.h')
|
2018-02-07 19:02:15 +08:00
|
|
|
|
2018-03-20 21:03:28 +08:00
|
|
|
src_dir = include_directories('src')
|
2018-05-28 03:30:32 +08:00
|
|
|
|
2019-05-29 14:20:05 +08:00
|
|
|
executable('scrcpy', src,
|
|
|
|
dependencies: dependencies,
|
|
|
|
include_directories: src_dir,
|
|
|
|
install: true,
|
2020-12-16 04:50:46 +08:00
|
|
|
c_args: [])
|
2017-12-14 18:38:44 +08:00
|
|
|
|
2019-10-30 22:14:30 +08:00
|
|
|
install_man('scrcpy.1')
|
2021-10-23 00:51:20 +08:00
|
|
|
install_data('../data/icon.png',
|
|
|
|
rename: 'scrcpy.png',
|
|
|
|
install_dir: 'share/icons/hicolor/256x256/apps')
|
2019-10-30 22:14:30 +08:00
|
|
|
|
2017-12-14 18:38:44 +08:00
|
|
|
|
|
|
|
### TESTS
|
|
|
|
|
2019-12-10 06:23:40 +08:00
|
|
|
# do not build tests in release (assertions would not be executed at all)
|
|
|
|
if get_option('buildtype') == 'debug'
|
|
|
|
tests = [
|
|
|
|
['test_buffer_util', [
|
|
|
|
'tests/test_buffer_util.c'
|
|
|
|
]],
|
|
|
|
['test_cbuf', [
|
|
|
|
'tests/test_cbuf.c',
|
|
|
|
]],
|
|
|
|
['test_cli', [
|
|
|
|
'tests/test_cli.c',
|
|
|
|
'src/cli.c',
|
|
|
|
'src/util/str_util.c',
|
|
|
|
]],
|
2021-07-07 05:57:01 +08:00
|
|
|
['test_clock', [
|
|
|
|
'tests/test_clock.c',
|
|
|
|
'src/clock.c',
|
|
|
|
]],
|
2020-06-05 03:43:07 +08:00
|
|
|
['test_control_msg_serialize', [
|
2019-12-10 06:23:40 +08:00
|
|
|
'tests/test_control_msg_serialize.c',
|
|
|
|
'src/control_msg.c',
|
|
|
|
'src/util/str_util.c',
|
|
|
|
]],
|
2020-06-05 03:43:07 +08:00
|
|
|
['test_device_msg_deserialize', [
|
2019-12-10 06:23:40 +08:00
|
|
|
'tests/test_device_msg_deserialize.c',
|
|
|
|
'src/device_msg.c',
|
|
|
|
]],
|
|
|
|
['test_queue', [
|
|
|
|
'tests/test_queue.c',
|
|
|
|
]],
|
|
|
|
['test_strutil', [
|
|
|
|
'tests/test_strutil.c',
|
|
|
|
'src/util/str_util.c',
|
|
|
|
]],
|
|
|
|
]
|
2017-12-14 18:38:44 +08:00
|
|
|
|
2019-12-10 06:23:40 +08:00
|
|
|
foreach t : tests
|
|
|
|
exe = executable(t[0], t[1],
|
|
|
|
include_directories: src_dir,
|
|
|
|
dependencies: dependencies,
|
2020-07-17 06:00:42 +08:00
|
|
|
c_args: ['-DSDL_MAIN_HANDLED', '-DSC_TEST'])
|
2019-12-10 06:23:40 +08:00
|
|
|
test(t[0], exe)
|
|
|
|
endforeach
|
|
|
|
endif
|