mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-04-21 03:55:05 +00:00
initial work on removing posix and gcc dependencies and adding cmake with vcpkg
This commit is contained in:
parent
d3d955f67b
commit
1f6f68dba4
21 changed files with 1700 additions and 45 deletions
66
.clang-format
Normal file
66
.clang-format
Normal file
|
@ -0,0 +1,66 @@
|
|||
# Generated from CLion C/C++ Code Style settings
|
||||
BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: None
|
||||
AlignOperands: Align
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: Always
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: Always
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: Never
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterUnion: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakInheritanceList: BeforeColon
|
||||
ColumnLimit: 0
|
||||
CompactNamespaces: false
|
||||
ContinuationIndentWidth: 4
|
||||
IndentCaseLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentWidth: 4
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
MaxEmptyLinesToKeep: 2
|
||||
NamespaceIndentation: All
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PointerAlignment: Right
|
||||
ReflowComments: false
|
||||
SpaceAfterCStyleCast: true
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: false
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 0
|
||||
SpacesInAngles: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInContainerLiterals: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -7,3 +7,4 @@ build/
|
|||
.gradle/
|
||||
/x/
|
||||
local.properties
|
||||
cmake-build-*/
|
||||
|
|
42
app/CMakeLists.txt
Normal file
42
app/CMakeLists.txt
Normal file
|
@ -0,0 +1,42 @@
|
|||
cmake_minimum_required(VERSION 3.14)
|
||||
project(scrcpy C)
|
||||
|
||||
configure_file(src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
|
||||
add_executable(scrcpy
|
||||
src/main.c
|
||||
src/cli.c
|
||||
src/command.c
|
||||
src/control_msg.c
|
||||
src/controller.c
|
||||
src/decoder.c
|
||||
src/device.c
|
||||
src/device_msg.c
|
||||
src/event_converter.c
|
||||
src/file_handler.c
|
||||
src/fps_counter.c
|
||||
src/input_manager.c
|
||||
src/opengl.c
|
||||
src/receiver.c
|
||||
src/recorder.c
|
||||
src/scrcpy.c
|
||||
src/screen.c
|
||||
src/server.c
|
||||
src/stream.c
|
||||
src/tiny_xpm.c
|
||||
src/video_buffer.c
|
||||
src/util/net.c
|
||||
src/util/str_util.c
|
||||
$<$<PLATFORM_ID:Windows>:
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/sys/win/getopt.c
|
||||
>)
|
||||
|
||||
find_package(SDL2 CONFIG REQUIRED)
|
||||
find_package(FFMPEG COMPONENTS avformat avcodec avutil REQUIRED)
|
||||
|
||||
target_include_directories(scrcpy
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${FFMPEG_INCLUDE_DIRS}
|
||||
$<$<PLATFORM_ID:Windows>:${CMAKE_CURRENT_LIST_DIR}/src/sys/win/>)
|
||||
target_link_libraries(scrcpy SDL2::SDL2 SDL2::SDL2main ${FFMPEG_LIBRARIES})
|
|
@ -4,7 +4,6 @@
|
|||
#include <getopt.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "scrcpy.h"
|
||||
|
|
|
@ -104,7 +104,7 @@ show_adb_err_msg(enum process_result err, const char *const argv[]) {
|
|||
|
||||
process_t
|
||||
adb_execute(const char *serial, const char *const adb_cmd[], size_t len) {
|
||||
const char *cmd[len + 4];
|
||||
const char **cmd = malloc(sizeof(*cmd) * (len + 4));
|
||||
int i;
|
||||
process_t process;
|
||||
cmd[0] = get_adb_command();
|
||||
|
@ -121,8 +121,9 @@ adb_execute(const char *serial, const char *const adb_cmd[], size_t len) {
|
|||
enum process_result r = cmd_execute(cmd, &process);
|
||||
if (r != PROCESS_SUCCESS) {
|
||||
show_adb_err_msg(r, cmd);
|
||||
return PROCESS_NONE;
|
||||
process = PROCESS_NONE;
|
||||
}
|
||||
free(cmd);
|
||||
return process;
|
||||
}
|
||||
|
||||
|
|
62
app/src/config.h.in
Normal file
62
app/src/config.h.in
Normal file
|
@ -0,0 +1,62 @@
|
|||
#ifndef SCRCPY_CONFIG_H_IN_H
|
||||
#define SCRCPY_CONFIG_H_IN_H
|
||||
|
||||
|
||||
// expose the build type
|
||||
/*conf.set('NDEBUG', get_option('buildtype') != 'debug')*/
|
||||
|
||||
// the version, updated on release
|
||||
#define SCRCPY_VERSION "${SCRCPY_VERSION}"
|
||||
// the prefix used during configuration (meson --prefix=PREFIX)
|
||||
#define PREFIX "${PREFIX}"
|
||||
|
||||
// build a "portable" version (with scrcpy-server accessible from the same
|
||||
// directory as the executable)
|
||||
#cmakedefine01 PORTABLE
|
||||
|
||||
// the default client TCP port range for the "adb reverse" tunnel
|
||||
// overridden by option --port
|
||||
#cmakedefine DEFAULT_LOCAL_PORT_RANGE_FIRST ${DEFAULT_LOCAL_PORT_RANGE_FIRST}
|
||||
#ifndef DEFAULT_LOCAL_PORT_RANGE_FIRST
|
||||
#define DEFAULT_LOCAL_PORT_RANGE_FIRST 27183
|
||||
#endif
|
||||
|
||||
#cmakedefine DEFAULT_LOCAL_PORT_RANGE_LAST ${DEFAULT_LOCAL_PORT_RANGE_LAST}
|
||||
#ifndef DEFAULT_LOCAL_PORT_RANGE_LAST
|
||||
#define DEFAULT_LOCAL_PORT_RANGE_LAST 27199
|
||||
#endif
|
||||
|
||||
|
||||
// the default max video size for both dimensions, in pixels
|
||||
// overridden by option --max-size
|
||||
#cmakedefine DEFAULT_MAX_SIZE ${DEFAULT_MAX_SIZE}
|
||||
#ifndef DEFAULT_MAX_SIZE
|
||||
#define DEFAULT_MAX_SIZE 0 /* 0 - unlimited */
|
||||
#endif
|
||||
|
||||
// the default video orientation
|
||||
// natural device orientation is 0 and each increment adds 90 degrees
|
||||
// counterclockwise
|
||||
// overridden by option --lock-video-orientation
|
||||
#cmakedefine DEFAULT_LOCK_VIDEO_ORIENTATION ${DEFAULT_LOCK_VIDEO_ORIENTATION}
|
||||
#ifndef DEFAULT_LOCK_VIDEO_ORIENTATION
|
||||
#define DEFAULT_LOCK_VIDEO_ORIENTATION -1 /* -1 - unlocked */
|
||||
#endif
|
||||
|
||||
// the default video bitrate, in bits/second
|
||||
// overridden by option --bit-rate
|
||||
#cmakedefine DEFAULT_BIT_RATE ${DEFAULT_BIT_RATE}
|
||||
#ifndef DEFAULT_BIT_RATE
|
||||
#define DEFAULT_BIT_RATE 8000000 // 8Mbps
|
||||
#endif
|
||||
// enable High DPI support
|
||||
#define HIDPI_SUPPORT ${HIDPI_SUPPORT}
|
||||
|
||||
// run a server debugger and wait for a client to be attached
|
||||
#define SERVER_DEBUGGER ${SERVER_DEBUGGER}
|
||||
|
||||
// select the debugger method ('old' for Android < 9, 'new' for Android >= 9)
|
||||
#cmakedefine01 SERVER_DEBUGGER_METHOD_NEW
|
||||
|
||||
|
||||
#endif //SCRCPY_CONFIG_H_IN_H
|
|
@ -5,7 +5,6 @@
|
|||
#include <SDL2/SDL_events.h>
|
||||
#include <SDL2/SDL_mutex.h>
|
||||
#include <SDL2/SDL_thread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "compat.h"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "util/buffer_util.h"
|
||||
#include "util/log.h"
|
||||
|
||||
ssize_t
|
||||
size_t
|
||||
device_msg_deserialize(const unsigned char *buf, size_t len,
|
||||
struct device_msg *msg) {
|
||||
if (len < 5) {
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
@ -25,7 +24,7 @@ struct device_msg {
|
|||
};
|
||||
|
||||
// return the number of bytes consumed (0 for no msg available, -1 on error)
|
||||
ssize_t
|
||||
size_t
|
||||
device_msg_deserialize(const unsigned char *buf, size_t len,
|
||||
struct device_msg *msg);
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
#ifndef FPSCOUNTER_H
|
||||
#define FPSCOUNTER_H
|
||||
|
||||
#include <stdatomic.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <SDL2/SDL_mutex.h>
|
||||
#include <SDL2/SDL_thread.h>
|
||||
/* todo: this */
|
||||
#define atomic_bool bool
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#define SDL_MAIN_HANDLED // avoid link error on Linux Windows Subsystem
|
||||
#include <SDL2/SDL.h>
|
||||
|
|
|
@ -41,12 +41,12 @@ process_msg(struct device_msg *msg) {
|
|||
}
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
static size_t
|
||||
process_msgs(const unsigned char *buf, size_t len) {
|
||||
size_t head = 0;
|
||||
for (;;) {
|
||||
struct device_msg msg;
|
||||
ssize_t r = device_msg_deserialize(&buf[head], len - head, &msg);
|
||||
size_t r = device_msg_deserialize(&buf[head], len - head, &msg);
|
||||
if (r == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ run_receiver(void *data) {
|
|||
|
||||
for (;;) {
|
||||
assert(head < DEVICE_MSG_MAX_SIZE);
|
||||
ssize_t r = net_recv(receiver->control_socket, buf + head,
|
||||
size_t r = net_recv(receiver->control_socket, buf + head,
|
||||
DEVICE_MSG_MAX_SIZE - head);
|
||||
if (r <= 0) {
|
||||
LOGD("Receiver stopped");
|
||||
|
@ -82,7 +82,7 @@ run_receiver(void *data) {
|
|||
}
|
||||
|
||||
head += r;
|
||||
ssize_t consumed = process_msgs(buf, head);
|
||||
size_t consumed = process_msgs(buf, head);
|
||||
if (consumed == -1) {
|
||||
// an error occurred
|
||||
break;
|
||||
|
|
|
@ -36,7 +36,7 @@ stream_recv_packet(struct stream *stream, AVPacket *packet) {
|
|||
// It is followed by <packet_size> bytes containing the packet/frame.
|
||||
|
||||
uint8_t header[HEADER_SIZE];
|
||||
ssize_t r = net_recv_all(stream->socket, header, HEADER_SIZE);
|
||||
size_t r = net_recv_all(stream->socket, header, HEADER_SIZE);
|
||||
if (r < HEADER_SIZE) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ get_executable_path(void) {
|
|||
// <https://stackoverflow.com/a/1024937/1987178>
|
||||
#ifdef __linux__
|
||||
char buf[PATH_MAX + 1]; // +1 for the null byte
|
||||
ssize_t len = readlink("/proc/self/exe", buf, PATH_MAX);
|
||||
size_t len = readlink("/proc/self/exe", buf, PATH_MAX);
|
||||
if (len == -1) {
|
||||
perror("readlink");
|
||||
return NULL;
|
||||
|
|
1274
app/src/sys/win/getopt.c
Normal file
1274
app/src/sys/win/getopt.c
Normal file
File diff suppressed because it is too large
Load diff
193
app/src/sys/win/getopt.h
Normal file
193
app/src/sys/win/getopt.h
Normal file
|
@ -0,0 +1,193 @@
|
|||
/* Declarations for getopt.
|
||||
Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2009,2010
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#ifndef _GETOPT_H
|
||||
|
||||
#ifndef __need_getopt
|
||||
# define _GETOPT_H 1
|
||||
#endif
|
||||
|
||||
/* If __GNU_LIBRARY__ is not already defined, either we are being used
|
||||
standalone, or this is the first header included in the source file.
|
||||
If we are being used with glibc, we need to include <features.h>, but
|
||||
that does not exist if we are standalone. So: if __GNU_LIBRARY__ is
|
||||
not defined, include <ctype.h>, which will pull in <features.h> for us
|
||||
if it's from glibc. (Why ctype.h? It's guaranteed to exist and it
|
||||
doesn't flood the namespace with stuff the way some other headers do.) */
|
||||
#if !defined __GNU_LIBRARY__
|
||||
# include <ctype.h>
|
||||
#endif
|
||||
|
||||
#ifndef __THROW
|
||||
# ifndef __GNUC_PREREQ
|
||||
# define __GNUC_PREREQ(maj, min) (0)
|
||||
# endif
|
||||
# if defined __cplusplus && __GNUC_PREREQ (2,8)
|
||||
# define __THROW throw ()
|
||||
# else
|
||||
# define __THROW
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* For communication from `getopt' to the caller.
|
||||
When `getopt' finds an option that takes an argument,
|
||||
the argument value is returned here.
|
||||
Also, when `ordering' is RETURN_IN_ORDER,
|
||||
each non-option ARGV-element is returned here. */
|
||||
|
||||
extern char *optarg;
|
||||
|
||||
/* Index in ARGV of the next element to be scanned.
|
||||
This is used for communication to and from the caller
|
||||
and for communication between successive calls to `getopt'.
|
||||
|
||||
On entry to `getopt', zero means this is the first call; initialize.
|
||||
|
||||
When `getopt' returns -1, this is the index of the first of the
|
||||
non-option elements that the caller should itself scan.
|
||||
|
||||
Otherwise, `optind' communicates from one call to the next
|
||||
how much of ARGV has been scanned so far. */
|
||||
|
||||
extern int optind;
|
||||
|
||||
/* Callers store zero here to inhibit the error message `getopt' prints
|
||||
for unrecognized options. */
|
||||
|
||||
extern int opterr;
|
||||
|
||||
/* Set to an option character which was unrecognized. */
|
||||
|
||||
extern int optopt;
|
||||
|
||||
#ifndef __need_getopt
|
||||
/* Describe the long-named options requested by the application.
|
||||
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
|
||||
of `struct option' terminated by an element containing a name which is
|
||||
zero.
|
||||
|
||||
The field `has_arg' is:
|
||||
no_argument (or 0) if the option does not take an argument,
|
||||
required_argument (or 1) if the option requires an argument,
|
||||
optional_argument (or 2) if the option takes an optional argument.
|
||||
|
||||
If the field `flag' is not NULL, it points to a variable that is set
|
||||
to the value given in the field `val' when the option is found, but
|
||||
left unchanged if the option is not found.
|
||||
|
||||
To have a long-named option do something other than set an `int' to
|
||||
a compiled-in constant, such as set a value from `optarg', set the
|
||||
option's `flag' field to zero and its `val' field to a nonzero
|
||||
value (the equivalent single-letter option character, if there is
|
||||
one). For long options that have a zero `flag' field, `getopt'
|
||||
returns the contents of the `val' field. */
|
||||
|
||||
struct option
|
||||
{
|
||||
const char *name;
|
||||
/* has_arg can't be an enum because some compilers complain about
|
||||
type mismatches in all the code that assumes it is an int. */
|
||||
int has_arg;
|
||||
int *flag;
|
||||
int val;
|
||||
};
|
||||
|
||||
/* Names for the values of the `has_arg' field of `struct option'. */
|
||||
|
||||
# define no_argument 0
|
||||
# define required_argument 1
|
||||
# define optional_argument 2
|
||||
#endif /* need getopt */
|
||||
|
||||
|
||||
/* Get definitions and prototypes for functions to process the
|
||||
arguments in ARGV (ARGC of them, minus the program name) for
|
||||
options given in OPTS.
|
||||
|
||||
Return the option character from OPTS just read. Return -1 when
|
||||
there are no more options. For unrecognized options, or options
|
||||
missing arguments, `optopt' is set to the option letter, and '?' is
|
||||
returned.
|
||||
|
||||
The OPTS string is a list of characters which are recognized option
|
||||
letters, optionally followed by colons, specifying that that letter
|
||||
takes an argument, to be placed in `optarg'.
|
||||
|
||||
If a letter in OPTS is followed by two colons, its argument is
|
||||
optional. This behavior is specific to the GNU `getopt'.
|
||||
|
||||
The argument `--' causes premature termination of argument
|
||||
scanning, explicitly telling `getopt' that there are no more
|
||||
options.
|
||||
|
||||
If OPTS begins with `--', then non-option arguments are treated as
|
||||
arguments to the option '\0'. This behavior is specific to the GNU
|
||||
`getopt'. */
|
||||
|
||||
#ifdef __GNU_LIBRARY__
|
||||
/* Many other libraries have conflicting prototypes for getopt, with
|
||||
differences in the consts, in stdlib.h. To avoid compilation
|
||||
errors, only prototype getopt for the GNU C library. */
|
||||
extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
|
||||
__THROW;
|
||||
|
||||
# if defined __need_getopt && defined __USE_POSIX2 \
|
||||
&& !defined __USE_POSIX_IMPLICITLY && !defined __USE_GNU
|
||||
/* The GNU getopt has more functionality than the standard version. The
|
||||
additional functionality can be disable at runtime. This redirection
|
||||
helps to also do this at runtime. */
|
||||
# ifdef __REDIRECT
|
||||
extern int __REDIRECT_NTH (getopt, (int ___argc, char *const *___argv,
|
||||
const char *__shortopts),
|
||||
__posix_getopt);
|
||||
# else
|
||||
extern int __posix_getopt (int ___argc, char *const *___argv,
|
||||
const char *__shortopts) __THROW;
|
||||
# define getopt __posix_getopt
|
||||
# endif
|
||||
# endif
|
||||
#else /* not __GNU_LIBRARY__ */
|
||||
extern int getopt ();
|
||||
#endif /* __GNU_LIBRARY__ */
|
||||
|
||||
#ifndef __need_getopt
|
||||
extern int getopt_long (int ___argc, char *const *___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind)
|
||||
__THROW;
|
||||
extern int getopt_long_only (int ___argc, char *const *___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind)
|
||||
__THROW;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Make sure we later can get all the definitions and declarations. */
|
||||
#undef __need_getopt
|
||||
|
||||
#endif /* getopt.h */
|
|
@ -3,7 +3,6 @@
|
|||
#define CBUF_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
@ -29,24 +28,26 @@
|
|||
#define cbuf_init(PCBUF) \
|
||||
(void) ((PCBUF)->head = (PCBUF)->tail = 0)
|
||||
|
||||
#define cbuf_push(PCBUF, ITEM) \
|
||||
({ \
|
||||
bool ok = !cbuf_is_full(PCBUF); \
|
||||
if (ok) { \
|
||||
(PCBUF)->data[(PCBUF)->head] = (ITEM); \
|
||||
(PCBUF)->head = ((PCBUF)->head + 1) % cbuf_size_(PCBUF); \
|
||||
} \
|
||||
ok; \
|
||||
})
|
||||
#define cbuf_push(PCBUF, ITEM) \
|
||||
( \
|
||||
(!cbuf_is_full(PCBUF)) \
|
||||
? ( \
|
||||
(PCBUF)->data[(PCBUF)->head] = (ITEM), \
|
||||
(PCBUF)->head = ((PCBUF)->head + 1) % cbuf_size_(PCBUF), \
|
||||
1 \
|
||||
) \
|
||||
: 0 \
|
||||
)
|
||||
|
||||
#define cbuf_take(PCBUF, PITEM) \
|
||||
({ \
|
||||
bool ok = !cbuf_is_empty(PCBUF); \
|
||||
if (ok) { \
|
||||
*(PITEM) = (PCBUF)->data[(PCBUF)->tail]; \
|
||||
(PCBUF)->tail = ((PCBUF)->tail + 1) % cbuf_size_(PCBUF); \
|
||||
} \
|
||||
ok; \
|
||||
})
|
||||
#define cbuf_take(PCBUF, PITEM) \
|
||||
( \
|
||||
cbuf_is_empty(PCBUF) \
|
||||
? ( \
|
||||
*(PITEM) = (PCBUF)->data[(PCBUF)->tail], \
|
||||
(PCBUF)->tail = ((PCBUF)->tail + 1) % cbuf_size_(PCBUF), \
|
||||
1 \
|
||||
) \
|
||||
: 0 \
|
||||
)
|
||||
|
||||
#endif
|
||||
|
|
|
@ -83,24 +83,24 @@ net_accept(socket_t server_socket) {
|
|||
return accept(server_socket, (SOCKADDR *) &csin, &sinsize);
|
||||
}
|
||||
|
||||
ssize_t
|
||||
size_t
|
||||
net_recv(socket_t socket, void *buf, size_t len) {
|
||||
return recv(socket, buf, len, 0);
|
||||
}
|
||||
|
||||
ssize_t
|
||||
size_t
|
||||
net_recv_all(socket_t socket, void *buf, size_t len) {
|
||||
return recv(socket, buf, len, MSG_WAITALL);
|
||||
}
|
||||
|
||||
ssize_t
|
||||
size_t
|
||||
net_send(socket_t socket, const void *buf, size_t len) {
|
||||
return send(socket, buf, len, 0);
|
||||
}
|
||||
|
||||
ssize_t
|
||||
size_t
|
||||
net_send_all(socket_t socket, const void *buf, size_t len) {
|
||||
ssize_t w = 0;
|
||||
size_t w = 0;
|
||||
while (len > 0) {
|
||||
w = send(socket, buf, len, 0);
|
||||
if (w == -1) {
|
||||
|
|
|
@ -35,16 +35,16 @@ socket_t
|
|||
net_accept(socket_t server_socket);
|
||||
|
||||
// the _all versions wait/retry until len bytes have been written/read
|
||||
ssize_t
|
||||
size_t
|
||||
net_recv(socket_t socket, void *buf, size_t len);
|
||||
|
||||
ssize_t
|
||||
size_t
|
||||
net_recv_all(socket_t socket, void *buf, size_t len);
|
||||
|
||||
ssize_t
|
||||
size_t
|
||||
net_send(socket_t socket, const void *buf, size_t len);
|
||||
|
||||
ssize_t
|
||||
size_t
|
||||
net_send_all(socket_t socket, const void *buf, size_t len);
|
||||
|
||||
// how is SHUT_RD (read), SHUT_WR (write) or SHUT_RDWR (both)
|
||||
|
|
|
@ -13,7 +13,7 @@ static void test_deserialize_clipboard(void) {
|
|||
};
|
||||
|
||||
struct device_msg msg;
|
||||
ssize_t r = device_msg_deserialize(input, sizeof(input), &msg);
|
||||
size_t r = device_msg_deserialize(input, sizeof(input), &msg);
|
||||
assert(r == 8);
|
||||
|
||||
assert(msg.type == DEVICE_MSG_TYPE_CLIPBOARD);
|
||||
|
@ -34,7 +34,7 @@ static void test_deserialize_clipboard_big(void) {
|
|||
memset(input + 5, 'a', DEVICE_MSG_TEXT_MAX_LENGTH);
|
||||
|
||||
struct device_msg msg;
|
||||
ssize_t r = device_msg_deserialize(input, sizeof(input), &msg);
|
||||
size_t r = device_msg_deserialize(input, sizeof(input), &msg);
|
||||
assert(r == DEVICE_MSG_MAX_SIZE);
|
||||
|
||||
assert(msg.type == DEVICE_MSG_TYPE_CLIPBOARD);
|
||||
|
|
17
app/vcpkg.json
Normal file
17
app/vcpkg.json
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "scrcpy",
|
||||
"version-string": "0.0.1",
|
||||
"dependencies": [
|
||||
"sdl2",
|
||||
"opengl",
|
||||
{
|
||||
"name": "ffmpeg",
|
||||
"default-features": false,
|
||||
"features": [
|
||||
"avformat",
|
||||
"avcodec",
|
||||
"avutil"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Add table
Reference in a new issue