diff --git a/sflphone-client-gnome/src/callable_obj.c b/sflphone-client-gnome/src/callable_obj.c index 811e71640038634768d5ae412fe53344cd2d0a27..66766a485ccb0833a17cff9ab0a969b844abf65c 100644 --- a/sflphone-client-gnome/src/callable_obj.c +++ b/sflphone-client-gnome/src/callable_obj.c @@ -233,6 +233,7 @@ void create_new_call (callable_type_t type, call_state_t state, gchar* callID , obj->_peer_name = g_strdup (peer_name); obj->_peer_number = g_strdup (peer_number); obj->_peer_info = g_strdup (get_peer_info (peer_name, peer_number)); + obj->_recordfile = NULL; obj->_trsft_to = ""; set_timestamp (& (obj->_time_start)); @@ -300,6 +301,7 @@ void create_history_entry_from_serialized_form (gchar *timestamp, gchar *details { gchar *peer_name=""; gchar *peer_number="", *accountID="", *time_stop=""; + gchar *recordfile=""; callable_obj_t *new_call; history_state_t history_state = MISSED; char **ptr; @@ -311,7 +313,6 @@ void create_history_entry_from_serialized_form (gchar *timestamp, gchar *details if ( (ptr = g_strsplit (details, delim,5)) != NULL) { while (ptr != NULL && token < 5) { - switch (token) { case 0: history_state = get_history_state_from_id (*ptr); @@ -328,6 +329,8 @@ void create_history_entry_from_serialized_form (gchar *timestamp, gchar *details case 4: accountID = *ptr; break; + case 5: + recordfile = *ptr; default: break; } @@ -346,6 +349,7 @@ void create_history_entry_from_serialized_form (gchar *timestamp, gchar *details new_call->_history_state = history_state; new_call->_time_start = convert_gchar_to_timestamp (timestamp); new_call->_time_stop = convert_gchar_to_timestamp (time_stop); + new_call->_recordfile = g_strdup(recordfile); *call = new_call; } @@ -361,6 +365,12 @@ void free_callable_obj_t (callable_obj_t *c) g_free (c->_peer_name); g_free (c->_peer_number); g_free (c->_peer_info); + + if(c->_recordfile != NULL) { + g_free(c->_recordfile); + c->_recordfile = NULL; + } + g_free (c); DEBUG ("If you don't see it that is because there is a problem"); @@ -458,7 +468,8 @@ gchar* serialize_history_entry (callable_obj_t *entry) entry->_peer_number, separator, peer_name, separator, timestamp, separator, - account_id, + account_id, separator, + entry->_recordfile ? entry->_recordfile : "", NULL); return result; diff --git a/sflphone-client-gnome/src/callable_obj.h b/sflphone-client-gnome/src/callable_obj.h index 3b8bc941edca2f3b7e8511121b5377d89c609c66..fd43e7abf2e70846b2384cb445d7a27fed7f490d 100644 --- a/sflphone-client-gnome/src/callable_obj.h +++ b/sflphone-client-gnome/src/callable_obj.h @@ -150,6 +150,12 @@ typedef struct { /* The audio codec used for this call, if applicable */ gchar *_audio_codec; + /** + * The recording file for this call, if NULL, no recording available + * Should be used only for history items + */ + gchar *_recordfile; + /* Associated IM widget */ GtkWidget *_im_widget; diff --git a/sflphone-common/src/audio/sound/audiofile.cpp b/sflphone-common/src/audio/sound/audiofile.cpp index 2c5f48eb2ccb8f09b3406dddeeb38163d22a5d26..e49b2947036a22b495d329baf13b6f599cc65d19 100644 --- a/sflphone-common/src/audio/sound/audiofile.cpp +++ b/sflphone-common/src/audio/sound/audiofile.cpp @@ -44,8 +44,7 @@ #include "manager.h" -RawFile::RawFile() : _filename() - , _codec (NULL) +RawFile::RawFile() : filename(), audioCodec (NULL) { AudioFile::_start = false; } @@ -55,47 +54,34 @@ RawFile::~RawFile() } // load file in mono format -bool -RawFile::loadFile (const std::string& filename, sfl::AudioCodec* codec , unsigned int sampleRate=8000) +void RawFile::loadFile (const std::string& name, sfl::AudioCodec* codec, unsigned int sampleRate = 8000) throw(AudioFileException) { - _codec = codec; + audioCodec = codec; // if the filename was already load, with the same samplerate // we do nothing - if (strcmp (_filename.c_str(), filename.c_str()) == 0 && _sampleRate == (int) sampleRate) { - return true; - } else { - // reset to 0 - delete [] _buffer; - _buffer = 0; - _size = 0; - _pos = 0; + if ((filename == name) && (_sampleRate == (int)sampleRate)) { + return; } - + filename = name; // no filename to load if (filename.empty()) { - _debug ("Unable to open audio file: filename is empty"); - return false; + throw AudioFileException("Unable to open audio file: filename is empty"); } std::fstream file; file.open (filename.c_str(), std::fstream::in); - if (!file.is_open()) { - // unable to load the file - _debug ("Unable to open audio file %s", filename.c_str()); - return false; + throw AudioFileException("Unable to open audio file"); } // get length of file: file.seekg (0, std::ios::end); - int length = file.tellg(); - file.seekg (0, std::ios::beg); // allocate memory: @@ -112,18 +98,15 @@ RawFile::loadFile (const std::string& filename, sfl::AudioCodec* codec , unsigne // expandedsize should be exactly two time more, else failed int16 monoBuffer[length]; - int expandedsize = (int) _codec->decode (monoBuffer, (unsigned char *) fileBuffer, length); - - if (expandedsize != length*2) { - _debug ("Audio file error on loading audio file!"); - return false; + unsigned int expandedsize = audioCodec->decode (monoBuffer, reinterpret_cast<unsigned char *>(fileBuffer), length); + if (expandedsize != length * sizeof(int16)) { + throw AudioFileException("Audio file error on loading audio file!"); } - unsigned int nbSampling = expandedsize/sizeof (int16); + unsigned int nbSampling = expandedsize / sizeof(int16); // we need to change the sample rating here: // case 1: we don't have to resample : only do splitting and convert - if (sampleRate == 8000) { // just s _size = nbSampling; @@ -174,20 +157,18 @@ RawFile::loadFile (const std::string& filename, sfl::AudioCodec* codec , unsigne _buffer = bufferTmp; // just send the buffer pointer; bufferTmp = 0; } - - return true; } -WaveFile::WaveFile () : _byte_counter (0) - , _nb_channels (1) - , _fileLength (0) - , _data_offset (0) - , _channels (0) - , _data_type (0) - , _file_rate (0) +WaveFile::WaveFile () : byteCounter (0) + , nbChannels (1) + , fileLength (0) + , dataOffset (0) + , channels (0) + , dataType (0) + , fileRate (0) { AudioFile::_start = false; } @@ -200,24 +181,26 @@ WaveFile::~WaveFile() -bool WaveFile::openFile (const std::string& fileName, int audioSamplingRate) +void WaveFile::openFile (const std::string& fileName, int audioSamplingRate) throw(AudioFileException) { - if (isFileExist (fileName)) { - openExistingWaveFile (fileName, audioSamplingRate); - } + try { - return true; + if (isFileExist (fileName)) { + openExistingWaveFile (fileName, audioSamplingRate); + } + } + catch(AudioFileException &e) { + throw; + } } bool WaveFile::closeFile() { - - _file_stream.close(); + fileStream.close(); return true; - } @@ -238,7 +221,7 @@ bool WaveFile::isFileExist (const std::string& fileName) bool WaveFile::isFileOpened() { - if (_file_stream.is_open()) { + if (fileStream.is_open()) { _debug ("WaveFile: file is openened"); return true; } else { @@ -248,87 +231,87 @@ bool WaveFile::isFileOpened() } -bool WaveFile::openExistingWaveFile (const std::string& fileName, int audioSamplingRate) +void WaveFile::openExistingWaveFile (const std::string& fileName, int audioSamplingRate) throw(AudioFileException) { int maxIteration = 0; _debug ("WaveFile: Opening %s", fileName.c_str()); - _file_stream.open (fileName.c_str(), std::ios::in | std::ios::binary); + fileStream.open (fileName.c_str(), std::ios::in | std::ios::binary); char riff[4] = {}; - _file_stream.read (riff, 4); + fileStream.read (riff, 4); if (strncmp ("RIFF", riff, 4) != 0) { - _debug ("WaveFile: File is not of RIFF format"); - return false; + throw AudioFileException("File is not of RIFF format"); } - // Find the "fmt " chunk char fmt[4] = {}; maxIteration = 10; while ((maxIteration > 0) && strncmp ("fmt ", fmt, 4)) { - _file_stream.read (fmt, 4); + fileStream.read (fmt, 4); maxIteration--; } - SINT32 chunk_size; // fmt chunk size - unsigned short format_tag; // data compression tag + if(maxIteration == 0) { + throw AudioFileException("Could not find \"fmt \" chunk"); + } - _file_stream.read ( (char*) &chunk_size, 4); // Read fmt chunk size. - _file_stream.read ( (char*) &format_tag, 2); + SINT32 chunk_size; // fmt chunk size + unsigned short formatTag; // data compression tag + + fileStream.read ( (char*) &chunk_size, 4); // Read fmt chunk size. + fileStream.read ( (char*) &formatTag, 2); _debug ("WaveFile: Chunk size: %d", chunk_size); - _debug ("WaveFile: Format tag: %d", format_tag); + _debug ("WaveFile: Format tag: %d", formatTag); - if (format_tag != 1) { // PCM = 1, FLOAT = 3 - _debug ("WaveFile: File contains an unsupported data format type"); - return false; + if (formatTag != 1) { // PCM = 1, FLOAT = 3 + throw AudioFileException("File contains an unsupported data format type"); } // Get number of channels from the header. SINT16 chan; - _file_stream.read ( (char*) &chan, 2); - _channels = chan; - _debug ("WaveFile: Channel %d", _channels); + fileStream.read ( (char*) &chan, 2); + channels = chan; + _debug ("WaveFile: Channel %d", channels); // Get file sample rate from the header. SINT32 srate; - _file_stream.read ( (char*) &srate, 4); - _file_rate = (double) srate; + fileStream.read ( (char*) &srate, 4); + fileRate = (double) srate; _debug ("WaveFile: Sampling rate %d", srate); SINT32 avgb; - _file_stream.read ( (char*) &avgb, 4); + fileStream.read ( (char*) &avgb, 4); _debug ("WaveFile: Average byte %d", avgb);\ SINT16 blockal; - _file_stream.read ( (char*) &blockal, 2); + fileStream.read ( (char*) &blockal, 2); _debug ("WaveFile: Block alignment %d", blockal); // Determine the data type - _data_type = 0; + dataType = 0; SINT16 dt; - _file_stream.read ( (char*) &dt, 2); + fileStream.read ( (char*) &dt, 2); _debug ("WaveFile: dt %d", dt); - if (format_tag == 1) { + if (formatTag == 1) { if (dt == 8) - _data_type = 1; // SINT8; + dataType = 1; // SINT8; else if (dt == 16) - _data_type = 2; // SINT16; + dataType = 2; // SINT16; else if (dt == 32) - _data_type = 3; // SINT32; + dataType = 3; // SINT32; } else { - _debug ("WaveFile: File's bits per sample with is not supported"); - return false; + throw AudioFileException("File's bits per sample with is not supported"); } // Find the "data" chunk char data[4] = {}; maxIteration = 10; while ((maxIteration > 0) && strncmp ("data", data, 4)) { - _file_stream.read (data, 4); + fileStream.read (data, 4); maxIteration--; } @@ -341,30 +324,30 @@ bool WaveFile::openExistingWaveFile (const std::string& fileName, int audioSampl // Get length of data from the header. SINT32 bytes; - _file_stream.read ( (char*) &bytes, 4); + fileStream.read ( (char*) &bytes, 4); _debug ("WaveFile: data size in byte %d", bytes); - _fileLength = 8 * bytes / dt / _channels; // sample frames - _debug ("WaveFile: data size in frame %ld", _fileLength); + fileLength = 8 * bytes / dt / channels; // sample frames + _debug ("WaveFile: data size in frame %ld", fileLength); // Should not be longer than a minute - if (_fileLength > (unsigned int) (60*srate)) - _fileLength = 60*srate; + if (fileLength > (unsigned int) (60*srate)) + fileLength = 60*srate; - SFLDataFormat *tempBuffer = new SFLDataFormat[_fileLength]; + SFLDataFormat *tempBuffer = new SFLDataFormat[fileLength]; if (!tempBuffer) { - return false; + throw AudioFileException("Could not allocate temporary buffer"); } SFLDataFormat *tempBufferRsmpl = NULL; - _file_stream.read ( (char *) tempBuffer, _fileLength*sizeof (SFLDataFormat)); + fileStream.read ( (char *) tempBuffer, fileLength*sizeof (SFLDataFormat)); // mix two channels together if stereo - if(_channels == 2) { + if(channels == 2) { int tmp = 0; unsigned j = 0; - for(unsigned int i = 0; i < _fileLength-1; i+=2) { + for(unsigned int i = 0; i < fileLength-1; i+=2) { tmp = (tempBuffer[i] + tempBuffer[i+1]) / 2; // saturate if(tmp > SHRT_MAX) { @@ -373,21 +356,20 @@ bool WaveFile::openExistingWaveFile (const std::string& fileName, int audioSampl tempBuffer[j++] = (SFLDataFormat)tmp; } - _fileLength /= 2; + fileLength /= 2; } - else if(_channels > 2) { - _debug("WaveFile: unsupported number of channels"); - delete [] tempBuffer; - return false; + else if(channels > 2) { + delete [] tempBuffer; + throw AudioFileException("WaveFile: unsupported number of channels"); } // compute size of final buffer int nbSample; if (srate != audioSamplingRate) { - nbSample = (int) ( (float) _fileLength * ( (float) audioSamplingRate / (float) srate)); + nbSample = (int) ( (float) fileLength * ( (float) audioSamplingRate / (float) srate)); } else { - nbSample = _fileLength; + nbSample = fileLength; } int totalprocessed = 0; @@ -396,12 +378,12 @@ bool WaveFile::openExistingWaveFile (const std::string& fileName, int audioSampl if (srate != audioSamplingRate) { // initialize remaining samples to process - int remainingSamples = _fileLength; + int remainingSamples = fileLength; tempBufferRsmpl = new SFLDataFormat[nbSample]; - - if (!tempBufferRsmpl) - return false; + if (!tempBufferRsmpl) { + throw AudioFileException("Could not allocate temporary buffer for ressampling"); + } SFLDataFormat *in = tempBuffer; SFLDataFormat *out = tempBufferRsmpl; @@ -428,35 +410,37 @@ bool WaveFile::openExistingWaveFile (const std::string& fileName, int audioSampl // Init audio loop buffer info _buffer = new SFLDataFormat[nbSample]; - - if (!_buffer) - return false; + if (_buffer == NULL) { + throw AudioFileException("Could not allocate buffer for audio"); + } _size = nbSample; _sampleRate = (int) audioSamplingRate; - // Copy audio into audioloop - if (srate != audioSamplingRate) + // Copy audio into audioloopi + if (srate != audioSamplingRate) { memcpy ( (void *) _buffer, (void *) tempBufferRsmpl, nbSample*sizeof (SFLDataFormat)); - else + } + else { memcpy ( (void *) _buffer, (void *) tempBuffer, nbSample*sizeof (SFLDataFormat)); - + } _debug ("WaveFile: file successfully opened"); delete[] tempBuffer; - if (tempBufferRsmpl) + if (tempBufferRsmpl) { delete[] tempBufferRsmpl; - - return true; - + } } -bool WaveFile::loadFile (const std::string& filename, sfl::AudioCodec * /*codec*/, unsigned int sampleRate) +void WaveFile::loadFile (const std::string& filename, sfl::AudioCodec * /*codec*/, unsigned int sampleRate) throw(AudioFileException) { - openFile (filename, sampleRate); - - return true; + try { + openFile (filename, sampleRate); + } + catch(AudioFileException &e) { + throw; + } } diff --git a/sflphone-common/src/audio/sound/audiofile.h b/sflphone-common/src/audio/sound/audiofile.h index f0d0ff701eac4eda3c86d5be9c5b407f33901667..975bfe136fbf9f5c10c815a52a0b77f415e36ec1 100644 --- a/sflphone-common/src/audio/sound/audiofile.h +++ b/sflphone-common/src/audio/sound/audiofile.h @@ -34,6 +34,7 @@ #ifndef __AUDIOFILE_H__ #define __AUDIOFILE_H__ +#include <exception> #include <fstream> #include "audio/audioloop.h" @@ -42,49 +43,68 @@ namespace sfl { class AudioCodec; } -/** - * @brief Abstract interface for file readers - */ -class AudioFile : public AudioLoop +class AudioFileException : public std::exception { - public: +public: + AudioFileException (const std::string& str="") throw() : errstr(str) {} - /** - * Load a sound file in memory - * @param filename The absolute path to the file - * @param codec The codec to decode and encode it - * @param sampleRate The sample rate to read it - * @return bool True on success - */ - virtual bool loadFile (const std::string& filename, sfl::AudioCodec *codec , unsigned int sampleRate) = 0; + virtual ~AudioFileException() throw() {} - /** - * Start the sound file - */ - void start() { - _start = true; - } - - /** - * Stop the sound file - */ - void stop() { - _start = false; - } + virtual const char *what() const throw() { + std::string expt("AudioFile: AudioFileException occured: "); + expt.append(errstr); + return expt.c_str(); + } - /** - * Tells whether or not the file is playing - * @return bool True if yes - * false otherwise - */ - bool isStarted() { - return _start; - } +private: + std::string errstr; - protected: +}; - /** start or not */ - bool _start; +/** + * @brief Abstract interface for file readers + */ +class AudioFile : public AudioLoop +{ +public: + + /** + * Load a sound file in memory + * + * @param filename The absolute path to the file + * @param codec The codec to decode and encode it + * @param sampleRate The sample rate to read it + * @return bool True on success + */ + virtual void loadFile (const std::string& filename, sfl::AudioCodec *codec , unsigned int sampleRate) throw(AudioFileException) = 0; + + /** + * Start the sound file + */ + void start() { + _start = true; + } + + /** + * Stop the sound file + */ + void stop() { + _start = false; + } + + /** + * Tells whether or not the file is playing + * @return bool True if yes + * false otherwise + */ + bool isStarted() { + return _start; + } + +protected: + + /** start or not */ + bool _start; }; @@ -115,7 +135,7 @@ class RawFile : public AudioFile * @param sampleRate The sample rate to read it * @return bool True on success */ - virtual bool loadFile (const std::string& filename, sfl::AudioCodec *codec , unsigned int sampleRate); + virtual void loadFile (const std::string&, sfl::AudioCodec *, unsigned int sampleRate) throw(AudioFileException); private: // Copy Constructor @@ -125,64 +145,112 @@ class RawFile : public AudioFile RawFile& operator= (const RawFile& rh); /** The absolute path to the sound file */ - std::string _filename; + std::string filename; /** Your preferred codec */ - sfl::AudioCodec* _codec; + sfl::AudioCodec* audioCodec; }; - class WaveFile : public AudioFile { public: - WaveFile (); + WaveFile(); ~WaveFile(); - bool openFile (const std::string& fileName, int audioSamplingRate); + /** + * Open a file give a file name + * + * @param A reference to a string containing the filename + * @param The internal sampling rate, file will be resampled + * if it's sampling rate does not correspond to internal one + */ + void openFile (const std::string&, int) throw(AudioFileException); + /** + * Close an opened file + */ bool closeFile(); + /** + * Test if the specified file already exist + */ bool isFileExist (const std::string& fileName); + /** + * Test if file opend + */ bool isFileOpened(); /** - * Load a sound file in memory + * Load a sound file in memory * @param filename The absolute path to the file * @param codec The codec to decode and encode it * @param sampleRate The sample rate to read it * @return bool True on success */ - virtual bool loadFile (const std::string& filename, sfl::AudioCodec *codec , unsigned int sampleRate); + virtual void loadFile (const std::string& filename, sfl::AudioCodec *codec , unsigned int sampleRate) throw(AudioFileException); private: - bool setWaveFile(); - - bool openExistingWaveFile (const std::string& fileName, int audioSamplingRate); - - SOUND_FORMAT _snd_format; + /** + * Open an existing wave file + * @param File name + * @param Audio sampling rate + */ + void openExistingWaveFile (const std::string&, int) throw(AudioFileException); - long _byte_counter; + /** + * Sound format for this file (16/32 bits) + */ + SOUND_FORMAT sndFormat; + + /** + * Nb of bytes for this file + */ + long byteCounter; - int _nb_channels; + /** + * Number of channels for this file + */ + int nbChannels; - unsigned long _fileLength; + /** + * Total file length + */ + unsigned long fileLength; - unsigned long _data_offset; + /** + * Audio data start offset in bytes + */ + unsigned long dataOffset; - SINT16 _channels; + /** + * Channels + */ + SINT16 channels; - SOUND_FORMAT _data_type; + /** + * Data type + */ + SOUND_FORMAT dataType; - double _file_rate; + /** + * File sampling rate + */ + double fileRate; - std::fstream _file_stream; + /** + * File stream + */ + std::fstream fileStream; - std::string _fileName; + /** + * File name + */ + std::string fileName; }; diff --git a/sflphone-common/src/history/historyitem.cpp b/sflphone-common/src/history/historyitem.cpp index 2f96f3f69206c9b73163a6efd060dad4476767c9..bf475861ab3d76b53a83ec02809ae5ac78d78ef9 100644 --- a/sflphone-common/src/history/historyitem.cpp +++ b/sflphone-common/src/history/historyitem.cpp @@ -2,6 +2,7 @@ * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc. * * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> + * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,13 +38,14 @@ #define ITEM_SEPARATOR "|" #define EMPTY_STRING "empty" -HistoryItem::HistoryItem (std::string timestamp_start, CallType call_type, std::string timestamp_stop, std::string name, std::string number, std::string account_id) +HistoryItem::HistoryItem (std::string timestamp_start, CallType call_type, std::string timestamp_stop, std::string name, std::string number, std::string account_id, std::string recording) : _timestamp_start (timestamp_start), _timestamp_stop (timestamp_stop), _call_type (call_type), _name (name), _number (number), - _account_id (account_id) + _account_id (account_id), + _recording_file(recording) { } @@ -52,7 +54,7 @@ HistoryItem::HistoryItem (std::string timestamp, std::string serialized_form) : _timestamp_start (timestamp) { size_t pos; - std::string tmp, id, name, number, stop, account; + std::string tmp, id, name, number, stop, account, recordFile; int indice=0; while (serialized_form.find (ITEM_SEPARATOR, 0) != std::string::npos) { @@ -61,27 +63,24 @@ HistoryItem::HistoryItem (std::string timestamp, std::string serialized_form) serialized_form.erase (0, pos + 1); switch (indice) { - case 0: // The call type id = tmp; break; - case 1: // The number field number = tmp; break; - case 2: // The name field name = tmp; break; - case 3: // The end timestamp stop = tmp; break; - case 4: // The account ID account = tmp; break; - + case 5: // The recorded file name + recordFile = tmp; + break; default: // error std::cout <<"[ERROR] unserialized form not recognized."<<std::endl; break; @@ -118,7 +117,8 @@ bool HistoryItem::save (Conf::ConfigTree **history) && (*history)->setConfigTreeItem (section, "timestamp_stop", _timestamp_stop) && (*history)->setConfigTreeItem (section, "number", _number) && (*history)->setConfigTreeItem (section, "accountid", _account_id) - && (*history)->setConfigTreeItem (section, "name", _name)); + && (*history)->setConfigTreeItem (section, "name", _name) + && (*history)->setConfigTreeItem (section, "recordfile", _recording_file)); return res; } @@ -136,7 +136,8 @@ std::string HistoryItem::serialize (void) (_account_id == "" || non_valid_account (_account_id)) ? accountID = "empty" : accountID = _account_id; // Serialize it - res << _call_type << separator << _number << separator << name << separator << _timestamp_stop << separator << accountID; + res << _call_type << separator << _number << separator << name << separator << _timestamp_stop << separator << accountID + << separator << _recording_file; return res.str(); } diff --git a/sflphone-common/src/history/historyitem.h b/sflphone-common/src/history/historyitem.h index d0274087655a913bf696283b078c779b7f7ab7df..df59bf36a06b1737fb0040c63859763376f7def6 100644 --- a/sflphone-common/src/history/historyitem.h +++ b/sflphone-common/src/history/historyitem.h @@ -2,6 +2,7 @@ * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc. * * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> + * Author: Alexamdre Savard <alexandre.savard@savoirfairelinux.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -49,8 +50,16 @@ class HistoryItem public: /* * Constructor + * + * @param Timestamp start + * @param Call type + * @param Timestamp stop + * @param Call name + * @param Call number + * @param Call account id + * @param Recording file name (if any recording were performed) */ - HistoryItem (std::string, CallType, std::string, std::string, std::string, std::string=""); + HistoryItem (std::string, CallType, std::string, std::string, std::string, std::string="", std::string=""); /* * Constructor from a serialized form @@ -99,6 +108,11 @@ class HistoryItem * The account the call was made with */ std::string _account_id; + + /** + * Wether or not a recording exist for this call + */ + std::string _recording_file; }; diff --git a/sflphone-common/src/history/historymanager.cpp b/sflphone-common/src/history/historymanager.cpp index 7130aed3f2b0c4517af5c27aaf2fb55c13624c09..8ef22ed1751268eb35bc6562e3f90d20a9f467f9 100644 --- a/sflphone-common/src/history/historymanager.cpp +++ b/sflphone-common/src/history/historymanager.cpp @@ -2,6 +2,7 @@ * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc. * * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> + * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -94,7 +95,7 @@ int HistoryManager::load_history_items_map (Conf::ConfigTree *history_list, int Conf::TokenList sections; HistoryItem *item; Conf::TokenList::iterator iter; - std::string number, name, accountID, timestamp_start, timestamp_stop; + std::string number, name, accountID, timestamp_start, timestamp_stop, recording_file; CallType type; int history_limit; time_t current_timestamp; @@ -116,12 +117,14 @@ int HistoryManager::load_history_items_map (Conf::ConfigTree *history_list, int name = getConfigString (*iter, "name", history_list); number = getConfigString (*iter, "number", history_list); accountID = getConfigString (*iter, "accountid", history_list); + recording_file = getConfigString(*iter, "recordfile", history_list); + timestamp_start = *iter; // Make a check on the start timestamp to know it is loadable according to CONFIG_HISTORY_LIMIT if (atoi (timestamp_start.c_str ()) >= ( (int) current_timestamp - history_limit)) { - item = new HistoryItem (timestamp_start, type, timestamp_stop, name, number, accountID); + item = new HistoryItem (timestamp_start, type, timestamp_stop, name, number, accountID, recording_file); add_new_history_entry (item); nb_items ++; } diff --git a/sflphone-common/src/history/historymanager.h b/sflphone-common/src/history/historymanager.h index 904d05f76bc08d2d7da855714a54c778f6ee0519..f3740feb5145e175ec03ed19fbe7d41c7042dcba 100644 --- a/sflphone-common/src/history/historymanager.h +++ b/sflphone-common/src/history/historymanager.h @@ -2,6 +2,7 @@ * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc. * * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> + * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -76,7 +77,7 @@ class HistoryManager */ int load_history_items_map (Conf::ConfigTree *history_list, int limit); - /* + /* * Inverse method, ie save a data structure containing the history into a file */ bool save_history_to_file (Conf::ConfigTree *history_list); diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index 23a2fd5ba15f72e3d7cc1a847459bef36f1d6cef..215e06ee490eecc569eb2ebb9618a105b3cbcfb4 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -2363,29 +2363,26 @@ void ManagerImpl::ringtone (const AccountID& accountID) else _audiofile = static_cast<AudioFile *> (new RawFile()); - loadFile = false; _debug ("Manager: ringChoice: %s, codecForTone: %d, samplerate %d", ringchoice.c_str(), codecForTone->getPayloadType(), samplerate); - if (_audiofile) - loadFile = _audiofile->loadFile (ringchoice, codecForTone, samplerate); - + if (_audiofile) { + _audiofile->loadFile (ringchoice, codecForTone, samplerate); + } + _toneMutex.leaveMutex(); - if (loadFile) { - _toneMutex.enterMutex(); - _audiofile->start(); - _toneMutex.leaveMutex(); + _toneMutex.enterMutex(); + _audiofile->start(); + _toneMutex.leaveMutex(); - audioLayerMutexLock(); - // start audio if not started AND flush all buffers (main and urgent) - _audiodriver->startStream(); - audioLayerMutexUnlock(); + audioLayerMutexLock(); + // start audio if not started AND flush all buffers (main and urgent) + _audiodriver->startStream(); + audioLayerMutexUnlock(); - } else { - ringback(); - } + ringback(); } else { ringback();