Display and control your Android device
Move utilities to util/
Romain Vimontdfd0707a2925
diff --git a/app/meson.build b/app/meson.buildindex 159ae695..005239b8 100644--- a/app/meson.build+++ b/app/meson.build@@ -10,16 +10,16 @@ src = ['src/file_handler.c','src/fps_counter.c','src/input_manager.c',- 'src/net.c','src/receiver.c','src/recorder.c','src/scrcpy.c','src/screen.c','src/server.c',- 'src/str_util.c',- 'src/tiny_xpm.c','src/stream.c',+ 'src/tiny_xpm.c','src/video_buffer.c',+ 'src/util/net.c',+ 'src/util/str_util.c']if not get_option('crossbuild_windows')@@ -147,7 +147,7 @@ tests = [['test_control_event_serialize', ['tests/test_control_msg_serialize.c','src/control_msg.c',- 'src/str_util.c'+ 'src/util/str_util.c']],['test_device_event_deserialize', ['tests/test_device_msg_deserialize.c',@@ -158,7 +158,7 @@ tests = []],['test_strutil', ['tests/test_strutil.c',- 'src/str_util.c'+ 'src/util/str_util.c']],]diff --git a/app/src/command.c b/app/src/command.cindex d914e6ab..33a9c587 100644--- a/app/src/command.c+++ b/app/src/command.c@@ -7,8 +7,8 @@#include "config.h"#include "common.h"-#include "log.h"-#include "str_util.h"+#include "util/log.h"+#include "util/str_util.h"static const char *adb_command;diff --git a/app/src/control_msg.c b/app/src/control_msg.cindex e042dc5a..363483eb 100644--- a/app/src/control_msg.c+++ b/app/src/control_msg.c@@ -4,9 +4,9 @@#include <SDL2/SDL_assert.h>#include "config.h"-#include "buffer_util.h"-#include "log.h"-#include "str_util.h"+#include "util/buffer_util.h"+#include "util/log.h"+#include "util/str_util.h"static voidwrite_position(uint8_t *buf, const struct position *position) {diff --git a/app/src/controller.c b/app/src/controller.cindex 7f90d787..ec706c95 100644--- a/app/src/controller.c+++ b/app/src/controller.c@@ -3,8 +3,8 @@#include <SDL2/SDL_assert.h>#include "config.h"-#include "lock_util.h"-#include "log.h"+#include "util/lock.h"+#include "util/log.h"boolcontroller_init(struct controller *controller, socket_t control_socket) {diff --git a/app/src/controller.h b/app/src/controller.hindex 1b0d005b..8011ef6a 100644--- a/app/src/controller.h+++ b/app/src/controller.h@@ -6,10 +6,10 @@#include <SDL2/SDL_thread.h>#include "config.h"-#include "cbuf.h"#include "control_msg.h"-#include "net.h"#include "receiver.h"+#include "util/cbuf.h"+#include "util/net.h"struct control_msg_queue CBUF(struct control_msg, 64);diff --git a/app/src/decoder.c b/app/src/decoder.cindex cad19913..52176484 100644--- a/app/src/decoder.c+++ b/app/src/decoder.c@@ -10,12 +10,12 @@#include "config.h"#include "compat.h"-#include "buffer_util.h"#include "events.h"-#include "lock_util.h"-#include "log.h"#include "recorder.h"#include "video_buffer.h"+#include "util/buffer_util.h"+#include "util/lock.h"+#include "util/log.h"// set the decoded frame as ready for rendering, and notifystatic voiddiff --git a/app/src/device.c b/app/src/device.cindex 4f50ab48..f4c2628b 100644--- a/app/src/device.c+++ b/app/src/device.c@@ -1,7 +1,7 @@#include "device.h"#include "config.h"-#include "log.h"+#include "util/log.h"booldevice_read_info(socket_t device_socket, char *device_name, struct size *size) {diff --git a/app/src/device.h b/app/src/device.hindex 34a5f17f..8a94cd86 100644--- a/app/src/device.h+++ b/app/src/device.h@@ -5,7 +5,7 @@#include "config.h"#include "common.h"-#include "net.h"+#include "util/net.h"#define DEVICE_NAME_FIELD_LENGTH 64diff --git a/app/src/device_msg.c b/app/src/device_msg.cindex 2fc90ae4..aba56bb3 100644--- a/app/src/device_msg.c+++ b/app/src/device_msg.c@@ -4,8 +4,8 @@#include <SDL2/SDL_assert.h>#include "config.h"-#include "buffer_util.h"-#include "log.h"+#include "util/buffer_util.h"+#include "util/log.h"ssize_tdevice_msg_deserialize(const unsigned char *buf, size_t len,diff --git a/app/src/file_handler.c b/app/src/file_handler.cindex e02ca2a9..c0b03bcf 100644--- a/app/src/file_handler.c+++ b/app/src/file_handler.c@@ -5,8 +5,8 @@#include "config.h"#include "command.h"-#include "lock_util.h"-#include "log.h"+#include "util/lock.h"+#include "util/log.h"#define DEFAULT_PUSH_TARGET "/sdcard/"diff --git a/app/src/file_handler.h b/app/src/file_handler.hindex 4c158296..078d0ca5 100644--- a/app/src/file_handler.h+++ b/app/src/file_handler.h@@ -6,8 +6,8 @@#include <SDL2/SDL_thread.h>#include "config.h"-#include "cbuf.h"#include "command.h"+#include "util/cbuf.h"typedef enum {ACTION_INSTALL_APK,diff --git a/app/src/fps_counter.c b/app/src/fps_counter.cindex 2a9478f6..0c3f13d4 100644--- a/app/src/fps_counter.c+++ b/app/src/fps_counter.c@@ -4,8 +4,8 @@#include <SDL2/SDL_timer.h>#include "config.h"-#include "lock_util.h"-#include "log.h"+#include "util/lock.h"+#include "util/log.h"#define FPS_COUNTER_INTERVAL_MS 1000diff --git a/app/src/input_manager.c b/app/src/input_manager.cindex 7d333c1b..e0aa6054 100644--- a/app/src/input_manager.c+++ b/app/src/input_manager.c@@ -4,8 +4,8 @@#include "config.h"#include "event_converter.h"-#include "lock_util.h"-#include "log.h"+#include "util/lock.h"+#include "util/log.h"// Convert window coordinates (as provided by SDL_GetMouseState() to renderer// coordinates (as provided in SDL mouse events)diff --git a/app/src/main.c b/app/src/main.cindex 8a835bf1..c17cc6bf 100644--- a/app/src/main.c+++ b/app/src/main.c@@ -10,8 +10,8 @@#include "config.h"#include "compat.h"-#include "log.h"#include "recorder.h"+#include "util/log.h"struct args {struct scrcpy_options opts;diff --git a/app/src/receiver.c b/app/src/receiver.cindex 1c80bb00..23944d5a 100644--- a/app/src/receiver.c+++ b/app/src/receiver.c@@ -5,8 +5,8 @@#include "config.h"#include "device_msg.h"-#include "lock_util.h"-#include "log.h"+#include "util/lock.h"+#include "util/log.h"boolreceiver_init(struct receiver *receiver, socket_t control_socket) {diff --git a/app/src/receiver.h b/app/src/receiver.hindex 6108e545..8387903b 100644--- a/app/src/receiver.h+++ b/app/src/receiver.h@@ -6,7 +6,7 @@#include <SDL2/SDL_thread.h>#include "config.h"-#include "net.h"+#include "util/net.h"// receive events from the device// managed by the controllerdiff --git a/app/src/recorder.c b/app/src/recorder.cindex f6f6fd96..b5314daf 100644--- a/app/src/recorder.c+++ b/app/src/recorder.c@@ -5,8 +5,8 @@#include "config.h"#include "compat.h"-#include "lock_util.h"-#include "log.h"+#include "util/lock.h"+#include "util/log.h"static const AVRational SCRCPY_TIME_BASE = {1, 1000000}; // timestamps in usdiff --git a/app/src/recorder.h b/app/src/recorder.hindex 4ad77197..4f5d526c 100644--- a/app/src/recorder.h+++ b/app/src/recorder.h@@ -8,7 +8,7 @@#include "config.h"#include "common.h"-#include "queue.h"+#include "util/queue.h"enum recorder_format {RECORDER_FORMAT_AUTO,diff --git a/app/src/scrcpy.c b/app/src/scrcpy.cindex 67f1de16..673ec678 100644--- a/app/src/scrcpy.c+++ b/app/src/scrcpy.c@@ -18,15 +18,15 @@#include "file_handler.h"#include "fps_counter.h"#include "input_manager.h"-#include "log.h"-#include "lock_util.h"-#include "net.h"#include "recorder.h"#include "screen.h"#include "server.h"#include "stream.h"#include "tiny_xpm.h"#include "video_buffer.h"+#include "util/lock.h"+#include "util/log.h"+#include "util/net.h"static struct server server = SERVER_INITIALIZER;static struct screen screen = SCREEN_INITIALIZER;diff --git a/app/src/screen.c b/app/src/screen.cindex ab4d434e..4cc7cde3 100644--- a/app/src/screen.c+++ b/app/src/screen.c@@ -7,10 +7,10 @@#include "common.h"#include "compat.h"#include "icon.xpm"-#include "lock_util.h"-#include "log.h"#include "tiny_xpm.h"#include "video_buffer.h"+#include "util/lock.h"+#include "util/log.h"#define DISPLAY_MARGINS 96diff --git a/app/src/server.c b/app/src/server.cindex 6061b8b3..d9114356 100644--- a/app/src/server.c+++ b/app/src/server.c@@ -9,8 +9,8 @@#include "config.h"#include "command.h"-#include "log.h"-#include "net.h"+#include "util/log.h"+#include "util/net.h"#define SOCKET_NAME "scrcpy"#define SERVER_FILENAME "scrcpy-server"diff --git a/app/src/server.h b/app/src/server.hindex f46ced19..0cb1ab3a 100644--- a/app/src/server.h+++ b/app/src/server.h@@ -6,7 +6,7 @@#include "config.h"#include "command.h"-#include "net.h"+#include "util/net.h"struct server {char *serial;diff --git a/app/src/stream.c b/app/src/stream.cindex 6c3192f2..c84de981 100644--- a/app/src/stream.c+++ b/app/src/stream.c@@ -10,12 +10,12 @@#include "config.h"#include "compat.h"-#include "buffer_util.h"#include "decoder.h"#include "events.h"-#include "lock_util.h"-#include "log.h"#include "recorder.h"+#include "util/buffer_util.h"+#include "util/lock.h"+#include "util/log.h"#define BUFSIZE 0x10000diff --git a/app/src/stream.h b/app/src/stream.hindex cb50468e..f7c5e475 100644--- a/app/src/stream.h+++ b/app/src/stream.h@@ -8,7 +8,7 @@#include <SDL2/SDL_thread.h>#include "config.h"-#include "net.h"+#include "util/net.h"struct video_buffer;diff --git a/app/src/sys/unix/command.c b/app/src/sys/unix/command.cindex 6a3a5a47..512b9af7 100644--- a/app/src/sys/unix/command.c+++ b/app/src/sys/unix/command.c@@ -17,7 +17,8 @@#include <sys/types.h>#include <sys/wait.h>#include <unistd.h>-#include "log.h"++#include "util/log.h"enum process_resultcmd_execute(const char *path, const char *const argv[], pid_t *pid) {diff --git a/app/src/sys/unix/net.c b/app/src/sys/unix/net.cindex d940f3bb..d67a660f 100644--- a/app/src/sys/unix/net.c+++ b/app/src/sys/unix/net.c@@ -1,4 +1,4 @@-#include "net.h"+#include "util/net.h"#include <unistd.h>diff --git a/app/src/tiny_xpm.c b/app/src/tiny_xpm.cindex 5ea89078..e96981fb 100644--- a/app/src/tiny_xpm.c+++ b/app/src/tiny_xpm.c@@ -6,7 +6,7 @@#include <stdlib.h>#include "config.h"-#include "log.h"+#include "util/log.h"struct index {char c;diff --git a/app/src/buffer_util.h b/app/src/util/buffer_util.hsimilarity index 100%rename from app/src/buffer_util.hrename to app/src/util/buffer_util.hdiff --git a/app/src/cbuf.h b/app/src/util/cbuf.hsimilarity index 100%rename from app/src/cbuf.hrename to app/src/util/cbuf.hdiff --git a/app/src/lock_util.h b/app/src/util/lock.hsimilarity index 96%rename from app/src/lock_util.hrename to app/src/util/lock.hindex 260d2c12..8ebee241 100644--- a/app/src/lock_util.h+++ b/app/src/util/lock.h@@ -1,5 +1,5 @@-#ifndef LOCKUTIL_H-#define LOCKUTIL_H+#ifndef LOCK_H+#define LOCK_H#include <stdint.h>#include <SDL2/SDL_mutex.h>diff --git a/app/src/log.h b/app/src/util/log.hsimilarity index 100%rename from app/src/log.hrename to app/src/util/log.hdiff --git a/app/src/net.c b/app/src/util/net.csimilarity index 100%rename from app/src/net.crename to app/src/util/net.cdiff --git a/app/src/net.h b/app/src/util/net.hsimilarity index 100%rename from app/src/net.hrename to app/src/util/net.hdiff --git a/app/src/queue.h b/app/src/util/queue.hsimilarity index 100%rename from app/src/queue.hrename to app/src/util/queue.hdiff --git a/app/src/str_util.c b/app/src/util/str_util.csimilarity index 100%rename from app/src/str_util.crename to app/src/util/str_util.cdiff --git a/app/src/str_util.h b/app/src/util/str_util.hsimilarity index 100%rename from app/src/str_util.hrename to app/src/util/str_util.hdiff --git a/app/src/video_buffer.c b/app/src/video_buffer.cindex 2b5f1c2f..9de3ad7f 100644--- a/app/src/video_buffer.c+++ b/app/src/video_buffer.c@@ -6,8 +6,8 @@#include <libavformat/avformat.h>#include "config.h"-#include "lock_util.h"-#include "log.h"+#include "util/lock.h"+#include "util/log.h"boolvideo_buffer_init(struct video_buffer *vb, struct fps_counter *fps_counter,diff --git a/app/tests/test_cbuf.c b/app/tests/test_cbuf.cindex 9d5fdc27..dbe50aab 100644--- a/app/tests/test_cbuf.c+++ b/app/tests/test_cbuf.c@@ -1,7 +1,7 @@#include <assert.h>#include <string.h>-#include "cbuf.h"+#include "util/cbuf.h"struct int_queue CBUF(int, 32);diff --git a/app/tests/test_queue.c b/app/tests/test_queue.cindex bcbced2b..b0950bb0 100644--- a/app/tests/test_queue.c+++ b/app/tests/test_queue.c@@ -1,6 +1,6 @@#include <assert.h>-#include <queue.h>+#include "util/queue.h"struct foo {int value;diff --git a/app/tests/test_strutil.c b/app/tests/test_strutil.cindex 18ac4a7d..64e62ed1 100644--- a/app/tests/test_strutil.c+++ b/app/tests/test_strutil.c@@ -1,7 +1,7 @@#include <assert.h>#include <string.h>-#include "str_util.h"+#include "util/str_util.h"static void test_xstrncpy_simple(void) {char s[] = "xxxxxxxxxx";