From 61ebefc1a835013c3940c6ed2d839d888400192e Mon Sep 17 00:00:00 2001 From: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> Date: Wed, 19 Dec 2007 14:30:12 -0500 Subject: [PATCH] Add methods for audio settings on server side --- doc/SFLvideo.txt | 4 +- sflphone-gtk/src/configurationmanager-glue.h | 38 ++++++++++++++ sflphone-gtk/src/dbus.c | 55 +++++++++++++++++++- sflphone-gtk/src/dbus.h | 2 + src/dbus/configurationmanager-glue.h | 18 +++++++ src/dbus/configurationmanager-introspec.xml | 4 ++ src/dbus/configurationmanager.cpp | 8 ++- src/dbus/configurationmanager.h | 1 + src/managerimpl.cpp | 11 ++++ src/managerimpl.h | 1 + src/user_cfg.h | 3 ++ 11 files changed, 141 insertions(+), 4 deletions(-) diff --git a/doc/SFLvideo.txt b/doc/SFLvideo.txt index c274178805..90c38105e8 100644 --- a/doc/SFLvideo.txt +++ b/doc/SFLvideo.txt @@ -3,9 +3,9 @@ Partnership ----------- -A working partnership between SavoirFaire-Linux and Polytechnic school of Montreal will begin in January 2008. +A partnership between Savoir-Faire Linux and the Polytechnic school of Montreal will begin in January 2008. -5 students of Polytechnic school will work part-time on the project. +Five students from Polytechnic school will be working part-time on the project for four months. Goals ----- diff --git a/sflphone-gtk/src/configurationmanager-glue.h b/sflphone-gtk/src/configurationmanager-glue.h index f4b3d0133e..4769afbf9c 100644 --- a/sflphone-gtk/src/configurationmanager-glue.h +++ b/sflphone-gtk/src/configurationmanager-glue.h @@ -315,6 +315,44 @@ static inline #endif gboolean +org_sflphone_SFLphone_ConfigurationManager_get_default_codec_list (DBusGProxy *proxy, char *** OUT_list, GError **error) + +{ + return dbus_g_proxy_call (proxy, "getDefaultCodecList", error, G_TYPE_INVALID, G_TYPE_STRV, OUT_list, G_TYPE_INVALID); +} + +typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_default_codec_list_reply) (DBusGProxy *proxy, char * *OUT_list, GError *error, gpointer userdata); + +static void +org_sflphone_SFLphone_ConfigurationManager_get_default_codec_list_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + char ** OUT_list; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRV, &OUT_list, G_TYPE_INVALID); + (*(org_sflphone_SFLphone_ConfigurationManager_get_default_codec_list_reply)data->cb) (proxy, OUT_list, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +org_sflphone_SFLphone_ConfigurationManager_get_default_codec_list_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_get_default_codec_list_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_new (DBusGAsyncData, 1); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "getDefaultCodecList", org_sflphone_SFLphone_ConfigurationManager_get_default_codec_list_async_callback, stuff, g_free, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean org_sflphone_SFLphone_ConfigurationManager_get_tone_locale_list (DBusGProxy *proxy, char *** OUT_list, GError **error) { diff --git a/sflphone-gtk/src/dbus.c b/sflphone-gtk/src/dbus.c index 53a3357620..b549e190f7 100644 --- a/sflphone-gtk/src/dbus.c +++ b/sflphone-gtk/src/dbus.c @@ -688,6 +688,33 @@ dbus_codec_list() return array; } +gchar ** +dbus_default_codec_list() +{ + g_print("Before"); + + GError *error = NULL; + char ** array; + org_sflphone_SFLphone_ConfigurationManager_get_default_codec_list ( + configurationManagerProxy, + &array, + &error); + + g_print("After"); + if (error) + { + g_printerr ("Failed to call get_default_codec_list() on ConfigurationManager: %s\n", + error->message); + g_error_free (error); + } + else + { + g_print ("DBus called get_default_codec_list() on ConfigurationManager\n"); + + } + return array; +} + void dbus_set_prefered_codec(const gchar* codec) { @@ -711,6 +738,32 @@ dbus_set_prefered_codec(const gchar* codec) g_print ("DBus called set_prefered_codec() on ConfigurationManager\n"); } - +} + + +gchar** +dbus_get_sample_rate_list() +{ + g_print("Before"); + + gchar ** array; + GError *error = NULL; + org_sflphone_SFLphone_ConfigurationManager_get_sample_rate_list ( + configurationManagerProxy, + &array, + &error); + g_print("After"); + if (error) + { + g_printerr ("Failed to call get_sample_rate_list() on ConfigurationManager: %s\n", + error->message); + g_error_free (error); + } + else + { + g_print ("DBus called get_sample_rate_list() on ConfigurationManager\n"); + + } + return array; } diff --git a/sflphone-gtk/src/dbus.h b/sflphone-gtk/src/dbus.h index f71a3a40e1..e3f34e631b 100644 --- a/sflphone-gtk/src/dbus.h +++ b/sflphone-gtk/src/dbus.h @@ -54,6 +54,8 @@ void dbus_play_dtmf(const gchar * key); gchar* dbus_get_default_account(); void dbus_set_default_account(gchar * accountID); gchar** dbus_codec_list(); +gchar** dbus_default_codec_list(); +gchar** dbus_get_sample_rate_list(); /* Instance */ diff --git a/src/dbus/configurationmanager-glue.h b/src/dbus/configurationmanager-glue.h index 621f9593f2..3c6f92d5cd 100644 --- a/src/dbus/configurationmanager-glue.h +++ b/src/dbus/configurationmanager-glue.h @@ -28,6 +28,7 @@ public: register_method(ConfigurationManager, getVersion, _getVersion_stub); register_method(ConfigurationManager, getRingtoneList, _getRingtoneList_stub); register_method(ConfigurationManager, getCodecList, _getCodecList_stub); + register_method(ConfigurationManager, getDefaultCodecList, _getDefaultCodecList_stub); register_method(ConfigurationManager, getToneLocaleList, _getToneLocaleList_stub); register_method(ConfigurationManager, setCodecPreferedOrder, _setCodecPreferedOrder_stub); register_method(ConfigurationManager, getCodecPreferedOrder, _getCodecPreferedOrder_stub); @@ -82,6 +83,11 @@ public: { "list", "as", false }, { 0, 0, 0 } }; + static ::DBus::IntrospectedArgument getDefaultCodecList_args[] = + { + { "list", "as", false }, + { 0, 0, 0 } + }; static ::DBus::IntrospectedArgument getToneLocaleList_args[] = { { "list", "as", false }, @@ -141,6 +147,7 @@ public: { "getVersion", getVersion_args }, { "getRingtoneList", getRingtoneList_args }, { "getCodecList", getCodecList_args }, + { "getDefaultCodecList", getDefaultCodecList_args }, { "getToneLocaleList", getToneLocaleList_args }, { "setCodecPreferedOrder", setCodecPreferedOrder_args }, { "getCodecPreferedOrder", getCodecPreferedOrder_args }, @@ -190,6 +197,7 @@ public: virtual ::DBus::String getVersion( ) = 0; virtual std::vector< ::DBus::String > getRingtoneList( ) = 0; virtual std::vector< ::DBus::String > getCodecList( ) = 0; + virtual std::vector< ::DBus::String > getDefaultCodecList( ) = 0; virtual std::vector< ::DBus::String > getToneLocaleList( ) = 0; virtual void setCodecPreferedOrder( const ::DBus::String& codec_name ) = 0; virtual ::DBus::String getCodecPreferedOrder( ) = 0; @@ -299,6 +307,16 @@ private: wi << argout1; return reply; } + ::DBus::Message _getDefaultCodecList_stub( const ::DBus::CallMessage& call ) + { + ::DBus::MessageIter ri = call.reader(); + + std::vector< ::DBus::String > argout1 = getDefaultCodecList(); + ::DBus::ReturnMessage reply(call); + ::DBus::MessageIter wi = reply.writer(); + wi << argout1; + return reply; + } ::DBus::Message _getToneLocaleList_stub( const ::DBus::CallMessage& call ) { ::DBus::MessageIter ri = call.reader(); diff --git a/src/dbus/configurationmanager-introspec.xml b/src/dbus/configurationmanager-introspec.xml index fd7c9171be..4102085477 100644 --- a/src/dbus/configurationmanager-introspec.xml +++ b/src/dbus/configurationmanager-introspec.xml @@ -36,6 +36,10 @@ <arg type="as" name="list" direction="out"/> </method> + <method name="getDefaultCodecList"> + <arg type="as" name="list" direction="out"/> + </method> + <method name="getToneLocaleList"> <arg type="as" name="list" direction="out"/> </method> diff --git a/src/dbus/configurationmanager.cpp b/src/dbus/configurationmanager.cpp index af0573ae1d..f809912187 100644 --- a/src/dbus/configurationmanager.cpp +++ b/src/dbus/configurationmanager.cpp @@ -101,9 +101,14 @@ ConfigurationManager::getCodecList( ) { _debug("ConfigurationManager::getCodecList received\n"); return Manager::instance().getCodecList(); - } + std::vector< ::DBus::String > +ConfigurationManager::getDefaultCodecList( ) +{ + _debug("ConfigurationManager::getDefaultCodecList received\n"); + return Manager::instance().getDefaultCodecList(); +} void ConfigurationManager::setCodecPreferedOrder( const ::DBus::String& codec_name ) @@ -140,6 +145,7 @@ ConfigurationManager::getRecordDeviceList( ) ConfigurationManager::getSampleRateList( ) { _debug("ConfigurationManager::getSampleRateList received\n"); + return Manager::instance().getSampleRateList(); } diff --git a/src/dbus/configurationmanager.h b/src/dbus/configurationmanager.h index 510ff52e58..6b49c01390 100644 --- a/src/dbus/configurationmanager.h +++ b/src/dbus/configurationmanager.h @@ -46,6 +46,7 @@ public: ::DBus::String getVersion( ); std::vector< ::DBus::String > getRingtoneList( ); std::vector< ::DBus::String > getCodecList( ); + std::vector< ::DBus::String > getDefaultCodecList( ); std::vector< ::DBus::String > getToneLocaleList( ); void setCodecPreferedOrder( const ::DBus::String& codec_name ); ::DBus::String getCodecPreferedOrder( ); diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index f4188f6b95..ffed542c61 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -1149,6 +1149,17 @@ ManagerImpl::getCodecList( void ) return v; } + +std::vector< std::string > +ManagerImpl::getSampleRateList( void ) +{ + std::vector< std::string > v; + v.push_back(SAMPLE_RATE1); + v.push_back(SAMPLE_RATE2); + v.push_back(SAMPLE_RATE3); + return v; +} + /** * Initialization: Main Thread */ diff --git a/src/managerimpl.h b/src/managerimpl.h index 7c14f20700..00acd9f9a4 100644 --- a/src/managerimpl.h +++ b/src/managerimpl.h @@ -286,6 +286,7 @@ public: */ std::vector< ::DBus::String > getDefaultCodecList( void ); + std::vector< ::DBus::String> getSampleRateList( void ); /* * Set an account as default diff --git a/src/user_cfg.h b/src/user_cfg.h index 2f757faa03..497674b914 100644 --- a/src/user_cfg.h +++ b/src/user_cfg.h @@ -106,6 +106,9 @@ #define DFT_VOICEMAIL "888" #define DFT_FRAME_SIZE "20" #define DFT_SAMPLE_RATE "44100" +#define SAMPLE_RATE1 "44100" +#define SAMPLE_RATE2 "48000" +#define SAMPLE_RATE3 "96000" // zeroconfig default value #ifdef USE_ZEROCONF #define CONFIG_ZEROCONF_DEFAULT_STR "1" -- GitLab