Display and control your Android device
Rename --display-buffer to --video-buffer
Romain Vimontc29ecd031435
diff --git a/app/data/bash-completion/scrcpy b/app/data/bash-completion/scrcpyindex 223c5264..d9a7be60 100644--- a/app/data/bash-completion/scrcpy+++ b/app/data/bash-completion/scrcpy@@ -20,7 +20,6 @@ _scrcpy() {--crop=-d --select-usb--disable-screensaver- --display-buffer=--display-id=--display-orientation=-e --select-tcpip@@ -90,6 +89,7 @@ _scrcpy() {--v4l2-sink=-v --version-V --verbosity=+ --video-buffer=--video-codec=--video-codec-options=--video-encoder=@@ -191,7 +191,6 @@ _scrcpy() {|--camera-size \|--crop \|--display-id \- |--display-buffer \|--max-fps \|-m|--max-size \|-p|--port \@@ -201,6 +200,7 @@ _scrcpy() {|--tunnel-port \|--v4l2-buffer \|--v4l2-sink \+ |--video-buffer \|--video-codec-options \|--video-encoder \|--tcpip \diff --git a/app/data/zsh-completion/_scrcpy b/app/data/zsh-completion/_scrcpyindex 8d1189c0..c4e0e60c 100644--- a/app/data/zsh-completion/_scrcpy+++ b/app/data/zsh-completion/_scrcpy@@ -27,7 +27,6 @@ arguments=('--crop=[\[width\:height\:x\:y\] Crop the device screen on the server]'{-d,--select-usb}'[Use USB device]''--disable-screensaver[Disable screensaver while scrcpy is running]'- '--display-buffer=[Add a buffering delay \(in milliseconds\) before displaying]''--display-id=[Specify the display id to mirror]''--display-orientation=[Set the initial display orientation]:orientation values:(0 90 180 270 flip0 flip90 flip180 flip270)'{-e,--select-tcpip}'[Use TCP/IP device]'@@ -92,6 +91,7 @@ arguments=('--v4l2-sink=[\[\/dev\/videoN\] Output to v4l2loopback device]'{-v,--version}'[Print the version of scrcpy]'{-V,--verbosity=}'[Set the log level]:verbosity:(verbose debug info warn error)'+ '--video-buffer=[Add a buffering delay \(in milliseconds\) before displaying video frames]''--video-codec=[Select the video codec]:codec:(h264 h265 av1)''--video-codec-options=[Set a list of comma-separated key\:type=value options for the device video encoder]''--video-encoder=[Use a specific MediaCodec video encoder]'diff --git a/app/scrcpy.1 b/app/scrcpy.1index 1b81d05e..f517ad4c 100644--- a/app/scrcpy.1+++ b/app/scrcpy.1@@ -139,12 +139,6 @@ Also see \fB\-e\fR (\fB\-\-select\-tcpip\fR)..BI "\-\-disable\-screensaver"Disable screensaver while scrcpy is running.-.TP-.BI "\-\-display\-buffer " ms-Add a buffering delay (in milliseconds) before displaying. This increases latency to compensate for jitter.--Default is 0 (no buffering).-.TP.BI "\-\-display\-id " idSpecify the device display id to mirror.@@ -560,7 +554,15 @@ It requires to lock the video orientation (see \fB\-\-lock\-video\-orientation\f.BI "\-\-v4l2-buffer " msAdd a buffering delay (in milliseconds) before pushing frames. This increases latency to compensate for jitter.-This option is similar to \fB\-\-display\-buffer\fR, but specific to V4L2 sink.+This option is similar to \fB\-\-video\-buffer\fR, but specific to V4L2 sink.++Default is 0 (no buffering).++.TP+.BI "\-\-video\-buffer " ms+Add a buffering delay (in milliseconds) before displaying video frames.++This increases latency to compensate for jitter.Default is 0 (no buffering).diff --git a/app/src/cli.c b/app/src/cli.cindex 95035836..77747e93 100644--- a/app/src/cli.c+++ b/app/src/cli.c@@ -50,6 +50,7 @@ enum {OPT_POWER_OFF_ON_CLOSE,OPT_V4L2_SINK,OPT_DISPLAY_BUFFER,+ OPT_VIDEO_BUFFER,OPT_V4L2_BUFFER,OPT_TUNNEL_HOST,OPT_TUNNEL_PORT,@@ -321,12 +322,10 @@ static const struct sc_option options[] = {.argdesc = "id",},{+ // deprecated.longopt_id = OPT_DISPLAY_BUFFER,.longopt = "display-buffer",.argdesc = "ms",- .text = "Add a buffering delay (in milliseconds) before displaying. "- "This increases latency to compensate for jitter.\n"- "Default is 0 (no buffering).",},{.longopt_id = OPT_DISPLAY_ID,@@ -898,11 +897,20 @@ static const struct sc_option options[] = {.argdesc = "ms",.text = "Add a buffering delay (in milliseconds) before pushing ""frames. This increases latency to compensate for jitter.\n"- "This option is similar to --display-buffer, but specific to "+ "This option is similar to --video-buffer, but specific to ""V4L2 sink.\n""Default is 0 (no buffering).\n""This option is only available on Linux.",},+ {+ .longopt_id = OPT_VIDEO_BUFFER,+ .longopt = "video-buffer",+ .argdesc = "ms",+ .text = "Add a buffering delay (in milliseconds) before displaying "+ "video frames.\n"+ "This increases latency to compensate for jitter.\n"+ "Default is 0 (no buffering).",+ },{.longopt_id = OPT_VIDEO_CODEC,.longopt = "video-codec",@@ -2549,7 +2557,11 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],opts->power_off_on_close = true;break;case OPT_DISPLAY_BUFFER:- if (!parse_buffering_time(optarg, &opts->display_buffer)) {+ LOGW("--display-buffer is deprecated, use --video-buffer "+ "instead.");+ // fall through+ case OPT_VIDEO_BUFFER:+ if (!parse_buffering_time(optarg, &opts->video_buffer)) {return false;}break;diff --git a/app/src/options.c b/app/src/options.cindex 8106ce3d..b1a3b739 100644--- a/app/src/options.c+++ b/app/src/options.c@@ -58,7 +58,7 @@ const struct scrcpy_options scrcpy_options_default = {.window_width = 0,.window_height = 0,.display_id = 0,- .display_buffer = 0,+ .video_buffer = 0,.audio_buffer = -1, // depends on the audio format,.audio_output_buffer = SC_TICK_FROM_MS(5),.time_limit = 0,diff --git a/app/src/options.h b/app/src/options.hindex 2d458ab4..d37ac0a2 100644--- a/app/src/options.h+++ b/app/src/options.h@@ -261,7 +261,7 @@ struct scrcpy_options {uint16_t window_width;uint16_t window_height;uint32_t display_id;- sc_tick display_buffer;+ sc_tick video_buffer;sc_tick audio_buffer;sc_tick audio_output_buffer;sc_tick time_limit;diff --git a/app/src/scrcpy.c b/app/src/scrcpy.cindex f0ce1959..8d135394 100644--- a/app/src/scrcpy.c+++ b/app/src/scrcpy.c@@ -53,7 +53,7 @@ struct scrcpy {struct sc_decoder video_decoder;struct sc_decoder audio_decoder;struct sc_recorder recorder;- struct sc_delay_buffer display_buffer;+ struct sc_delay_buffer video_buffer;#ifdef HAVE_V4L2struct sc_v4l2_sink v4l2_sink;struct sc_delay_buffer v4l2_buffer;@@ -815,11 +815,11 @@ aoa_complete:if (options->video_playback) {struct sc_frame_source *src = &s->video_decoder.frame_source;- if (options->display_buffer) {- sc_delay_buffer_init(&s->display_buffer,- options->display_buffer, true);- sc_frame_source_add_sink(src, &s->display_buffer.frame_sink);- src = &s->display_buffer.frame_source;+ if (options->video_buffer) {+ sc_delay_buffer_init(&s->video_buffer,+ options->video_buffer, true);+ sc_frame_source_add_sink(src, &s->video_buffer.frame_sink);+ src = &s->video_buffer.frame_source;}sc_frame_source_add_sink(src, &s->screen.frame_sink);diff --git a/doc/audio.md b/doc/audio.mdindex 750163e0..85f76ac5 100644--- a/doc/audio.md+++ b/doc/audio.md@@ -170,7 +170,7 @@ latency (for both [video](video.md#buffering) and audio) might be preferable toavoid glitches and smooth the playback:```-scrcpy --display-buffer=200 --audio-buffer=200+scrcpy --video-buffer=200 --audio-buffer=200```It is also possible to configure another audio buffer (the audio output buffer),diff --git a/doc/develop.md b/doc/develop.mdindex e5274783..a094aa32 100644--- a/doc/develop.md+++ b/doc/develop.md@@ -21,9 +21,9 @@ the client and on the server.If video is enabled, then the server sends a raw video stream (H.264 by default)of the device screen, with some additional headers for each packet. The clientdecodes the video frames, and displays them as soon as possible, without-buffering (unless `--display-buffer=delay` is specified) to minimize latency.-The client is not aware of the device rotation (which is handled by the server),-it just knows the dimensions of the video frames it receives.+buffering (unless `--video-buffer=delay` is specified) to minimize latency. The+client is not aware of the device rotation (which is handled by the server), it+just knows the dimensions of the video frames it receives.Similarly, if audio is enabled, then the server sends a raw audio stream (OPUSby default) of the device audio output (or the microphone ifdiff --git a/doc/video.md b/doc/video.mdindex ed92cb22..74ec74dd 100644--- a/doc/video.md+++ b/doc/video.md@@ -189,15 +189,15 @@ The configuration is available independently for the display,[v4l2 sinks](video.md#video4linux) and [audio](audio.md#buffering) playback.```bash-scrcpy --display-buffer=50 # add 50ms buffering for display-scrcpy --v4l2-buffer=300 # add 300ms buffering for v4l2 sink+scrcpy --video-buffer=50 # add 50ms buffering for video playbackscrcpy --audio-buffer=200 # set 200ms buffering for audio playback+scrcpy --v4l2-buffer=300 # add 300ms buffering for v4l2 sink```They can be applied simultaneously:```bash-scrcpy --display-buffer=50 --v4l2-buffer=300+scrcpy --video-buffer=50 --v4l2-buffer=300```