32 lines
816 B
C++
32 lines
816 B
C++
#include "RecorderMutex.h"
|
|
#include <algorithm>
|
|
|
|
|
|
namespace CameraRecorder {
|
|
namespace Util {
|
|
|
|
RecorderMutex::RecorderMutex()
|
|
{
|
|
}
|
|
|
|
void RecorderMutex::RegisterRecording(const std::string& ipAddress)
|
|
{
|
|
std::unique_lock<std::mutex> lock(m_mutex);
|
|
m_activeRecordings.push_back(ipAddress);
|
|
}
|
|
|
|
void RecorderMutex::UnregisterRecording(const std::string& ipAddress)
|
|
{
|
|
std::unique_lock<std::mutex> lock(m_mutex);
|
|
m_activeRecordings.erase(std::remove(m_activeRecordings.begin(), m_activeRecordings.end(), ipAddress), m_activeRecordings.end());
|
|
}
|
|
|
|
bool RecorderMutex::IsRecording(const std::string& ipAddress)
|
|
{
|
|
std::unique_lock<std::mutex> lock(m_mutex);
|
|
return std::find(m_activeRecordings.begin(), m_activeRecordings.end(), ipAddress) != m_activeRecordings.end();
|
|
}
|
|
|
|
} // namespace Util
|
|
} // namespace CameraRecorder
|