mirror of
https://github.com/Genymobile/scrcpy
synced 2024-12-28 02:02:17 +00:00
9b056f5091
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.
102 lines
2.9 KiB
Meson
102 lines
2.9 KiB
Meson
src = [
|
|
'src/main.c',
|
|
'src/command.c',
|
|
'src/controlevent.c',
|
|
'src/controller.c',
|
|
'src/convert.c',
|
|
'src/decoder.c',
|
|
'src/device.c',
|
|
'src/fpscounter.c',
|
|
'src/frames.c',
|
|
'src/inputmanager.c',
|
|
'src/lockutil.c',
|
|
'src/net.c',
|
|
'src/scrcpy.c',
|
|
'src/screen.c',
|
|
'src/server.c',
|
|
'src/strutil.c',
|
|
'src/tinyxpm.c',
|
|
]
|
|
|
|
dependencies = [
|
|
dependency('libavformat'),
|
|
dependency('libavcodec'),
|
|
dependency('libavutil'),
|
|
dependency('sdl2'),
|
|
]
|
|
|
|
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
|
|
|
|
conf = configuration_data()
|
|
|
|
# expose the build type
|
|
conf.set('BUILD_DEBUG', get_option('buildtype') == 'debug')
|
|
|
|
# the version, updated on release
|
|
conf.set_quoted('SCRCPY_VERSION', '0.1')
|
|
|
|
# the prefix used during configuration (meson --prefix=PREFIX)
|
|
conf.set_quoted('PREFIX', get_option('prefix'))
|
|
|
|
# the path of the server, which will be appended to the prefix
|
|
# ignored if OVERRIDE_SERVER_JAR if defined
|
|
# must be consistent with the install_dir in server/meson.build
|
|
conf.set_quoted('PREFIXED_SERVER_JAR', '/share/scrcpy/scrcpy-server.jar')
|
|
|
|
# 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)
|
|
override_server_jar = get_option('override_server_jar')
|
|
if override_server_jar != ''
|
|
conf.set_quoted('OVERRIDE_SERVER_JAR', override_server_jar)
|
|
else
|
|
# undefine it
|
|
conf.set('OVERRIDE_SERVER_JAR', false)
|
|
endif
|
|
|
|
# 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
|
|
conf.set('DEFAULT_BIT_RATE', '4000000') # 4Mbps
|
|
|
|
# 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
|
|
conf.set('SKIP_FRAMES', get_option('skip_frames'))
|
|
|
|
configure_file(configuration: conf, output: 'config.h')
|
|
|
|
executable('scrcpy', src, dependencies: dependencies, install: true)
|
|
|
|
|
|
### TESTS
|
|
|
|
tests = [
|
|
['test_control_event_queue', ['tests/test_control_event_queue.c', 'src/controlevent.c']],
|
|
['test_control_event_serialize', ['tests/test_control_event_serialize.c', 'src/controlevent.c']],
|
|
['test_strutil', ['tests/test_strutil.c', 'src/strutil.c']],
|
|
]
|
|
|
|
src_dir = include_directories('src')
|
|
|
|
foreach t : tests
|
|
exe = executable(t[0], t[1], include_directories: src_dir, dependencies: dependencies)
|
|
test(t[0], exe)
|
|
endforeach
|