增加windows多设备投屏

This commit is contained in:
huanglinhuan
2025-12-19 15:28:38 +08:00
parent 16a066ac94
commit 2b47c4c2f3
3 changed files with 38 additions and 15 deletions

View File

@@ -2,21 +2,37 @@
#include "ScreenCapture.h"
#include "VideoEncoder.h"
#include <iostream>
#include <sstream>
#include <vector>
#include <thread>
#include <chrono>
#include <fstream>
int main(int argc, char* argv[]) {
std::string ip = "127.0.0.1";
std::string ipStr = "127.0.0.1";
int port = 8888;
std::string outputFileName = "";
if (argc > 1) ip = argv[1];
if (argc > 1) ipStr = argv[1];
if (argc > 2) port = std::stoi(argv[2]);
if (argc > 3) outputFileName = argv[3];
// Parse IPs
std::vector<std::string> ips;
std::stringstream ss(ipStr);
std::string item;
while (std::getline(ss, item, ',')) {
// Trim spaces might be good but let's assume no spaces for simplicity or user should handle
if (!item.empty()) {
ips.push_back(item);
}
}
if (ips.empty()) ips.push_back("127.0.0.1");
std::cout << "Starting Windows Sender Demo..." << std::endl;
std::cout << "Target: " << ip << ":" << port << std::endl;
std::cout << "Targets: ";
for (const auto& ip : ips) std::cout << ip << " ";
std::cout << ", Port: " << port << std::endl;
if (!outputFileName.empty()) {
std::cout << "Output File: " << outputFileName << std::endl;
}
@@ -60,7 +76,7 @@ int main(int argc, char* argv[]) {
}
NetworkSender sender;
if (!sender.Initialize(ip, port)) {
if (!sender.Initialize(ips, port)) {
std::cerr << "Failed to initialize Network Sender" << std::endl;
return 1;
}