| 58 | |
| 59 | |
| 60 | int main(int argc, char *argv[]) { |
| 61 | // Parse the command line arguments. |
| 62 | Sarge sarge; |
| 63 | sarge.setArgument("h", "help", "Get this help message.", false); |
| 64 | sarge.setArgument("v", "version", "Output the NymphCast client version and exit.", false); |
| 65 | sarge.setArgument("r", "remotes", "Display online NymphCast receivers and quit.", false); |
| 66 | sarge.setArgument("f", "file", "Name of file to stream to remote receiver.", true); |
| 67 | sarge.setArgument("i", "ip", "IP address of the target NymphCast receiver.", true); |
| 68 | sarge.setDescription("NymphCast client application. For use with NymphCast servers. More details: http://nyanko.ws/nymphcast.php."); |
| 69 | sarge.setUsage("nymphcast_client <options>"); |
| 70 | |
| 71 | sarge.parseArguments(argc, argv); |
| 72 | |
| 73 | if (sarge.flagCount() == 0) { |
| 74 | sarge.printHelp(); |
| 75 | return 0; |
| 76 | } |
| 77 | |
| 78 | if (sarge.exists("help")) { |
| 79 | sarge.printHelp(); |
| 80 | return 0; |
| 81 | } |
| 82 | |
| 83 | if (sarge.exists("version")) { |
| 84 | std::cout << "NymphCast client version: " << __VERSION << std::endl; |
| 85 | return 0; |
| 86 | } |
| 87 | |
| 88 | // We need access to the NymphCast client library from this point. |
| 89 | NymphCastClient client; |
| 90 | |
| 91 | if (sarge.exists("remotes")) { |
| 92 | std::cout << "Scanning for online remote receivers..." << std::endl; |
| 93 | |
| 94 | std::vector remotes = client.findServers(); |
| 95 | if (remotes.size() < 1) { |
| 96 | std::cout << "No remotes found." << std::endl; |
| 97 | return 0; |
| 98 | } |
| 99 | |
| 100 | // Print out list of remotes. |
| 101 | std::cout << "Found remotes:" << std::endl; |
| 102 | for (int i = 0; i < remotes.size(); ++i) { |
| 103 | std::cout << i << ". " << remotes[i].name << " <" << remotes[i].ipv4 << ":" |
| 104 | << remotes[i].port << "> (" << remotes[i].ipv6 << ")" |
| 105 | << std::endl; |
| 106 | } |
| 107 | |
| 108 | return 0; |
| 109 | } |
| 110 | |
| 111 | // Enter command processing loop. |
| 112 | // If the 'file' flag is set, start by playing back the file, optionally using the provided IP. |
| 113 | |
| 114 | // Allow the IP address of the server to be passed on the command line. |
| 115 | // Try to open the file. |
| 116 | std::string filename; |
| 117 | std::string serverip = "127.0.0.1"; |
nothing calls this directly
no test coverage detected