Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add flussonic api for playback & download #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.vscode/
build/
log/
eSDK_IVS_API/
*.mp4
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ build/
log/

IVS_SDK/
external/eSDK_IVS_API/
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "external/spdlog"]
path = external/spdlog
url = https://github.com/gabime/spdlog.git
url = https://github.com/gabime/spdlog.git
[submodule "modules/flussonic/external/cpr"]
path = modules/flussonic/external/cpr
url = https://github.com/whoshuu/cpr.git
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@ endif()
# Add modules
# ----------------------------------------------------------------------------

add_subdirectory(modules/huawei)

# add_subdirectory(modules/huawei)
add_subdirectory(modules/flussonic)
add_subdirectory(modules/api)
12 changes: 9 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ FROM ubuntu:16.04

WORKDIR /app

RUN apt-get update && apt-get install -y build-essential cmake curl libboost-all-dev && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y \
build-essential cmake curl libboost-all-dev \
libssl-dev libcurl4-openssl-dev \
&& rm -rf /var/lib/apt/lists/*

ADD . /app

ENV IVS_SDK_PATH=/app/IVS_SDK
ENV IVS_SDK_PATH=/app/external/eSDK_IVS_API

RUN mkdir /app/build && cd /app/build && cmake .. && cmake --build /app/build --target all --config Release -- -j 10
RUN mkdir /app/build \
&& cd /app/build \
&& cmake -DUSE_SYSTEM_CURL=ON .. \
&& cmake --build /app/build --target all --config Release -- -j 10

EXPOSE 8000

Expand Down
5 changes: 4 additions & 1 deletion modules/api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ file(GLOB hwivs_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)

set(vmsapi_INCLUDE_DIR
${CMAKE_SOURCE_DIR}/external/spdlog/include
${CPR_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/external
${CMAKE_CURRENT_SOURCE_DIR}/../base
${CMAKE_CURRENT_SOURCE_DIR}/../huawei/include
${CMAKE_CURRENT_SOURCE_DIR}/../flussonic/include
$ENV{IVS_SDK_PATH}/inc
)

Expand All @@ -35,7 +37,8 @@ target_include_directories(vmsapi PRIVATE ${vmsapi_INCLUDE_DIR})
target_link_libraries(vmsapi
${CMAKE_THREAD_LIBS_INIT}
${Boost_LIBRARIES}
hwivs
${CPR_LIBRARIES}
flussonic
)

target_compile_options(vmsapi PRIVATE -Wall -Wextra -Wunused-parameter)
Expand Down
8 changes: 1 addition & 7 deletions modules/api/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
#include "IVS_SDK.h"
#include "server.h"

int main() {
IVS_SDK_SetLogPath("./log");
IVS_SDK_Init();

vms::api::Server server;
server.run();

IVS_SDK_Cleanup();

return 0;
}
}
6 changes: 3 additions & 3 deletions modules/api/src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ api::Server::Server() {

void api::Server::run(int port) { _app.port(port).multithreaded().run(); }

std::shared_ptr<vms::hwivs::HuaweiIVS> api::Server::_login(
std::shared_ptr<vms::flussonic::Flussonic> api::Server::_login(
const crow::json::rvalue body) {
const std::string ip = body["ip"].s();
const std::string username = body["username"].s();
const std::string password = body["password"].s();
const std::string vendor = body["vendor"].s();

try {
auto vms = std::make_shared<vms::hwivs::HuaweiIVS>("./log");
vms->login(ip, 9900, username, password);
auto vms = std::make_shared<vms::flussonic::Flussonic>("./log");
vms->login(ip, 8090, username, password);
return vms;
// return session.login(ip, username, password, vendor);
} catch (std::exception) {
Expand Down
3 changes: 2 additions & 1 deletion modules/api/src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define SERVER_H

#include "crow/crow_all.h"
#include "flussonic.h"
#include "hw_ivs.h"
#include "session.h"

Expand All @@ -15,7 +16,7 @@ class Server {
void run(int port = 8000);

private:
static std::shared_ptr<vms::hwivs::HuaweiIVS> _login(
static std::shared_ptr<vms::flussonic::Flussonic> _login(
const crow::json::rvalue body);

static void _camera_list(const crow::request &req, crow::response &res);
Expand Down
3 changes: 1 addition & 2 deletions modules/api/src/session.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <iostream>
#include <stdexcept>

#include "hw_ivs.h"
#include "session.h"

namespace api = vms::api;
Expand Down Expand Up @@ -38,7 +37,7 @@ std::shared_ptr<vms::VMSInterface> api::Session::_create_vendor_vms(
std::shared_ptr<vms::VMSInterface> vms{nullptr};

if (vendor == "huawei") {
vms = std::make_shared<vms::hwivs::HuaweiIVS>("./log");
// vms = std::make_shared<vms::hwivs::HuaweiIVS>("./log");
}

return vms;
Expand Down
5 changes: 5 additions & 0 deletions modules/base/vms_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ class VMSInterface {
const std::string &start_time,
const std::string &end_time) = 0;

virtual std::string download(const std::string &camera_code,
const std::string &nvr_code,
const std::string &start_time,
const std::string &end_time) = 0;

virtual std::string live_stream(const std::string &camera_code,
const std::string &nvr_code,
const std::string &transport) = 0;
Expand Down
28 changes: 28 additions & 0 deletions modules/flussonic/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
cmake_minimum_required(VERSION 3.0.0)
project(flussonic VERSION 0.1.0)

add_subdirectory(external/cpr)

# ----------------------------------------------------------------------------
# Target definition
# ----------------------------------------------------------------------------

file(GLOB flussonic_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)

set(flussonic_INCLUDE_DIR
${CPR_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/external/spdlog/include
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/../base
)

add_library(flussonic ${flussonic_SRC})

target_include_directories(flussonic PRIVATE ${flussonic_INCLUDE_DIR})

target_link_libraries(flussonic
${CPR_LIBRARIES}
)

target_compile_options(flussonic PRIVATE -Wall -Wextra -Wunused-parameter)
set_property(TARGET flussonic PROPERTY CXX_STANDARD 14)
63 changes: 63 additions & 0 deletions modules/flussonic/include/flussonic.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#ifndef FLUSSONIC_H
#define FLUSSONIC_H

#include <ctime>
#include "vms_interface.h"

namespace vms {
namespace flussonic {
class Flussonic : public VMSInterface {
public:
Flussonic(const std::string &log_path);

void login(const std::string &ip, unsigned int port,
const std::string &username, const std::string &password) override;

void logout() override;

int session_id() override;

std::vector<Device> nvr_list(unsigned int max) override;

std::vector<Device> camera_list(unsigned int max) override;

std::vector<Record> recording_list(const std::string &camera_code,
const std::string &start_time,
const std::string &end_time,
unsigned int max) override;

std::string playback(const std::string &camera_code,
const std::string &nvr_code,
const std::string &start_time,
const std::string &end_time) override;

std::string download(const std::string &camera_code,
const std::string &nvr_code,
const std::string &start_time,
const std::string &end_time) override;

std::string live_stream(const std::string &camera_code,
const std::string &nvr_code,
const std::string &transport) override;

std::string create_url(const std::string &_ip, const std::string &camera_code,
const std::string &start_time,
const std::string &end_time);

std::time_t to_unix_timestamp(const std::string &timestamp);

bool status_stream(const std::string &_ip, const unsigned int &_port,
const std::string &camera_code);

bool to_bool(std::string str);

private:
int _session_id;
bool _logged_in;
std::string _ip, _id, _pass;
unsigned int _port;
};
} // namespace flussonic
} // namespace vms

#endif
Loading