2017-12-12 22:12:07 +08:00
|
|
|
src = [
|
2018-01-23 23:32:29 +08:00
|
|
|
'src/main.c',
|
2017-12-12 22:12:07 +08:00
|
|
|
'src/command.c',
|
2018-08-15 23:01:54 +08:00
|
|
|
'src/control_event.c',
|
2018-02-08 18:26:31 +08:00
|
|
|
'src/controller.c',
|
2017-12-14 18:38:44 +08:00
|
|
|
'src/convert.c',
|
2017-12-12 22:12:07 +08:00
|
|
|
'src/decoder.c',
|
2018-02-08 22:42:49 +08:00
|
|
|
'src/device.c',
|
2019-05-30 06:24:26 +08:00
|
|
|
'src/device_event.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',
|
|
|
|
'src/input_manager.c',
|
|
|
|
'src/lock_util.c',
|
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
|
|
|
'src/net.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',
|
2018-08-15 23:01:54 +08:00
|
|
|
'src/str_util.c',
|
|
|
|
'src/tiny_xpm.c',
|
2019-03-02 23:43:43 +08:00
|
|
|
'src/stream.c',
|
2019-03-02 22:16:55 +08:00
|
|
|
'src/video_buffer.c',
|
2017-12-12 22:12:07 +08:00
|
|
|
]
|
|
|
|
|
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'),
|
|
|
|
]
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
# cross-compile mingw32 build (from Linux to Windows)
|
|
|
|
cc = meson.get_compiler('c')
|
|
|
|
|
|
|
|
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
|
|
|
cc = meson.get_compiler('c')
|
|
|
|
|
|
|
|
if host_machine.system() == 'windows'
|
|
|
|
src += [ 'src/sys/win/command.c' ]
|
|
|
|
src += [ 'src/sys/win/net.c' ]
|
|
|
|
dependencies += cc.find_library('ws2_32')
|
|
|
|
else
|
|
|
|
src += [ 'src/sys/unix/command.c' ]
|
|
|
|
src += [ 'src/sys/unix/net.c' ]
|
|
|
|
endif
|
|
|
|
|
2018-02-07 19:02:15 +08:00
|
|
|
conf = configuration_data()
|
|
|
|
|
2018-02-12 18:07:38 +08:00
|
|
|
# expose the build type
|
|
|
|
conf.set('BUILD_DEBUG', get_option('buildtype') == 'debug')
|
|
|
|
|
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
|
|
|
|
|
|
|
# the path of the server, which will be appended to the prefix
|
2018-02-16 22:19:35 +08:00
|
|
|
# ignored if OVERRIDE_SERVER_PATH if defined
|
2018-02-13 18:55:12 +08:00
|
|
|
# must be consistent with the install_dir in server/meson.build
|
2018-02-16 22:19:35 +08:00
|
|
|
conf.set_quoted('PREFIXED_SERVER_PATH', '/share/scrcpy/scrcpy-server.jar')
|
2018-02-13 18:55:12 +08:00
|
|
|
|
|
|
|
# the path of the server to be used "as is"
|
|
|
|
# this is useful for building a "portable" version (with the server in the same
|
|
|
|
# directory as the client)
|
2018-02-16 22:19:35 +08:00
|
|
|
override_server_path = get_option('override_server_path')
|
|
|
|
if override_server_path != ''
|
|
|
|
conf.set_quoted('OVERRIDE_SERVER_PATH', override_server_path)
|
2018-02-14 20:37:01 +08:00
|
|
|
else
|
|
|
|
# undefine it
|
2018-02-16 22:19:35 +08:00
|
|
|
conf.set('OVERRIDE_SERVER_PATH', false)
|
2018-02-13 18:55:12 +08:00
|
|
|
endif
|
|
|
|
|
2018-02-07 19:02:15 +08:00
|
|
|
# the default client TCP port for the "adb reverse" tunnel
|
|
|
|
# overridden by option --port
|
|
|
|
conf.set('DEFAULT_LOCAL_PORT', '27183')
|
|
|
|
|
|
|
|
# the default max video size for both dimensions, in pixels
|
|
|
|
# overridden by option --max-size
|
|
|
|
conf.set('DEFAULT_MAX_SIZE', '0') # 0: unlimited
|
|
|
|
|
|
|
|
# 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
|
|
|
|
2018-02-07 19:25:52 +08:00
|
|
|
# whether the app should always display the most recent available frame, even
|
|
|
|
# if the previous one has not been displayed
|
|
|
|
# SKIP_FRAMES improves latency at the cost of framerate
|
2018-02-15 18:23:14 +08:00
|
|
|
conf.set('SKIP_FRAMES', get_option('skip_frames'))
|
2018-02-07 19:25:52 +08:00
|
|
|
|
2018-03-07 17:53:39 +08:00
|
|
|
# enable High DPI support
|
|
|
|
conf.set('HIDPI_SUPPORT', get_option('hidpi_support'))
|
|
|
|
|
2018-05-29 04:26:32 +08:00
|
|
|
# disable console on Windows
|
|
|
|
conf.set('WINDOWS_NOCONSOLE', get_option('windows_noconsole'))
|
|
|
|
|
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
|
|
|
|
|
|
|
if get_option('windows_noconsole')
|
|
|
|
c_args = [ '-mwindows' ]
|
|
|
|
link_args = [ '-mwindows' ]
|
|
|
|
else
|
|
|
|
c_args = []
|
|
|
|
link_args = []
|
|
|
|
endif
|
|
|
|
|
2019-05-29 14:20:05 +08:00
|
|
|
executable('scrcpy', src,
|
|
|
|
dependencies: dependencies,
|
|
|
|
include_directories: src_dir,
|
|
|
|
install: true,
|
|
|
|
c_args: c_args,
|
|
|
|
link_args: link_args)
|
2017-12-14 18:38:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
### TESTS
|
|
|
|
|
|
|
|
tests = [
|
2019-05-30 02:53:21 +08:00
|
|
|
['test_cbuf', [
|
|
|
|
'tests/test_cbuf.c',
|
|
|
|
]],
|
2019-05-29 14:20:05 +08:00
|
|
|
['test_control_event_serialize', [
|
|
|
|
'tests/test_control_event_serialize.c',
|
2019-05-31 01:01:08 +08:00
|
|
|
'src/control_event.c',
|
|
|
|
'src/str_util.c'
|
2019-05-29 14:20:05 +08:00
|
|
|
]],
|
2019-05-30 06:24:26 +08:00
|
|
|
['test_device_event_deserialize', [
|
|
|
|
'tests/test_device_event_deserialize.c',
|
|
|
|
'src/device_event.c'
|
|
|
|
]],
|
2019-05-29 14:20:05 +08:00
|
|
|
['test_strutil', [
|
|
|
|
'tests/test_strutil.c',
|
|
|
|
'src/str_util.c'
|
|
|
|
]],
|
2017-12-14 18:38:44 +08:00
|
|
|
]
|
|
|
|
|
|
|
|
foreach t : tests
|
2019-05-29 14:20:05 +08:00
|
|
|
exe = executable(t[0], t[1],
|
|
|
|
include_directories: src_dir,
|
|
|
|
dependencies: dependencies)
|
2017-12-14 18:38:44 +08:00
|
|
|
test(t[0], exe)
|
|
|
|
endforeach
|