Minor changes
This commit is contained in:
parent
6a025c1e7a
commit
0b27a6ee9e
@ -31,7 +31,7 @@ std::pair<uint32_t, std::string> get_interface_ip(
|
|||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
BOOST_LOG_TRIVIAL(error)
|
BOOST_LOG_TRIVIAL(error)
|
||||||
<< "Cannot retrieve IP address for interface " << interface_name;
|
<< "Cannot retrieve IP address for interface " << interface_name;
|
||||||
return std::make_pair(0, "");
|
return {0, ""};
|
||||||
}
|
}
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
ifr.ifr_addr.sa_family = AF_INET;
|
ifr.ifr_addr.sa_family = AF_INET;
|
||||||
@ -40,7 +40,7 @@ std::pair<uint32_t, std::string> get_interface_ip(
|
|||||||
close(fd);
|
close(fd);
|
||||||
BOOST_LOG_TRIVIAL(error)
|
BOOST_LOG_TRIVIAL(error)
|
||||||
<< "Cannot retrieve IP address for interface " << interface_name;
|
<< "Cannot retrieve IP address for interface " << interface_name;
|
||||||
return std::make_pair(0, "");
|
return {0, ""};
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ std::pair<uint32_t, std::string> get_interface_ip(
|
|||||||
/*BOOST_LOG_TRIVIAL(debug) << "interface " << interface_name
|
/*BOOST_LOG_TRIVIAL(debug) << "interface " << interface_name
|
||||||
<< " IP address " << str_addr;*/
|
<< " IP address " << str_addr;*/
|
||||||
|
|
||||||
return std::make_pair(addr, str_addr);
|
return {addr, str_addr};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<std::array<uint8_t, 6>, std::string> get_interface_mac(
|
std::pair<std::array<uint8_t, 6>, std::string> get_interface_mac(
|
||||||
@ -61,7 +61,7 @@ std::pair<std::array<uint8_t, 6>, std::string> get_interface_mac(
|
|||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
BOOST_LOG_TRIVIAL(error)
|
BOOST_LOG_TRIVIAL(error)
|
||||||
<< "Cannot retrieve MAC address for interface " << interface_name;
|
<< "Cannot retrieve MAC address for interface " << interface_name;
|
||||||
return std::make_pair(mac, "");
|
return {mac, ""};
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
@ -71,7 +71,7 @@ std::pair<std::array<uint8_t, 6>, std::string> get_interface_mac(
|
|||||||
close(fd);
|
close(fd);
|
||||||
BOOST_LOG_TRIVIAL(error)
|
BOOST_LOG_TRIVIAL(error)
|
||||||
<< "Cannot retrieve MAC address for interface " << interface_name;
|
<< "Cannot retrieve MAC address for interface " << interface_name;
|
||||||
return std::make_pair(mac, "");
|
return {mac, ""};
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ std::pair<std::array<uint8_t, 6>, std::string> get_interface_mac(
|
|||||||
/*BOOST_LOG_TRIVIAL(debug) << "interface " << interface_name
|
/*BOOST_LOG_TRIVIAL(debug) << "interface " << interface_name
|
||||||
<< " MAC address " << str_mac;*/
|
<< " MAC address " << str_mac;*/
|
||||||
|
|
||||||
return std::make_pair(mac, str_mac);
|
return {mac, str_mac};
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_interface_index(const std::string& interface_name) {
|
int get_interface_index(const std::string& interface_name) {
|
||||||
|
@ -109,7 +109,7 @@ void MDNSClient::resolve_callback(AvahiServiceResolver* r,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* remove the resolver from the active pool */
|
/* 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);
|
avahi_service_resolver_free(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ void MDNSClient::browse_callback(AvahiServiceBrowser* b,
|
|||||||
<< "service " << name << " of type " << type
|
<< "service " << name << " of type " << type
|
||||||
<< " in domain " << domain;
|
<< " in domain " << domain;
|
||||||
/* check if a resolver is already running for this name and 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()) {
|
mdns.active_resolvers.end()) {
|
||||||
/* if already running we don't run a new resolver */
|
/* if already running we don't run a new resolver */
|
||||||
BOOST_LOG_TRIVIAL(info)
|
BOOST_LOG_TRIVIAL(info)
|
||||||
@ -154,7 +154,7 @@ void MDNSClient::browse_callback(AvahiServiceBrowser* b,
|
|||||||
<< avahi_strerror(avahi_client_errno(mdns.client_.get()));
|
<< avahi_strerror(avahi_client_errno(mdns.client_.get()));
|
||||||
} else {
|
} else {
|
||||||
/* add the resolver to the active pool */
|
/* add the resolver to the active pool */
|
||||||
mdns.active_resolvers.insert(std::pair(name, domain));
|
mdns.active_resolvers.insert({name, domain});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ std::pair<bool, RtspSource> RtspClient::process(
|
|||||||
if (!s) {
|
if (!s) {
|
||||||
BOOST_LOG_TRIVIAL(warning)
|
BOOST_LOG_TRIVIAL(warning)
|
||||||
<< "rtsp_client:: unable to connect to " << address << ":" << port;
|
<< "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++;
|
uint16_t cseq = g_seq_number++;
|
||||||
@ -143,14 +143,14 @@ std::pair<bool, RtspSource> RtspClient::process(
|
|||||||
if (!s || rtsp_version.substr(0, 5) != "RTSP/") {
|
if (!s || rtsp_version.substr(0, 5) != "RTSP/") {
|
||||||
BOOST_LOG_TRIVIAL(error) << "rtsp_client:: invalid response from "
|
BOOST_LOG_TRIVIAL(error) << "rtsp_client:: invalid response from "
|
||||||
<< "rtsp://" << address << ":" << port << path;
|
<< "rtsp://" << address << ":" << port << path;
|
||||||
return std::make_pair(false, rtsp_source);
|
return {false, rtsp_source};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status_code != 200) {
|
if (status_code != 200) {
|
||||||
BOOST_LOG_TRIVIAL(error) << "rtsp_client:: response with status code "
|
BOOST_LOG_TRIVIAL(error) << "rtsp_client:: response with status code "
|
||||||
<< status_code << " from "
|
<< status_code << " from "
|
||||||
<< "rtsp://" << address << ":" << port << path;
|
<< "rtsp://" << address << ":" << port << path;
|
||||||
return std::make_pair(false, rtsp_source);
|
return {false, rtsp_source};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_announce = false;
|
bool is_announce = false;
|
||||||
@ -162,7 +162,7 @@ std::pair<bool, RtspSource> RtspClient::process(
|
|||||||
BOOST_LOG_TRIVIAL(error)
|
BOOST_LOG_TRIVIAL(error)
|
||||||
<< "rtsp_client:: invalid response sequence " << res.cseq
|
<< "rtsp_client:: invalid response sequence " << res.cseq
|
||||||
<< " from rtsp://" << address << ":" << port << path;
|
<< " from rtsp://" << address << ":" << port << path;
|
||||||
return std::make_pair(false, rtsp_source);
|
return {false, rtsp_source};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!res.content_type.empty() &&
|
if (!res.content_type.empty() &&
|
||||||
@ -171,7 +171,7 @@ std::pair<bool, RtspSource> RtspClient::process(
|
|||||||
<< res.content_type << " from "
|
<< res.content_type << " from "
|
||||||
<< "rtsp://" << address << ":" << port << path;
|
<< "rtsp://" << address << ":" << port << path;
|
||||||
if (is_describe) {
|
if (is_describe) {
|
||||||
return std::make_pair(false, rtsp_source);
|
return {false, rtsp_source};
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
@ -207,9 +207,8 @@ std::pair<bool, RtspSource> RtspClient::process(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wait_for_updates) {
|
if (wait_for_updates) {
|
||||||
auto name_domain = std::make_pair(name, domain);
|
|
||||||
g_mutex.lock();
|
g_mutex.lock();
|
||||||
g_active_clients[name_domain] = &s;
|
g_active_clients[{name, domain}] = &s;
|
||||||
g_mutex.unlock();
|
g_mutex.unlock();
|
||||||
|
|
||||||
/* we start waiting for updates */
|
/* we start waiting for updates */
|
||||||
@ -251,19 +250,19 @@ std::pair<bool, RtspSource> RtspClient::process(
|
|||||||
|
|
||||||
if (wait_for_updates) {
|
if (wait_for_updates) {
|
||||||
std::lock_guard<std::mutex> lock(g_mutex);
|
std::lock_guard<std::mutex> 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) {
|
if (it != g_active_clients.end() && it->second == &s) {
|
||||||
g_active_clients.erase(it);
|
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) {
|
void RtspClient::stop(const std::string& name, const std::string& domain) {
|
||||||
std::lock_guard<std::mutex> lock(g_mutex);
|
std::lock_guard<std::mutex> 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()) {
|
if (it != g_active_clients.end()) {
|
||||||
BOOST_LOG_TRIVIAL(info)
|
BOOST_LOG_TRIVIAL(info)
|
||||||
<< "rtsp_client:: stopping client " << name << " " << domain;
|
<< "rtsp_client:: stopping client " << name << " " << domain;
|
||||||
|
@ -43,7 +43,7 @@ parse_url(const std::string& _url) {
|
|||||||
size_t protocol_sep_pos = url.find_first_of("://");
|
size_t protocol_sep_pos = url.find_first_of("://");
|
||||||
if (protocol_sep_pos == std::string::npos) {
|
if (protocol_sep_pos == std::string::npos) {
|
||||||
/* no protocol, invalid URL */
|
/* no protocol, invalid URL */
|
||||||
return std::make_tuple(false, "", "", "", "");
|
return {false, "", "", "", ""};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string port, host, path("/");
|
std::string port, host, path("/");
|
||||||
@ -70,7 +70,7 @@ parse_url(const std::string& _url) {
|
|||||||
/* port and path not specified */
|
/* port and path not specified */
|
||||||
host = url_new;
|
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() {
|
std::string get_node_id() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user