From 0b27a6ee9ee63ac212d81ce9fb3907c655a00e79 Mon Sep 17 00:00:00 2001 From: Andrea Bondavalli Date: Thu, 4 Jun 2020 10:26:42 -0700 Subject: [PATCH] Minor changes --- daemon/interface.cpp | 12 ++++++------ daemon/mdns_client.cpp | 6 +++--- daemon/rtsp_client.cpp | 19 +++++++++---------- daemon/utils.cpp | 4 ++-- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/daemon/interface.cpp b/daemon/interface.cpp index f2793c2..a288226 100644 --- a/daemon/interface.cpp +++ b/daemon/interface.cpp @@ -31,7 +31,7 @@ std::pair get_interface_ip( if (fd < 0) { BOOST_LOG_TRIVIAL(error) << "Cannot retrieve IP address for interface " << interface_name; - return std::make_pair(0, ""); + return {0, ""}; } struct ifreq ifr; ifr.ifr_addr.sa_family = AF_INET; @@ -40,7 +40,7 @@ std::pair get_interface_ip( close(fd); BOOST_LOG_TRIVIAL(error) << "Cannot retrieve IP address for interface " << interface_name; - return std::make_pair(0, ""); + return {0, ""}; } close(fd); @@ -51,7 +51,7 @@ std::pair get_interface_ip( /*BOOST_LOG_TRIVIAL(debug) << "interface " << interface_name << " IP address " << str_addr;*/ - return std::make_pair(addr, str_addr); + return {addr, str_addr}; } std::pair, std::string> get_interface_mac( @@ -61,7 +61,7 @@ std::pair, std::string> get_interface_mac( if (fd < 0) { BOOST_LOG_TRIVIAL(error) << "Cannot retrieve MAC address for interface " << interface_name; - return std::make_pair(mac, ""); + return {mac, ""}; } struct ifreq ifr; @@ -71,7 +71,7 @@ std::pair, std::string> get_interface_mac( close(fd); BOOST_LOG_TRIVIAL(error) << "Cannot retrieve MAC address for interface " << interface_name; - return std::make_pair(mac, ""); + return {mac, ""}; } close(fd); @@ -84,7 +84,7 @@ std::pair, std::string> get_interface_mac( /*BOOST_LOG_TRIVIAL(debug) << "interface " << interface_name << " MAC address " << str_mac;*/ - return std::make_pair(mac, str_mac); + return {mac, str_mac}; } int get_interface_index(const std::string& interface_name) { diff --git a/daemon/mdns_client.cpp b/daemon/mdns_client.cpp index 79ba3dd..85b2991 100644 --- a/daemon/mdns_client.cpp +++ b/daemon/mdns_client.cpp @@ -109,7 +109,7 @@ void MDNSClient::resolve_callback(AvahiServiceResolver* r, } /* remove the resolver from the active pool */ - mdns.active_resolvers.erase(std::pair(name, domain)); + mdns.active_resolvers.erase({name, domain}); avahi_service_resolver_free(r); } @@ -138,7 +138,7 @@ void MDNSClient::browse_callback(AvahiServiceBrowser* b, << "service " << name << " of type " << type << " in domain " << domain; /* check if a resolver is already running for this name and domain */ - if (mdns.active_resolvers.find(std::pair(name, domain)) != + if (mdns.active_resolvers.find({name, domain}) != mdns.active_resolvers.end()) { /* if already running we don't run a new resolver */ BOOST_LOG_TRIVIAL(info) @@ -154,7 +154,7 @@ void MDNSClient::browse_callback(AvahiServiceBrowser* b, << avahi_strerror(avahi_client_errno(mdns.client_.get())); } else { /* add the resolver to the active pool */ - mdns.active_resolvers.insert(std::pair(name, domain)); + mdns.active_resolvers.insert({name, domain}); } break; diff --git a/daemon/rtsp_client.cpp b/daemon/rtsp_client.cpp index c421c18..c38d99e 100644 --- a/daemon/rtsp_client.cpp +++ b/daemon/rtsp_client.cpp @@ -118,7 +118,7 @@ std::pair RtspClient::process( if (!s) { BOOST_LOG_TRIVIAL(warning) << "rtsp_client:: unable to connect to " << address << ":" << port; - return std::make_pair(false, rtsp_source); + return {false, rtsp_source}; } uint16_t cseq = g_seq_number++; @@ -143,14 +143,14 @@ std::pair RtspClient::process( if (!s || rtsp_version.substr(0, 5) != "RTSP/") { BOOST_LOG_TRIVIAL(error) << "rtsp_client:: invalid response from " << "rtsp://" << address << ":" << port << path; - return std::make_pair(false, rtsp_source); + return {false, rtsp_source}; } if (status_code != 200) { BOOST_LOG_TRIVIAL(error) << "rtsp_client:: response with status code " << status_code << " from " << "rtsp://" << address << ":" << port << path; - return std::make_pair(false, rtsp_source); + return {false, rtsp_source}; } bool is_announce = false; @@ -162,7 +162,7 @@ std::pair RtspClient::process( BOOST_LOG_TRIVIAL(error) << "rtsp_client:: invalid response sequence " << res.cseq << " from rtsp://" << address << ":" << port << path; - return std::make_pair(false, rtsp_source); + return {false, rtsp_source}; } if (!res.content_type.empty() && @@ -171,7 +171,7 @@ std::pair RtspClient::process( << res.content_type << " from " << "rtsp://" << address << ":" << port << path; if (is_describe) { - return std::make_pair(false, rtsp_source); + return {false, rtsp_source}; } } else { std::stringstream ss; @@ -207,9 +207,8 @@ std::pair RtspClient::process( } if (wait_for_updates) { - auto name_domain = std::make_pair(name, domain); g_mutex.lock(); - g_active_clients[name_domain] = &s; + g_active_clients[{name, domain}] = &s; g_mutex.unlock(); /* we start waiting for updates */ @@ -251,19 +250,19 @@ std::pair RtspClient::process( if (wait_for_updates) { std::lock_guard lock(g_mutex); - auto it = g_active_clients.find(std::make_pair(name, domain)); + auto it = g_active_clients.find({name, domain}); if (it != g_active_clients.end() && it->second == &s) { g_active_clients.erase(it); } } - return std::make_pair(true, rtsp_source); + return {true, rtsp_source}; } void RtspClient::stop(const std::string& name, const std::string& domain) { std::lock_guard lock(g_mutex); - auto it = g_active_clients.find(std::make_pair(name, domain)); + auto it = g_active_clients.find({name, domain}); if (it != g_active_clients.end()) { BOOST_LOG_TRIVIAL(info) << "rtsp_client:: stopping client " << name << " " << domain; diff --git a/daemon/utils.cpp b/daemon/utils.cpp index 54f446a..2ff1e79 100644 --- a/daemon/utils.cpp +++ b/daemon/utils.cpp @@ -43,7 +43,7 @@ parse_url(const std::string& _url) { size_t protocol_sep_pos = url.find_first_of("://"); if (protocol_sep_pos == std::string::npos) { /* no protocol, invalid URL */ - return std::make_tuple(false, "", "", "", ""); + return {false, "", "", "", ""}; } std::string port, host, path("/"); @@ -70,7 +70,7 @@ parse_url(const std::string& _url) { /* port and path not specified */ host = url_new; } - return std::make_tuple(host.length() > 0, protocol, host, port, path); + return {host.length() > 0, protocol, host, port, path}; } std::string get_node_id() {