int main(int argc, char* argv[]) { if (argc < 2) { boost::filesystem::path exePath(argv[0]); std::cout << "usage: " << exePath.filename().string() << " <RTSP url of stream>" << std::endl; return -1; } boost::program_options::options_description desc(""); desc.add_options() ("no-display", "") ("url", boost::program_options::value<std::string>(), "url") ("interface", boost::program_options::value<std::string>(), "interface") ("buffer-size", boost::program_options::value<unsigned long>(), "buffer-size"); boost::program_options::positional_options_description p; p.add("url", -1); boost::program_options::variables_map vm; boost::program_options::store(boost::program_options::command_line_parser(argc, argv). options(desc).positional(p).run(), vm); boost::program_options::notify(vm); const char* interfaceAddress; if (vm.count("interface")) { interfaceAddress = vm["interface"].as<std::string>().c_str(); } else { interfaceAddress = "0.0.0.0"; } unsigned long bufferSize; if (vm.count("buffer-size")) { bufferSize = vm["buffer-size"].as<unsigned long>(); } else { bufferSize = DEFAULT_SINK_BUFFER_SIZE; } std::cout << "Buffer size " << to_human_readable_byte_count(bufferSize, false, false) << std::endl; rtspClient = RTSPCubemapSourceClient::create(vm["url"].as<std::string>().c_str(), bufferSize, AV_PIX_FMT_RGBA, false, interfaceAddress); std::function<void (RTSPCubemapSourceClient*, CubemapSource*)> callback(boost::bind(&onDidConnect, _1, _2)); rtspClient->setOnDidConnect(callback); rtspClient->connect(); barrier.wait(); Renderer renderer(cubemapSource); renderer.setOnDisplayedCubemapFace(boost::bind(&onDisplayedCubemapFace, _1, _2)); renderer.setOnDisplayedFrame(boost::bind(&onDisplayedFrame, _1)); renderer.start(); // Returns when window is closed CubemapSource::destroy(cubemapSource); }
int main(int argc, char* argv[]) { boost::program_options::options_description desc(""); desc.add_options() ("multicast-address", boost::program_options::value<std::string>(), "") ("interface", boost::program_options::value<std::string>(), "") ("rtsp-port", boost::program_options::value<boost::uint16_t>(), "") ("avg-bit-rate", boost::program_options::value<int>(), "") ("buffer-size", boost::program_options::value<size_t>(), "") ("stats-interval", boost::program_options::value<size_t>(), ""); boost::program_options::variables_map vm; boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm); boost::program_options::notify(vm); if (vm.count("interface")) { std::string interfaceAddress = vm["interface"].as<std::string>(); NetAddressList addresses(interfaceAddress.c_str()); if (addresses.numAddresses() == 0) { std::cout << "Failed to find network address for \"" << interfaceAddress << "\"" << std::endl; return -1; } ReceivingInterfaceAddr = *(unsigned*)(addresses.firstAddress()->data()); } char sourceAddressStr[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &(ReceivingInterfaceAddr), sourceAddressStr, sizeof(sourceAddressStr)); std::cout << "Using source address " << sourceAddressStr << std::endl; if (vm.count("rtsp-port")) { rtspPort = vm["rtsp-port"].as<boost::uint16_t>(); } else { rtspPort = 8555; } std::cout << "Using RTSP port " << rtspPort << std::endl; // Create 'groupsocks' for RTP and RTCP: if(vm.count("multicast-address")) { inet_pton(AF_INET, vm["multicast-address"].as<std::string>().c_str(), &(destinationAddress.s_addr)); } else { inet_pton(AF_INET, "224.0.67.67", &(destinationAddress.s_addr)); } if (vm.count("avg-bit-rate")) { avgBitRate = vm["avg-bit-rate"].as<int>(); } else { avgBitRate = DEFAULT_AVG_BIT_RATE; } std::string bitRateString = to_human_readable_byte_count(avgBitRate, true, false); std::cout << "Using an average encoding bit rate of " << bitRateString << "/s per face" << std::endl; if (vm.count("buffer-size")) { bufferSize = vm["buffer-size"].as<size_t>(); } else { bufferSize = DEFAULT_BUFFER_SIZE; } std::string bufferSizeString = to_human_readable_byte_count(bufferSize, false, false); std::cout << "Using a buffer size of " << bufferSizeString << std::endl; size_t statsInterval; if (vm.count("stats-interval")) { statsInterval = vm["stats-interval"].as<size_t>(); } else { statsInterval = DEFAULT_STATS_INTERVAL; } av_log_set_level(AV_LOG_WARNING); avcodec_register_all(); setupRTSP(); boost::thread networkThread = boost::thread(&networkLoop); Process unityProcess(CUBEMAPEXTRACTIONPLUGIN_ID, false); Process thisProcess(ALLOSERVER_ID, true); while (true) { std::cout << "Waiting for Unity ..." << std::endl; unityProcess.waitForBirth(); std::cout << "Connected to Unity :)" << std::endl; startStreaming(); stats.autoSummary(boost::chrono::seconds(statsInterval), AlloReceiver::statValsMaker, AlloReceiver::postProcessorMaker, AlloReceiver::formatStringMaker); unityProcess.join(); std::cout << "Lost connection to Unity :(" << std::endl; stopStreaming(); stats.stopAutoSummary(); } return 0; }