Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Commit

Permalink
Fixed #39
Browse files Browse the repository at this point in the history
  • Loading branch information
Razican committed Jun 2, 2016
1 parent 082a9d3 commit 66e7241
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions camera/Camera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ bool Camera::stop()
return true;
}
this->logger->log("Error stopping video recording.");

if ( ! this->is_really_recording())
{
this->logger->log("Warning: error was already stopped.");
this->recording = false;
return true;
}
return false;
#else
this->logger->log("Test mode. Video recording stop simulated.");
Expand All @@ -175,6 +182,17 @@ bool Camera::stop()
#endif
}

bool Camera::is_really_recording() const
{
FILE* process = popen("pgrep raspivid", "r");
char response[5];
fgets(response, 5, process);
pclose(process);

if (process == NULL) this->logger->log("Error checking if raspivid is really recording");
return (process != NULL && response != NULL);
}

int os::get_file_count(const string& path)
{
DIR *dp;
Expand Down
1 change: 1 addition & 0 deletions camera/Camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace os {
bool recording = false;
Camera();
void record_thread(int time);
bool is_really_recording() const;
public:
Camera(Camera& copy) = delete;
~Camera();
Expand Down

0 comments on commit 66e7241

Please sign in to comment.