Commit 1e70d8cc authored by alexandresavard's avatar alexandresavard
Browse files

Now recording in HOME folder

parent b4784ab7
......@@ -36,39 +36,11 @@ Call::Call(const CallID& id, Call::CallType type)
, _peerName()
, _peerNumber()
{
time_t rawtime;
struct tm * timeinfo;
rawtime = std::time(NULL);
timeinfo = localtime ( &rawtime );
std::stringstream out;
out << timeinfo->tm_year+1900;
if (timeinfo->tm_mon < 9) // january is 01, not 1
out << 0;
out << timeinfo->tm_mon+1;
if (timeinfo->tm_mday < 10) // 01 02 03, not 1 2 3
out << 0;
out << timeinfo->tm_mday;
if (timeinfo->tm_hour < 10) // 01 02 03, not 1 2 3
out << 0;
out << timeinfo->tm_hour;
if (timeinfo->tm_min < 10) // 01 02 03, not 1 2 3
out << 0;
out << timeinfo->tm_min;
if (timeinfo->tm_sec < 10) // 01 02 03, not 1 2 3
out << 0;
out << timeinfo->tm_sec;
_filename = out.str();
printf("Call::constructor filename for this call %s \n",_filename.c_str());
FILE_TYPE fileType = FILE_WAV;
SOUND_FORMAT soundFormat = INT16;
recAudio.setRecordingOption(_filename.c_str(),fileType,soundFormat,44100);
recAudio.setRecordingOption(fileType,soundFormat,44100);
_debug("CALL::Constructor for this clss is called \n");
}
......
......@@ -29,6 +29,8 @@ AudioRecord::AudioRecord(){
recordingEnabled_ = false;
fp = 0;
createFilename();
}
......@@ -36,9 +38,7 @@ void AudioRecord::setSndSamplingRate(int smplRate){
sndSmplRate_ = smplRate;
}
void AudioRecord::setRecordingOption(std::string name, FILE_TYPE type, SOUND_FORMAT format, int sndSmplRate){
strncpy(fileName_, name.c_str(), 8192);
void AudioRecord::setRecordingOption(FILE_TYPE type, SOUND_FORMAT format, int sndSmplRate){
fileType_ = type;
sndFormat_ = format;
......@@ -61,10 +61,22 @@ void AudioRecord::setRecordingOption(std::string name, FILE_TYPE type, SOUND_FOR
void AudioRecord::openFile(){
_debug("AudioRecord::openFile()\n");
savePath_ = getenv("HOME");
std::string fName(fileName_);
savePath_ += "/";
savePath_.append(fName);
bool result = false;
_debug("AudioRecord::openFile()\n");
if(isFileExist()) {
_debug("AudioRecord::Filename does not exist, creating one \n");
byteCounter_ = 0;
......@@ -160,9 +172,47 @@ void AudioRecord::stopRecording() {
}
void AudioRecord::createFilename(){
time_t rawtime;
struct tm * timeinfo;
rawtime = time(NULL);
timeinfo = localtime ( &rawtime );
stringstream out;
// DATE
out << timeinfo->tm_year+1900;
if (timeinfo->tm_mon < 9) // january is 01, not 1
out << 0;
out << timeinfo->tm_mon+1;
if (timeinfo->tm_mday < 10) // 01 02 03, not 1 2 3
out << 0;
out << timeinfo->tm_mday;
out << '-';
// hour
if (timeinfo->tm_hour < 10) // 01 02 03, not 1 2 3
out << 0;
out << timeinfo->tm_hour;
if (timeinfo->tm_min < 10) // 01 02 03, not 1 2 3
out << 0;
out << timeinfo->tm_min;
if (timeinfo->tm_sec < 10) // 01 02 03, not 1 2 3
out << 0;
out << timeinfo->tm_sec;
// fileName_ = out.str();
strncpy(fileName_, out.str().c_str(), 8192);
printf("AudioRecord::createFilename::filename for this call %s \n",fileName_);
}
bool AudioRecord::setRawFile() {
fp = fopen(fileName_, "wb");
fp = fopen(savePath_.c_str(), "wb");
if ( !fp ) {
_debug("AudioRecord::setRawFile() : could not create RAW file!\n");
return false;
......@@ -180,7 +230,7 @@ bool AudioRecord::setRawFile() {
bool AudioRecord::setWavFile() {
fp = fopen(fileName_, "wb");
fp = fopen(savePath_.c_str(), "wb");
if ( !fp ) {
_debug("AudioRecord::setWavFile() : could not create WAV file.\n");
return false;
......
......@@ -21,6 +21,8 @@
#include <iostream>
#include <string.h>
#include <sndfile.h>
#include <stdlib.h>
#include <sstream>
#include "global.h"
#include "plug-in/plugin.h"
......@@ -55,7 +57,7 @@ public:
void setSndSamplingRate(int smplRate);
void setRecordingOption(std::string name, FILE_TYPE type, SOUND_FORMAT format, int sndSmplRate);
void setRecordingOption(FILE_TYPE type, SOUND_FORMAT format, int sndSmplRate);
/**
* Check if no otehr file is opened, then create a new one
......@@ -113,6 +115,11 @@ public:
protected:
/**
* Create name file according to current date
*/
void createFilename();
/**
* Set the header for raw files
*/
......@@ -188,5 +195,10 @@ protected:
*/
char fileName_[8192];
/**
* Path for this recording
*/
std::string savePath_;
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment