mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-08-03 14:49:29 +00:00
Fix missing char and error
This commit is contained in:
parent
17947e175c
commit
4078f7b9e6
5 changed files with 15 additions and 12 deletions
|
@ -17,6 +17,7 @@ src = [
|
||||||
'src/scrcpy.c',
|
'src/scrcpy.c',
|
||||||
'src/screen.c',
|
'src/screen.c',
|
||||||
'src/server.c',
|
'src/server.c',
|
||||||
|
'src/serve.c',
|
||||||
'src/stream.c',
|
'src/stream.c',
|
||||||
'src/tiny_xpm.c',
|
'src/tiny_xpm.c',
|
||||||
'src/video_buffer.c',
|
'src/video_buffer.c',
|
||||||
|
|
|
@ -461,7 +461,7 @@ str_split(const char *a_str, const char a_delim) {
|
||||||
char** result = 0;
|
char** result = 0;
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
char* tmp = (char*)a_str;
|
char* tmp = (char*)a_str;
|
||||||
char str[100];
|
char str[50];
|
||||||
strncpy(str, a_str, sizeof(str));
|
strncpy(str, a_str, sizeof(str));
|
||||||
char* last_comma = 0;
|
char* last_comma = 0;
|
||||||
char delim[2];
|
char delim[2];
|
||||||
|
@ -517,7 +517,7 @@ check_if_ip_valid(char *ip) {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
while (ptr) {
|
while (ptr) {
|
||||||
long value:
|
long value;
|
||||||
if (!parse_integer(ptr, &value)) //Check whether the substring is holding only number or not
|
if (!parse_integer(ptr, &value)) //Check whether the substring is holding only number or not
|
||||||
return false;
|
return false;
|
||||||
num = atoi(ptr); //Convert substring to number
|
num = atoi(ptr); //Convert substring to number
|
||||||
|
@ -537,7 +537,7 @@ check_if_ip_valid(char *ip) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
parse_serve_args(const char *optarg, char **s_protocol, uint32_t *s_ip, uint16_t *s_port) {
|
parse_serve_args(const char *optarg, const char **s_protocol, uint32_t *s_ip, uint16_t *s_port) {
|
||||||
bool protocol_valid = false;
|
bool protocol_valid = false;
|
||||||
bool ip_valid = false;
|
bool ip_valid = false;
|
||||||
bool port_valid = false;
|
bool port_valid = false;
|
||||||
|
@ -562,7 +562,7 @@ parse_serve_args(const char *optarg, char **s_protocol, uint32_t *s_ip, uint16_t
|
||||||
if (!strcmp(protocol, "tcp")) {
|
if (!strcmp(protocol, "tcp")) {
|
||||||
protocol_valid = true;
|
protocol_valid = true;
|
||||||
} else {
|
} else {
|
||||||
LOGE("Unexpected protocol: $s (expected tcp)", protocol);
|
LOGE("Unexpected protocol (expected tcp)");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,11 +579,11 @@ parse_serve_args(const char *optarg, char **s_protocol, uint32_t *s_ip, uint16_t
|
||||||
|
|
||||||
//Check if the choosen port is valid
|
//Check if the choosen port is valid
|
||||||
long port_value = 0;
|
long port_value = 0;
|
||||||
port_valid = parse_interger_arg(port, &port_value, false, 0, 0xFFFF, "port");
|
port_valid = parse_integer_arg(port, &port_value, false, 0, 0xFFFF, "port");
|
||||||
|
|
||||||
//Check if everything is valid
|
//Check if everything is valid
|
||||||
if (!protocol_valid || !ip_valid || !port_valid) {
|
if (!protocol_valid || !ip_valid || !port_valid) {
|
||||||
LOGE("Unexpected argument format: $s (expected [tcp]:[ip or \"localhost\"]:[port])", optarg);
|
LOGE("Unexpected argument format (expected [tcp]:[ip or \"localhost\"]:[port])");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -639,7 +639,7 @@ scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
|
||||||
OPT_RENDER_EXPIRED_FRAMES},
|
OPT_RENDER_EXPIRED_FRAMES},
|
||||||
{"rotation", required_argument, NULL, OPT_ROTATION},
|
{"rotation", required_argument, NULL, OPT_ROTATION},
|
||||||
{"serial", required_argument, NULL, 's'},
|
{"serial", required_argument, NULL, 's'},
|
||||||
{"serve", required_argument, NULL, OPT_SERVE}
|
{"serve", required_argument, NULL, OPT_SERVE},
|
||||||
{"show-touches", no_argument, NULL, 't'},
|
{"show-touches", no_argument, NULL, 't'},
|
||||||
{"turn-screen-off", no_argument, NULL, 'S'},
|
{"turn-screen-off", no_argument, NULL, 'S'},
|
||||||
{"prefer-text", no_argument, NULL, OPT_PREFER_TEXT},
|
{"prefer-text", no_argument, NULL, OPT_PREFER_TEXT},
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/net.h"
|
#include "util/net.h"
|
||||||
|
|
||||||
# define SOCKET_ERROR -1
|
# define SOCKET_ERROR (-1)
|
||||||
|
|
||||||
void
|
void
|
||||||
serve_init(struct serve* serve, char *protocol, uint32_t ip, uint16_t port) {
|
serve_init(struct serve* serve, char *protocol, uint32_t ip, uint16_t port) {
|
||||||
|
@ -32,6 +32,8 @@ serve_start(struct serve* serve) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOGI("Waiting for a client to connect");
|
||||||
|
|
||||||
ClientSocket = net_accept(Listensocket);
|
ClientSocket = net_accept(Listensocket);
|
||||||
if (ClientSocket == INVALID_SOCKET) {
|
if (ClientSocket == INVALID_SOCKET) {
|
||||||
LOGI("Client error");
|
LOGI("Client error");
|
||||||
|
@ -49,8 +51,8 @@ serve_start(struct serve* serve) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
serve_push(struct serve* serve, const AVPacket packet) {
|
serve_push(struct serve* serve, const AVPacket *packet) {
|
||||||
if (net_send(serve->socket, packet.data, packet.size) == SOCKET_ERROR) {
|
if (net_send(serve->socket, packet->data, packet->size) == SOCKET_ERROR) {
|
||||||
LOGI("Client lost");
|
LOGI("Client lost");
|
||||||
net_close(serve->socket);
|
net_close(serve->socket);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -24,5 +24,5 @@ bool
|
||||||
serve_start(struct serve* serve);
|
serve_start(struct serve* serve);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
serve_push(struct serve* serve, const AVPacket packet);
|
serve_push(struct serve* serve, const AVPacket *packet);
|
||||||
#endif
|
#endif
|
|
@ -97,7 +97,7 @@ process_frame(struct stream *stream, AVPacket *packet) {
|
||||||
if (stream->serve) {
|
if (stream->serve) {
|
||||||
packet->dts = packet->pts;
|
packet->dts = packet->pts;
|
||||||
|
|
||||||
if (!serve_push(stream->serve, packet) {
|
if (!serve_push(stream->serve, packet)) {
|
||||||
LOGE("Could not serve packet");
|
LOGE("Could not serve packet");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue