v1.0.2 - Fix issues with MySQL CM
This commit is contained in:
+1
-1
@@ -23,7 +23,7 @@ message ("Here")
|
|||||||
|
|
||||||
set (${PROJECT_NAME}_VERSION_MAJOR 1)
|
set (${PROJECT_NAME}_VERSION_MAJOR 1)
|
||||||
set (${PROJECT_NAME}_VERSION_MINOR 0)
|
set (${PROJECT_NAME}_VERSION_MINOR 0)
|
||||||
set (${PROJECT_NAME}_VERSION_PATCH 1)
|
set (${PROJECT_NAME}_VERSION_PATCH 2)
|
||||||
set (${PROJECT_NAME}_SUFFIX "-beta")
|
set (${PROJECT_NAME}_SUFFIX "-beta")
|
||||||
set (${PROJECT_NAME}_VERSION "${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH}${${PROJECT_NAME}_SUFFIX}")
|
set (${PROJECT_NAME}_VERSION "${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH}${${PROJECT_NAME}_SUFFIX}")
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
## An RTSP surveillance camera access multitool
|
## An RTSP surveillance camera access multitool
|
||||||
|
|
||||||
[](#license)
|
[](#license)
|
||||||
[](https://github.com/EtixLabs/cameradar/releases/latest)
|
[](https://github.com/EtixLabs/cameradar/releases/latest)
|
||||||
|
|
||||||
|
|
||||||
#### Cameradar allows you to:
|
#### Cameradar allows you to:
|
||||||
|
|||||||
@@ -149,28 +149,33 @@ void
|
|||||||
mysql_cache_manager::set_streams(std::vector<etix::cameradar::stream_model> models) {
|
mysql_cache_manager::set_streams(std::vector<etix::cameradar::stream_model> models) {
|
||||||
LOG_DEBUG_("Beginning stream list DB insertion", "mysql_cache_manager");
|
LOG_DEBUG_("Beginning stream list DB insertion", "mysql_cache_manager");
|
||||||
for (const auto& model : models) {
|
for (const auto& model : models) {
|
||||||
auto query = tool::fmt(
|
if (!model.service_name.compare("rtsp") && !model.state.compare("open")) {
|
||||||
this->exist_query, this->connection.get_db_name().c_str(), model.address.c_str());
|
auto query = tool::fmt(
|
||||||
auto result = this->connection.query(query);
|
this->exist_query, this->connection.get_db_name().c_str(), model.address.c_str());
|
||||||
// If an entry already exists for this address in the database,
|
auto result = this->connection.query(query);
|
||||||
// no need to insert it.
|
// If an entry already exists for this address in the database,
|
||||||
if (result.data->next()) return;
|
// no need to insert it.
|
||||||
|
|
||||||
query = tool::fmt(this->insert_with_id_query,
|
// TODO : Update an entry if it already exists.
|
||||||
this->connection.get_db_name().c_str(),
|
|
||||||
model.address.c_str(),
|
if (result.data->next()) return;
|
||||||
model.password.c_str(),
|
|
||||||
model.product.c_str(),
|
query = tool::fmt(this->insert_with_id_query,
|
||||||
model.protocol.c_str(),
|
this->connection.get_db_name().c_str(),
|
||||||
model.route.c_str(),
|
model.address.c_str(),
|
||||||
model.service_name.c_str(),
|
model.password.c_str(),
|
||||||
model.state.c_str(),
|
model.product.c_str(),
|
||||||
model.thumbnail_path.c_str(),
|
model.protocol.c_str(),
|
||||||
model.username.c_str(),
|
model.route.c_str(),
|
||||||
std::to_string(model.port).c_str(),
|
model.service_name.c_str(),
|
||||||
std::to_string(model.ids_found).c_str(),
|
model.state.c_str(),
|
||||||
std::to_string(model.path_found).c_str());
|
model.thumbnail_path.c_str(),
|
||||||
execute_query(query);
|
model.username.c_str(),
|
||||||
|
std::to_string(model.port).c_str(),
|
||||||
|
std::to_string(model.ids_found).c_str(),
|
||||||
|
std::to_string(model.path_found).c_str());
|
||||||
|
execute_query(query);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,6 +224,18 @@ mysql_cache_manager::get_streams() {
|
|||||||
result.data->getString("state"), result.data->getBoolean("ids_found"),
|
result.data->getString("state"), result.data->getBoolean("ids_found"),
|
||||||
result.data->getBoolean("path_found"), result.data->getString("thumbnail_path")
|
result.data->getBoolean("path_found"), result.data->getString("thumbnail_path")
|
||||||
};
|
};
|
||||||
|
LOG_DEBUG_("Got a result whose address was " + s.address, "mysql_cache_manager");
|
||||||
|
LOG_DEBUG_("Got a result whose port was " + std::to_string(s.port), "mysql_cache_manager");
|
||||||
|
LOG_DEBUG_("Got a result whose username was " + s.username, "mysql_cache_manager");
|
||||||
|
LOG_DEBUG_("Got a result whose password was " + s.password, "mysql_cache_manager");
|
||||||
|
LOG_DEBUG_("Got a result whose route was " + s.route, "mysql_cache_manager");
|
||||||
|
LOG_DEBUG_("Got a result whose service name was " + s.service_name, "mysql_cache_manager");
|
||||||
|
LOG_DEBUG_("Got a result whose product was " + s.product, "mysql_cache_manager");
|
||||||
|
LOG_DEBUG_("Got a result whose protocol was " + s.protocol, "mysql_cache_manager");
|
||||||
|
LOG_DEBUG_("Got a result whose state was " + s.state, "mysql_cache_manager");
|
||||||
|
LOG_DEBUG_("Got a result whose ids found was " + std::to_string(s.ids_found), "mysql_cache_manager");
|
||||||
|
LOG_DEBUG_("Got a result whose path found was " + std::to_string(s.path_found), "mysql_cache_manager");
|
||||||
|
LOG_DEBUG_("Got a result whose thumbnail was " + s.thumbnail_path, "mysql_cache_manager");
|
||||||
lst.push_back(s);
|
lst.push_back(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,16 +42,16 @@ brutelogs::test_ids(const etix::cameradar::stream_model& stream,
|
|||||||
LOG_DEBUG_("[FOUND IDS] : " + path, "brutelogs");
|
LOG_DEBUG_("[FOUND IDS] : " + path, "brutelogs");
|
||||||
found = true;
|
found = true;
|
||||||
stream_model newstream{
|
stream_model newstream{
|
||||||
stream.address, stream.port, username, password,
|
stream.address, stream.port, username, password,
|
||||||
stream.route, stream.service_name, stream.product, stream.protocol,
|
stream.route, stream.service_name, stream.product, stream.protocol,
|
||||||
stream.state, stream.path_found, true, stream.thumbnail_path
|
stream.state, true, stream.path_found, stream.thumbnail_path
|
||||||
};
|
};
|
||||||
(*cache)->update_stream(newstream);
|
(*cache)->update_stream(newstream);
|
||||||
} else {
|
} else {
|
||||||
stream_model newstream{ stream.address, stream.port, username,
|
stream_model newstream{ stream.address, stream.port, username,
|
||||||
password, stream.route, stream.service_name,
|
password, stream.route, stream.service_name,
|
||||||
stream.product, stream.protocol, stream.state,
|
stream.product, stream.protocol, stream.state,
|
||||||
stream.path_found, false, stream.thumbnail_path };
|
false, stream.path_found, stream.thumbnail_path };
|
||||||
(*cache)->update_stream(newstream);
|
(*cache)->update_stream(newstream);
|
||||||
}
|
}
|
||||||
} catch (const std::runtime_error& e) {
|
} catch (const std::runtime_error& e) {
|
||||||
@@ -77,6 +77,7 @@ brutelogs::run() const {
|
|||||||
"take a while.",
|
"take a while.",
|
||||||
"brutelogs");
|
"brutelogs");
|
||||||
std::vector<etix::cameradar::stream_model> streams = (*cache)->get_streams();
|
std::vector<etix::cameradar::stream_model> streams = (*cache)->get_streams();
|
||||||
|
LOG_DEBUG_("Found " + std::to_string(streams.size()) + " streams in the cache", "brutelogs");
|
||||||
bool doubleskip;
|
bool doubleskip;
|
||||||
size_t found = 0;
|
size_t found = 0;
|
||||||
for (const auto& stream : streams) {
|
for (const auto& stream : streams) {
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ static const std::string no_hosts_found_ =
|
|||||||
//! Avoids segfaults on unknown xml structure
|
//! Avoids segfaults on unknown xml structure
|
||||||
std::string
|
std::string
|
||||||
xml_safe_get(const TiXmlElement* elem, const std::string& attr) {
|
xml_safe_get(const TiXmlElement* elem, const std::string& attr) {
|
||||||
if (elem == nullptr) return "Closed";
|
if (elem == nullptr) return "closed";
|
||||||
if (elem->Attribute(attr.c_str()) != nullptr) return std::string(elem->Attribute(attr.c_str()));
|
if (elem->Attribute(attr.c_str()) != nullptr) return std::string(elem->Attribute(attr.c_str()));
|
||||||
return "Closed";
|
return "closed";
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Parse a single host node (generally containing only one camera)
|
//! Parse a single host node (generally containing only one camera)
|
||||||
@@ -51,8 +51,8 @@ parsing::parse_camera(TiXmlElement* xml_host, std::vector<stream_model>& data) c
|
|||||||
stream.service_name = xml_safe_get(service, "name");
|
stream.service_name = xml_safe_get(service, "name");
|
||||||
stream.product = xml_safe_get(service, "product");
|
stream.product = xml_safe_get(service, "product");
|
||||||
} else {
|
} else {
|
||||||
stream.service_name = "Closed";
|
stream.service_name = "closed";
|
||||||
stream.product = "Closed";
|
stream.product = "closed";
|
||||||
}
|
}
|
||||||
data.push_back(stream);
|
data.push_back(stream);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ stream_check::run() const {
|
|||||||
|
|
||||||
std::vector<stream_model> streams = (*cache)->get_valid_streams();
|
std::vector<stream_model> streams = (*cache)->get_valid_streams();
|
||||||
|
|
||||||
|
if (not streams.size()) {
|
||||||
|
LOG_WARN_("There were no valid streams to check. Cameradar will stop.", "stream_check");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
for (const auto& stream : streams) {
|
for (const auto& stream : streams) {
|
||||||
GError* error = NULL;
|
GError* error = NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,12 @@ bool
|
|||||||
thumbnail::run() const {
|
thumbnail::run() const {
|
||||||
std::vector<stream_model> streams = (*cache)->get_valid_streams();
|
std::vector<stream_model> streams = (*cache)->get_valid_streams();
|
||||||
LOG_INFO_("Started thumbnail generation, it may take a while", "thumbnail");
|
LOG_INFO_("Started thumbnail generation, it may take a while", "thumbnail");
|
||||||
|
if (not streams.size()) {
|
||||||
|
LOG_WARN_("There were no valid streams to generate thumbnails from. Cameradar will stop.", "thumbnail_generation");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
for (const auto& stream : streams) {
|
for (const auto& stream : streams) {
|
||||||
|
LOG_DEBUG_("Generating thumbnail for " + stream.address, "thumbnail_generation");
|
||||||
if (signal_handler::instance().should_stop() != etix::cameradar::stop_priority::running)
|
if (signal_handler::instance().should_stop() != etix::cameradar::stop_priority::running)
|
||||||
break;
|
break;
|
||||||
std::string ffmpeg_cmd =
|
std::string ffmpeg_cmd =
|
||||||
|
|||||||
Reference in New Issue
Block a user