Minor changes to code indentation
This commit is contained in:
parent
7f2bd7f4f0
commit
e7cfaa1d99
27
daemon/rtsp_client.cpp
Executable file → Normal file
27
daemon/rtsp_client.cpp
Executable file → Normal file
@ -21,13 +21,13 @@
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
#include <chrono>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <istream>
|
||||
#include <map>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
#include <map>
|
||||
|
||||
#include "log.hpp"
|
||||
#include "utils.hpp"
|
||||
@ -37,7 +37,6 @@ using namespace boost::asio;
|
||||
using namespace boost::asio::ip;
|
||||
using namespace boost::algorithm;
|
||||
|
||||
|
||||
struct RtspResponse {
|
||||
int32_t cseq{-1};
|
||||
std::string content_type;
|
||||
@ -101,8 +100,7 @@ RtspResponse read_response(tcp::iostream& s, uint16_t max_length) {
|
||||
return res;
|
||||
}
|
||||
|
||||
std::pair<bool, RtspSource> RtspClient::process(
|
||||
RtspClient::Observer callback,
|
||||
std::pair<bool, RtspSource> RtspClient::process(RtspClient::Observer callback,
|
||||
const std::string& name,
|
||||
const std::string& domain,
|
||||
const std::string& path,
|
||||
@ -178,7 +176,8 @@ std::pair<bool, RtspSource> RtspClient::process(
|
||||
ss << "rtsp:" << std::hex
|
||||
<< crc16(reinterpret_cast<const uint8_t*>(res.body.c_str()),
|
||||
res.body.length());
|
||||
/*<< std::hex << ip::address_v4::from_string(address.c_str()).to_ulong();*/
|
||||
/*<< std::hex <<
|
||||
* ip::address_v4::from_string(address.c_str()).to_ulong();*/
|
||||
rtsp_source.id = ss.str();
|
||||
rtsp_source.source = "mDNS";
|
||||
rtsp_source.address = address;
|
||||
@ -216,8 +215,8 @@ std::pair<bool, RtspSource> RtspClient::process(
|
||||
std::getline(s, request);
|
||||
} while (request.empty() && !s.error());
|
||||
if (s.error()) {
|
||||
BOOST_LOG_TRIVIAL(info) << "rtsp_client:: end: "
|
||||
<< s.error().message();
|
||||
BOOST_LOG_TRIVIAL(info)
|
||||
<< "rtsp_client:: end: " << s.error().message();
|
||||
break;
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << "rtsp_client:: received " << request;
|
||||
@ -234,8 +233,8 @@ std::pair<bool, RtspSource> RtspClient::process(
|
||||
auto path = std::get<4>(res);
|
||||
if (path.rfind("/by-name/") != std::string::npos) {
|
||||
announced_name = path.substr(9);
|
||||
BOOST_LOG_TRIVIAL(debug) << "rtsp_client:: found announced name "
|
||||
<< announced_name;
|
||||
BOOST_LOG_TRIVIAL(debug)
|
||||
<< "rtsp_client:: found announced name " << announced_name;
|
||||
}
|
||||
}
|
||||
is_announce = true;
|
||||
@ -259,7 +258,6 @@ std::pair<bool, RtspSource> RtspClient::process(
|
||||
return {true, rtsp_source};
|
||||
}
|
||||
|
||||
|
||||
void RtspClient::stop(const std::string& name, const std::string& domain) {
|
||||
std::lock_guard<std::mutex> lock(g_mutex);
|
||||
auto it = g_active_clients.find({name, domain});
|
||||
@ -279,8 +277,7 @@ void RtspClient::stop_all() {
|
||||
std::lock_guard<std::mutex> lock(g_mutex);
|
||||
auto it = g_active_clients.begin();
|
||||
while (it != g_active_clients.end()) {
|
||||
BOOST_LOG_TRIVIAL(info)
|
||||
<< "rtsp_client:: stopping client "
|
||||
BOOST_LOG_TRIVIAL(info) << "rtsp_client:: stopping client "
|
||||
<< it->first.first << " " << it->first.second;
|
||||
#if BOOST_VERSION < 106600
|
||||
it->second->close();
|
||||
@ -291,10 +288,8 @@ void RtspClient::stop_all() {
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<bool, RtspSource> RtspClient::describe(
|
||||
const std::string& path,
|
||||
std::pair<bool, RtspSource> RtspClient::describe(const std::string& path,
|
||||
const std::string& address,
|
||||
const std::string& port) {
|
||||
return RtspClient::process({}, {}, {}, path, address, port, false);
|
||||
}
|
||||
|
||||
|
@ -20,8 +20,8 @@
|
||||
#ifndef _RTSP_CLIENT_HPP_
|
||||
#define _RTSP_CLIENT_HPP_
|
||||
|
||||
#include <mutex>
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
#include <mutex>
|
||||
|
||||
struct RtspSource {
|
||||
std::string id;
|
||||
@ -36,13 +36,11 @@ class RtspClient {
|
||||
constexpr static uint16_t client_timeout = 10; // sec
|
||||
constexpr static const char dft_port[] = "554";
|
||||
|
||||
using Observer = std::function<void(
|
||||
const std::string& name,
|
||||
using Observer = std::function<void(const std::string& name,
|
||||
const std::string& domain,
|
||||
const RtspSource& source)>;
|
||||
|
||||
static std::pair<bool, RtspSource> process(
|
||||
Observer callback,
|
||||
static std::pair<bool, RtspSource> process(Observer callback,
|
||||
const std::string& name,
|
||||
const std::string& domain,
|
||||
const std::string& path,
|
||||
@ -59,10 +57,11 @@ class RtspClient {
|
||||
const std::string& port = dft_port);
|
||||
|
||||
inline static std::atomic<uint16_t> g_seq_number{0};
|
||||
inline static std::map<std::pair<std::string /*name*/, std::string /*domain*/>,
|
||||
boost::asio::ip::tcp::iostream* /*stream*/> g_active_clients;
|
||||
inline static std::map<
|
||||
std::pair<std::string /*name*/, std::string /*domain*/>,
|
||||
boost::asio::ip::tcp::iostream* /*stream*/>
|
||||
g_active_clients;
|
||||
inline static std::mutex g_mutex;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user