Commit 20882241 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Add configuration panel for audio record module

parent 3dd14d02
...@@ -798,7 +798,7 @@ GtkWidget* create_audio_configuration() ...@@ -798,7 +798,7 @@ GtkWidget* create_audio_configuration()
box = codecs_box(); box = codecs_box();
gtk_container_add( GTK_CONTAINER(codecs_conf) , box ); gtk_container_add( GTK_CONTAINER(codecs_conf) , box );
// Box for the codecs // Box for the ringtones
ringtones_conf = gtk_frame_new(_("Ringtones")); ringtones_conf = gtk_frame_new(_("Ringtones"));
gtk_box_pack_start(GTK_BOX(ret), ringtones_conf, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(ret), ringtones_conf, FALSE, FALSE, 0);
gtk_widget_show( ringtones_conf ); gtk_widget_show( ringtones_conf );
......
...@@ -672,37 +672,36 @@ create_general_settings () ...@@ -672,37 +672,36 @@ create_general_settings ()
return ret; return ret;
} }
void void
record_path_changed( GtkFileChooser *chooser , GtkLabel *label UNUSED) record_path_changed( GtkFileChooser *chooser , GtkLabel *label UNUSED)
{ {
// gchar* tone = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( chooser )); gchar* path;
// dbus_set_ringtone_choice( tone );
path = gtk_file_chooser_get_uri( GTK_FILE_CHOOSER( chooser ));
dbus_set_record_path( path );
} }
GtkWidget* GtkWidget*
create_recording_settings () create_recording_settings ()
{ {
int curPort;
int n;
gchar *defaultSavePath = "/home/alexandresavard/";
GtkWidget *ret; GtkWidget *ret;
GtkWidget *label; GtkWidget *label;
GtkWidget *table; GtkWidget *table;
GtkWidget *savePathFrame; GtkWidget *savePathFrame;
GtkWidget *savePathText;
GtkWidget *folderChooser; GtkWidget *folderChooser;
gchar *dftPath;
/* Get the path where to save audio files */
dftPath = dbus_get_record_path ();
// Main widget // Main widget
ret = gtk_vbox_new(FALSE, 10); ret = gtk_vbox_new(FALSE, 10);
gtk_container_set_border_width(GTK_CONTAINER(ret), 10); gtk_container_set_border_width(GTK_CONTAINER(ret), 10);
// Recorded file saving path // Recorded file saving path
savePathFrame = gtk_frame_new(_("Recorded File Saving Path")); savePathFrame = gtk_frame_new(_("General"));
gtk_box_pack_start(GTK_BOX(ret), savePathFrame, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(ret), savePathFrame, FALSE, FALSE, 5);
gtk_widget_show(savePathFrame); gtk_widget_show(savePathFrame);
table = gtk_table_new(1, 2, FALSE); table = gtk_table_new(1, 2, FALSE);
...@@ -712,20 +711,16 @@ create_recording_settings () ...@@ -712,20 +711,16 @@ create_recording_settings ()
gtk_container_add(GTK_CONTAINER(savePathFrame), table); gtk_container_add(GTK_CONTAINER(savePathFrame), table);
// label // label
label = gtk_label_new_with_mnemonic(_("_Save Path")); label = gtk_label_new_with_mnemonic(_("_Destination folder"));
gtk_table_attach( GTK_TABLE(table), label, 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_table_attach( GTK_TABLE(table), label, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 5);
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
savePathText = gtk_entry_new();
gtk_label_set_mnemonic_widget(GTK_LABEL(label), savePathText);
gtk_entry_set_text(GTK_ENTRY(savePathText),defaultSavePath);
gtk_table_attach(GTK_TABLE(table), savePathText, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
// folder chooser button // folder chooser button
folderChooser = gtk_file_chooser_button_new(_("Choose a path"), GTK_FILE_CHOOSER_ACTION_OPEN); folderChooser = gtk_file_chooser_button_new(_("Select a folder"), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER( folderChooser) , g_get_home_dir()); gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER( folderChooser) ,
g_signal_connect( G_OBJECT( folderChooser ) , "recordPath_changed" , G_CALLBACK( record_path_changed ) , NULL ); (strcmp(dftPath,"")==0)?g_get_home_dir():dftPath);
gtk_box_pack_start( GTK_BOX(ret) , folderChooser , TRUE , TRUE , 1); gtk_table_attach(GTK_TABLE(table), folderChooser, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 5);
// gtk_container_add(GTK_CONTAINER(savePathFrame), folder); g_signal_connect( G_OBJECT( folderChooser ) , "selection_changed" , G_CALLBACK( record_path_changed ) , NULL );
gtk_widget_show_all(ret); gtk_widget_show_all(ret);
...@@ -776,7 +771,7 @@ show_config_window () ...@@ -776,7 +771,7 @@ show_config_window ()
// Recording tab // Recording tab
tab = create_recording_settings(); tab = create_recording_settings();
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), tab, gtk_label_new(_("Recording Settings"))); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), tab, gtk_label_new(_("Record")));
gtk_notebook_page_num(GTK_NOTEBOOK(notebook), tab); gtk_notebook_page_num(GTK_NOTEBOOK(notebook), tab);
gtk_notebook_set_current_page( GTK_NOTEBOOK( notebook) , 1); gtk_notebook_set_current_page( GTK_NOTEBOOK( notebook) , 1);
......
...@@ -178,7 +178,7 @@ error_alert(DBusGProxy *proxy UNUSED, ...@@ -178,7 +178,7 @@ error_alert(DBusGProxy *proxy UNUSED,
} }
static void nameOwnerChanged(DBusGProxy *proxy UNUSED, char *name , char *old_owner, char *new_owner, gpointer data UNUSED) static void nameOwnerChanged(DBusGProxy *proxy UNUSED, char *name , char *old_owner UNUSED, char *new_owner UNUSED, gpointer data UNUSED)
{ {
#if 0 #if 0
g_print("******************************************************************\n"); g_print("******************************************************************\n");
...@@ -1301,6 +1301,35 @@ dbus_set_record(const call_t * c) ...@@ -1301,6 +1301,35 @@ dbus_set_record(const call_t * c)
g_print("called dbus_set_record on CallManager\n"); g_print("called dbus_set_record on CallManager\n");
} }
void
dbus_set_record_path(const gchar* path)
{
GError* error = NULL;
org_sflphone_SFLphone_ConfigurationManager_set_record_path (
configurationManagerProxy,
path,
&error);
if(error)
{
g_error_free(error);
}
}
gchar*
dbus_get_record_path(void)
{
GError* error = NULL;
gchar *path;
org_sflphone_SFLphone_ConfigurationManager_get_record_path (
configurationManagerProxy,
&path,
&error);
if(error)
{
g_error_free(error);
}
return path;
}
void void
dbus_set_max_calls( const guint calls ) dbus_set_max_calls( const guint calls )
......
...@@ -436,4 +436,8 @@ gint dbus_stun_is_enabled (void); ...@@ -436,4 +436,8 @@ gint dbus_stun_is_enabled (void);
void dbus_enable_stun (void); void dbus_enable_stun (void);
void dbus_set_record (const call_t * c); void dbus_set_record (const call_t * c);
void dbus_set_record_path (const gchar *path);
gchar* dbus_get_record_path (void);
#endif #endif
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include "call.h" #include "call.h"
#include "manager.h"
Call::Call(const CallID& id, Call::CallType type) Call::Call(const CallID& id, Call::CallType type)
: _callMutex() : _callMutex()
...@@ -40,7 +41,7 @@ Call::Call(const CallID& id, Call::CallType type) ...@@ -40,7 +41,7 @@ Call::Call(const CallID& id, Call::CallType type)
FILE_TYPE fileType = FILE_WAV; FILE_TYPE fileType = FILE_WAV;
SOUND_FORMAT soundFormat = INT16; SOUND_FORMAT soundFormat = INT16;
recAudio.setRecordingOption(fileType,soundFormat,44100); recAudio.setRecordingOption(fileType,soundFormat,44100, Manager::instance().getConfigString (AUDIO, RECORD_PATH));
_debug("CALL::Constructor for this clss is called \n"); _debug("CALL::Constructor for this clss is called \n");
} }
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
typedef std::string CallID; typedef std::string CallID;
class AudioRecord;
class Call{ class Call{
public: public:
/** /**
......
...@@ -1410,7 +1410,7 @@ ManagerImpl::getRecordPath( void ) ...@@ -1410,7 +1410,7 @@ ManagerImpl::getRecordPath( void )
void void
ManagerImpl::setRecordPath( const std::string& recPath) ManagerImpl::setRecordPath( const std::string& recPath)
{ {
setConfig( AUDIO, RECORD_PATH, recPath ); setConfig( AUDIO, RECORD_PATH, recPath.substr(7));
} }
int int
......
...@@ -19,6 +19,22 @@ ...@@ -19,6 +19,22 @@
#include "audiorecord.h" #include "audiorecord.h"
// structure for the wave header
struct wavhdr {
char riff[4]; // "RIFF"
SINT32 file_size; // in bytes
char wave[4]; // "WAVE"
char fmt[4]; // "fmt "
SINT32 chunk_size; // in bytes (16 for PCM)
SINT16 format_tag; // 1=PCM, 2=ADPCM, 3=IEEE float, 6=A-Law, 7=Mu-Law
SINT16 num_chans; // 1=mono, 2=stereo
SINT32 sample_rate;
SINT32 bytes_per_sec;
SINT16 bytes_per_samp; // 2=16-bit mono, 4=16-bit stereo
SINT16 bits_per_samp;
char data[4]; // "data"
SINT32 data_length; // in bytes
};
AudioRecord::AudioRecord(){ AudioRecord::AudioRecord(){
...@@ -38,9 +54,11 @@ void AudioRecord::setSndSamplingRate(int smplRate){ ...@@ -38,9 +54,11 @@ void AudioRecord::setSndSamplingRate(int smplRate){
sndSmplRate_ = smplRate; sndSmplRate_ = smplRate;
} }
void AudioRecord::setRecordingOption(FILE_TYPE type, SOUND_FORMAT format, int sndSmplRate){ void AudioRecord::setRecordingOption(FILE_TYPE type, SOUND_FORMAT format, int sndSmplRate, std::string path){
fileType_ = type; std::string fName;
fileType_ = type;
sndFormat_ = format; sndFormat_ = format;
channels_ = 1; channels_ = 1;
sndSmplRate_ = sndSmplRate; sndSmplRate_ = sndSmplRate;
...@@ -57,6 +75,11 @@ void AudioRecord::setRecordingOption(FILE_TYPE type, SOUND_FORMAT format, int sn ...@@ -57,6 +75,11 @@ void AudioRecord::setRecordingOption(FILE_TYPE type, SOUND_FORMAT format, int sn
strcat(fileName_, ".wav"); strcat(fileName_, ".wav");
} }
} }
fName = fileName_;
savePath_ = path + "/";
savePath_.append(fName);
} }
void AudioRecord::openFile(){ void AudioRecord::openFile(){
...@@ -64,16 +87,6 @@ void AudioRecord::openFile(){ ...@@ -64,16 +87,6 @@ void AudioRecord::openFile(){
_debug("AudioRecord::openFile()\n"); _debug("AudioRecord::openFile()\n");
savePath_ = getenv("HOME");
std::string fName(fileName_);
savePath_ += "/";
savePath_.append(fName);
bool result = false; bool result = false;
_debug("AudioRecord::openFile()\n"); _debug("AudioRecord::openFile()\n");
......
...@@ -17,34 +17,17 @@ ...@@ -17,34 +17,17 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef _AUDIO_RECORD_H
#define _AUDIO_RECORD_H
#include <iostream> #include <iostream>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <sstream> #include <sstream>
#include "global.h"
#include "plug-in/plugin.h" #include "plug-in/plugin.h"
using namespace std; using namespace std;
// structure for the wave header
struct wavhdr {
char riff[4]; // "RIFF"
SINT32 file_size; // in bytes
char wave[4]; // "WAVE"
char fmt[4]; // "fmt "
SINT32 chunk_size; // in bytes (16 for PCM)
SINT16 format_tag; // 1=PCM, 2=ADPCM, 3=IEEE float, 6=A-Law, 7=Mu-Law
SINT16 num_chans; // 1=mono, 2=stereo
SINT32 sample_rate;
SINT32 bytes_per_sec;
SINT16 bytes_per_samp; // 2=16-bit mono, 4=16-bit stereo
SINT16 bits_per_samp;
char data[4]; // "data"
SINT32 data_length; // in bytes
};
typedef std::string CallID; typedef std::string CallID;
class AudioRecord class AudioRecord
...@@ -56,7 +39,7 @@ public: ...@@ -56,7 +39,7 @@ public:
void setSndSamplingRate(int smplRate); void setSndSamplingRate(int smplRate);
void setRecordingOption(FILE_TYPE type, SOUND_FORMAT format, int sndSmplRate); void setRecordingOption(FILE_TYPE type, SOUND_FORMAT format, int sndSmplRate, std::string path);
/** /**
* Check if no otehr file is opened, then create a new one * Check if no otehr file is opened, then create a new one
...@@ -201,3 +184,5 @@ protected: ...@@ -201,3 +184,5 @@ protected:
}; };
#endif // _AUDIO_RECORD_H
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
#ifndef __VOIP_LINK_H__ #ifndef __VOIP_LINK_H__
#define __VOIP_LINK_H__ #define __VOIP_LINK_H__
#include "call.h"
#include "account.h" #include "account.h"
#include "call.h"
class AudioCodec; class AudioCodec;
class Account; class Account;
......
Supports Markdown
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