Compare commits
8 Commits
android12_
...
thread
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f2cf12acf | ||
|
|
2a3c6b64dd | ||
|
|
a9582b1d43 | ||
|
|
fa3e84b700 | ||
|
|
1521de9051 | ||
|
|
eabaabdb78 | ||
|
|
8b48003074 | ||
|
|
74bd25a0ed |
@@ -99,6 +99,9 @@ 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())
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
#ifndef HAVE_STRDUP
|
#ifdef HAVE_STRDUP
|
||||||
char *strdup(const char *s);
|
char *strdup(const char *s);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
#define EVENT_NEW_FRAME SDL_USEREVENT
|
#define EVENT_NEW_SESSION SDL_USEREVENT
|
||||||
#define EVENT_STREAM_STOPPED (SDL_USEREVENT + 1)
|
#define EVENT_NEW_FRAME (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);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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
|
||||||
@@ -551,7 +551,7 @@ convert_mouse_motion(const SDL_MouseMotionEvent *from, struct screen *screen,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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 +605,7 @@ convert_touch(const SDL_TouchFingerEvent *from, struct screen *screen,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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 +637,7 @@ convert_mouse_button(const SDL_MouseButtonEvent *from, struct screen *screen,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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 +736,7 @@ convert_mouse_wheel(const SDL_MouseWheelEvent *from, struct screen *screen,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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,46 +746,3 @@ 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;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -40,7 +40,28 @@ 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);
|
||||||
|
|
||||||
bool
|
void
|
||||||
input_manager_handle_event(struct input_manager *im, SDL_Event *event);
|
input_manager_process_text_input(struct input_manager *im,
|
||||||
|
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;
|
static struct screen screen = SCREEN_INITIALIZER;
|
||||||
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;
|
||||||
@@ -173,6 +173,54 @@ 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;
|
||||||
@@ -194,16 +242,6 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,8 +427,6 @@ 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);
|
|
||||||
|
|
||||||
if (!screen_init_rendering(&screen, window_title, frame_size,
|
if (!screen_init_rendering(&screen, window_title, frame_size,
|
||||||
options->always_on_top, options->window_x,
|
options->always_on_top, options->window_x,
|
||||||
options->window_y, options->window_width,
|
options->window_y, options->window_width,
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#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"
|
||||||
@@ -192,9 +191,8 @@ screen_update_content_rect(struct screen *screen) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
screen_init(struct screen *screen, struct video_buffer *vb) {
|
screen_init(struct screen *screen) {
|
||||||
*screen = (struct screen) SCREEN_INITIALIZER;
|
*screen = (struct screen) SCREEN_INITIALIZER;
|
||||||
screen->vb = vb;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline SDL_Texture *
|
static inline SDL_Texture *
|
||||||
@@ -272,7 +270,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());
|
||||||
SDL_DestroyWindow(screen->window);
|
screen_destroy(screen);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,8 +280,8 @@ screen_init_rendering(struct screen *screen, const char *window_title,
|
|||||||
LOGI("Renderer: %s", renderer_name ? renderer_name : "(unknown)");
|
LOGI("Renderer: %s", renderer_name ? renderer_name : "(unknown)");
|
||||||
|
|
||||||
// starts with "opengl"
|
// starts with "opengl"
|
||||||
bool use_opengl = renderer_name && !strncmp(renderer_name, "opengl", 6);
|
screen->use_opengl = renderer_name && !strncmp(renderer_name, "opengl", 6);
|
||||||
if (use_opengl) {
|
if (screen->use_opengl) {
|
||||||
struct sc_opengl *gl = &screen->gl;
|
struct sc_opengl *gl = &screen->gl;
|
||||||
sc_opengl_init(gl);
|
sc_opengl_init(gl);
|
||||||
|
|
||||||
@@ -303,7 +301,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 {
|
||||||
LOGD("Trilinear filtering disabled (not an OpenGL renderer)");
|
LOGD("Trilinear filtering disabled (not an OpenGL renderer)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,8 +318,6 @@ screen_init_rendering(struct screen *screen, const char *window_title,
|
|||||||
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_DestroyWindow(screen->window);
|
|
||||||
screen_destroy(screen);
|
screen_destroy(screen);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -346,8 +342,12 @@ screen_destroy(struct screen *screen) {
|
|||||||
if (screen->texture) {
|
if (screen->texture) {
|
||||||
SDL_DestroyTexture(screen->texture);
|
SDL_DestroyTexture(screen->texture);
|
||||||
}
|
}
|
||||||
|
if (screen->renderer) {
|
||||||
SDL_DestroyRenderer(screen->renderer);
|
SDL_DestroyRenderer(screen->renderer);
|
||||||
|
}
|
||||||
|
if (screen->window) {
|
||||||
SDL_DestroyWindow(screen->window);
|
SDL_DestroyWindow(screen->window);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -444,17 +444,19 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
bool
|
||||||
screen_update_frame(struct screen *screen) {
|
screen_update_frame(struct screen *screen, struct video_buffer *vb) {
|
||||||
const AVFrame *frame = video_buffer_take_rendering_frame(screen->vb);
|
const AVFrame *frame = video_buffer_take_rendering_frame(vb);
|
||||||
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);
|
||||||
@@ -544,26 +546,10 @@ screen_resize_to_pixel_perfect(struct screen *screen) {
|
|||||||
content_size.height);
|
content_size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
void
|
||||||
screen_handle_event(struct screen *screen, SDL_Event *event) {
|
screen_handle_window_event(struct screen *screen,
|
||||||
switch (event->type) {
|
const SDL_WindowEvent *event) {
|
||||||
case EVENT_NEW_FRAME:
|
switch (event->event) {
|
||||||
if (!screen->has_frame) {
|
|
||||||
screen->has_frame = true;
|
|
||||||
// this is the very first frame, show the window
|
|
||||||
screen_show_window(screen);
|
|
||||||
}
|
|
||||||
bool ok = screen_update_frame(screen);
|
|
||||||
if (!ok) {
|
|
||||||
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:
|
case SDL_WINDOWEVENT_EXPOSED:
|
||||||
screen_render(screen, true);
|
screen_render(screen, true);
|
||||||
break;
|
break;
|
||||||
@@ -575,21 +561,16 @@ screen_handle_event(struct screen *screen, SDL_Event *event) {
|
|||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_RESTORED:
|
case SDL_WINDOWEVENT_RESTORED:
|
||||||
if (screen->fullscreen) {
|
if (screen->fullscreen) {
|
||||||
// On Windows, in maximized+fullscreen, disabling
|
// On Windows, in maximized+fullscreen, disabling fullscreen
|
||||||
// fullscreen mode unexpectedly triggers the "restored"
|
// mode unexpectedly triggers the "restored" then "maximized"
|
||||||
// then "maximized" events, leaving the window in a
|
// events, leaving the window in a weird state (maximized
|
||||||
// weird state (maximized according to the events, but
|
// according to the events, but not maximized visually).
|
||||||
// not maximized visually).
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
screen->maximized = false;
|
screen->maximized = false;
|
||||||
apply_pending_resize(screen);
|
apply_pending_resize(screen);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct point
|
struct point
|
||||||
|
|||||||
@@ -13,10 +13,10 @@
|
|||||||
struct video_buffer;
|
struct video_buffer;
|
||||||
|
|
||||||
struct screen {
|
struct screen {
|
||||||
struct video_buffer *vb;
|
|
||||||
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
|
||||||
@@ -38,10 +38,10 @@ struct screen {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define SCREEN_INITIALIZER { \
|
#define SCREEN_INITIALIZER { \
|
||||||
.vb = NULL, \
|
|
||||||
.window = NULL, \
|
.window = NULL, \
|
||||||
.renderer = NULL, \
|
.renderer = NULL, \
|
||||||
.texture = NULL, \
|
.texture = NULL, \
|
||||||
|
.use_opengl = false, \
|
||||||
.gl = {0}, \
|
.gl = {0}, \
|
||||||
.frame_size = { \
|
.frame_size = { \
|
||||||
.width = 0, \
|
.width = 0, \
|
||||||
@@ -72,7 +72,7 @@ struct screen {
|
|||||||
|
|
||||||
// initialize default values
|
// initialize default values
|
||||||
void
|
void
|
||||||
screen_init(struct screen *screen, struct video_buffer *vb);
|
screen_init(struct screen *screen);
|
||||||
|
|
||||||
// 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
|
// window_x and window_y accept SC_WINDOW_POSITION_UNDEFINED
|
||||||
@@ -91,6 +91,10 @@ 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
|
||||||
@@ -114,9 +118,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 SDL events
|
// react to window events
|
||||||
bool
|
void
|
||||||
screen_handle_event(struct screen *screen, SDL_Event *event);
|
screen_handle_window_event(struct screen *screen, const SDL_WindowEvent *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,6 +375,8 @@ 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;
|
||||||
@@ -408,6 +410,8 @@ 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,6 +26,7 @@ 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,7 +61,6 @@ 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);
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ 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')
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user