Initial commit
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
#include "VStarCamRecorder.h"
|
||||
#include "Util.h"
|
||||
#include <HttpClient.h>
|
||||
#include <Logging.h>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
|
||||
namespace CameraRecorder {
|
||||
namespace Recorder {
|
||||
|
||||
VStarCamRecorder::VStarCamRecorder(Http::HttpClient* pHttpClient, const Settings& settings) :
|
||||
m_pHttpClient(pHttpClient),
|
||||
m_settings(settings)
|
||||
{
|
||||
}
|
||||
|
||||
VStarCamRecorder::~VStarCamRecorder()
|
||||
{
|
||||
}
|
||||
|
||||
std::string VStarCamRecorder::Snapshot(ctpl::thread_pool* pThreadPool)
|
||||
{
|
||||
Logging::Log(Logging::Severity::Debug, "VStarCamRecorder Snapshot");
|
||||
std::stringstream url;
|
||||
url << "http://" << m_settings.Username << ":" << m_settings.Password << "@" << m_settings.IpAddress << ":" << m_settings.Port << "/img/snapshot.cgi?res=0";
|
||||
|
||||
std::stringstream fileName;
|
||||
fileName << m_settings.Path << "/" << m_settings.IpAddress << "/VSTA000000XXXXX_0_" << GetDateTimeString(true);
|
||||
|
||||
int i = 0;
|
||||
while (i < 3)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::ofstream file(fileName.str() + "_" + std::to_string(i) + ".jpg");
|
||||
file << m_pHttpClient->GetUrlContents(url.str());
|
||||
file.close();
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "CameraDevice::PerformVStarCamAction() - Error: " << e.what() << std::endl;
|
||||
Logging::Log(Logging::Severity::Error, ss.str());
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
||||
return fileName.str() + "_0.jpg";
|
||||
}
|
||||
|
||||
std::string VStarCamRecorder::Video(ctpl::thread_pool* pThreadPool, const std::string& ffmpeg)
|
||||
{
|
||||
Logging::Log(Logging::Severity::Debug, "VStarCamRecorder Video");
|
||||
int port = 10554;
|
||||
|
||||
std::stringstream url;
|
||||
url << "rtsp://" << m_settings.Username << ":" << m_settings.Password << "@" << m_settings.IpAddress << ":" << port << "/udp/av0_0";
|
||||
|
||||
std::stringstream fileName;
|
||||
fileName << m_settings.Path << "/" << m_settings.IpAddress << "/VSTA000000XXXXX_0_" << GetDateTimeString(true) << ".mp4";
|
||||
|
||||
std::stringstream command;
|
||||
command << ffmpeg << " -i \"" << url.str() << "\" -t 30 -c:v copy -c:a aac -b:a 8k -strict experimental " << fileName.str() << " > /dev/null 2>&1";
|
||||
|
||||
std::string cmd(command.str());
|
||||
Logging::Log(Logging::Severity::Debug, cmd);
|
||||
pThreadPool->push( [cmd](int) { int retval = std::system(cmd.c_str()); } );
|
||||
|
||||
return fileName.str();
|
||||
}
|
||||
|
||||
} // namespace Recorder
|
||||
} // namespace CameraRecorder
|
||||
Reference in New Issue
Block a user