1 /* 2 * Copyright © 2019 Manuel Stoeckl 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining 5 * a copy of this software and associated documentation files (the 6 * "Software"), to deal in the Software without restriction, including 7 * without limitation the rights to use, copy, modify, merge, publish, 8 * distribute, sublicense, and/or sell copies of the Software, and to 9 * permit persons to whom the Software is furnished to do so, subject to 10 * the following conditions: 11 * 12 * The above copyright notice and this permission notice (including the 13 * next paragraph) shall be included in all copies or substantial 14 * portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 * SOFTWARE. 24 */ 25 #ifndef WAYPIPE_MAIN_H 26 #define WAYPIPE_MAIN_H 27 28 #include "parsing.h" 29 #include "shadow.h" 30 #include "util.h" 31 32 struct main_config { 33 const char *drm_node; 34 int n_worker_threads; 35 enum compression_mode compression; 36 int compression_level; 37 bool no_gpu; 38 bool only_linear_dmabuf; 39 bool video_if_possible; 40 int video_bpf; 41 enum video_coding_fmt video_fmt; 42 bool prefer_hwvideo; 43 bool old_video_mode; 44 }; 45 struct globals { 46 const struct main_config *config; 47 struct fd_translation_map map; 48 struct render_data render; 49 struct message_tracker tracker; 50 struct thread_pool threads; 51 }; 52 53 /** Main processing loop 54 * 55 * chanfd: connected socket to channel 56 * progfd: connected socket to Wayland program 57 * linkfd: optional socket providing new chanfds. (-1 means not provided) 58 * 59 * Returns either EXIT_SUCCESS or EXIT_FAILURE (if exit caused by an error.) 60 */ 61 int main_interface_loop(int chanfd, int progfd, int linkfd, 62 const struct main_config *config, bool display_side); 63 /** Act as a Wayland server */ 64 int run_server(const struct sockaddr_un *socket_path, const char *display_path, 65 const char *control_path, const struct main_config *config, 66 bool oneshot, bool unlink_at_end, char *const app_argv[], 67 bool login_shell_if_backup); 68 /** Act as a Wayland client */ 69 int run_client(const struct sockaddr_un *socket_path, 70 const struct main_config *config, bool oneshot, 71 const char *wayland_socket, pid_t eol_pid, int channelsock); 72 /** Run benchmarking tool; n_worker_threads defined as with \ref main_config */ 73 int run_bench(float bandwidth_mBps, uint32_t test_size, int n_worker_threads); 74 75 #endif // WAYPIPE_MAIN_H 76