Compare commits
23 Commits
android12_
...
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 |
@@ -114,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
|
||||||
|
|||||||
@@ -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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|
||||||
@@ -332,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;
|
||||||
@@ -366,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)) {
|
||||||
@@ -389,14 +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;
|
||||||
|
|
||||||
screen_init(&screen, &video_buffer);
|
struct screen_params screen_params = {
|
||||||
|
.window_title = window_title,
|
||||||
|
.frame_size = frame_size,
|
||||||
|
.always_on_top = options->always_on_top,
|
||||||
|
.window_x = options->window_x,
|
||||||
|
.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_rendering(&screen, window_title, frame_size,
|
if (!screen_init(&screen, &video_buffer, &fps_counter,
|
||||||
options->always_on_top, options->window_x,
|
&screen_params)) {
|
||||||
options->window_y, options->window_width,
|
|
||||||
options->window_height,
|
|
||||||
options->window_borderless,
|
|
||||||
options->rotation, options->mipmaps)) {
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -415,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, \
|
||||||
|
|||||||
@@ -191,10 +191,25 @@ screen_update_content_rect(struct screen *screen) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
screen_init(struct screen *screen, struct video_buffer *vb) {
|
on_frame_available(struct video_buffer *vb, void *userdata) {
|
||||||
*screen = (struct screen) SCREEN_INITIALIZER;
|
(void) vb;
|
||||||
screen->vb = 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 *
|
||||||
@@ -225,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
|
||||||
@@ -252,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) {
|
||||||
@@ -281,6 +310,8 @@ 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"
|
||||||
bool use_opengl = renderer_name && !strncmp(renderer_name, "opengl", 6);
|
bool use_opengl = renderer_name && !strncmp(renderer_name, "opengl", 6);
|
||||||
if (use_opengl) {
|
if (use_opengl) {
|
||||||
@@ -289,7 +320,7 @@ screen_init_rendering(struct screen *screen, const char *window_title,
|
|||||||
|
|
||||||
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+ */);
|
||||||
@@ -303,7 +334,7 @@ screen_init_rendering(struct screen *screen, const char *window_title,
|
|||||||
} else {
|
} else {
|
||||||
LOGI("Trilinear filtering disabled");
|
LOGI("Trilinear filtering disabled");
|
||||||
}
|
}
|
||||||
} else if (mipmaps) {
|
} else if (params->mipmaps) {
|
||||||
LOGD("Trilinear filtering disabled (not an OpenGL renderer)");
|
LOGD("Trilinear filtering disabled (not an OpenGL renderer)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,14 +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());
|
||||||
SDL_DestroyRenderer(screen->renderer);
|
SDL_DestroyRenderer(screen->renderer);
|
||||||
SDL_DestroyWindow(screen->window);
|
SDL_DestroyWindow(screen->window);
|
||||||
screen_destroy(screen);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,9 +373,7 @@ 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_DestroyRenderer(screen->renderer);
|
||||||
SDL_DestroyWindow(screen->window);
|
SDL_DestroyWindow(screen->window);
|
||||||
}
|
}
|
||||||
@@ -452,7 +480,10 @@ update_texture(struct screen *screen, const AVFrame *frame) {
|
|||||||
|
|
||||||
static bool
|
static bool
|
||||||
screen_update_frame(struct screen *screen) {
|
screen_update_frame(struct screen *screen) {
|
||||||
const AVFrame *frame = video_buffer_take_rendering_frame(screen->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)) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ struct video_buffer;
|
|||||||
|
|
||||||
struct screen {
|
struct screen {
|
||||||
struct video_buffer *vb;
|
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;
|
||||||
@@ -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 {
|
||||||
.vb = NULL, \
|
const char *window_title;
|
||||||
.window = NULL, \
|
struct size frame_size;
|
||||||
.renderer = NULL, \
|
bool always_on_top;
|
||||||
.texture = NULL, \
|
|
||||||
.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, struct video_buffer *vb);
|
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
|
||||||
|
|||||||
@@ -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'
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import android.media.MediaCodec;
|
|||||||
import android.media.MediaCodecInfo;
|
import android.media.MediaCodecInfo;
|
||||||
import android.media.MediaCodecList;
|
import android.media.MediaCodecList;
|
||||||
import android.media.MediaFormat;
|
import android.media.MediaFormat;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
|
|
||||||
@@ -226,9 +225,7 @@ public class ScreenEncoder implements Device.RotationListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static IBinder createDisplay() {
|
private static IBinder createDisplay() {
|
||||||
// Since Android 12, secure displays could not be created with shell permissions anymore
|
return SurfaceControl.createDisplay("scrcpy", true);
|
||||||
boolean secure = Build.VERSION.SDK_INT <= Build.VERSION_CODES.R;
|
|
||||||
return SurfaceControl.createDisplay("scrcpy", secure);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void configure(MediaCodec codec, MediaFormat format) {
|
private static void configure(MediaCodec codec, MediaFormat format) {
|
||||||
|
|||||||
@@ -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