blob: cb3d3ade14aedec13de3074fc69db21f0841e707 [file] [log] [blame]
Eddie James9d7ff842018-12-11 12:54:35 -06001#pragma once
2
3#include <string>
4
5namespace ikvm
6{
7
8/*
9 * @class Args
10 * @brief Command line argument parser and storage
11 */
12class Args
13{
14 public:
15 /*
16 * @struct CommandLine
17 * @brief Stores the original command line arguments for later use
18 */
19 struct CommandLine
20 {
21 /*
22 * @brief Constructs CommandLine object
23 *
24 * @param[in] c - Number of arguments
25 * @param[in] v - Array of arguments
26 */
27 CommandLine(int c, char** v) : argc(c), argv(v)
George Liuf79f6f52022-07-06 09:32:35 +080028 {}
Eddie James9d7ff842018-12-11 12:54:35 -060029 ~CommandLine() = default;
30 CommandLine(const CommandLine&) = default;
31 CommandLine& operator=(const CommandLine&) = default;
32 CommandLine(CommandLine&&) = default;
33 CommandLine& operator=(CommandLine&&) = default;
34
35 int argc;
36 char** argv;
37 };
38
39 /*
40 * @brief Constructs Args object
41 *
42 * @param[in] argc - The number of arguments in the command line call
43 * @param[in] argv - The array of arguments from the command line
44 */
45 Args(int argc, char* argv[]);
46 ~Args() = default;
47 Args(const Args&) = default;
48 Args& operator=(const Args&) = default;
49 Args(Args&&) = default;
50 Args& operator=(Args&&) = default;
51
52 /*
53 * @brief Get the original command line arguments
54 *
55 * @return Reference to the CommandLine structure storing the original
56 * command line arguments
57 */
58 inline const CommandLine& getCommandLine() const
59 {
60 return commandLine;
61 }
62
63 /*
64 * @brief Get the desired video frame rate
65 *
66 * @return Value of the desired frame rate in frames per second
67 */
68 inline int getFrameRate() const
69 {
70 return frameRate;
71 }
72
73 /*
Jammy Huanga4f63b32022-02-14 14:43:21 +080074 * @brief Get the video subsampling
75 *
76 * @return Value of the video subsampling
77 */
78 inline int getSubsampling() const
79 {
80 return subsampling;
81 }
82
83 /*
Jae Hyun Yoo7dfac9f2019-01-15 10:14:59 -080084 * @brief Get the path to the USB keyboard device
Eddie James9d7ff842018-12-11 12:54:35 -060085 *
Jae Hyun Yoo7dfac9f2019-01-15 10:14:59 -080086 * @return Reference to the string storing the path to the keyboard device
Eddie James9d7ff842018-12-11 12:54:35 -060087 */
Jae Hyun Yoo7dfac9f2019-01-15 10:14:59 -080088 inline const std::string& getKeyboardPath() const
Eddie James9d7ff842018-12-11 12:54:35 -060089 {
Jae Hyun Yoo7dfac9f2019-01-15 10:14:59 -080090 return keyboardPath;
91 }
92
93 /*
94 * @brief Get the path to the USB mouse device
95 *
96 * @return Reference to the string storing the path to the mouse device
97 */
98 inline const std::string& getPointerPath() const
99 {
100 return pointerPath;
Eddie James9d7ff842018-12-11 12:54:35 -0600101 }
102
103 /*
Marvin Linfe685fb2022-10-25 16:20:08 +0800104 * @brief Get the name of UDC
105 *
106 * @return Reference to the string storing the name of UDC
107 */
108 inline const std::string& getUdcName() const
109 {
110 return udcName;
111 }
112
113 /*
Eddie James9d7ff842018-12-11 12:54:35 -0600114 * @brief Get the path to the V4L2 video device
115 *
116 * @return Reference to the string storing the path to the video device
117 */
118 inline const std::string& getVideoPath() const
119 {
120 return videoPath;
121 }
122
Paul Fertser2d2f3da2021-06-18 11:16:43 +0000123 /*
124 * @brief Get the identical frames detection setting
125 *
126 * @return True if identical frames detection is enabled
127 */
128 inline bool getCalcFrameCRC() const
129 {
130 return calcFrameCRC;
131 }
132
Eddie James9d7ff842018-12-11 12:54:35 -0600133 private:
134 /* @brief Prints the application usage to stderr */
135 void printUsage();
136
137 /*
138 * @brief Desired frame rate (in frames per second) of the video
139 * stream
140 */
141 int frameRate;
Jammy Huanga4f63b32022-02-14 14:43:21 +0800142 /* @brief Desired subsampling (0: 444, 1: 420) */
143 int subsampling;
Jae Hyun Yoo7dfac9f2019-01-15 10:14:59 -0800144 /* @brief Path to the USB keyboard device */
145 std::string keyboardPath;
146 /* @brief Path to the USB mouse device */
147 std::string pointerPath;
Marvin Linfe685fb2022-10-25 16:20:08 +0800148 /* @brief Name of UDC */
149 std::string udcName;
Eddie James9d7ff842018-12-11 12:54:35 -0600150 /* @brief Path to the V4L2 video device */
151 std::string videoPath;
Paul Fertser2d2f3da2021-06-18 11:16:43 +0000152 /* @brief Identical frames detection */
153 bool calcFrameCRC;
Eddie James9d7ff842018-12-11 12:54:35 -0600154 /* @brief Original command line arguments passed to the application */
155 CommandLine commandLine;
156};
157
158} // namespace ikvm