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 | */ |
Patrick Williams | 3c11033 | 2023-05-10 07:51:28 -0500 | [diff] [blame] | 26 | CommandLine(int c, char** v) : argc(c), argv(v) {} |
Eddie James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 27 | ~CommandLine() = default; |
| 28 | CommandLine(const CommandLine&) = default; |
| 29 | CommandLine& operator=(const CommandLine&) = default; |
| 30 | CommandLine(CommandLine&&) = default; |
| 31 | CommandLine& operator=(CommandLine&&) = default; |
| 32 | |
| 33 | int argc; |
| 34 | char** argv; |
| 35 | }; |
| 36 | |
| 37 | /* |
| 38 | * @brief Constructs Args object |
| 39 | * |
| 40 | * @param[in] argc - The number of arguments in the command line call |
| 41 | * @param[in] argv - The array of arguments from the command line |
| 42 | */ |
| 43 | Args(int argc, char* argv[]); |
| 44 | ~Args() = default; |
| 45 | Args(const Args&) = default; |
| 46 | Args& operator=(const Args&) = default; |
| 47 | Args(Args&&) = default; |
| 48 | Args& operator=(Args&&) = default; |
| 49 | |
| 50 | /* |
| 51 | * @brief Get the original command line arguments |
| 52 | * |
| 53 | * @return Reference to the CommandLine structure storing the original |
| 54 | * command line arguments |
| 55 | */ |
| 56 | inline const CommandLine& getCommandLine() const |
| 57 | { |
| 58 | return commandLine; |
| 59 | } |
| 60 | |
| 61 | /* |
| 62 | * @brief Get the desired video frame rate |
| 63 | * |
| 64 | * @return Value of the desired frame rate in frames per second |
| 65 | */ |
| 66 | inline int getFrameRate() const |
| 67 | { |
| 68 | return frameRate; |
| 69 | } |
| 70 | |
| 71 | /* |
Jammy Huang | a4f63b3 | 2022-02-14 14:43:21 +0800 | [diff] [blame] | 72 | * @brief Get the video subsampling |
| 73 | * |
| 74 | * @return Value of the video subsampling |
| 75 | */ |
| 76 | inline int getSubsampling() const |
| 77 | { |
| 78 | return subsampling; |
| 79 | } |
| 80 | |
| 81 | /* |
Jae Hyun Yoo | 7dfac9f | 2019-01-15 10:14:59 -0800 | [diff] [blame] | 82 | * @brief Get the path to the USB keyboard device |
Eddie James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 83 | * |
Jae Hyun Yoo | 7dfac9f | 2019-01-15 10:14:59 -0800 | [diff] [blame] | 84 | * @return Reference to the string storing the path to the keyboard device |
Eddie James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 85 | */ |
Jae Hyun Yoo | 7dfac9f | 2019-01-15 10:14:59 -0800 | [diff] [blame] | 86 | inline const std::string& getKeyboardPath() const |
Eddie James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 87 | { |
Jae Hyun Yoo | 7dfac9f | 2019-01-15 10:14:59 -0800 | [diff] [blame] | 88 | return keyboardPath; |
| 89 | } |
| 90 | |
| 91 | /* |
| 92 | * @brief Get the path to the USB mouse device |
| 93 | * |
| 94 | * @return Reference to the string storing the path to the mouse device |
| 95 | */ |
| 96 | inline const std::string& getPointerPath() const |
| 97 | { |
| 98 | return pointerPath; |
Eddie James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | /* |
Marvin Lin | fe685fb | 2022-10-25 16:20:08 +0800 | [diff] [blame] | 102 | * @brief Get the name of UDC |
| 103 | * |
| 104 | * @return Reference to the string storing the name of UDC |
| 105 | */ |
| 106 | inline const std::string& getUdcName() const |
| 107 | { |
| 108 | return udcName; |
| 109 | } |
| 110 | |
| 111 | /* |
Eddie James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 112 | * @brief Get the path to the V4L2 video device |
| 113 | * |
| 114 | * @return Reference to the string storing the path to the video device |
| 115 | */ |
| 116 | inline const std::string& getVideoPath() const |
| 117 | { |
| 118 | return videoPath; |
| 119 | } |
| 120 | |
Paul Fertser | 2d2f3da | 2021-06-18 11:16:43 +0000 | [diff] [blame] | 121 | /* |
| 122 | * @brief Get the identical frames detection setting |
| 123 | * |
| 124 | * @return True if identical frames detection is enabled |
| 125 | */ |
| 126 | inline bool getCalcFrameCRC() const |
| 127 | { |
| 128 | return calcFrameCRC; |
| 129 | } |
| 130 | |
Eddie James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 131 | private: |
| 132 | /* @brief Prints the application usage to stderr */ |
| 133 | void printUsage(); |
| 134 | |
| 135 | /* |
| 136 | * @brief Desired frame rate (in frames per second) of the video |
| 137 | * stream |
| 138 | */ |
| 139 | int frameRate; |
Jammy Huang | a4f63b3 | 2022-02-14 14:43:21 +0800 | [diff] [blame] | 140 | /* @brief Desired subsampling (0: 444, 1: 420) */ |
| 141 | int subsampling; |
Jae Hyun Yoo | 7dfac9f | 2019-01-15 10:14:59 -0800 | [diff] [blame] | 142 | /* @brief Path to the USB keyboard device */ |
| 143 | std::string keyboardPath; |
| 144 | /* @brief Path to the USB mouse device */ |
| 145 | std::string pointerPath; |
Marvin Lin | fe685fb | 2022-10-25 16:20:08 +0800 | [diff] [blame] | 146 | /* @brief Name of UDC */ |
| 147 | std::string udcName; |
Eddie James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 148 | /* @brief Path to the V4L2 video device */ |
| 149 | std::string videoPath; |
Paul Fertser | 2d2f3da | 2021-06-18 11:16:43 +0000 | [diff] [blame] | 150 | /* @brief Identical frames detection */ |
| 151 | bool calcFrameCRC; |
Eddie James | 9d7ff84 | 2018-12-11 12:54:35 -0600 | [diff] [blame] | 152 | /* @brief Original command line arguments passed to the application */ |
| 153 | CommandLine commandLine; |
| 154 | }; |
| 155 | |
| 156 | } // namespace ikvm |