Skip to content

Commit

Permalink
Simplify default values
Browse files Browse the repository at this point in the history
It makes sense to extract default values for bitrate and port range
(which are arbitrary and might be changed in the future).

However, the default values for "max size" and "lock video orientation"
are naturally unlimited/unlocked, and will never be changed. Extracting
these options just added complexity for no benefit, so hardcode them.
  • Loading branch information
rom1v committed Feb 25, 2021
1 parent a3aa5ac commit b16b65a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 24 deletions.
10 changes: 0 additions & 10 deletions app/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,6 @@ conf.set('PORTABLE', get_option('portable'))
conf.set('DEFAULT_LOCAL_PORT_RANGE_FIRST', '27183')
conf.set('DEFAULT_LOCAL_PORT_RANGE_LAST', '27199')

# 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 orientation
# natural device orientation is 0 and each increment adds 90 degrees
# counterclockwise
# overridden by option --lock-video-orientation
conf.set('DEFAULT_LOCK_VIDEO_ORIENTATION', '-1') # -1: unlocked

# the default video bitrate, in bits/second
# overridden by option --bit-rate
conf.set('DEFAULT_BIT_RATE', '8000000') # 8Mbps
Expand Down
14 changes: 2 additions & 12 deletions app/src/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,7 @@ scrcpy_print_usage(const char *arg0) {
" Possible values are -1 (unlocked), 0, 1, 2 and 3.\n"
" Natural device orientation is 0, and each increment adds a\n"
" 90 degrees rotation counterclockwise.\n"
#if DEFAULT_LOCK_VIDEO_ORIENTATION == -1
# define DEFAULT_LOCK_VIDEO_ORIENTATION_STR "-1 (unlocked)"
#else
# define DEFAULT_LOCK_VIDEO_ORIENTATION_STR STR(DEFAULT_LOCK_VIDEO_ORIENTATION)
#endif
" Default is " DEFAULT_LOCK_VIDEO_ORIENTATION_STR ".\n"
" Default is -1 (unlocked).\n"
"\n"
" --max-fps value\n"
" Limit the frame rate of screen capture (officially supported\n"
Expand All @@ -99,12 +94,7 @@ scrcpy_print_usage(const char *arg0) {
" Limit both the width and height of the video to value. The\n"
" other dimension is computed so that the device aspect-ratio\n"
" is preserved.\n"
#if DEFAULT_MAX_SIZE == 0
# define DEFAULT_MAX_SIZE_STR "0 (unlimited)"
#else
# define DEFAULT_MAX_SIZE_STR STR(DEFAULT_MAX_SIZE)
#endif
" Default is " DEFAULT_MAX_SIZE_STR ".\n"
" Default is 0 (unlimited).\n"
"\n"
" -n, --no-control\n"
" Disable device control (mirror the device in read-only).\n"
Expand Down
4 changes: 2 additions & 2 deletions app/src/scrcpy.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ struct scrcpy_options {
.data = {SC_MOD_LALT, SC_MOD_LSUPER}, \
.count = 2, \
}, \
.max_size = DEFAULT_MAX_SIZE, \
.max_size = 0, \
.bit_rate = DEFAULT_BIT_RATE, \
.max_fps = 0, \
.lock_video_orientation = DEFAULT_LOCK_VIDEO_ORIENTATION, \
.lock_video_orientation = -1, \
.rotation = 0, \
.window_x = SC_WINDOW_POSITION_UNDEFINED, \
.window_y = SC_WINDOW_POSITION_UNDEFINED, \
Expand Down

0 comments on commit b16b65a

Please sign in to comment.