Initial commit
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
#include "WatchBotRecorder.h"
|
||||
#include "Util.h"
|
||||
#include <HttpClient.h>
|
||||
#include <Logging.h>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
|
||||
namespace CameraRecorder {
|
||||
namespace Recorder {
|
||||
|
||||
WatchBotRecorder::WatchBotRecorder(Http::HttpClient* pHttpClient, const Settings& settings) :
|
||||
m_pHttpClient(pHttpClient),
|
||||
m_settings(settings)
|
||||
{
|
||||
}
|
||||
|
||||
WatchBotRecorder::~WatchBotRecorder()
|
||||
{
|
||||
}
|
||||
|
||||
std::string WatchBotRecorder::Snapshot(ctpl::thread_pool* pThreadPool)
|
||||
{
|
||||
Logging::Log(Logging::Severity::Debug, "WatchBotRecorder Snapshot");
|
||||
std::stringstream url;
|
||||
url << "http://" << m_settings.IpAddress << ":" << m_settings.Port << "/snapshot.cgi?user=" << m_settings.Username << "&pwd=" << m_settings.Password;
|
||||
|
||||
std::stringstream fileName;
|
||||
fileName << m_settings.Path << "/" << m_settings.IpAddress << "/" << GetDateTimeString() << ".jpg";
|
||||
|
||||
try
|
||||
{
|
||||
std::ofstream file(fileName.str());
|
||||
file << m_pHttpClient->GetUrlContents(url.str());
|
||||
file.close();
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "CameraDevice::PerformWatchBotAction() - Error: " << e.what() << std::endl;
|
||||
Logging::Log(Logging::Severity::Error, ss.str());
|
||||
return std::string();
|
||||
}
|
||||
|
||||
return fileName.str();
|
||||
}
|
||||
|
||||
std::string WatchBotRecorder::Video(ctpl::thread_pool* pThreadPool, const std::string& ffmpeg)
|
||||
{
|
||||
Logging::Log(Logging::Severity::Debug, "WatchBotRecorder Video");
|
||||
/*
|
||||
std::stringstream url;
|
||||
url << "http://" << m_settings.IpAddress << ":" << m_settings.Port << "/videostream.asf?user=" << m_settings.Username << "&pwd=" << m_settings.Password << "&resolution=64&rate=0";
|
||||
|
||||
std::stringstream fileName;
|
||||
fileName << m_settings.Path << "/" << m_settings.IpAddress << "/" << GetDateTimeString() << ".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();
|
||||
*/
|
||||
return std::string();
|
||||
}
|
||||
|
||||
} // namespace Recorder
|
||||
} // namespace CameraRecorder
|
||||
Reference in New Issue
Block a user