Compare commits
36 Commits
thread
...
device_id_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
40febf4a91 | ||
|
|
429fdef04f | ||
|
|
d1789f082a | ||
|
|
eb7e1070cf | ||
|
|
386f017ba9 | ||
|
|
cc48b24324 | ||
|
|
597c54f049 | ||
|
|
955da3b578 | ||
|
|
cb9c42bdcb | ||
|
|
fb9f9848bd | ||
|
|
c50b958ee4 | ||
|
|
441d3fb119 | ||
|
|
cb197ee3a2 | ||
|
|
218636dc10 | ||
|
|
b16b65a715 | ||
|
|
a3aa5ac95e | ||
|
|
0207e3df33 | ||
|
|
9cd1a7380d | ||
|
|
24b637b972 | ||
|
|
76a3d9805b | ||
|
|
50b4a730e3 | ||
|
|
ea2369f568 | ||
|
|
0538e9645b | ||
|
|
626094ad13 | ||
|
|
a566635c43 | ||
|
|
862948b132 | ||
|
|
c0c4ba7009 | ||
|
|
c53bd4d8b6 | ||
|
|
54f5c42d7b | ||
|
|
21d206f360 | ||
|
|
d2689fc168 | ||
|
|
f6320c7e31 | ||
|
|
30e619d37f | ||
|
|
c0dde0fade | ||
|
|
ace438e52a | ||
|
|
8e83f3e8af |
@@ -99,9 +99,6 @@ foreach f : check_functions
|
|||||||
endif
|
endif
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
# expose the build type
|
|
||||||
conf.set('NDEBUG', get_option('buildtype') != 'debug')
|
|
||||||
|
|
||||||
# the version, updated on release
|
# the version, updated on release
|
||||||
conf.set_quoted('SCRCPY_VERSION', meson.project_version())
|
conf.set_quoted('SCRCPY_VERSION', meson.project_version())
|
||||||
|
|
||||||
@@ -117,16 +114,6 @@ conf.set('PORTABLE', get_option('portable'))
|
|||||||
conf.set('DEFAULT_LOCAL_PORT_RANGE_FIRST', '27183')
|
conf.set('DEFAULT_LOCAL_PORT_RANGE_FIRST', '27183')
|
||||||
conf.set('DEFAULT_LOCAL_PORT_RANGE_LAST', '27199')
|
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
|
# the default video bitrate, in bits/second
|
||||||
# overridden by option --bit-rate
|
# overridden by option --bit-rate
|
||||||
conf.set('DEFAULT_BIT_RATE', '8000000') # 8Mbps
|
conf.set('DEFAULT_BIT_RATE', '8000000') # 8Mbps
|
||||||
|
|||||||
@@ -10,6 +10,9 @@
|
|||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/str_util.h"
|
#include "util/str_util.h"
|
||||||
|
|
||||||
|
#define STR_IMPL_(x) #x
|
||||||
|
#define STR(x) STR_IMPL_(x)
|
||||||
|
|
||||||
void
|
void
|
||||||
scrcpy_print_usage(const char *arg0) {
|
scrcpy_print_usage(const char *arg0) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
@@ -23,7 +26,7 @@ scrcpy_print_usage(const char *arg0) {
|
|||||||
" -b, --bit-rate value\n"
|
" -b, --bit-rate value\n"
|
||||||
" Encode the video at the given bit-rate, expressed in bits/s.\n"
|
" Encode the video at the given bit-rate, expressed in bits/s.\n"
|
||||||
" Unit suffixes are supported: 'K' (x1000) and 'M' (x1000000).\n"
|
" Unit suffixes are supported: 'K' (x1000) and 'M' (x1000000).\n"
|
||||||
" Default is %d.\n"
|
" Default is " STR(DEFAULT_BIT_RATE) ".\n"
|
||||||
"\n"
|
"\n"
|
||||||
" --codec-options key[:type]=value[,...]\n"
|
" --codec-options key[:type]=value[,...]\n"
|
||||||
" Set a list of comma-separated key:type=value options for the\n"
|
" Set a list of comma-separated key:type=value options for the\n"
|
||||||
@@ -81,7 +84,7 @@ scrcpy_print_usage(const char *arg0) {
|
|||||||
" Possible values are -1 (unlocked), 0, 1, 2 and 3.\n"
|
" Possible values are -1 (unlocked), 0, 1, 2 and 3.\n"
|
||||||
" Natural device orientation is 0, and each increment adds a\n"
|
" Natural device orientation is 0, and each increment adds a\n"
|
||||||
" 90 degrees rotation counterclockwise.\n"
|
" 90 degrees rotation counterclockwise.\n"
|
||||||
" Default is %d%s.\n"
|
" Default is -1 (unlocked).\n"
|
||||||
"\n"
|
"\n"
|
||||||
" --max-fps value\n"
|
" --max-fps value\n"
|
||||||
" Limit the frame rate of screen capture (officially supported\n"
|
" Limit the frame rate of screen capture (officially supported\n"
|
||||||
@@ -91,7 +94,7 @@ scrcpy_print_usage(const char *arg0) {
|
|||||||
" Limit both the width and height of the video to value. The\n"
|
" Limit both the width and height of the video to value. The\n"
|
||||||
" other dimension is computed so that the device aspect-ratio\n"
|
" other dimension is computed so that the device aspect-ratio\n"
|
||||||
" is preserved.\n"
|
" is preserved.\n"
|
||||||
" Default is %d%s.\n"
|
" Default is 0 (unlimited).\n"
|
||||||
"\n"
|
"\n"
|
||||||
" -n, --no-control\n"
|
" -n, --no-control\n"
|
||||||
" Disable device control (mirror the device in read-only).\n"
|
" Disable device control (mirror the device in read-only).\n"
|
||||||
@@ -110,7 +113,8 @@ scrcpy_print_usage(const char *arg0) {
|
|||||||
"\n"
|
"\n"
|
||||||
" -p, --port port[:port]\n"
|
" -p, --port port[:port]\n"
|
||||||
" Set the TCP port (range) used by the client to listen.\n"
|
" Set the TCP port (range) used by the client to listen.\n"
|
||||||
" Default is %d:%d.\n"
|
" Default is " STR(DEFAULT_LOCAL_PORT_RANGE_FIRST) ":"
|
||||||
|
STR(DEFAULT_LOCAL_PORT_RANGE_LAST) ".\n"
|
||||||
"\n"
|
"\n"
|
||||||
" --prefer-text\n"
|
" --prefer-text\n"
|
||||||
" Inject alpha characters and space as text events instead of\n"
|
" Inject alpha characters and space as text events instead of\n"
|
||||||
@@ -297,12 +301,7 @@ scrcpy_print_usage(const char *arg0) {
|
|||||||
"\n"
|
"\n"
|
||||||
" Drag & drop APK file\n"
|
" Drag & drop APK file\n"
|
||||||
" Install APK from computer\n"
|
" Install APK from computer\n"
|
||||||
"\n",
|
"\n", arg0);
|
||||||
arg0,
|
|
||||||
DEFAULT_BIT_RATE,
|
|
||||||
DEFAULT_LOCK_VIDEO_ORIENTATION, DEFAULT_LOCK_VIDEO_ORIENTATION >= 0 ? "" : " (unlocked)",
|
|
||||||
DEFAULT_MAX_SIZE, DEFAULT_MAX_SIZE ? "" : " (unlimited)",
|
|
||||||
DEFAULT_LOCAL_PORT_RANGE_FIRST, DEFAULT_LOCAL_PORT_RANGE_LAST);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
# define SCRCPY_SDL_HAS_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR
|
# define SCRCPY_SDL_HAS_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_STRDUP
|
#ifndef HAVE_STRDUP
|
||||||
char *strdup(const char *s);
|
char *strdup(const char *s);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -11,22 +11,6 @@
|
|||||||
#include "util/buffer_util.h"
|
#include "util/buffer_util.h"
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
|
|
||||||
// set the decoded frame as ready for rendering, and notify
|
|
||||||
static void
|
|
||||||
push_frame(struct decoder *decoder) {
|
|
||||||
bool previous_frame_skipped;
|
|
||||||
video_buffer_offer_decoded_frame(decoder->video_buffer,
|
|
||||||
&previous_frame_skipped);
|
|
||||||
if (previous_frame_skipped) {
|
|
||||||
// the previous EVENT_NEW_FRAME will consume this frame
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
static SDL_Event new_frame_event = {
|
|
||||||
.type = EVENT_NEW_FRAME,
|
|
||||||
};
|
|
||||||
SDL_PushEvent(&new_frame_event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
decoder_init(struct decoder *decoder, struct video_buffer *vb) {
|
decoder_init(struct decoder *decoder, struct video_buffer *vb) {
|
||||||
decoder->video_buffer = vb;
|
decoder->video_buffer = vb;
|
||||||
@@ -66,10 +50,10 @@ decoder_push(struct decoder *decoder, const AVPacket *packet) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ret = avcodec_receive_frame(decoder->codec_ctx,
|
ret = avcodec_receive_frame(decoder->codec_ctx,
|
||||||
decoder->video_buffer->decoding_frame);
|
decoder->video_buffer->producer_frame);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
// a frame was received
|
// a frame was received
|
||||||
push_frame(decoder);
|
video_buffer_producer_offer_frame(decoder->video_buffer);
|
||||||
} else if (ret != AVERROR(EAGAIN)) {
|
} else if (ret != AVERROR(EAGAIN)) {
|
||||||
LOGE("Could not receive video frame: %d", ret);
|
LOGE("Could not receive video frame: %d", ret);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ struct video_buffer;
|
|||||||
|
|
||||||
struct decoder {
|
struct decoder {
|
||||||
struct video_buffer *video_buffer;
|
struct video_buffer *video_buffer;
|
||||||
|
|
||||||
AVCodecContext *codec_ctx;
|
AVCodecContext *codec_ctx;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,2 @@
|
|||||||
#define EVENT_NEW_SESSION SDL_USEREVENT
|
#define EVENT_NEW_FRAME SDL_USEREVENT
|
||||||
#define EVENT_NEW_FRAME (SDL_USEREVENT + 1)
|
#define EVENT_STREAM_STOPPED (SDL_USEREVENT + 1)
|
||||||
#define EVENT_STREAM_STOPPED (SDL_USEREVENT + 2)
|
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ rotate_client_right(struct screen *screen) {
|
|||||||
screen_set_rotation(screen, new_rotation);
|
screen_set_rotation(screen, new_rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
input_manager_process_text_input(struct input_manager *im,
|
input_manager_process_text_input(struct input_manager *im,
|
||||||
const SDL_TextInputEvent *event) {
|
const SDL_TextInputEvent *event) {
|
||||||
if (is_shortcut_mod(im, SDL_GetModState())) {
|
if (is_shortcut_mod(im, SDL_GetModState())) {
|
||||||
@@ -366,7 +366,7 @@ convert_input_key(const SDL_KeyboardEvent *from, struct control_msg *to,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
input_manager_process_key(struct input_manager *im,
|
input_manager_process_key(struct input_manager *im,
|
||||||
const SDL_KeyboardEvent *event) {
|
const SDL_KeyboardEvent *event) {
|
||||||
// control: indicates the state of the command-line option --no-control
|
// control: indicates the state of the command-line option --no-control
|
||||||
@@ -480,9 +480,7 @@ input_manager_process_key(struct input_manager *im,
|
|||||||
return;
|
return;
|
||||||
case SDLK_i:
|
case SDLK_i:
|
||||||
if (!shift && !repeat && down) {
|
if (!shift && !repeat && down) {
|
||||||
struct fps_counter *fps_counter =
|
switch_fps_counter_state(im->fps_counter);
|
||||||
im->video_buffer->fps_counter;
|
|
||||||
switch_fps_counter_state(fps_counter);
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case SDLK_n:
|
case SDLK_n:
|
||||||
@@ -551,7 +549,7 @@ convert_mouse_motion(const SDL_MouseMotionEvent *from, struct screen *screen,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
input_manager_process_mouse_motion(struct input_manager *im,
|
input_manager_process_mouse_motion(struct input_manager *im,
|
||||||
const SDL_MouseMotionEvent *event) {
|
const SDL_MouseMotionEvent *event) {
|
||||||
if (!event->state) {
|
if (!event->state) {
|
||||||
@@ -605,7 +603,7 @@ convert_touch(const SDL_TouchFingerEvent *from, struct screen *screen,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
input_manager_process_touch(struct input_manager *im,
|
input_manager_process_touch(struct input_manager *im,
|
||||||
const SDL_TouchFingerEvent *event) {
|
const SDL_TouchFingerEvent *event) {
|
||||||
struct control_msg msg;
|
struct control_msg msg;
|
||||||
@@ -637,7 +635,7 @@ convert_mouse_button(const SDL_MouseButtonEvent *from, struct screen *screen,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
input_manager_process_mouse_button(struct input_manager *im,
|
input_manager_process_mouse_button(struct input_manager *im,
|
||||||
const SDL_MouseButtonEvent *event) {
|
const SDL_MouseButtonEvent *event) {
|
||||||
bool control = im->control;
|
bool control = im->control;
|
||||||
@@ -736,7 +734,7 @@ convert_mouse_wheel(const SDL_MouseWheelEvent *from, struct screen *screen,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
input_manager_process_mouse_wheel(struct input_manager *im,
|
input_manager_process_mouse_wheel(struct input_manager *im,
|
||||||
const SDL_MouseWheelEvent *event) {
|
const SDL_MouseWheelEvent *event) {
|
||||||
struct control_msg msg;
|
struct control_msg msg;
|
||||||
@@ -746,3 +744,46 @@ input_manager_process_mouse_wheel(struct input_manager *im,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
input_manager_handle_event(struct input_manager *im, SDL_Event *event) {
|
||||||
|
switch (event->type) {
|
||||||
|
case SDL_TEXTINPUT:
|
||||||
|
if (!im->control) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
input_manager_process_text_input(im, &event->text);
|
||||||
|
return true;
|
||||||
|
case SDL_KEYDOWN:
|
||||||
|
case SDL_KEYUP:
|
||||||
|
// some key events do not interact with the device, so process the
|
||||||
|
// event even if control is disabled
|
||||||
|
input_manager_process_key(im, &event->key);
|
||||||
|
return true;
|
||||||
|
case SDL_MOUSEMOTION:
|
||||||
|
if (!im->control) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
input_manager_process_mouse_motion(im, &event->motion);
|
||||||
|
return true;
|
||||||
|
case SDL_MOUSEWHEEL:
|
||||||
|
if (!im->control) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
input_manager_process_mouse_wheel(im, &event->wheel);
|
||||||
|
return true;
|
||||||
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
|
case SDL_MOUSEBUTTONUP:
|
||||||
|
// some mouse events do not interact with the device, so process
|
||||||
|
// the event even if control is disabled
|
||||||
|
input_manager_process_mouse_button(im, &event->button);
|
||||||
|
return true;
|
||||||
|
case SDL_FINGERMOTION:
|
||||||
|
case SDL_FINGERDOWN:
|
||||||
|
case SDL_FINGERUP:
|
||||||
|
input_manager_process_touch(im, &event->tfinger);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
struct input_manager {
|
struct input_manager {
|
||||||
struct controller *controller;
|
struct controller *controller;
|
||||||
struct video_buffer *video_buffer;
|
struct video_buffer *video_buffer;
|
||||||
|
struct fps_counter *fps_counter;
|
||||||
struct screen *screen;
|
struct screen *screen;
|
||||||
|
|
||||||
// SDL reports repeated events as a boolean, but Android expects the actual
|
// SDL reports repeated events as a boolean, but Android expects the actual
|
||||||
@@ -40,28 +41,7 @@ void
|
|||||||
input_manager_init(struct input_manager *im,
|
input_manager_init(struct input_manager *im,
|
||||||
const struct scrcpy_options *options);
|
const struct scrcpy_options *options);
|
||||||
|
|
||||||
void
|
bool
|
||||||
input_manager_process_text_input(struct input_manager *im,
|
input_manager_handle_event(struct input_manager *im, SDL_Event *event);
|
||||||
const SDL_TextInputEvent *event);
|
|
||||||
|
|
||||||
void
|
|
||||||
input_manager_process_key(struct input_manager *im,
|
|
||||||
const SDL_KeyboardEvent *event);
|
|
||||||
|
|
||||||
void
|
|
||||||
input_manager_process_mouse_motion(struct input_manager *im,
|
|
||||||
const SDL_MouseMotionEvent *event);
|
|
||||||
|
|
||||||
void
|
|
||||||
input_manager_process_touch(struct input_manager *im,
|
|
||||||
const SDL_TouchFingerEvent *event);
|
|
||||||
|
|
||||||
void
|
|
||||||
input_manager_process_mouse_button(struct input_manager *im,
|
|
||||||
const SDL_MouseButtonEvent *event);
|
|
||||||
|
|
||||||
void
|
|
||||||
input_manager_process_mouse_wheel(struct input_manager *im,
|
|
||||||
const SDL_MouseWheelEvent *event);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
#include "util/net.h"
|
#include "util/net.h"
|
||||||
|
|
||||||
static struct server server;
|
static struct server server;
|
||||||
static struct screen screen = SCREEN_INITIALIZER;
|
static struct screen screen;
|
||||||
static struct fps_counter fps_counter;
|
static struct fps_counter fps_counter;
|
||||||
static struct video_buffer video_buffer;
|
static struct video_buffer video_buffer;
|
||||||
static struct stream stream;
|
static struct stream stream;
|
||||||
@@ -42,6 +42,7 @@ static struct file_handler file_handler;
|
|||||||
static struct input_manager input_manager = {
|
static struct input_manager input_manager = {
|
||||||
.controller = &controller,
|
.controller = &controller,
|
||||||
.video_buffer = &video_buffer,
|
.video_buffer = &video_buffer,
|
||||||
|
.fps_counter = &fps_counter,
|
||||||
.screen = &screen,
|
.screen = &screen,
|
||||||
.repeat = 0,
|
.repeat = 0,
|
||||||
|
|
||||||
@@ -173,54 +174,6 @@ handle_event(SDL_Event *event, const struct scrcpy_options *options) {
|
|||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
LOGD("User requested to quit");
|
LOGD("User requested to quit");
|
||||||
return EVENT_RESULT_STOPPED_BY_USER;
|
return EVENT_RESULT_STOPPED_BY_USER;
|
||||||
case EVENT_NEW_FRAME:
|
|
||||||
if (!screen.has_frame) {
|
|
||||||
screen.has_frame = true;
|
|
||||||
// this is the very first frame, show the window
|
|
||||||
screen_show_window(&screen);
|
|
||||||
}
|
|
||||||
if (!screen_update_frame(&screen, &video_buffer)) {
|
|
||||||
return EVENT_RESULT_CONTINUE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SDL_WINDOWEVENT:
|
|
||||||
screen_handle_window_event(&screen, &event->window);
|
|
||||||
break;
|
|
||||||
case SDL_TEXTINPUT:
|
|
||||||
if (!options->control) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
input_manager_process_text_input(&input_manager, &event->text);
|
|
||||||
break;
|
|
||||||
case SDL_KEYDOWN:
|
|
||||||
case SDL_KEYUP:
|
|
||||||
// some key events do not interact with the device, so process the
|
|
||||||
// event even if control is disabled
|
|
||||||
input_manager_process_key(&input_manager, &event->key);
|
|
||||||
break;
|
|
||||||
case SDL_MOUSEMOTION:
|
|
||||||
if (!options->control) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
input_manager_process_mouse_motion(&input_manager, &event->motion);
|
|
||||||
break;
|
|
||||||
case SDL_MOUSEWHEEL:
|
|
||||||
if (!options->control) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
input_manager_process_mouse_wheel(&input_manager, &event->wheel);
|
|
||||||
break;
|
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
|
||||||
case SDL_MOUSEBUTTONUP:
|
|
||||||
// some mouse events do not interact with the device, so process
|
|
||||||
// the event even if control is disabled
|
|
||||||
input_manager_process_mouse_button(&input_manager, &event->button);
|
|
||||||
break;
|
|
||||||
case SDL_FINGERMOTION:
|
|
||||||
case SDL_FINGERDOWN:
|
|
||||||
case SDL_FINGERUP:
|
|
||||||
input_manager_process_touch(&input_manager, &event->tfinger);
|
|
||||||
break;
|
|
||||||
case SDL_DROPFILE: {
|
case SDL_DROPFILE: {
|
||||||
if (!options->control) {
|
if (!options->control) {
|
||||||
break;
|
break;
|
||||||
@@ -242,6 +195,16 @@ handle_event(SDL_Event *event, const struct scrcpy_options *options) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool consumed = screen_handle_event(&screen, event);
|
||||||
|
if (consumed) {
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
consumed = input_manager_handle_event(&input_manager, event);
|
||||||
|
(void) consumed;
|
||||||
|
|
||||||
|
end:
|
||||||
return EVENT_RESULT_CONTINUE;
|
return EVENT_RESULT_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,8 +333,7 @@ scrcpy(const struct scrcpy_options *options) {
|
|||||||
}
|
}
|
||||||
fps_counter_initialized = true;
|
fps_counter_initialized = true;
|
||||||
|
|
||||||
if (!video_buffer_init(&video_buffer, &fps_counter,
|
if (!video_buffer_init(&video_buffer, options->render_expired_frames)) {
|
||||||
options->render_expired_frames)) {
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
video_buffer_initialized = true;
|
video_buffer_initialized = true;
|
||||||
@@ -404,13 +366,6 @@ scrcpy(const struct scrcpy_options *options) {
|
|||||||
|
|
||||||
stream_init(&stream, server.video_socket, dec, rec);
|
stream_init(&stream, server.video_socket, dec, rec);
|
||||||
|
|
||||||
// now we consumed the header values, the socket receives the video stream
|
|
||||||
// start the stream
|
|
||||||
if (!stream_start(&stream)) {
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
stream_started = true;
|
|
||||||
|
|
||||||
if (options->display) {
|
if (options->display) {
|
||||||
if (options->control) {
|
if (options->control) {
|
||||||
if (!controller_init(&controller, server.control_socket)) {
|
if (!controller_init(&controller, server.control_socket)) {
|
||||||
@@ -427,12 +382,21 @@ scrcpy(const struct scrcpy_options *options) {
|
|||||||
const char *window_title =
|
const char *window_title =
|
||||||
options->window_title ? options->window_title : device_name;
|
options->window_title ? options->window_title : device_name;
|
||||||
|
|
||||||
if (!screen_init_rendering(&screen, window_title, frame_size,
|
struct screen_params screen_params = {
|
||||||
options->always_on_top, options->window_x,
|
.window_title = window_title,
|
||||||
options->window_y, options->window_width,
|
.frame_size = frame_size,
|
||||||
options->window_height,
|
.always_on_top = options->always_on_top,
|
||||||
options->window_borderless,
|
.window_x = options->window_x,
|
||||||
options->rotation, options->mipmaps)) {
|
.window_y = options->window_y,
|
||||||
|
.window_width = options->window_width,
|
||||||
|
.window_height = options->window_height,
|
||||||
|
.window_borderless = options->window_borderless,
|
||||||
|
.rotation = options->rotation,
|
||||||
|
.mipmaps = options->mipmaps,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!screen_init(&screen, &video_buffer, &fps_counter,
|
||||||
|
&screen_params)) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,6 +415,13 @@ scrcpy(const struct scrcpy_options *options) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// now we consumed the header values, the socket receives the video stream
|
||||||
|
// start the stream
|
||||||
|
if (!stream_start(&stream)) {
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
stream_started = true;
|
||||||
|
|
||||||
input_manager_init(&input_manager, options);
|
input_manager_init(&input_manager, options);
|
||||||
|
|
||||||
ret = event_loop(options);
|
ret = event_loop(options);
|
||||||
|
|||||||
@@ -103,10 +103,10 @@ struct scrcpy_options {
|
|||||||
.data = {SC_MOD_LALT, SC_MOD_LSUPER}, \
|
.data = {SC_MOD_LALT, SC_MOD_LSUPER}, \
|
||||||
.count = 2, \
|
.count = 2, \
|
||||||
}, \
|
}, \
|
||||||
.max_size = DEFAULT_MAX_SIZE, \
|
.max_size = 0, \
|
||||||
.bit_rate = DEFAULT_BIT_RATE, \
|
.bit_rate = DEFAULT_BIT_RATE, \
|
||||||
.max_fps = 0, \
|
.max_fps = 0, \
|
||||||
.lock_video_orientation = DEFAULT_LOCK_VIDEO_ORIENTATION, \
|
.lock_video_orientation = -1, \
|
||||||
.rotation = 0, \
|
.rotation = 0, \
|
||||||
.window_x = SC_WINDOW_POSITION_UNDEFINED, \
|
.window_x = SC_WINDOW_POSITION_UNDEFINED, \
|
||||||
.window_y = SC_WINDOW_POSITION_UNDEFINED, \
|
.window_y = SC_WINDOW_POSITION_UNDEFINED, \
|
||||||
|
|||||||
184
app/src/screen.c
184
app/src/screen.c
@@ -4,6 +4,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
|
|
||||||
|
#include "events.h"
|
||||||
#include "icon.xpm"
|
#include "icon.xpm"
|
||||||
#include "scrcpy.h"
|
#include "scrcpy.h"
|
||||||
#include "tiny_xpm.h"
|
#include "tiny_xpm.h"
|
||||||
@@ -190,9 +191,25 @@ screen_update_content_rect(struct screen *screen) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
screen_init(struct screen *screen) {
|
on_frame_available(struct video_buffer *vb, void *userdata) {
|
||||||
*screen = (struct screen) SCREEN_INITIALIZER;
|
(void) vb;
|
||||||
|
(void) userdata;
|
||||||
|
|
||||||
|
static SDL_Event new_frame_event = {
|
||||||
|
.type = EVENT_NEW_FRAME,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Post the event on the UI thread
|
||||||
|
SDL_PushEvent(&new_frame_event);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_frame_skipped(struct video_buffer *vb, void *userdata) {
|
||||||
|
(void) vb;
|
||||||
|
|
||||||
|
struct screen *screen = userdata;
|
||||||
|
fps_counter_add_skipped_frame(screen->fps_counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline SDL_Texture *
|
static inline SDL_Texture *
|
||||||
@@ -223,26 +240,40 @@ create_texture(struct screen *screen) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
screen_init_rendering(struct screen *screen, const char *window_title,
|
screen_init(struct screen *screen, struct video_buffer *vb,
|
||||||
struct size frame_size, bool always_on_top,
|
struct fps_counter *fps_counter,
|
||||||
int16_t window_x, int16_t window_y, uint16_t window_width,
|
const struct screen_params *params) {
|
||||||
uint16_t window_height, bool window_borderless,
|
screen->vb = vb;
|
||||||
uint8_t rotation, bool mipmaps) {
|
screen->fps_counter = fps_counter;
|
||||||
screen->frame_size = frame_size;
|
|
||||||
screen->rotation = rotation;
|
screen->resize_pending = false;
|
||||||
if (rotation) {
|
screen->has_frame = false;
|
||||||
LOGI("Initial display rotation set to %u", rotation);
|
screen->fullscreen = false;
|
||||||
|
screen->maximized = false;
|
||||||
|
|
||||||
|
static const struct video_buffer_callbacks cbs = {
|
||||||
|
.on_frame_available = on_frame_available,
|
||||||
|
.on_frame_skipped = on_frame_skipped,
|
||||||
|
};
|
||||||
|
video_buffer_set_consumer_callbacks(vb, &cbs, screen);
|
||||||
|
|
||||||
|
screen->frame_size = params->frame_size;
|
||||||
|
screen->rotation = params->rotation;
|
||||||
|
if (screen->rotation) {
|
||||||
|
LOGI("Initial display rotation set to %u", screen->rotation);
|
||||||
}
|
}
|
||||||
struct size content_size = get_rotated_size(frame_size, screen->rotation);
|
struct size content_size =
|
||||||
|
get_rotated_size(screen->frame_size, screen->rotation);
|
||||||
screen->content_size = content_size;
|
screen->content_size = content_size;
|
||||||
|
|
||||||
struct size window_size =
|
struct size window_size = get_initial_optimal_size(content_size,
|
||||||
get_initial_optimal_size(content_size, window_width, window_height);
|
params->window_width,
|
||||||
|
params->window_height);
|
||||||
uint32_t window_flags = SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE;
|
uint32_t window_flags = SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE;
|
||||||
#ifdef HIDPI_SUPPORT
|
#ifdef HIDPI_SUPPORT
|
||||||
window_flags |= SDL_WINDOW_ALLOW_HIGHDPI;
|
window_flags |= SDL_WINDOW_ALLOW_HIGHDPI;
|
||||||
#endif
|
#endif
|
||||||
if (always_on_top) {
|
if (params->always_on_top) {
|
||||||
#ifdef SCRCPY_SDL_HAS_WINDOW_ALWAYS_ON_TOP
|
#ifdef SCRCPY_SDL_HAS_WINDOW_ALWAYS_ON_TOP
|
||||||
window_flags |= SDL_WINDOW_ALWAYS_ON_TOP;
|
window_flags |= SDL_WINDOW_ALWAYS_ON_TOP;
|
||||||
#else
|
#else
|
||||||
@@ -250,15 +281,15 @@ screen_init_rendering(struct screen *screen, const char *window_title,
|
|||||||
"(compile with SDL >= 2.0.5 to enable it)");
|
"(compile with SDL >= 2.0.5 to enable it)");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (window_borderless) {
|
if (params->window_borderless) {
|
||||||
window_flags |= SDL_WINDOW_BORDERLESS;
|
window_flags |= SDL_WINDOW_BORDERLESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int x = window_x != SC_WINDOW_POSITION_UNDEFINED
|
int x = params->window_x != SC_WINDOW_POSITION_UNDEFINED
|
||||||
? window_x : (int) SDL_WINDOWPOS_UNDEFINED;
|
? params->window_x : (int) SDL_WINDOWPOS_UNDEFINED;
|
||||||
int y = window_y != SC_WINDOW_POSITION_UNDEFINED
|
int y = params->window_y != SC_WINDOW_POSITION_UNDEFINED
|
||||||
? window_y : (int) SDL_WINDOWPOS_UNDEFINED;
|
? params->window_y : (int) SDL_WINDOWPOS_UNDEFINED;
|
||||||
screen->window = SDL_CreateWindow(window_title, x, y,
|
screen->window = SDL_CreateWindow(params->window_title, x, y,
|
||||||
window_size.width, window_size.height,
|
window_size.width, window_size.height,
|
||||||
window_flags);
|
window_flags);
|
||||||
if (!screen->window) {
|
if (!screen->window) {
|
||||||
@@ -270,7 +301,7 @@ screen_init_rendering(struct screen *screen, const char *window_title,
|
|||||||
SDL_RENDERER_ACCELERATED);
|
SDL_RENDERER_ACCELERATED);
|
||||||
if (!screen->renderer) {
|
if (!screen->renderer) {
|
||||||
LOGC("Could not create renderer: %s", SDL_GetError());
|
LOGC("Could not create renderer: %s", SDL_GetError());
|
||||||
screen_destroy(screen);
|
SDL_DestroyWindow(screen->window);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,15 +310,17 @@ screen_init_rendering(struct screen *screen, const char *window_title,
|
|||||||
const char *renderer_name = r ? NULL : renderer_info.name;
|
const char *renderer_name = r ? NULL : renderer_info.name;
|
||||||
LOGI("Renderer: %s", renderer_name ? renderer_name : "(unknown)");
|
LOGI("Renderer: %s", renderer_name ? renderer_name : "(unknown)");
|
||||||
|
|
||||||
|
screen->mipmaps = false;
|
||||||
|
|
||||||
// starts with "opengl"
|
// starts with "opengl"
|
||||||
screen->use_opengl = renderer_name && !strncmp(renderer_name, "opengl", 6);
|
bool use_opengl = renderer_name && !strncmp(renderer_name, "opengl", 6);
|
||||||
if (screen->use_opengl) {
|
if (use_opengl) {
|
||||||
struct sc_opengl *gl = &screen->gl;
|
struct sc_opengl *gl = &screen->gl;
|
||||||
sc_opengl_init(gl);
|
sc_opengl_init(gl);
|
||||||
|
|
||||||
LOGI("OpenGL version: %s", gl->version);
|
LOGI("OpenGL version: %s", gl->version);
|
||||||
|
|
||||||
if (mipmaps) {
|
if (params->mipmaps) {
|
||||||
bool supports_mipmaps =
|
bool supports_mipmaps =
|
||||||
sc_opengl_version_at_least(gl, 3, 0, /* OpenGL 3.0+ */
|
sc_opengl_version_at_least(gl, 3, 0, /* OpenGL 3.0+ */
|
||||||
2, 0 /* OpenGL ES 2.0+ */);
|
2, 0 /* OpenGL ES 2.0+ */);
|
||||||
@@ -301,7 +334,7 @@ screen_init_rendering(struct screen *screen, const char *window_title,
|
|||||||
} else {
|
} else {
|
||||||
LOGI("Trilinear filtering disabled");
|
LOGI("Trilinear filtering disabled");
|
||||||
}
|
}
|
||||||
} else {
|
} else if (params->mipmaps) {
|
||||||
LOGD("Trilinear filtering disabled (not an OpenGL renderer)");
|
LOGD("Trilinear filtering disabled (not an OpenGL renderer)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,12 +346,13 @@ screen_init_rendering(struct screen *screen, const char *window_title,
|
|||||||
LOGW("Could not load icon");
|
LOGW("Could not load icon");
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGI("Initial texture: %" PRIu16 "x%" PRIu16, frame_size.width,
|
LOGI("Initial texture: %" PRIu16 "x%" PRIu16, params->frame_size.width,
|
||||||
frame_size.height);
|
params->frame_size.height);
|
||||||
screen->texture = create_texture(screen);
|
screen->texture = create_texture(screen);
|
||||||
if (!screen->texture) {
|
if (!screen->texture) {
|
||||||
LOGC("Could not create texture: %s", SDL_GetError());
|
LOGC("Could not create texture: %s", SDL_GetError());
|
||||||
screen_destroy(screen);
|
SDL_DestroyRenderer(screen->renderer);
|
||||||
|
SDL_DestroyWindow(screen->window);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -339,15 +373,9 @@ screen_show_window(struct screen *screen) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
screen_destroy(struct screen *screen) {
|
screen_destroy(struct screen *screen) {
|
||||||
if (screen->texture) {
|
SDL_DestroyTexture(screen->texture);
|
||||||
SDL_DestroyTexture(screen->texture);
|
SDL_DestroyRenderer(screen->renderer);
|
||||||
}
|
SDL_DestroyWindow(screen->window);
|
||||||
if (screen->renderer) {
|
|
||||||
SDL_DestroyRenderer(screen->renderer);
|
|
||||||
}
|
|
||||||
if (screen->window) {
|
|
||||||
SDL_DestroyWindow(screen->window);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -444,19 +472,20 @@ update_texture(struct screen *screen, const AVFrame *frame) {
|
|||||||
frame->data[2], frame->linesize[2]);
|
frame->data[2], frame->linesize[2]);
|
||||||
|
|
||||||
if (screen->mipmaps) {
|
if (screen->mipmaps) {
|
||||||
assert(screen->use_opengl);
|
|
||||||
SDL_GL_BindTexture(screen->texture, NULL, NULL);
|
SDL_GL_BindTexture(screen->texture, NULL, NULL);
|
||||||
screen->gl.GenerateMipmap(GL_TEXTURE_2D);
|
screen->gl.GenerateMipmap(GL_TEXTURE_2D);
|
||||||
SDL_GL_UnbindTexture(screen->texture);
|
SDL_GL_UnbindTexture(screen->texture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
static bool
|
||||||
screen_update_frame(struct screen *screen, struct video_buffer *vb) {
|
screen_update_frame(struct screen *screen) {
|
||||||
const AVFrame *frame = video_buffer_take_rendering_frame(vb);
|
const AVFrame *frame = video_buffer_consumer_take_frame(screen->vb);
|
||||||
|
|
||||||
|
fps_counter_add_rendered_frame(screen->fps_counter);
|
||||||
|
|
||||||
struct size new_frame_size = {frame->width, frame->height};
|
struct size new_frame_size = {frame->width, frame->height};
|
||||||
if (!prepare_for_frame(screen, new_frame_size)) {
|
if (!prepare_for_frame(screen, new_frame_size)) {
|
||||||
sc_mutex_unlock(&vb->mutex);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
update_texture(screen, frame);
|
update_texture(screen, frame);
|
||||||
@@ -546,31 +575,52 @@ screen_resize_to_pixel_perfect(struct screen *screen) {
|
|||||||
content_size.height);
|
content_size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
bool
|
||||||
screen_handle_window_event(struct screen *screen,
|
screen_handle_event(struct screen *screen, SDL_Event *event) {
|
||||||
const SDL_WindowEvent *event) {
|
switch (event->type) {
|
||||||
switch (event->event) {
|
case EVENT_NEW_FRAME:
|
||||||
case SDL_WINDOWEVENT_EXPOSED:
|
if (!screen->has_frame) {
|
||||||
screen_render(screen, true);
|
screen->has_frame = true;
|
||||||
break;
|
// this is the very first frame, show the window
|
||||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
screen_show_window(screen);
|
||||||
screen_render(screen, true);
|
|
||||||
break;
|
|
||||||
case SDL_WINDOWEVENT_MAXIMIZED:
|
|
||||||
screen->maximized = true;
|
|
||||||
break;
|
|
||||||
case SDL_WINDOWEVENT_RESTORED:
|
|
||||||
if (screen->fullscreen) {
|
|
||||||
// On Windows, in maximized+fullscreen, disabling fullscreen
|
|
||||||
// mode unexpectedly triggers the "restored" then "maximized"
|
|
||||||
// events, leaving the window in a weird state (maximized
|
|
||||||
// according to the events, but not maximized visually).
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
screen->maximized = false;
|
bool ok = screen_update_frame(screen);
|
||||||
apply_pending_resize(screen);
|
if (!ok) {
|
||||||
break;
|
LOGW("Frame update failed\n");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case SDL_WINDOWEVENT:
|
||||||
|
if (!screen->has_frame) {
|
||||||
|
// Do nothing
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
switch (event->window.event) {
|
||||||
|
case SDL_WINDOWEVENT_EXPOSED:
|
||||||
|
screen_render(screen, true);
|
||||||
|
break;
|
||||||
|
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||||
|
screen_render(screen, true);
|
||||||
|
break;
|
||||||
|
case SDL_WINDOWEVENT_MAXIMIZED:
|
||||||
|
screen->maximized = true;
|
||||||
|
break;
|
||||||
|
case SDL_WINDOWEVENT_RESTORED:
|
||||||
|
if (screen->fullscreen) {
|
||||||
|
// On Windows, in maximized+fullscreen, disabling
|
||||||
|
// fullscreen mode unexpectedly triggers the "restored"
|
||||||
|
// then "maximized" events, leaving the window in a
|
||||||
|
// weird state (maximized according to the events, but
|
||||||
|
// not maximized visually).
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
screen->maximized = false;
|
||||||
|
apply_pending_resize(screen);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct point
|
struct point
|
||||||
|
|||||||
@@ -13,10 +13,12 @@
|
|||||||
struct video_buffer;
|
struct video_buffer;
|
||||||
|
|
||||||
struct screen {
|
struct screen {
|
||||||
|
struct video_buffer *vb;
|
||||||
|
struct fps_counter *fps_counter;
|
||||||
|
|
||||||
SDL_Window *window;
|
SDL_Window *window;
|
||||||
SDL_Renderer *renderer;
|
SDL_Renderer *renderer;
|
||||||
SDL_Texture *texture;
|
SDL_Texture *texture;
|
||||||
bool use_opengl;
|
|
||||||
struct sc_opengl gl;
|
struct sc_opengl gl;
|
||||||
struct size frame_size;
|
struct size frame_size;
|
||||||
struct size content_size; // rotated frame_size
|
struct size content_size; // rotated frame_size
|
||||||
@@ -33,55 +35,30 @@ struct screen {
|
|||||||
bool has_frame;
|
bool has_frame;
|
||||||
bool fullscreen;
|
bool fullscreen;
|
||||||
bool maximized;
|
bool maximized;
|
||||||
bool no_window;
|
|
||||||
bool mipmaps;
|
bool mipmaps;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SCREEN_INITIALIZER { \
|
struct screen_params {
|
||||||
.window = NULL, \
|
const char *window_title;
|
||||||
.renderer = NULL, \
|
struct size frame_size;
|
||||||
.texture = NULL, \
|
bool always_on_top;
|
||||||
.use_opengl = false, \
|
|
||||||
.gl = {0}, \
|
|
||||||
.frame_size = { \
|
|
||||||
.width = 0, \
|
|
||||||
.height = 0, \
|
|
||||||
}, \
|
|
||||||
.content_size = { \
|
|
||||||
.width = 0, \
|
|
||||||
.height = 0, \
|
|
||||||
}, \
|
|
||||||
.resize_pending = false, \
|
|
||||||
.windowed_content_size = { \
|
|
||||||
.width = 0, \
|
|
||||||
.height = 0, \
|
|
||||||
}, \
|
|
||||||
.rotation = 0, \
|
|
||||||
.rect = { \
|
|
||||||
.x = 0, \
|
|
||||||
.y = 0, \
|
|
||||||
.w = 0, \
|
|
||||||
.h = 0, \
|
|
||||||
}, \
|
|
||||||
.has_frame = false, \
|
|
||||||
.fullscreen = false, \
|
|
||||||
.maximized = false, \
|
|
||||||
.no_window = false, \
|
|
||||||
.mipmaps = false, \
|
|
||||||
}
|
|
||||||
|
|
||||||
// initialize default values
|
int16_t window_x;
|
||||||
void
|
int16_t window_y;
|
||||||
screen_init(struct screen *screen);
|
uint16_t window_width; // accepts SC_WINDOW_POSITION_UNDEFINED
|
||||||
|
uint16_t window_height; // accepts SC_WINDOW_POSITION_UNDEFINED
|
||||||
|
|
||||||
|
bool window_borderless;
|
||||||
|
|
||||||
|
uint8_t rotation;
|
||||||
|
bool mipmaps;
|
||||||
|
};
|
||||||
|
|
||||||
// initialize screen, create window, renderer and texture (window is hidden)
|
// initialize screen, create window, renderer and texture (window is hidden)
|
||||||
// window_x and window_y accept SC_WINDOW_POSITION_UNDEFINED
|
|
||||||
bool
|
bool
|
||||||
screen_init_rendering(struct screen *screen, const char *window_title,
|
screen_init(struct screen *screen, struct video_buffer *vb,
|
||||||
struct size frame_size, bool always_on_top,
|
struct fps_counter *fps_counter,
|
||||||
int16_t window_x, int16_t window_y, uint16_t window_width,
|
const struct screen_params *params);
|
||||||
uint16_t window_height, bool window_borderless,
|
|
||||||
uint8_t rotation, bool mipmaps);
|
|
||||||
|
|
||||||
// show the window
|
// show the window
|
||||||
void
|
void
|
||||||
@@ -91,10 +68,6 @@ screen_show_window(struct screen *screen);
|
|||||||
void
|
void
|
||||||
screen_destroy(struct screen *screen);
|
screen_destroy(struct screen *screen);
|
||||||
|
|
||||||
// resize if necessary and write the rendered frame into the texture
|
|
||||||
bool
|
|
||||||
screen_update_frame(struct screen *screen, struct video_buffer *vb);
|
|
||||||
|
|
||||||
// render the texture to the renderer
|
// render the texture to the renderer
|
||||||
//
|
//
|
||||||
// Set the update_content_rect flag if the window or content size may have
|
// Set the update_content_rect flag if the window or content size may have
|
||||||
@@ -118,9 +91,9 @@ screen_resize_to_pixel_perfect(struct screen *screen);
|
|||||||
void
|
void
|
||||||
screen_set_rotation(struct screen *screen, unsigned rotation);
|
screen_set_rotation(struct screen *screen, unsigned rotation);
|
||||||
|
|
||||||
// react to window events
|
// react to SDL events
|
||||||
void
|
bool
|
||||||
screen_handle_window_event(struct screen *screen, const SDL_WindowEvent *event);
|
screen_handle_event(struct screen *screen, SDL_Event *event);
|
||||||
|
|
||||||
// convert point from window coordinates to frame coordinates
|
// convert point from window coordinates to frame coordinates
|
||||||
// x and y are expressed in pixels
|
// x and y are expressed in pixels
|
||||||
|
|||||||
@@ -375,8 +375,6 @@ server_init(struct server *server) {
|
|||||||
server->video_socket = INVALID_SOCKET;
|
server->video_socket = INVALID_SOCKET;
|
||||||
server->control_socket = INVALID_SOCKET;
|
server->control_socket = INVALID_SOCKET;
|
||||||
|
|
||||||
server->port_range.first = 0;
|
|
||||||
server->port_range.last = 0;
|
|
||||||
server->local_port = 0;
|
server->local_port = 0;
|
||||||
|
|
||||||
server->tunnel_enabled = false;
|
server->tunnel_enabled = false;
|
||||||
@@ -410,8 +408,6 @@ run_wait_server(void *data) {
|
|||||||
bool
|
bool
|
||||||
server_start(struct server *server, const char *serial,
|
server_start(struct server *server, const char *serial,
|
||||||
const struct server_params *params) {
|
const struct server_params *params) {
|
||||||
server->port_range = params->port_range;
|
|
||||||
|
|
||||||
if (serial) {
|
if (serial) {
|
||||||
server->serial = strdup(serial);
|
server->serial = strdup(serial);
|
||||||
if (!server->serial) {
|
if (!server->serial) {
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ struct server {
|
|||||||
socket_t server_socket; // only used if !tunnel_forward
|
socket_t server_socket; // only used if !tunnel_forward
|
||||||
socket_t video_socket;
|
socket_t video_socket;
|
||||||
socket_t control_socket;
|
socket_t control_socket;
|
||||||
struct sc_port_range port_range;
|
|
||||||
uint16_t local_port; // selected from port_range
|
uint16_t local_port; // selected from port_range
|
||||||
bool tunnel_enabled;
|
bool tunnel_enabled;
|
||||||
bool tunnel_forward; // use "adb forward" instead of "adb reverse"
|
bool tunnel_forward; // use "adb forward" instead of "adb reverse"
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ sc_mutex_lock(sc_mutex *mutex) {
|
|||||||
void
|
void
|
||||||
sc_mutex_unlock(sc_mutex *mutex) {
|
sc_mutex_unlock(sc_mutex *mutex) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
assert(sc_mutex_held(mutex));
|
||||||
mutex->locker = 0;
|
mutex->locker = 0;
|
||||||
#endif
|
#endif
|
||||||
int r = SDL_UnlockMutex(mutex->mutex);
|
int r = SDL_UnlockMutex(mutex->mutex);
|
||||||
|
|||||||
@@ -7,12 +7,9 @@
|
|||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
|
|
||||||
bool
|
bool
|
||||||
video_buffer_init(struct video_buffer *vb, struct fps_counter *fps_counter,
|
video_buffer_init(struct video_buffer *vb, bool wait_consumer) {
|
||||||
bool render_expired_frames) {
|
vb->producer_frame = av_frame_alloc();
|
||||||
vb->fps_counter = fps_counter;
|
if (!vb->producer_frame) {
|
||||||
|
|
||||||
vb->decoding_frame = av_frame_alloc();
|
|
||||||
if (!vb->decoding_frame) {
|
|
||||||
goto error_0;
|
goto error_0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,8 +18,8 @@ video_buffer_init(struct video_buffer *vb, struct fps_counter *fps_counter,
|
|||||||
goto error_1;
|
goto error_1;
|
||||||
}
|
}
|
||||||
|
|
||||||
vb->rendering_frame = av_frame_alloc();
|
vb->consumer_frame = av_frame_alloc();
|
||||||
if (!vb->rendering_frame) {
|
if (!vb->consumer_frame) {
|
||||||
goto error_2;
|
goto error_2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,105 +28,116 @@ video_buffer_init(struct video_buffer *vb, struct fps_counter *fps_counter,
|
|||||||
goto error_3;
|
goto error_3;
|
||||||
}
|
}
|
||||||
|
|
||||||
vb->render_expired_frames = render_expired_frames;
|
vb->wait_consumer = wait_consumer;
|
||||||
if (render_expired_frames) {
|
if (wait_consumer) {
|
||||||
ok = sc_cond_init(&vb->pending_frame_consumed_cond);
|
ok = sc_cond_init(&vb->pending_frame_consumed_cond);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
sc_mutex_destroy(&vb->mutex);
|
sc_mutex_destroy(&vb->mutex);
|
||||||
goto error_2;
|
goto error_2;
|
||||||
}
|
}
|
||||||
// interrupted is not used if expired frames are not rendered
|
// interrupted is not used if wait_consumer is disabled since offering
|
||||||
// since offering a frame will never block
|
// a frame will never block
|
||||||
vb->interrupted = false;
|
vb->interrupted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// there is initially no rendering frame, so consider it has already been
|
// there is initially no frame, so consider it has already been consumed
|
||||||
// consumed
|
|
||||||
vb->pending_frame_consumed = true;
|
vb->pending_frame_consumed = true;
|
||||||
|
|
||||||
|
// The callbacks must be set by the consumer via
|
||||||
|
// video_buffer_set_consumer_callbacks()
|
||||||
|
vb->cbs = NULL;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
error_3:
|
error_3:
|
||||||
av_frame_free(&vb->rendering_frame);
|
av_frame_free(&vb->consumer_frame);
|
||||||
error_2:
|
error_2:
|
||||||
av_frame_free(&vb->pending_frame);
|
av_frame_free(&vb->pending_frame);
|
||||||
error_1:
|
error_1:
|
||||||
av_frame_free(&vb->decoding_frame);
|
av_frame_free(&vb->producer_frame);
|
||||||
error_0:
|
error_0:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
video_buffer_destroy(struct video_buffer *vb) {
|
video_buffer_destroy(struct video_buffer *vb) {
|
||||||
if (vb->render_expired_frames) {
|
if (vb->wait_consumer) {
|
||||||
sc_cond_destroy(&vb->pending_frame_consumed_cond);
|
sc_cond_destroy(&vb->pending_frame_consumed_cond);
|
||||||
}
|
}
|
||||||
sc_mutex_destroy(&vb->mutex);
|
sc_mutex_destroy(&vb->mutex);
|
||||||
av_frame_free(&vb->rendering_frame);
|
av_frame_free(&vb->consumer_frame);
|
||||||
av_frame_free(&vb->pending_frame);
|
av_frame_free(&vb->pending_frame);
|
||||||
av_frame_free(&vb->decoding_frame);
|
av_frame_free(&vb->producer_frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static inline void
|
||||||
video_buffer_swap_decoding_frame(struct video_buffer *vb) {
|
swap_frames(AVFrame **lhs, AVFrame **rhs) {
|
||||||
sc_mutex_assert(&vb->mutex);
|
AVFrame *tmp = *lhs;
|
||||||
AVFrame *tmp = vb->decoding_frame;
|
*lhs = *rhs;
|
||||||
vb->decoding_frame = vb->pending_frame;
|
*rhs = tmp;
|
||||||
vb->pending_frame = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
video_buffer_swap_rendering_frame(struct video_buffer *vb) {
|
|
||||||
sc_mutex_assert(&vb->mutex);
|
|
||||||
AVFrame *tmp = vb->rendering_frame;
|
|
||||||
vb->rendering_frame = vb->pending_frame;
|
|
||||||
vb->pending_frame = tmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
video_buffer_offer_decoded_frame(struct video_buffer *vb,
|
video_buffer_set_consumer_callbacks(struct video_buffer *vb,
|
||||||
bool *previous_frame_skipped) {
|
const struct video_buffer_callbacks *cbs,
|
||||||
|
void *cbs_userdata) {
|
||||||
|
assert(!vb->cbs); // must be set only once
|
||||||
|
assert(cbs);
|
||||||
|
assert(cbs->on_frame_available);
|
||||||
|
vb->cbs = cbs;
|
||||||
|
vb->cbs_userdata = cbs_userdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
video_buffer_producer_offer_frame(struct video_buffer *vb) {
|
||||||
|
assert(vb->cbs);
|
||||||
|
|
||||||
sc_mutex_lock(&vb->mutex);
|
sc_mutex_lock(&vb->mutex);
|
||||||
if (vb->render_expired_frames) {
|
if (vb->wait_consumer) {
|
||||||
// wait for the current (expired) frame to be consumed
|
// wait for the current (expired) frame to be consumed
|
||||||
while (!vb->pending_frame_consumed && !vb->interrupted) {
|
while (!vb->pending_frame_consumed && !vb->interrupted) {
|
||||||
sc_cond_wait(&vb->pending_frame_consumed_cond, &vb->mutex);
|
sc_cond_wait(&vb->pending_frame_consumed_cond, &vb->mutex);
|
||||||
}
|
}
|
||||||
} else if (!vb->pending_frame_consumed) {
|
|
||||||
fps_counter_add_skipped_frame(vb->fps_counter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
video_buffer_swap_decoding_frame(vb);
|
av_frame_unref(vb->pending_frame);
|
||||||
|
swap_frames(&vb->producer_frame, &vb->pending_frame);
|
||||||
|
|
||||||
*previous_frame_skipped = !vb->pending_frame_consumed;
|
bool skipped = !vb->pending_frame_consumed;
|
||||||
vb->pending_frame_consumed = false;
|
vb->pending_frame_consumed = false;
|
||||||
|
|
||||||
sc_mutex_unlock(&vb->mutex);
|
sc_mutex_unlock(&vb->mutex);
|
||||||
|
|
||||||
|
if (skipped) {
|
||||||
|
if (vb->cbs->on_frame_skipped)
|
||||||
|
vb->cbs->on_frame_skipped(vb, vb->cbs_userdata);
|
||||||
|
} else {
|
||||||
|
vb->cbs->on_frame_available(vb, vb->cbs_userdata);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const AVFrame *
|
const AVFrame *
|
||||||
video_buffer_take_rendering_frame(struct video_buffer *vb) {
|
video_buffer_consumer_take_frame(struct video_buffer *vb) {
|
||||||
sc_mutex_lock(&vb->mutex);
|
sc_mutex_lock(&vb->mutex);
|
||||||
assert(!vb->pending_frame_consumed);
|
assert(!vb->pending_frame_consumed);
|
||||||
vb->pending_frame_consumed = true;
|
vb->pending_frame_consumed = true;
|
||||||
|
|
||||||
fps_counter_add_rendered_frame(vb->fps_counter);
|
swap_frames(&vb->consumer_frame, &vb->pending_frame);
|
||||||
|
av_frame_unref(vb->pending_frame);
|
||||||
|
|
||||||
video_buffer_swap_rendering_frame(vb);
|
if (vb->wait_consumer) {
|
||||||
|
|
||||||
if (vb->render_expired_frames) {
|
|
||||||
// unblock video_buffer_offer_decoded_frame()
|
// unblock video_buffer_offer_decoded_frame()
|
||||||
sc_cond_signal(&vb->pending_frame_consumed_cond);
|
sc_cond_signal(&vb->pending_frame_consumed_cond);
|
||||||
}
|
}
|
||||||
sc_mutex_unlock(&vb->mutex);
|
sc_mutex_unlock(&vb->mutex);
|
||||||
|
|
||||||
// rendering_frame is only written from this thread, no need to lock
|
// consumer_frame is only written from this thread, no need to lock
|
||||||
return vb->rendering_frame;
|
return vb->consumer_frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
video_buffer_interrupt(struct video_buffer *vb) {
|
video_buffer_interrupt(struct video_buffer *vb) {
|
||||||
if (vb->render_expired_frames) {
|
if (vb->wait_consumer) {
|
||||||
sc_mutex_lock(&vb->mutex);
|
sc_mutex_lock(&vb->mutex);
|
||||||
vb->interrupted = true;
|
vb->interrupted = true;
|
||||||
sc_mutex_unlock(&vb->mutex);
|
sc_mutex_unlock(&vb->mutex);
|
||||||
|
|||||||
@@ -13,53 +13,67 @@ typedef struct AVFrame AVFrame;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* There are 3 frames in memory:
|
* There are 3 frames in memory:
|
||||||
* - one frame is held by the decoder (decoding_frame)
|
* - one frame is held by the producer (producer_frame)
|
||||||
* - one frame is held by the renderer (rendering_frame)
|
* - one frame is held by the consumer (consumer_frame)
|
||||||
* - one frame is shared between the decoder and the renderer (pending_frame)
|
* - one frame is shared between the producer and the consumer (pending_frame)
|
||||||
*
|
*
|
||||||
* The decoder decodes a packet into the decoding_frame (it may takes time).
|
* The producer generates a frame into the producer_frame (it may takes time).
|
||||||
*
|
*
|
||||||
* Once the frame is decoded, it calls video_buffer_offer_decoded_frame(),
|
* Once the frame is produced, it calls video_buffer_producer_offer_frame(),
|
||||||
* which swaps the decoding and pending frames.
|
* which swaps the producer and pending frames.
|
||||||
*
|
*
|
||||||
* When the renderer is notified that a new frame is available, it calls
|
* When the consumer is notified that a new frame is available, it calls
|
||||||
* video_buffer_take_rendering_frame() to retrieve it, which swaps the pending
|
* video_buffer_consumer_take_frame() to retrieve it, which swaps the pending
|
||||||
* and rendering frames. The frame is valid until the next call, without
|
* and consumer frames. The frame is valid until the next call, without
|
||||||
* blocking the decoder.
|
* blocking the producer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct video_buffer {
|
struct video_buffer {
|
||||||
AVFrame *decoding_frame;
|
AVFrame *producer_frame;
|
||||||
AVFrame *pending_frame;
|
AVFrame *pending_frame;
|
||||||
AVFrame *rendering_frame;
|
AVFrame *consumer_frame;
|
||||||
|
|
||||||
sc_mutex mutex;
|
sc_mutex mutex;
|
||||||
bool render_expired_frames;
|
bool wait_consumer; // never overwrite a pending frame if it is not consumed
|
||||||
bool interrupted;
|
bool interrupted;
|
||||||
|
|
||||||
sc_cond pending_frame_consumed_cond;
|
sc_cond pending_frame_consumed_cond;
|
||||||
bool pending_frame_consumed;
|
bool pending_frame_consumed;
|
||||||
|
|
||||||
struct fps_counter *fps_counter;
|
const struct video_buffer_callbacks *cbs;
|
||||||
|
void *cbs_userdata;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct video_buffer_callbacks {
|
||||||
|
// Called when a new frame can be consumed by
|
||||||
|
// video_buffer_consumer_take_frame(vb)
|
||||||
|
// This callback is mandatory (it must not be NULL).
|
||||||
|
void (*on_frame_available)(struct video_buffer *vb, void *userdata);
|
||||||
|
|
||||||
|
// Called when a pending frame has been overwritten by the producer
|
||||||
|
// This callback is optional (it may be NULL).
|
||||||
|
void (*on_frame_skipped)(struct video_buffer *vb, void *userdata);
|
||||||
};
|
};
|
||||||
|
|
||||||
bool
|
bool
|
||||||
video_buffer_init(struct video_buffer *vb, struct fps_counter *fps_counter,
|
video_buffer_init(struct video_buffer *vb, bool wait_consumer);
|
||||||
bool render_expired_frames);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
video_buffer_destroy(struct video_buffer *vb);
|
video_buffer_destroy(struct video_buffer *vb);
|
||||||
|
|
||||||
// set the decoded frame as ready for rendering
|
|
||||||
// the output flag is set to report whether the previous frame has been skipped
|
|
||||||
void
|
void
|
||||||
video_buffer_offer_decoded_frame(struct video_buffer *vb,
|
video_buffer_set_consumer_callbacks(struct video_buffer *vb,
|
||||||
bool *previous_frame_skipped);
|
const struct video_buffer_callbacks *cbs,
|
||||||
|
void *cbs_userdata);
|
||||||
|
|
||||||
// mark the rendering frame as consumed and return it
|
// set the producer frame as ready for consuming
|
||||||
|
void
|
||||||
|
video_buffer_producer_offer_frame(struct video_buffer *vb);
|
||||||
|
|
||||||
|
// mark the consumer frame as consumed and return it
|
||||||
// the frame is valid until the next call to this function
|
// the frame is valid until the next call to this function
|
||||||
const AVFrame *
|
const AVFrame *
|
||||||
video_buffer_take_rendering_frame(struct video_buffer *vb);
|
video_buffer_consumer_take_frame(struct video_buffer *vb);
|
||||||
|
|
||||||
// wake up and avoid any blocking call
|
// wake up and avoid any blocking call
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
[binaries]
|
[binaries]
|
||||||
name = 'mingw'
|
name = 'mingw'
|
||||||
c = '/usr/bin/i686-w64-mingw32-gcc'
|
c = 'i686-w64-mingw32-gcc'
|
||||||
cpp = '/usr/bin/i686-w64-mingw32-g++'
|
cpp = 'i686-w64-mingw32-g++'
|
||||||
ar = '/usr/bin/i686-w64-mingw32-ar'
|
ar = 'i686-w64-mingw32-ar'
|
||||||
strip = '/usr/bin/i686-w64-mingw32-strip'
|
strip = 'i686-w64-mingw32-strip'
|
||||||
pkgconfig = '/usr/bin/i686-w64-mingw32-pkg-config'
|
pkgconfig = 'i686-w64-mingw32-pkg-config'
|
||||||
|
|
||||||
[host_machine]
|
[host_machine]
|
||||||
system = 'windows'
|
system = 'windows'
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
[binaries]
|
[binaries]
|
||||||
name = 'mingw'
|
name = 'mingw'
|
||||||
c = '/usr/bin/x86_64-w64-mingw32-gcc'
|
c = 'x86_64-w64-mingw32-gcc'
|
||||||
cpp = '/usr/bin/x86_64-w64-mingw32-g++'
|
cpp = 'x86_64-w64-mingw32-g++'
|
||||||
ar = '/usr/bin/x86_64-w64-mingw32-ar'
|
ar = 'x86_64-w64-mingw32-ar'
|
||||||
strip = '/usr/bin/x86_64-w64-mingw32-strip'
|
strip = 'x86_64-w64-mingw32-strip'
|
||||||
pkgconfig = '/usr/bin/x86_64-w64-mingw32-pkg-config'
|
pkgconfig = 'x86_64-w64-mingw32-pkg-config'
|
||||||
|
|
||||||
[host_machine]
|
[host_machine]
|
||||||
system = 'windows'
|
system = 'windows'
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ project('scrcpy', 'c',
|
|||||||
default_options: [
|
default_options: [
|
||||||
'c_std=c11',
|
'c_std=c11',
|
||||||
'warning_level=2',
|
'warning_level=2',
|
||||||
|
'b_ndebug=if-release',
|
||||||
])
|
])
|
||||||
|
|
||||||
if get_option('compile_app')
|
if get_option('compile_app')
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
|
|
||||||
public class Controller {
|
public class Controller {
|
||||||
|
|
||||||
private static final int DEVICE_ID_VIRTUAL = -1;
|
private static final int DEFAULT_DEVICE_ID = 0;
|
||||||
|
|
||||||
private static final ScheduledExecutorService EXECUTOR = Executors.newSingleThreadScheduledExecutor();
|
private static final ScheduledExecutorService EXECUTOR = Executors.newSingleThreadScheduledExecutor();
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ public class Controller {
|
|||||||
|
|
||||||
MotionEvent.PointerCoords coords = new MotionEvent.PointerCoords();
|
MotionEvent.PointerCoords coords = new MotionEvent.PointerCoords();
|
||||||
coords.orientation = 0;
|
coords.orientation = 0;
|
||||||
coords.size = 1;
|
coords.size = 0;
|
||||||
|
|
||||||
pointerProperties[i] = props;
|
pointerProperties[i] = props;
|
||||||
pointerCoords[i] = coords;
|
pointerCoords[i] = coords;
|
||||||
@@ -210,7 +210,7 @@ public class Controller {
|
|||||||
int source = nonPrimaryButtonPressed ? InputDevice.SOURCE_MOUSE : InputDevice.SOURCE_TOUCHSCREEN;
|
int source = nonPrimaryButtonPressed ? InputDevice.SOURCE_MOUSE : InputDevice.SOURCE_TOUCHSCREEN;
|
||||||
|
|
||||||
MotionEvent event = MotionEvent
|
MotionEvent event = MotionEvent
|
||||||
.obtain(lastTouchDown, now, action, pointerCount, pointerProperties, pointerCoords, 0, buttons, 1f, 1f, DEVICE_ID_VIRTUAL, 0, source,
|
.obtain(lastTouchDown, now, action, pointerCount, pointerProperties, pointerCoords, 0, buttons, 1f, 1f, DEFAULT_DEVICE_ID, 0, source,
|
||||||
0);
|
0);
|
||||||
return device.injectEvent(event);
|
return device.injectEvent(event);
|
||||||
}
|
}
|
||||||
@@ -233,7 +233,7 @@ public class Controller {
|
|||||||
coords.setAxisValue(MotionEvent.AXIS_VSCROLL, vScroll);
|
coords.setAxisValue(MotionEvent.AXIS_VSCROLL, vScroll);
|
||||||
|
|
||||||
MotionEvent event = MotionEvent
|
MotionEvent event = MotionEvent
|
||||||
.obtain(lastTouchDown, now, MotionEvent.ACTION_SCROLL, 1, pointerProperties, pointerCoords, 0, 0, 1f, 1f, DEVICE_ID_VIRTUAL, 0,
|
.obtain(lastTouchDown, now, MotionEvent.ACTION_SCROLL, 1, pointerProperties, pointerCoords, 0, 0, 1f, 1f, DEFAULT_DEVICE_ID, 0,
|
||||||
InputDevice.SOURCE_TOUCHSCREEN, 0);
|
InputDevice.SOURCE_TOUCHSCREEN, 0);
|
||||||
return device.injectEvent(event);
|
return device.injectEvent(event);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ public final class Server {
|
|||||||
if (encoders != null && encoders.length > 0) {
|
if (encoders != null && encoders.length > 0) {
|
||||||
Ln.e("Try to use one of the available encoders:");
|
Ln.e("Try to use one of the available encoders:");
|
||||||
for (MediaCodecInfo encoder : encoders) {
|
for (MediaCodecInfo encoder : encoders) {
|
||||||
Ln.e(" scrcpy --encoder-name '" + encoder.getName() + "'");
|
Ln.e(" scrcpy --encoder '" + encoder.getName() + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user