Skip to content

Commit

Permalink
Fixed bug when creating motion video
Browse files Browse the repository at this point in the history
Would accidentally trigger stream processor writing as well.
  • Loading branch information
Unknown committed Feb 24, 2018
1 parent 1c894b1 commit 0092b76
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Source/IpFreelyMainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ void IpFreelyMainWindow::on_updateFeedsTimer()
auto currentVideoFrame = streamProcessor.second->CurrentVideoFrame(&motionBoundingRect);

auto fps = streamProcessor.second->CurrentFps();
auto isRecording = streamProcessor.second->GetEnableVideoWriting();
auto isRecording = streamProcessor.second->EnableVideoWriting();

UpdateCamFeedFrame(
streamProcessor.first, currentVideoFrame, motionBoundingRect, isRecording);
Expand Down Expand Up @@ -1207,7 +1207,7 @@ void IpFreelyMainWindow::RecordActionHandler(ipfreely::eCamId const camId, QTool
return;
}

if (streamProcIter->second->GetEnableVideoWriting())
if (streamProcIter->second->EnableVideoWriting())
{
streamProcIter->second->StopVideoWriting();

Expand Down
22 changes: 11 additions & 11 deletions Source/IpFreelyStreamProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,9 @@ IpFreelyStreamProcessor::IpFreelyStreamProcessor(

m_updatePeriodMillisecs = static_cast<unsigned int>(1000.0 / m_fps);

DEBUG_MESSAGE_EX_INFO("Stream at: " << m_cameraDetails.streamUrl << " running with FPS of: "
<< m_fps
<< ", thread update period (ms): "
<< m_updatePeriodMillisecs);
DEBUG_MESSAGE_EX_INFO("Stream at: "
<< m_cameraDetails.streamUrl << " running with FPS of: " << m_fps
<< ", thread update period (ms): " << m_updatePeriodMillisecs);

m_eventThread = std::make_shared<core_lib::threads::EventThread>(
std::bind(&IpFreelyStreamProcessor::ThreadEventCallback, this), m_updatePeriodMillisecs);
Expand Down Expand Up @@ -184,14 +183,9 @@ void IpFreelyStreamProcessor::StopVideoWriting() noexcept
SetEnableVideoWriting(false);
}

bool IpFreelyStreamProcessor::GetEnableVideoWriting() const noexcept
bool IpFreelyStreamProcessor::EnableVideoWriting() const noexcept
{
bool isWriting = false;

{
std::lock_guard<std::mutex> lock(m_writingMutex);
isWriting = m_enableVideoWriting;
}
bool isWriting = GetEnableVideoWriting();

if (!isWriting && m_motionDetector)
{
Expand Down Expand Up @@ -328,6 +322,12 @@ void IpFreelyStreamProcessor::SetEnableVideoWriting(bool enable) noexcept
m_enableVideoWriting = enable;
}

bool IpFreelyStreamProcessor::GetEnableVideoWriting() const noexcept
{
std::lock_guard<std::mutex> lock(m_writingMutex);
return m_enableVideoWriting;
}

void IpFreelyStreamProcessor::CheckRecordingSchedule()
{
if (m_recordingSchedule.empty())
Expand Down
5 changes: 3 additions & 2 deletions Source/IpFreelyStreamProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ class IpFreelyStreamProcessor final
void StopVideoWriting() noexcept;

/*!
* \brief GetEnableVideoWriting reports if stream is being written to disk.
* \brief EnableVideoWriting reports if stream is being written to disk.
* \return True if writing, false otherwise.
*/
bool GetEnableVideoWriting() const noexcept;
bool EnableVideoWriting() const noexcept;

/*!c
* \brief VideoFrameUpdated monitors stream activity.
Expand Down Expand Up @@ -127,6 +127,7 @@ class IpFreelyStreamProcessor final
std::vector<std::vector<bool>> const& schedule);
void ThreadEventCallback() noexcept;
void SetEnableVideoWriting(bool enable) noexcept;
bool GetEnableVideoWriting() const noexcept;
void CheckRecordingSchedule();
void CreateCaptureObjects();
void GrabVideoFrame();
Expand Down

0 comments on commit 0092b76

Please sign in to comment.