• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2024 Intel Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  */
23 
24 #ifndef SCREENSHOT_PARAMS_H
25 #define SCREENSHOT_PARAMS_H
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #include <stdio.h>
32 #include <stdint.h>
33 #include <stdbool.h>
34 
35 #define SCREENSHOT_PARAMS                               \
36    SCREENSHOT_PARAM_BOOL(comms)                         \
37    SCREENSHOT_PARAM_CUSTOM(control)                     \
38    SCREENSHOT_PARAM_CUSTOM(frames)                      \
39    SCREENSHOT_PARAM_CUSTOM(log_type)                    \
40    SCREENSHOT_PARAM_CUSTOM(output_dir)                  \
41    SCREENSHOT_PARAM_CUSTOM(region)                      \
42    SCREENSHOT_PARAM_CUSTOM(help)
43 
44 #define LARGE_BUFFER_SIZE 16384  // 16 KB for large input strings
45 #define STANDARD_BUFFER_SIZE 256
46 
47 enum screenshot_param_enabled {
48 #define SCREENSHOT_PARAM_BOOL(name) SCREENSHOT_PARAM_ENABLED_##name,
49 #define SCREENSHOT_PARAM_CUSTOM(name)
50    SCREENSHOT_PARAMS
51 #undef SCREENSHOT_PARAM_BOOL
52 #undef SCREENSHOT_PARAM_CUSTOM
53    SCREENSHOT_PARAM_ENABLED_MAX
54 };
55 
56 enum LogType {
57    DEBUG,
58    ERROR,
59    INFO,
60    NO_PREFIX, // Don't prefix the log with text
61    REQUIRED, // Non-error logs that must be printed for user
62    WARN
63 };
64 
65 extern enum LogType LOG_TYPE;
66 
67 struct frame_node {
68    uint32_t frame_num;
69    struct frame_node *next;
70 };
71 
72 /* List should be sorted into ascending order, in terms of frame_node data */
73 struct frame_list {
74    uint32_t size;
75    bool all_frames;
76    struct frame_node *head;
77 };
78 
79 /*
80    Regions use percentages of an image to create a subimage
81    Ex: startX% = 0.25, startY% = 0.25, endX% = 0.60, endY% = 0.75
82    Original image size: width = 1920, height = 1080
83    startX = 480, startY = 270, endX = 1152, endY = 810
84    Resulting coordinates: ((480, 270), (1152, 270), (480, 810), (1152, 810))
85 */
86 struct ImageRegion {
87    float startX, startY, endX, endY;
88    bool useImageRegion;
89 };
90 
91 void remove_node(struct frame_list *, struct frame_node *, struct frame_node *);
92 void destroy_frame_list(struct frame_list *);
93 struct ImageRegion getRegionFromInput(const char *);
94 
95 void LOG(enum LogType, const char *, ...);
96 
97 struct screenshot_params {
98    bool enabled[SCREENSHOT_PARAM_ENABLED_MAX];
99    struct frame_list *frames;
100    struct ImageRegion region;
101    const char *control;
102    enum LogType log_type;
103    const char *output_dir;
104    bool help;
105 };
106 
107 const extern char *screenshot_param_names[];
108 
109 void parse_screenshot_env(struct screenshot_params *params,
110                        const char *env);
111 
112 #ifdef __cplusplus
113 }
114 #endif
115 
116 #endif /* SCREENSHOT_PARAMS_H */
117