blob: 183bbfa8d1ba39c04cb0873e7f8b98caf33582dc [file] [log] [blame]
Eddie James9d7ff842018-12-11 12:54:35 -06001#pragma once
2
3#include <string>
4
5namespace ikvm
6{
Eddie James9d7ff842018-12-11 12:54:35 -06007/*
8 * @class Args
9 * @brief Command line argument parser and storage
10 */
11class Args
12{
13 public:
14 /*
15 * @struct CommandLine
16 * @brief Stores the original command line arguments for later use
17 */
18 struct CommandLine
19 {
20 /*
21 * @brief Constructs CommandLine object
22 *
23 * @param[in] c - Number of arguments
24 * @param[in] v - Array of arguments
25 */
26 CommandLine(int c, char** v) : argc(c), argv(v)
George Liuf79f6f52022-07-06 09:32:35 +080027 {}
Eddie James9d7ff842018-12-11 12:54:35 -060028 ~CommandLine() = default;
29 CommandLine(const CommandLine&) = default;
30 CommandLine& operator=(const CommandLine&) = default;
31 CommandLine(CommandLine&&) = default;
32 CommandLine& operator=(CommandLine&&) = default;
33
34 int argc;
35 char** argv;
36 };
37
38 /*
39 * @brief Constructs Args object
40 *
41 * @param[in] argc - The number of arguments in the command line call
42 * @param[in] argv - The array of arguments from the command line
43 */
44 Args(int argc, char* argv[]);
45 ~Args() = default;
46 Args(const Args&) = default;
47 Args& operator=(const Args&) = default;
48 Args(Args&&) = default;
49 Args& operator=(Args&&) = default;
50
51 /*
52 * @brief Get the original command line arguments
53 *
54 * @return Reference to the CommandLine structure storing the original
55 * command line arguments
56 */
57 inline const CommandLine& getCommandLine() const
58 {
59 return commandLine;
60 }
61
62 /*
63 * @brief Get the desired video frame rate
64 *
65 * @return Value of the desired frame rate in frames per second
66 */
67 inline int getFrameRate() const
68 {
69 return frameRate;
70 }
71
72 /*
Jammy Huanga4f63b32022-02-14 14:43:21 +080073 * @brief Get the video subsampling
74 *
75 * @return Value of the video subsampling
76 */
77 inline int getSubsampling() const
78 {
79 return subsampling;
80 }
81
82 /*
Jae Hyun Yoo7dfac9f2019-01-15 10:14:59 -080083 * @brief Get the path to the USB keyboard device
Eddie James9d7ff842018-12-11 12:54:35 -060084 *
Jae Hyun Yoo7dfac9f2019-01-15 10:14:59 -080085 * @return Reference to the string storing the path to the keyboard device
Eddie James9d7ff842018-12-11 12:54:35 -060086 */
Jae Hyun Yoo7dfac9f2019-01-15 10:14:59 -080087 inline const std::string& getKeyboardPath() const
Eddie James9d7ff842018-12-11 12:54:35 -060088 {
Jae Hyun Yoo7dfac9f2019-01-15 10:14:59 -080089 return keyboardPath;
90 }
91
92 /*
93 * @brief Get the path to the USB mouse device
94 *
95 * @return Reference to the string storing the path to the mouse device
96 */
97 inline const std::string& getPointerPath() const
98 {
99 return pointerPath;
Eddie James9d7ff842018-12-11 12:54:35 -0600100 }
101
102 /*
Marvin Linfe685fb2022-10-25 16:20:08 +0800103 * @brief Get the name of UDC
104 *
105 * @return Reference to the string storing the name of UDC
106 */
107 inline const std::string& getUdcName() const
108 {
109 return udcName;
110 }
111
112 /*
Eddie James9d7ff842018-12-11 12:54:35 -0600113 * @brief Get the path to the V4L2 video device
114 *
115 * @return Reference to the string storing the path to the video device
116 */
117 inline const std::string& getVideoPath() const
118 {
119 return videoPath;
120 }
121
Paul Fertser2d2f3da2021-06-18 11:16:43 +0000122 /*
123 * @brief Get the identical frames detection setting
124 *
125 * @return True if identical frames detection is enabled
126 */
127 inline bool getCalcFrameCRC() const
128 {
129 return calcFrameCRC;
130 }
131
Eddie James9d7ff842018-12-11 12:54:35 -0600132 private:
133 /* @brief Prints the application usage to stderr */
134 void printUsage();
135
136 /*
137 * @brief Desired frame rate (in frames per second) of the video
138 * stream
139 */
140 int frameRate;
Jammy Huanga4f63b32022-02-14 14:43:21 +0800141 /* @brief Desired subsampling (0: 444, 1: 420) */
142 int subsampling;
Jae Hyun Yoo7dfac9f2019-01-15 10:14:59 -0800143 /* @brief Path to the USB keyboard device */
144 std::string keyboardPath;
145 /* @brief Path to the USB mouse device */
146 std::string pointerPath;
Marvin Linfe685fb2022-10-25 16:20:08 +0800147 /* @brief Name of UDC */
148 std::string udcName;
Eddie James9d7ff842018-12-11 12:54:35 -0600149 /* @brief Path to the V4L2 video device */
150 std::string videoPath;
Paul Fertser2d2f3da2021-06-18 11:16:43 +0000151 /* @brief Identical frames detection */
152 bool calcFrameCRC;
Eddie James9d7ff842018-12-11 12:54:35 -0600153 /* @brief Original command line arguments passed to the application */
154 CommandLine commandLine;
155};
156
157} // namespace ikvm