mirror of
https://github.com/Genymobile/scrcpy.git
synced 2026-03-25 05:24:27 +01:00
Compare commits
1 Commits
pr5499
...
server_deb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0200760f87 |
@@ -167,9 +167,6 @@ conf.set('DEFAULT_LOCAL_PORT_RANGE_LAST', '27199')
|
|||||||
# run a server debugger and wait for a client to be attached
|
# run a server debugger and wait for a client to be attached
|
||||||
conf.set('SERVER_DEBUGGER', get_option('server_debugger'))
|
conf.set('SERVER_DEBUGGER', get_option('server_debugger'))
|
||||||
|
|
||||||
# select the debugger method ('old' for Android < 9, 'new' for Android >= 9)
|
|
||||||
conf.set('SERVER_DEBUGGER_METHOD_NEW', get_option('server_debugger_method') == 'new')
|
|
||||||
|
|
||||||
# enable V4L2 support (linux only)
|
# enable V4L2 support (linux only)
|
||||||
conf.set('HAVE_V4L2', v4l2_support)
|
conf.set('HAVE_V4L2', v4l2_support)
|
||||||
|
|
||||||
|
|||||||
@@ -143,14 +143,8 @@ sc_recorder_open_output_file(struct sc_recorder *recorder) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *file_url = sc_str_concat("file:", recorder->filename);
|
int ret = avio_open(&recorder->ctx->pb, recorder->filename,
|
||||||
if (!file_url) {
|
AVIO_FLAG_WRITE);
|
||||||
avformat_free_context(recorder->ctx);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ret = avio_open(&recorder->ctx->pb, file_url, AVIO_FLAG_WRITE);
|
|
||||||
free(file_url);
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
LOGE("Failed to open output file: %s", recorder->filename);
|
LOGE("Failed to open output file: %s", recorder->filename);
|
||||||
avformat_free_context(recorder->ctx);
|
avformat_free_context(recorder->ctx);
|
||||||
|
|||||||
@@ -183,6 +183,27 @@ validate_string(const char *s) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint16_t
|
||||||
|
get_device_sdk_version(struct sc_server *server) {
|
||||||
|
struct sc_intr *intr = &server->intr;
|
||||||
|
|
||||||
|
char *sdk_version =
|
||||||
|
sc_adb_getprop(intr, server->serial, "ro.build.version.sdk",
|
||||||
|
SC_ADB_SILENT);
|
||||||
|
if (!sdk_version) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
long value;
|
||||||
|
bool ok = sc_str_parse_integer(sdk_version, &value);
|
||||||
|
free(sdk_version);
|
||||||
|
if (!ok || value < 0 || value > 0xFFFF) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
static sc_pid
|
static sc_pid
|
||||||
execute_server(struct sc_server *server,
|
execute_server(struct sc_server *server,
|
||||||
const struct sc_server_params *params) {
|
const struct sc_server_params *params) {
|
||||||
@@ -201,18 +222,26 @@ execute_server(struct sc_server *server,
|
|||||||
cmd[count++] = "app_process";
|
cmd[count++] = "app_process";
|
||||||
|
|
||||||
#ifdef SERVER_DEBUGGER
|
#ifdef SERVER_DEBUGGER
|
||||||
|
uint16_t sdk_version = get_device_sdk_version(server);
|
||||||
|
if (!sdk_version) {
|
||||||
|
LOGE("Could not determine SDK version");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
# define SERVER_DEBUGGER_PORT "5005"
|
# define SERVER_DEBUGGER_PORT "5005"
|
||||||
cmd[count++] =
|
const char *dbg;
|
||||||
# ifdef SERVER_DEBUGGER_METHOD_NEW
|
if (sdk_version < 28) {
|
||||||
/* Android 9 and above */
|
// Android < 9
|
||||||
"-XjdwpProvider:internal -XjdwpOptions:transport=dt_socket,suspend=y,"
|
dbg = "-agentlib:jdwp=transport=dt_socket,suspend=y,server=y,address="
|
||||||
"server=y,address="
|
SERVER_DEBUGGER_PORT;
|
||||||
# else
|
} else {
|
||||||
/* Android 8 and below */
|
// Android >= 9
|
||||||
"-agentlib:jdwp=transport=dt_socket,suspend=y,server=y,address="
|
dbg = "-XjdwpProvider:internal -XjdwpOptions:transport=dt_socket,"
|
||||||
# endif
|
"suspend=y,server=y,address=" SERVER_DEBUGGER_PORT;
|
||||||
SERVER_DEBUGGER_PORT;
|
}
|
||||||
|
cmd[count++] = dbg;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cmd[count++] = "/"; // unused
|
cmd[count++] = "/"; // unused
|
||||||
cmd[count++] = "com.genymobile.scrcpy.Server";
|
cmd[count++] = "com.genymobile.scrcpy.Server";
|
||||||
cmd[count++] = SCRCPY_VERSION;
|
cmd[count++] = SCRCPY_VERSION;
|
||||||
|
|||||||
@@ -64,26 +64,6 @@ sc_str_quote(const char *src) {
|
|||||||
return quoted;
|
return quoted;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
|
||||||
sc_str_concat(const char *start, const char *end) {
|
|
||||||
assert(start);
|
|
||||||
assert(end);
|
|
||||||
|
|
||||||
size_t start_len = strlen(start);
|
|
||||||
size_t end_len = strlen(end);
|
|
||||||
|
|
||||||
char *result = malloc(start_len + end_len + 1);
|
|
||||||
if (!result) {
|
|
||||||
LOG_OOM();
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(result, start, start_len);
|
|
||||||
memcpy(result + start_len, end, end_len + 1);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
sc_str_parse_integer(const char *s, long *out) {
|
sc_str_parse_integer(const char *s, long *out) {
|
||||||
char *endptr;
|
char *endptr;
|
||||||
|
|||||||
@@ -38,15 +38,6 @@ sc_str_join(char *dst, const char *const tokens[], char sep, size_t n);
|
|||||||
char *
|
char *
|
||||||
sc_str_quote(const char *src);
|
sc_str_quote(const char *src);
|
||||||
|
|
||||||
/**
|
|
||||||
* Concat two strings
|
|
||||||
*
|
|
||||||
* Return a new allocated string, contanining the concatenation of the two
|
|
||||||
* input strings.
|
|
||||||
*/
|
|
||||||
char *
|
|
||||||
sc_str_concat(const char *start, const char *end);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse `s` as an integer into `out`
|
* Parse `s` as an integer into `out`
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -141,16 +141,6 @@ static void test_quote(void) {
|
|||||||
free(out);
|
free(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_concat(void) {
|
|
||||||
const char *s = "2024:11";
|
|
||||||
char *out = sc_str_concat("my-prefix:", s);
|
|
||||||
|
|
||||||
// contains the concat
|
|
||||||
assert(!strcmp("my-prefix:2024:11", out));
|
|
||||||
|
|
||||||
free(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_utf8_truncate(void) {
|
static void test_utf8_truncate(void) {
|
||||||
const char *s = "aÉbÔc";
|
const char *s = "aÉbÔc";
|
||||||
assert(strlen(s) == 7); // É and Ô are 2 bytes-wide
|
assert(strlen(s) == 7); // É and Ô are 2 bytes-wide
|
||||||
@@ -399,7 +389,6 @@ int main(int argc, char *argv[]) {
|
|||||||
test_join_truncated_before_sep();
|
test_join_truncated_before_sep();
|
||||||
test_join_truncated_after_sep();
|
test_join_truncated_after_sep();
|
||||||
test_quote();
|
test_quote();
|
||||||
test_concat();
|
|
||||||
test_utf8_truncate();
|
test_utf8_truncate();
|
||||||
test_parse_integer();
|
test_parse_integer();
|
||||||
test_parse_integers();
|
test_parse_integers();
|
||||||
|
|||||||
@@ -3,6 +3,5 @@ option('compile_server', type: 'boolean', value: true, description: 'Build the s
|
|||||||
option('prebuilt_server', type: 'string', description: 'Path of the prebuilt server')
|
option('prebuilt_server', type: 'string', description: 'Path of the prebuilt server')
|
||||||
option('portable', type: 'boolean', value: false, description: 'Use scrcpy-server from the same directory as the scrcpy executable')
|
option('portable', type: 'boolean', value: false, description: 'Use scrcpy-server from the same directory as the scrcpy executable')
|
||||||
option('server_debugger', type: 'boolean', value: false, description: 'Run a server debugger and wait for a client to be attached')
|
option('server_debugger', type: 'boolean', value: false, description: 'Run a server debugger and wait for a client to be attached')
|
||||||
option('server_debugger_method', type: 'combo', choices: ['old', 'new'], value: 'new', description: 'Select the debugger method (Android < 9: "old", Android >= 9: "new")')
|
|
||||||
option('v4l2', type: 'boolean', value: true, description: 'Enable V4L2 feature when supported')
|
option('v4l2', type: 'boolean', value: true, description: 'Enable V4L2 feature when supported')
|
||||||
option('usb', type: 'boolean', value: true, description: 'Enable HID/OTG features when supported')
|
option('usb', type: 'boolean', value: true, description: 'Enable HID/OTG features when supported')
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ public class SurfaceEncoder implements AsyncProcessor {
|
|||||||
if (!prepareRetry(size)) {
|
if (!prepareRetry(size)) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
Ln.i("Retrying...");
|
||||||
alive = true;
|
alive = true;
|
||||||
} finally {
|
} finally {
|
||||||
reset.setRunningMediaCodec(null);
|
reset.setRunningMediaCodec(null);
|
||||||
|
|||||||
Reference in New Issue
Block a user