Initial commit

This commit is contained in:
Brendan LE GLAUNEC
2016-05-20 13:43:28 +02:00
committed by Brendan LE GLAUNEC
parent 2af5f4475e
commit 201d7e31c6
88 changed files with 17719 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
## Copyright 2016 Etix Labs
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
cmake_minimum_required (VERSION 2.8.1)
cmake_policy(SET CMP0042 NEW)
# set temporarly the ouput path for all server plugins
set (LIBRARY_OUTPUT_PATH ${CCTV_CAMERA_MANAGER_OUTPUT_PATH})
add_subdirectory(dumb_cache_manager)
set (CCTV_CACHE_MANAGERS ${CCTV_CACHE_MANAGERS} PARENT_SCOPE)
@@ -0,0 +1,34 @@
## Copyright 2016 Etix Labs
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
cmake_minimum_required (VERSION 2.8.1)
cmake_policy(SET CMP0042 NEW)
project(dumb_cache_manager CXX)
find_package(PkgConfig)
include_directories (${PROJECT_SOURCE_DIR}/include ${CAMERADAR_INCLUDES})
message("${CAMERADAR_INCLUDES}")
include (find_sources)
find_sources ("src" "include")
add_library (dumb_cache_manager SHARED ${SOURCES})
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined")
target_link_libraries (dumb_cache_manager)
set (CACHE_MANAGER_NAME ${CAMERADAR_CACHE_MANAGER_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}dumb_cache_manager{CMAKE_SHARED_LIBRARY_SUFFIX})
list (APPEND CAMERADAR_CACHE_MANAGERS ${CACHE_MANAGER_NAME})
set (CAMERADAR_CACHE_MANAGERS ${CAMERADAR_CACHE_MANAGERS} PARENT_SCOPE)
@@ -0,0 +1,50 @@
// Copyright 2016 Etix Labs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <vector>
#include <cachemanager.h>
#include <stream_model.h>
#include <configuration.h>
#include <logger.h>
namespace etix {
namespace cameradar {
class dumb_cache_manager : public cache_manager_base {
private:
static const std::string name;
std::vector<etix::cameradar::stream_model> streams;
std::shared_ptr<etix::cameradar::configuration> configuration;
public:
using cache_manager_base::cache_manager_base;
~dumb_cache_manager();
const std::string& get_name() const override;
static const std::string& static_get_name();
bool load_dumb_conf(std::shared_ptr<etix::cameradar::configuration> configuration);
bool configure(std::shared_ptr<etix::cameradar::configuration> configuration) override;
void set_streams(std::vector<etix::cameradar::stream_model> model);
void update_stream(const etix::cameradar::stream_model& newmodel);
std::vector<etix::cameradar::stream_model> get_streams() const;
std::vector<etix::cameradar::stream_model> get_valid_streams() const;
};
}
}
@@ -0,0 +1,90 @@
// Copyright 2016 Etix Labs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <dumb_cache_manager.h>
namespace etix {
namespace cameradar {
const std::string dumb_cache_manager::name = "dumb-cache-manager";
dumb_cache_manager::~dumb_cache_manager() {}
const std::string&
dumb_cache_manager::get_name() const {
return dumb_cache_manager::static_get_name();
}
const std::string&
dumb_cache_manager::static_get_name() {
return dumb_cache_manager::name;
}
bool
dumb_cache_manager::configure(std::shared_ptr<etix::cameradar::configuration> configuration) {
return this->load_dumb_conf(configuration);
}
bool
dumb_cache_manager::load_dumb_conf(std::shared_ptr<etix::cameradar::configuration> configuration) {
this->configuration = configuration;
return true;
}
//! Replaces all cached streams by the content of the vector given as
//! parameter
void
dumb_cache_manager::set_streams(std::vector<etix::cameradar::stream_model> model) {
this->streams = model;
}
//! Inserts a single stream to the cache
void
dumb_cache_manager::update_stream(const etix::cameradar::stream_model& newmodel) {
for (auto& it : this->streams) {
if (it.address == newmodel.address && it.port == newmodel.port) { it = newmodel; }
}
}
//! Gets all cached streams
std::vector<etix::cameradar::stream_model>
dumb_cache_manager::get_streams() const {
std::vector<stream_model> ret;
for (const auto& it : this->streams) {
if (not it.service_name.compare("rtsp") && not it.state.compare("open")) ret.push_back(it);
}
return ret;
}
//! Gets all valid streams
std::vector<etix::cameradar::stream_model>
dumb_cache_manager::get_valid_streams() const {
std::vector<stream_model> ret;
for (const auto& it : this->streams) {
if ((not it.service_name.compare("rtsp") && not it.state.compare("open")) && it.ids_found &&
it.path_found)
ret.push_back(it);
}
return ret;
}
extern "C" {
cache_manager_iface*
cache_manager_instance_new() {
return new dumb_cache_manager();
}
}
}
}