Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
162 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* InteractionRecorder.cpp | ||
* | ||
* Created on: 10/03/2012 | ||
* Author: arturo | ||
*/ | ||
|
||
#include "InteractionRecorder.h" | ||
|
||
InteractionRecorder::InteractionRecorder() { | ||
settings.loadFile("serversettings.xml"); | ||
ftpServer = settings.getValue("server","arturocastro.net"); | ||
user = settings.getValue("user","user"); | ||
password = settings.getValue("password","password"); | ||
serverPath = settings.getValue("interaction_recordings_path","interaction_recordings_path"); | ||
folder = "recordings_interaction"; | ||
} | ||
|
||
InteractionRecorder::~InteractionRecorder() { | ||
// TODO Auto-generated destructor stub | ||
} | ||
|
||
|
||
|
||
void InteractionRecorder::setup(string path,string currentFace, int w, int h, int fps){ | ||
cout << "start recording at " << path << " with current face " << currentFace; | ||
recordedVideoPath = path; | ||
recorder.setup("recordings_interaction/"+recordedVideoPath,w,h,fps); | ||
framesRecorded = 0; | ||
ofFile recordedVideoMeta(ofFilePath::join(folder,recordedVideoPath)+".meta",ofFile::WriteOnly); | ||
recordedVideoMeta << currentFace << " " << framesRecorded; | ||
if(!isThreadRunning()) startThread(true,false); | ||
} | ||
|
||
void InteractionRecorder::addFrame(ofPixels & frame){ | ||
recorder.addFrame(frame); | ||
} | ||
|
||
void InteractionRecorder::changeFace(string face){ | ||
cout << "changed face to " << face; | ||
ofFile recordedVideoMeta(ofFilePath::join(folder,recordedVideoPath)+".meta",ofFile::Append); | ||
recordedVideoMeta << face << " " << framesRecorded; | ||
} | ||
|
||
void InteractionRecorder::close(){ | ||
recorder.close(); | ||
lock(); | ||
uploadQueue.push(recordedVideoPath); | ||
unlock(); | ||
upload.signal(); | ||
} | ||
|
||
void InteractionRecorder::threadedFunction(){ | ||
while(isThreadRunning()){ | ||
upload.wait(mutex); | ||
while(!uploadQueue.empty()){ | ||
string nextUpload = uploadQueue.front(); | ||
uploadQueue.pop(); | ||
unlock(); | ||
string ftpCommand = "curl -u " + user+ ":" + password + " -T " + ofToDataPath(ofFilePath::join(folder,nextUpload)) + " ftp://" + ofFilePath::join(ftpServer , serverPath) + nextUpload; | ||
system(ftpCommand.c_str()); | ||
ftpCommand = "curl -u " + user+ ":" + password + " -T " + ofToDataPath(ofFilePath::join(folder,nextUpload + ".meta")) + " ftp://" + ofFilePath::join(ftpServer , serverPath) + nextUpload + ".meta"; | ||
system(ftpCommand.c_str()); | ||
lock(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* InteractionRecorder.h | ||
* | ||
* Created on: 10/03/2012 | ||
* Author: arturo | ||
*/ | ||
|
||
#ifndef INTERACTIONRECORDER_H_ | ||
#define INTERACTIONRECORDER_H_ | ||
|
||
#include <queue> | ||
#include "ofConstants.h" | ||
#include "ofThread.h" | ||
#include "ofxVideoRecorder.h" | ||
#include "ofxXmlSettings.h" | ||
|
||
class InteractionRecorder: public ofThread { | ||
public: | ||
InteractionRecorder(); | ||
virtual ~InteractionRecorder(); | ||
|
||
void setup(string path,string currentFace,int w, int h, int fps=30); | ||
void addFrame(ofPixels & frame); | ||
void changeFace(string face); | ||
void close(); | ||
|
||
protected: | ||
void threadedFunction(); | ||
|
||
private: | ||
ofxVideoRecorder recorder; | ||
string recordedVideoPath; | ||
int framesRecorded; | ||
queue<string> uploadQueue; | ||
Poco::Condition upload; | ||
ofxXmlSettings settings; | ||
string ftpServer; | ||
string user; | ||
string password; | ||
string serverPath; | ||
string folder; | ||
}; | ||
|
||
#endif /* INTERACTIONRECORDER_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters