Commit 706b1640 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Merge branch 'recording'

parents 42493f85 753e316d
......@@ -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,49 @@ 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;
out << ':';
if (timeinfo->tm_min < 10) // 01 02 03, not 1 2 3
out << 0;
out << timeinfo->tm_min;
out << ':';
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 +232,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_;
};
......@@ -737,6 +737,7 @@ SIPVoIPLink::transfer(const CallID& id, const std::string& to)
bool SIPVoIPLink::transferStep2()
{
_debug("SIPVoIPLink::transferStep2():When is this function called?");
_audiortp->closeRtpSession();
return true;
}
......@@ -944,24 +945,24 @@ std::string SIPVoIPLink::getSipTo(const std::string& to_url, std::string hostnam
}
}
return SIPToHeader(to_url);
}
}
std::string SIPVoIPLink::SIPToHeader(const std::string& to)
{
if (to.find("sip:") == std::string::npos) {
return ("sip:" + to );
} else {
return to;
}
std::string SIPVoIPLink::SIPToHeader(const std::string& to)
{
if (to.find("sip:") == std::string::npos) {
return ("sip:" + to );
} else {
return to;
}
}
bool
SIPVoIPLink::SIPCheckUrl(const std::string& url UNUSED)
{
return true;
}
bool
SIPVoIPLink::SIPCheckUrl(const std::string& url UNUSED)
{
return true;
}
bool setCallAudioLocal(SIPCall* call, std::string localIP, bool stun, std::string server)
bool setCallAudioLocal(SIPCall* call, std::string localIP, bool stun, std::string server)
{
// Setting Audio
unsigned int callLocalAudioPort = RANDOM_LOCAL_PORT;
......@@ -1720,9 +1721,9 @@ SIPVoIPLink::SIPCallAnswered(SIPCall *call, pjsip_rx_data *rdata)
}
pj_bool_t
mod_on_rx_request(pjsip_rx_data *rdata)
{
pj_bool_t
mod_on_rx_request(pjsip_rx_data *rdata)
{
pj_status_t status;
pj_str_t reason;
......@@ -2109,8 +2110,7 @@ SIPVoIPLink::SIPCallAnswered(SIPCall *call, pjsip_rx_data *rdata)
void xfer_func_cb( pjsip_evsub *sub, pjsip_event *event){
void xfer_func_cb( pjsip_evsub *sub, pjsip_event *event){
PJ_UNUSED_ARG(event);
......
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