#include "HIKBase.h"
#include <memory>
#include <cstring>
#include <chrono>

HIKBase::HIKBase()
{
    memset(&DeviceInfo, 0, sizeof(DeviceInfo));
}


HIKBase::~HIKBase() = default;

int HIKBase::Login(std::string ip, std::string port, std::string username, std::string password)
{
    Ip = ip;
    Port = port;
    Username = username;
    Password = password;

    LoginID = NET_DVR_Login_V30((char *)Ip.c_str(), atoi(Port.c_str()), (char *)Username.c_str(), (char *)Password.c_str(), &DeviceInfo);
    std::cout << LoginID <<std::endl;
    return LoginID;
}

void HIKBase::Logout()
{
    if (LoginID >= 0)
    {
        NET_DVR_Logout(LoginID);
        LoginID = -1;
    }
}

bool HK_DVR_Init(){
    return NET_DVR_Init();
}