Eddie James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <string> |
| 4 | |
| 5 | namespace ikvm |
| 6 | { |
Eddie James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 7 | /* |
| 8 | * @class Args |
| 9 | * @brief Command line argument parser and storage |
| 10 | */ |
| 11 | class 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 Liu | f79f6f5 | 2022-07-06 09:32:35 +0800 | [diff] [blame] | 27 | {} |
Eddie James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 28 | ~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 Huang | a4f63b3 | 2022-02-14 14:43:21 +0800 | [diff] [blame] | 73 | * @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 Yoo | 7dfac9f | 2019-01-15 10:14:59 -0800 | [diff] [blame] | 83 | * @brief Get the path to the USB keyboard device |
Eddie James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 84 | * |
Jae Hyun Yoo | 7dfac9f | 2019-01-15 10:14:59 -0800 | [diff] [blame] | 85 | * @return Reference to the string storing the path to the keyboard device |
Eddie James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 86 | */ |
Jae Hyun Yoo | 7dfac9f | 2019-01-15 10:14:59 -0800 | [diff] [blame] | 87 | inline const std::string& getKeyboardPath() const |
Eddie James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 88 | { |
Jae Hyun Yoo | 7dfac9f | 2019-01-15 10:14:59 -0800 | [diff] [blame] | 89 | 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 James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | /* |
Marvin Lin | fe685fb | 2022-10-25 16:20:08 +0800 | [diff] [blame] | 103 | * @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 James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 113 | * @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 Fertser | 2d2f3da | 2021-06-18 11:16:43 +0000 | [diff] [blame] | 122 | /* |
| 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 James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 132 | 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 Huang | a4f63b3 | 2022-02-14 14:43:21 +0800 | [diff] [blame] | 141 | /* @brief Desired subsampling (0: 444, 1: 420) */ |
| 142 | int subsampling; |
Jae Hyun Yoo | 7dfac9f | 2019-01-15 10:14:59 -0800 | [diff] [blame] | 143 | /* @brief Path to the USB keyboard device */ |
| 144 | std::string keyboardPath; |
| 145 | /* @brief Path to the USB mouse device */ |
| 146 | std::string pointerPath; |
Marvin Lin | fe685fb | 2022-10-25 16:20:08 +0800 | [diff] [blame] | 147 | /* @brief Name of UDC */ |
| 148 | std::string udcName; |
Eddie James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 149 | /* @brief Path to the V4L2 video device */ |
| 150 | std::string videoPath; |
Paul Fertser | 2d2f3da | 2021-06-18 11:16:43 +0000 | [diff] [blame] | 151 | /* @brief Identical frames detection */ |
| 152 | bool calcFrameCRC; |
Eddie James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 153 | /* @brief Original command line arguments passed to the application */ |
| 154 | CommandLine commandLine; |
| 155 | }; |
| 156 | |
| 157 | } // namespace ikvm |