diff --git a/doc/Dependencies.txt b/doc/Dependencies.txt index 7abaaeb2ca2cf1b18d16d8eb8cc39742f6c8ed02..64c8ee717e704eb43cc7c2e9babae05d48792e10 100644 --- a/doc/Dependencies.txt +++ b/doc/Dependencies.txt @@ -18,6 +18,7 @@ libsamplerate 0.1.2 http://www.mega-nerd.com/SRC/[website] libdbus-glib 0.73 Packaged with your favorite distribution. dbus-c++-1 0.5 Source code included in the git repository. See Build notes. libexpat1 1.95.8 Packaged with your favorite distribution. +libboost-dev 1.34.1 -------------------------------------------------------------------------------------- @@ -34,8 +35,11 @@ dbus-glib 0.35 gnome-common -------------------------------------------------------------------------------------- + + + Dependencies to use audio codecs ------------------------------------- +-------------------------------- `--------------------`----------`----------------------------------------------------- Program Version Notes diff --git a/doc/Goals.txt b/doc/Goals.txt index 3d224e1f8b3acdc36809e493ea145f9d6f4891ca..b9d84b73a759b511be7c8a0f0b9c91b9b9ac8569 100644 --- a/doc/Goals.txt +++ b/doc/Goals.txt @@ -11,10 +11,10 @@ Goals for next release (0.8) * Functional IAX transport * Near perfect audio * Multiple-client (GUI or other) connectivity to server - - New Gtk+ GUI with following functionnality (altough the server can do more): + - New Gtk+ GUI with following functionality (although the server can do more): * User can place a call * User can answer a call - * User can transfert a call + * User can transfer a call * User can have an unlimited number of calls * User can put a call on hold and off hold * User is informed of waiting voice mail @@ -29,7 +29,7 @@ Goals for release 0.8.5 - Server side: * Perfect audio * Better error handling of failed account registrations - * Fully working multiple account functionnality + * Fully working multiple account functionality - Gtk+ GUI updates * User can set up audio parameters * User can set up STUN and proxy settings for SIP accounts @@ -41,7 +41,7 @@ Goals for release 0.8.5 * User can place a call * User can answer calls * User can send DTMF - * User can transfert a call + * User can transfer a call @@ -55,7 +55,7 @@ Goals for release 0.9 - Gtk+ GUI updates * User can receive and send SMS messages * User is informed of call duration - * User can set up speel call buttons + * User can set up speed call buttons * User can consult/clear call history * User can set a status - Python CLI client diff --git a/sflphone-gtk/src/actions.c b/sflphone-gtk/src/actions.c index 36af50798445c507429f6db182702f927d91f0e9..83a75171e67b0223e00335aa834e38ea6ae07b38 100644 --- a/sflphone-gtk/src/actions.c +++ b/sflphone-gtk/src/actions.c @@ -580,26 +580,44 @@ sflphone_set_default_account( ) void sflphone_fill_codec_list() { - - int i=0; + + codec_list_clear(); + gchar** codecs = (gchar**)dbus_codec_list(); - while(codecs[i]!=NULL) + gchar** order = (gchar**)dbus_get_active_codec_list(); + gchar** details; + gchar** pl; + + for(pl=order; *order; order++) { - printf("%s\n", codecs[i]); codec_t * c = g_new0(codec_t, 1); - c->name = codecs[i]; - codec_set_active(codecs[i]); // active by default + c->_payload = atoi(*order); + details = (gchar **)dbus_codec_details(c->_payload); + //printf("Codec details: %s / %s / %s / %s\n",details[0],details[1],details[2],details[3]); + c->name = details[0]; + c->is_active = TRUE; + c->sample_rate = atoi(details[1]); + c->_bitrate = atof(details[2]); + c->_bandwidth = atof(details[3]); codec_list_add(c); - i++; + } + + for(pl=codecs; *codecs; codecs++) + { + details = (gchar **)dbus_codec_details(atoi(*codecs)); + if(codec_list_get(details[0])!=NULL){ + // does nothing - the codec is already in the list, so is active. + } + else{ + codec_t* c = g_new0(codec_t, 1); + c->_payload = atoi(*codecs); + c->name = details[0]; + c->is_active = FALSE; + c->sample_rate = atoi(details[1]); + c->_bitrate = atof(details[2]); + c->_bandwidth = atof(details[3]); + codec_list_add(c); + } } } - - - - - - - - - diff --git a/sflphone-gtk/src/calltree.c b/sflphone-gtk/src/calltree.c index 51563c3f7e194e450c56e49d0e68018305746238..8266db08149bbcde6f3904f582eef1ad2af8e28d 100644 --- a/sflphone-gtk/src/calltree.c +++ b/sflphone-gtk/src/calltree.c @@ -75,11 +75,11 @@ call_button( GtkWidget *widget, gpointer data ) /** * Pick up */ - static void +/* static void pick_up( GtkWidget *widget, gpointer data ) { sflphone_pick_up(); -} +}*/ /** * Hang up the line @@ -284,12 +284,14 @@ create_toolbar (){ image = gtk_image_new_from_file( ICONS_DIR "/call.svg"); callButton = gtk_tool_button_new (image, "Place a Call"); + gtk_widget_set_tooltip_text(GTK_WIDGET(callButton), "Place a call"); g_signal_connect (G_OBJECT (callButton), "clicked", G_CALLBACK (call_button), NULL); - gtk_toolbar_insert(GTK_TOOLBAR(ret), GTK_TOOL_ITEM(callButton), -1); + gtk_toolbar_insert(GTK_TOOLBAR(ret), GTK_TOOL_ITEM(callButton), -1); image = gtk_image_new_from_file( ICONS_DIR "/accept.svg"); pickupButton = gtk_tool_button_new(image, "Pick up"); + gtk_widget_set_tooltip_text(GTK_WIDGET(pickupButton), "Pick up"); gtk_widget_set_state( GTK_WIDGET(pickupButton), GTK_STATE_INSENSITIVE); g_signal_connect(G_OBJECT (pickupButton), "clicked", G_CALLBACK (call_button), NULL); @@ -297,6 +299,7 @@ create_toolbar (){ image = gtk_image_new_from_file( ICONS_DIR "/hang_up.svg"); hangupButton = gtk_tool_button_new (image, "Hang up"); + gtk_widget_set_tooltip_text(GTK_WIDGET(hangupButton), "Hang up"); gtk_widget_set_state( GTK_WIDGET(hangupButton), GTK_STATE_INSENSITIVE); g_signal_connect (G_OBJECT (hangupButton), "clicked", G_CALLBACK (hang_up), NULL); @@ -304,6 +307,7 @@ create_toolbar (){ image = gtk_image_new_from_file( ICONS_DIR "/unhold.svg"); unholdButton = gtk_tool_button_new (image, "Off Hold"); + gtk_widget_set_tooltip_text(GTK_WIDGET(unholdButton), "Off Hold"); gtk_widget_set_state( GTK_WIDGET(unholdButton), GTK_STATE_INSENSITIVE); g_signal_connect (G_OBJECT (unholdButton), "clicked", G_CALLBACK (unhold), NULL); @@ -311,14 +315,16 @@ create_toolbar (){ image = gtk_image_new_from_file( ICONS_DIR "/hold.svg"); holdButton = gtk_tool_button_new (image, "On Hold"); + gtk_widget_set_tooltip_text(GTK_WIDGET(holdButton), "On Hold"); gtk_widget_set_state( GTK_WIDGET(holdButton), GTK_STATE_INSENSITIVE); g_signal_connect (G_OBJECT (holdButton), "clicked", G_CALLBACK (hold), NULL); - gtk_toolbar_insert(GTK_TOOLBAR(ret), GTK_TOOL_ITEM(holdButton), -1); + gtk_toolbar_insert(GTK_TOOLBAR(ret), GTK_TOOL_ITEM(holdButton), -1); image = gtk_image_new_from_file( ICONS_DIR "/transfert.svg"); transfertButton = gtk_toggle_tool_button_new (); gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(transfertButton), image); + gtk_widget_set_tooltip_text(GTK_WIDGET(transfertButton), "Transfer"); gtk_tool_button_set_label(GTK_TOOL_BUTTON(transfertButton), "Transfer"); gtk_widget_set_state( GTK_WIDGET(transfertButton), GTK_STATE_INSENSITIVE); transfertButtonConnId = g_signal_connect (G_OBJECT (transfertButton), "toggled", diff --git a/sflphone-gtk/src/codeclist.c b/sflphone-gtk/src/codeclist.c index 9c62d0aae45b998c492d624af542e3ddfd0d165d..2e15fb657015d3b3ff7407952dd6152d35746a82 100644 --- a/sflphone-gtk/src/codeclist.c +++ b/sflphone-gtk/src/codeclist.c @@ -20,6 +20,7 @@ #include <codeclist.h> #include <string.h> +#include <stdlib.h> GQueue * codecQueue = NULL; @@ -33,12 +34,29 @@ is_name_codecstruct (gconstpointer a, gconstpointer b) return 1; } +gint +is_payload_codecstruct (gconstpointer a, gconstpointer b) +{ + codec_t * c = (codec_t *)a; + if(c->_payload == (int)b) + return 0; + else + return 1; +} + void codec_list_init() { codecQueue = g_queue_new(); } +void +codec_list_clear () +{ + g_queue_free (codecQueue); + codecQueue = g_queue_new(); +} + void codec_list_add(codec_t * c) { @@ -47,17 +65,19 @@ codec_list_add(codec_t * c) void -codec_set_active(gchar * codec_name) +codec_set_active(gchar* name) { - codec_t * c = codec_list_get(codec_name); - if(c) + codec_t * c = codec_list_get(name); + if(c){ + printf("%s set active/n", c->name); c->is_active = TRUE; + } } void -codec_set_inactive(gchar * codec_name) +codec_set_inactive(gchar* name) { - codec_t * c = codec_list_get(codec_name); + codec_t * c = codec_list_get(name); if(c) c->is_active = FALSE; } @@ -69,7 +89,7 @@ codec_list_get_size() } codec_t* -codec_list_get( const gchar * name) +codec_list_get( const gchar* name) { GList * c = g_queue_find_custom(codecQueue, name, is_name_codecstruct); if(c) @@ -92,3 +112,34 @@ codec_set_prefered_order(guint index) g_queue_push_head(codecQueue, prefered); } +void +codec_list_move_codec_up(guint index) +{ + if(index != 0) + { + gpointer codec = g_queue_pop_nth(codecQueue, index); + g_queue_push_nth(codecQueue, codec, index-1); + } + + // TEMP + int i; + printf("\nCodec list\n"); + for(i=0; i < codecQueue->length; i++) + printf("%s\n", codec_list_get_nth(i)->name); +} + +void +codec_list_move_codec_down(guint index) +{ + if(index != codecQueue->length) + { + gpointer codec = g_queue_pop_nth(codecQueue, index); + g_queue_push_nth(codecQueue, codec, index+1); + } + + // TEMP + int i; + printf("\nCodec list\n"); + for(i=0; i < codecQueue->length; i++) + printf("%s\n", codec_list_get_nth(i)->name); +} diff --git a/sflphone-gtk/src/codeclist.h b/sflphone-gtk/src/codeclist.h index d083231bbe5f75a36cf86a9636157f0ca60549ab..edeea9d9933a8d3fc2b13d26acd06e46d1164c99 100644 --- a/sflphone-gtk/src/codeclist.h +++ b/sflphone-gtk/src/codeclist.h @@ -26,17 +26,22 @@ */ typedef struct { - gchar * name; - guint sample_rate; + int _payload; gboolean is_active; + gchar * name; + int sample_rate; + gdouble _bitrate; + gdouble _bandwidth; }codec_t; void codec_list_init(); +void codec_list_clear(); void codec_list_add(codec_t * c); -void codec_set_active(gchar * codec_name); -void codec_set_inactive(gchar * codec_name); +void codec_set_active(gchar* name); +void codec_set_inactive(gchar* name); guint codec_list_get_size(); -codec_t * codec_list_get(const gchar * codec_name); +codec_t * codec_list_get(const gchar * name); +//codec_t * codec_list_get(const int payload); codec_t* codec_list_get_nth(guint index); /** @@ -47,4 +52,7 @@ void codec_set_prefered_order(guint index); //gchar * codec_get_name(codec_t * c); //guint codec_get_rate(gchar * codec_name); +void codec_list_move_codec_up(guint index); +void codec_list_move_codec_down(guint index); + #endif diff --git a/sflphone-gtk/src/configurationmanager-glue.h b/sflphone-gtk/src/configurationmanager-glue.h index 4769afbf9cf2c18fcb91a7a58f779772ee262dde..3afaab84a977e04c6cb9277829da05c079074380 100644 --- a/sflphone-gtk/src/configurationmanager-glue.h +++ b/sflphone-gtk/src/configurationmanager-glue.h @@ -201,22 +201,22 @@ static inline #endif gboolean -org_sflphone_SFLphone_ConfigurationManager_get_version (DBusGProxy *proxy, char ** OUT_version, GError **error) +org_sflphone_SFLphone_ConfigurationManager_get_default_account (DBusGProxy *proxy, char ** OUT_accountID, GError **error) { - return dbus_g_proxy_call (proxy, "getVersion", error, G_TYPE_INVALID, G_TYPE_STRING, OUT_version, G_TYPE_INVALID); + return dbus_g_proxy_call (proxy, "getDefaultAccount", error, G_TYPE_INVALID, G_TYPE_STRING, OUT_accountID, G_TYPE_INVALID); } -typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_version_reply) (DBusGProxy *proxy, char * OUT_version, GError *error, gpointer userdata); +typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_default_account_reply) (DBusGProxy *proxy, char * OUT_accountID, GError *error, gpointer userdata); static void -org_sflphone_SFLphone_ConfigurationManager_get_version_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +org_sflphone_SFLphone_ConfigurationManager_get_default_account_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) { DBusGAsyncData *data = (DBusGAsyncData*) user_data; GError *error = NULL; - char * OUT_version; - dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRING, &OUT_version, G_TYPE_INVALID); - (*(org_sflphone_SFLphone_ConfigurationManager_get_version_reply)data->cb) (proxy, OUT_version, error, data->userdata); + char * OUT_accountID; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRING, &OUT_accountID, G_TYPE_INVALID); + (*(org_sflphone_SFLphone_ConfigurationManager_get_default_account_reply)data->cb) (proxy, OUT_accountID, error, data->userdata); return; } @@ -225,36 +225,35 @@ static inline #endif DBusGProxyCall* -org_sflphone_SFLphone_ConfigurationManager_get_version_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_get_version_reply callback, gpointer userdata) +org_sflphone_SFLphone_ConfigurationManager_get_default_account_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_get_default_account_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, "getVersion", org_sflphone_SFLphone_ConfigurationManager_get_version_async_callback, stuff, g_free, G_TYPE_INVALID); + return dbus_g_proxy_begin_call (proxy, "getDefaultAccount", org_sflphone_SFLphone_ConfigurationManager_get_default_account_async_callback, stuff, g_free, G_TYPE_INVALID); } static #ifdef G_HAVE_INLINE inline #endif gboolean -org_sflphone_SFLphone_ConfigurationManager_get_ringtone_list (DBusGProxy *proxy, char *** OUT_list, GError **error) +org_sflphone_SFLphone_ConfigurationManager_set_default_account (DBusGProxy *proxy, const char * IN_accountID, GError **error) { - return dbus_g_proxy_call (proxy, "getRingtoneList", error, G_TYPE_INVALID, G_TYPE_STRV, OUT_list, G_TYPE_INVALID); + return dbus_g_proxy_call (proxy, "setDefaultAccount", error, G_TYPE_STRING, IN_accountID, G_TYPE_INVALID, G_TYPE_INVALID); } -typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_ringtone_list_reply) (DBusGProxy *proxy, char * *OUT_list, GError *error, gpointer userdata); +typedef void (*org_sflphone_SFLphone_ConfigurationManager_set_default_account_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); static void -org_sflphone_SFLphone_ConfigurationManager_get_ringtone_list_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +org_sflphone_SFLphone_ConfigurationManager_set_default_account_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_ringtone_list_reply)data->cb) (proxy, OUT_list, error, data->userdata); + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(org_sflphone_SFLphone_ConfigurationManager_set_default_account_reply)data->cb) (proxy, error, data->userdata); return; } @@ -263,36 +262,36 @@ static inline #endif DBusGProxyCall* -org_sflphone_SFLphone_ConfigurationManager_get_ringtone_list_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_get_ringtone_list_reply callback, gpointer userdata) +org_sflphone_SFLphone_ConfigurationManager_set_default_account_async (DBusGProxy *proxy, const char * IN_accountID, org_sflphone_SFLphone_ConfigurationManager_set_default_account_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, "getRingtoneList", org_sflphone_SFLphone_ConfigurationManager_get_ringtone_list_async_callback, stuff, g_free, G_TYPE_INVALID); + return dbus_g_proxy_begin_call (proxy, "setDefaultAccount", org_sflphone_SFLphone_ConfigurationManager_set_default_account_async_callback, stuff, g_free, G_TYPE_STRING, IN_accountID, G_TYPE_INVALID); } static #ifdef G_HAVE_INLINE inline #endif gboolean -org_sflphone_SFLphone_ConfigurationManager_get_codec_list (DBusGProxy *proxy, char *** OUT_list, GError **error) +org_sflphone_SFLphone_ConfigurationManager_get_tone_locale_list (DBusGProxy *proxy, char *** OUT_list, GError **error) { - return dbus_g_proxy_call (proxy, "getCodecList", error, G_TYPE_INVALID, G_TYPE_STRV, OUT_list, G_TYPE_INVALID); + return dbus_g_proxy_call (proxy, "getToneLocaleList", error, G_TYPE_INVALID, G_TYPE_STRV, OUT_list, G_TYPE_INVALID); } -typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_codec_list_reply) (DBusGProxy *proxy, char * *OUT_list, GError *error, gpointer userdata); +typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_tone_locale_list_reply) (DBusGProxy *proxy, char * *OUT_list, GError *error, gpointer userdata); static void -org_sflphone_SFLphone_ConfigurationManager_get_codec_list_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +org_sflphone_SFLphone_ConfigurationManager_get_tone_locale_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_codec_list_reply)data->cb) (proxy, OUT_list, error, data->userdata); + (*(org_sflphone_SFLphone_ConfigurationManager_get_tone_locale_list_reply)data->cb) (proxy, OUT_list, error, data->userdata); return; } @@ -301,36 +300,36 @@ static inline #endif DBusGProxyCall* -org_sflphone_SFLphone_ConfigurationManager_get_codec_list_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_get_codec_list_reply callback, gpointer userdata) +org_sflphone_SFLphone_ConfigurationManager_get_tone_locale_list_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_get_tone_locale_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, "getCodecList", org_sflphone_SFLphone_ConfigurationManager_get_codec_list_async_callback, stuff, g_free, G_TYPE_INVALID); + return dbus_g_proxy_begin_call (proxy, "getToneLocaleList", org_sflphone_SFLphone_ConfigurationManager_get_tone_locale_list_async_callback, stuff, g_free, G_TYPE_INVALID); } static #ifdef G_HAVE_INLINE inline #endif gboolean -org_sflphone_SFLphone_ConfigurationManager_get_default_codec_list (DBusGProxy *proxy, char *** OUT_list, GError **error) +org_sflphone_SFLphone_ConfigurationManager_get_version (DBusGProxy *proxy, char ** OUT_version, GError **error) { - return dbus_g_proxy_call (proxy, "getDefaultCodecList", error, G_TYPE_INVALID, G_TYPE_STRV, OUT_list, G_TYPE_INVALID); + return dbus_g_proxy_call (proxy, "getVersion", error, G_TYPE_INVALID, G_TYPE_STRING, OUT_version, G_TYPE_INVALID); } -typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_default_codec_list_reply) (DBusGProxy *proxy, char * *OUT_list, GError *error, gpointer userdata); +typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_version_reply) (DBusGProxy *proxy, char * OUT_version, GError *error, gpointer userdata); static void -org_sflphone_SFLphone_ConfigurationManager_get_default_codec_list_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +org_sflphone_SFLphone_ConfigurationManager_get_version_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); + char * OUT_version; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRING, &OUT_version, G_TYPE_INVALID); + (*(org_sflphone_SFLphone_ConfigurationManager_get_version_reply)data->cb) (proxy, OUT_version, error, data->userdata); return; } @@ -339,73 +338,36 @@ static 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) +org_sflphone_SFLphone_ConfigurationManager_get_version_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_get_version_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); + return dbus_g_proxy_begin_call (proxy, "getVersion", org_sflphone_SFLphone_ConfigurationManager_get_version_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) +org_sflphone_SFLphone_ConfigurationManager_get_ringtone_list (DBusGProxy *proxy, char *** OUT_list, GError **error) { - return dbus_g_proxy_call (proxy, "getToneLocaleList", error, G_TYPE_INVALID, G_TYPE_STRV, OUT_list, G_TYPE_INVALID); + return dbus_g_proxy_call (proxy, "getRingtoneList", error, G_TYPE_INVALID, G_TYPE_STRV, OUT_list, G_TYPE_INVALID); } -typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_tone_locale_list_reply) (DBusGProxy *proxy, char * *OUT_list, GError *error, gpointer userdata); +typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_ringtone_list_reply) (DBusGProxy *proxy, char * *OUT_list, GError *error, gpointer userdata); static void -org_sflphone_SFLphone_ConfigurationManager_get_tone_locale_list_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +org_sflphone_SFLphone_ConfigurationManager_get_ringtone_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_tone_locale_list_reply)data->cb) (proxy, OUT_list, error, data->userdata); - return; -} - -static -#ifdef G_HAVE_INLINE -inline -#endif -DBusGProxyCall* -org_sflphone_SFLphone_ConfigurationManager_get_tone_locale_list_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_get_tone_locale_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, "getToneLocaleList", org_sflphone_SFLphone_ConfigurationManager_get_tone_locale_list_async_callback, stuff, g_free, G_TYPE_INVALID); -} -static -#ifdef G_HAVE_INLINE -inline -#endif -gboolean -org_sflphone_SFLphone_ConfigurationManager_set_codec_prefered_order (DBusGProxy *proxy, const char * IN_codec_name, GError **error) - -{ - return dbus_g_proxy_call (proxy, "setCodecPreferedOrder", error, G_TYPE_STRING, IN_codec_name, G_TYPE_INVALID, G_TYPE_INVALID); -} - -typedef void (*org_sflphone_SFLphone_ConfigurationManager_set_codec_prefered_order_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); - -static void -org_sflphone_SFLphone_ConfigurationManager_set_codec_prefered_order_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) -{ - DBusGAsyncData *data = (DBusGAsyncData*) user_data; - GError *error = NULL; - dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); - (*(org_sflphone_SFLphone_ConfigurationManager_set_codec_prefered_order_reply)data->cb) (proxy, error, data->userdata); + (*(org_sflphone_SFLphone_ConfigurationManager_get_ringtone_list_reply)data->cb) (proxy, OUT_list, error, data->userdata); return; } @@ -414,36 +376,36 @@ static inline #endif DBusGProxyCall* -org_sflphone_SFLphone_ConfigurationManager_set_codec_prefered_order_async (DBusGProxy *proxy, const char * IN_codec_name, org_sflphone_SFLphone_ConfigurationManager_set_codec_prefered_order_reply callback, gpointer userdata) +org_sflphone_SFLphone_ConfigurationManager_get_ringtone_list_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_get_ringtone_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, "setCodecPreferedOrder", org_sflphone_SFLphone_ConfigurationManager_set_codec_prefered_order_async_callback, stuff, g_free, G_TYPE_STRING, IN_codec_name, G_TYPE_INVALID); + return dbus_g_proxy_begin_call (proxy, "getRingtoneList", org_sflphone_SFLphone_ConfigurationManager_get_ringtone_list_async_callback, stuff, g_free, G_TYPE_INVALID); } static #ifdef G_HAVE_INLINE inline #endif gboolean -org_sflphone_SFLphone_ConfigurationManager_get_codec_prefered_order (DBusGProxy *proxy, char ** OUT_codec_name, GError **error) +org_sflphone_SFLphone_ConfigurationManager_get_playback_device_list (DBusGProxy *proxy, char *** OUT_list, GError **error) { - return dbus_g_proxy_call (proxy, "getCodecPreferedOrder", error, G_TYPE_INVALID, G_TYPE_STRING, OUT_codec_name, G_TYPE_INVALID); + return dbus_g_proxy_call (proxy, "getPlaybackDeviceList", error, G_TYPE_INVALID, G_TYPE_STRV, OUT_list, G_TYPE_INVALID); } -typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_codec_prefered_order_reply) (DBusGProxy *proxy, char * OUT_codec_name, GError *error, gpointer userdata); +typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_playback_device_list_reply) (DBusGProxy *proxy, char * *OUT_list, GError *error, gpointer userdata); static void -org_sflphone_SFLphone_ConfigurationManager_get_codec_prefered_order_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +org_sflphone_SFLphone_ConfigurationManager_get_playback_device_list_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) { DBusGAsyncData *data = (DBusGAsyncData*) user_data; GError *error = NULL; - char * OUT_codec_name; - dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRING, &OUT_codec_name, G_TYPE_INVALID); - (*(org_sflphone_SFLphone_ConfigurationManager_get_codec_prefered_order_reply)data->cb) (proxy, OUT_codec_name, error, data->userdata); + char ** OUT_list; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRV, &OUT_list, G_TYPE_INVALID); + (*(org_sflphone_SFLphone_ConfigurationManager_get_playback_device_list_reply)data->cb) (proxy, OUT_list, error, data->userdata); return; } @@ -452,36 +414,36 @@ static inline #endif DBusGProxyCall* -org_sflphone_SFLphone_ConfigurationManager_get_codec_prefered_order_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_get_codec_prefered_order_reply callback, gpointer userdata) +org_sflphone_SFLphone_ConfigurationManager_get_playback_device_list_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_get_playback_device_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, "getCodecPreferedOrder", org_sflphone_SFLphone_ConfigurationManager_get_codec_prefered_order_async_callback, stuff, g_free, G_TYPE_INVALID); + return dbus_g_proxy_begin_call (proxy, "getPlaybackDeviceList", org_sflphone_SFLphone_ConfigurationManager_get_playback_device_list_async_callback, stuff, g_free, G_TYPE_INVALID); } static #ifdef G_HAVE_INLINE inline #endif gboolean -org_sflphone_SFLphone_ConfigurationManager_get_playback_device_list (DBusGProxy *proxy, char *** OUT_list, GError **error) +org_sflphone_SFLphone_ConfigurationManager_get_record_device_list (DBusGProxy *proxy, char *** OUT_list, GError **error) { - return dbus_g_proxy_call (proxy, "getPlaybackDeviceList", error, G_TYPE_INVALID, G_TYPE_STRV, OUT_list, G_TYPE_INVALID); + return dbus_g_proxy_call (proxy, "getRecordDeviceList", error, G_TYPE_INVALID, G_TYPE_STRV, OUT_list, G_TYPE_INVALID); } -typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_playback_device_list_reply) (DBusGProxy *proxy, char * *OUT_list, GError *error, gpointer userdata); +typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_record_device_list_reply) (DBusGProxy *proxy, char * *OUT_list, GError *error, gpointer userdata); static void -org_sflphone_SFLphone_ConfigurationManager_get_playback_device_list_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +org_sflphone_SFLphone_ConfigurationManager_get_record_device_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_playback_device_list_reply)data->cb) (proxy, OUT_list, error, data->userdata); + (*(org_sflphone_SFLphone_ConfigurationManager_get_record_device_list_reply)data->cb) (proxy, OUT_list, error, data->userdata); return; } @@ -490,36 +452,36 @@ static inline #endif DBusGProxyCall* -org_sflphone_SFLphone_ConfigurationManager_get_playback_device_list_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_get_playback_device_list_reply callback, gpointer userdata) +org_sflphone_SFLphone_ConfigurationManager_get_record_device_list_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_get_record_device_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, "getPlaybackDeviceList", org_sflphone_SFLphone_ConfigurationManager_get_playback_device_list_async_callback, stuff, g_free, G_TYPE_INVALID); + return dbus_g_proxy_begin_call (proxy, "getRecordDeviceList", org_sflphone_SFLphone_ConfigurationManager_get_record_device_list_async_callback, stuff, g_free, G_TYPE_INVALID); } static #ifdef G_HAVE_INLINE inline #endif gboolean -org_sflphone_SFLphone_ConfigurationManager_get_record_device_list (DBusGProxy *proxy, char *** OUT_list, GError **error) +org_sflphone_SFLphone_ConfigurationManager_get_codec_list (DBusGProxy *proxy, char *** OUT_list, GError **error) { - return dbus_g_proxy_call (proxy, "getRecordDeviceList", error, G_TYPE_INVALID, G_TYPE_STRV, OUT_list, G_TYPE_INVALID); + return dbus_g_proxy_call (proxy, "getCodecList", error, G_TYPE_INVALID, G_TYPE_STRV, OUT_list, G_TYPE_INVALID); } -typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_record_device_list_reply) (DBusGProxy *proxy, char * *OUT_list, GError *error, gpointer userdata); +typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_codec_list_reply) (DBusGProxy *proxy, char * *OUT_list, GError *error, gpointer userdata); static void -org_sflphone_SFLphone_ConfigurationManager_get_record_device_list_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +org_sflphone_SFLphone_ConfigurationManager_get_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_record_device_list_reply)data->cb) (proxy, OUT_list, error, data->userdata); + (*(org_sflphone_SFLphone_ConfigurationManager_get_codec_list_reply)data->cb) (proxy, OUT_list, error, data->userdata); return; } @@ -528,36 +490,36 @@ static inline #endif DBusGProxyCall* -org_sflphone_SFLphone_ConfigurationManager_get_record_device_list_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_get_record_device_list_reply callback, gpointer userdata) +org_sflphone_SFLphone_ConfigurationManager_get_codec_list_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_get_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, "getRecordDeviceList", org_sflphone_SFLphone_ConfigurationManager_get_record_device_list_async_callback, stuff, g_free, G_TYPE_INVALID); + return dbus_g_proxy_begin_call (proxy, "getCodecList", org_sflphone_SFLphone_ConfigurationManager_get_codec_list_async_callback, stuff, g_free, G_TYPE_INVALID); } static #ifdef G_HAVE_INLINE inline #endif gboolean -org_sflphone_SFLphone_ConfigurationManager_get_sample_rate_list (DBusGProxy *proxy, char *** OUT_list, GError **error) +org_sflphone_SFLphone_ConfigurationManager_get_codec_details (DBusGProxy *proxy, const gint IN_payload, char *** OUT_details, GError **error) { - return dbus_g_proxy_call (proxy, "getSampleRateList", error, G_TYPE_INVALID, G_TYPE_STRV, OUT_list, G_TYPE_INVALID); + return dbus_g_proxy_call (proxy, "getCodecDetails", error, G_TYPE_INT, IN_payload, G_TYPE_INVALID, G_TYPE_STRV, OUT_details, G_TYPE_INVALID); } -typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_sample_rate_list_reply) (DBusGProxy *proxy, char * *OUT_list, GError *error, gpointer userdata); +typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_codec_details_reply) (DBusGProxy *proxy, char * *OUT_details, GError *error, gpointer userdata); static void -org_sflphone_SFLphone_ConfigurationManager_get_sample_rate_list_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +org_sflphone_SFLphone_ConfigurationManager_get_codec_details_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_sample_rate_list_reply)data->cb) (proxy, OUT_list, error, data->userdata); + char ** OUT_details; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRV, &OUT_details, G_TYPE_INVALID); + (*(org_sflphone_SFLphone_ConfigurationManager_get_codec_details_reply)data->cb) (proxy, OUT_details, error, data->userdata); return; } @@ -566,36 +528,36 @@ static inline #endif DBusGProxyCall* -org_sflphone_SFLphone_ConfigurationManager_get_sample_rate_list_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_get_sample_rate_list_reply callback, gpointer userdata) +org_sflphone_SFLphone_ConfigurationManager_get_codec_details_async (DBusGProxy *proxy, const gint IN_payload, org_sflphone_SFLphone_ConfigurationManager_get_codec_details_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, "getSampleRateList", org_sflphone_SFLphone_ConfigurationManager_get_sample_rate_list_async_callback, stuff, g_free, G_TYPE_INVALID); + return dbus_g_proxy_begin_call (proxy, "getCodecDetails", org_sflphone_SFLphone_ConfigurationManager_get_codec_details_async_callback, stuff, g_free, G_TYPE_INT, IN_payload, G_TYPE_INVALID); } static #ifdef G_HAVE_INLINE inline #endif gboolean -org_sflphone_SFLphone_ConfigurationManager_get_default_account (DBusGProxy *proxy, char ** OUT_accountID, GError **error) +org_sflphone_SFLphone_ConfigurationManager_get_active_codec_list (DBusGProxy *proxy, char *** OUT_list, GError **error) { - return dbus_g_proxy_call (proxy, "getDefaultAccount", error, G_TYPE_INVALID, G_TYPE_STRING, OUT_accountID, G_TYPE_INVALID); + return dbus_g_proxy_call (proxy, "getActiveCodecList", error, G_TYPE_INVALID, G_TYPE_STRV, OUT_list, G_TYPE_INVALID); } -typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_default_account_reply) (DBusGProxy *proxy, char * OUT_accountID, GError *error, gpointer userdata); +typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_active_codec_list_reply) (DBusGProxy *proxy, char * *OUT_list, GError *error, gpointer userdata); static void -org_sflphone_SFLphone_ConfigurationManager_get_default_account_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +org_sflphone_SFLphone_ConfigurationManager_get_active_codec_list_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) { DBusGAsyncData *data = (DBusGAsyncData*) user_data; GError *error = NULL; - char * OUT_accountID; - dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRING, &OUT_accountID, G_TYPE_INVALID); - (*(org_sflphone_SFLphone_ConfigurationManager_get_default_account_reply)data->cb) (proxy, OUT_accountID, error, data->userdata); + char ** OUT_list; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRV, &OUT_list, G_TYPE_INVALID); + (*(org_sflphone_SFLphone_ConfigurationManager_get_active_codec_list_reply)data->cb) (proxy, OUT_list, error, data->userdata); return; } @@ -604,35 +566,35 @@ static inline #endif DBusGProxyCall* -org_sflphone_SFLphone_ConfigurationManager_get_default_account_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_get_default_account_reply callback, gpointer userdata) +org_sflphone_SFLphone_ConfigurationManager_get_active_codec_list_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_get_active_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, "getDefaultAccount", org_sflphone_SFLphone_ConfigurationManager_get_default_account_async_callback, stuff, g_free, G_TYPE_INVALID); + return dbus_g_proxy_begin_call (proxy, "getActiveCodecList", org_sflphone_SFLphone_ConfigurationManager_get_active_codec_list_async_callback, stuff, g_free, G_TYPE_INVALID); } static #ifdef G_HAVE_INLINE inline #endif gboolean -org_sflphone_SFLphone_ConfigurationManager_set_default_account (DBusGProxy *proxy, const char * IN_accountID, GError **error) +org_sflphone_SFLphone_ConfigurationManager_set_active_codec_list (DBusGProxy *proxy, const char ** IN_list, GError **error) { - return dbus_g_proxy_call (proxy, "setDefaultAccount", error, G_TYPE_STRING, IN_accountID, G_TYPE_INVALID, G_TYPE_INVALID); + return dbus_g_proxy_call (proxy, "setActiveCodecList", error, G_TYPE_STRV, IN_list, G_TYPE_INVALID, G_TYPE_INVALID); } -typedef void (*org_sflphone_SFLphone_ConfigurationManager_set_default_account_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); +typedef void (*org_sflphone_SFLphone_ConfigurationManager_set_active_codec_list_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); static void -org_sflphone_SFLphone_ConfigurationManager_set_default_account_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +org_sflphone_SFLphone_ConfigurationManager_set_active_codec_list_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) { DBusGAsyncData *data = (DBusGAsyncData*) user_data; GError *error = NULL; dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); - (*(org_sflphone_SFLphone_ConfigurationManager_set_default_account_reply)data->cb) (proxy, error, data->userdata); + (*(org_sflphone_SFLphone_ConfigurationManager_set_active_codec_list_reply)data->cb) (proxy, error, data->userdata); return; } @@ -641,14 +603,14 @@ static inline #endif DBusGProxyCall* -org_sflphone_SFLphone_ConfigurationManager_set_default_account_async (DBusGProxy *proxy, const char * IN_accountID, org_sflphone_SFLphone_ConfigurationManager_set_default_account_reply callback, gpointer userdata) +org_sflphone_SFLphone_ConfigurationManager_set_active_codec_list_async (DBusGProxy *proxy, const char ** IN_list, org_sflphone_SFLphone_ConfigurationManager_set_active_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, "setDefaultAccount", org_sflphone_SFLphone_ConfigurationManager_set_default_account_async_callback, stuff, g_free, G_TYPE_STRING, IN_accountID, G_TYPE_INVALID); + return dbus_g_proxy_begin_call (proxy, "setActiveCodecList", org_sflphone_SFLphone_ConfigurationManager_set_active_codec_list_async_callback, stuff, g_free, G_TYPE_STRV, IN_list, G_TYPE_INVALID); } #endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_sflphone_SFLphone_ConfigurationManager */ diff --git a/sflphone-gtk/src/configwindow.c b/sflphone-gtk/src/configwindow.c index 223c95f8542ebc1d74ba4c353e138fffc9202dab..219d8f4a9e64ff3073729edce81a5f1a937ac1ed 100644 --- a/sflphone-gtk/src/configwindow.c +++ b/sflphone-gtk/src/configwindow.c @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <accountlist.h> @@ -26,29 +26,42 @@ #include <dbus.h> #include <mainwindow.h> +#include <stdlib.h> + #include <gtk/gtk.h> /** * Local variables */ -gboolean dialogOpen = FALSE; - -GtkListStore * accountStore; -GtkListStore * codecStore; -GtkListStore * audioManagerStore; -GtkListStore * outputAudioDeviceManagerStore; -GtkListStore * inputAudioDeviceManagerStore; - -GtkWidget * addButton; -GtkWidget * editButton; -GtkWidget * deleteButton; -GtkWidget * defaultButton; -GtkWidget * restoreButton; - -account_t * selectedAccount; - -//GtkListStore * rate_store; -//GtkWidget * combo_box; +gboolean dialogOpen = FALSE; + +GtkListStore *accountStore; +GtkWidget *codecTreeView; // View used instead of store to get access to selection + // instead of keeping selected codec as a variable +GtkListStore *audioManagerStore; +GtkListStore *outputAudioDeviceManagerStore; +GtkListStore *inputAudioDeviceManagerStore; + +GtkWidget *addButton; +GtkWidget *editButton; +GtkWidget *deleteButton; +GtkWidget *defaultButton; +GtkWidget *restoreButton; + +GtkWidget *moveUpButton; +GtkWidget *moveDownButton; + +account_t *selectedAccount; + +// Codec properties ID +enum { + COLUMN_CODEC_ACTIVE, + COLUMN_CODEC_NAME, + COLUMN_CODEC_FREQUENCY, + COLUMN_CODEC_BITRATE, + COLUMN_CODEC_BANDWIDTH, + CODEC_COLUMN_COUNT +}; /** * Fills the treelist with accounts @@ -75,7 +88,7 @@ config_window_fill_account_list() 3, a, // Pointer -1); } - } + } gtk_widget_set_sensitive( GTK_WIDGET(editButton), FALSE); gtk_widget_set_sensitive( GTK_WIDGET(deleteButton), FALSE); @@ -91,23 +104,28 @@ config_window_fill_codec_list() { if(dialogOpen) { + GtkListStore *codecStore; GtkTreeIter iter; - int i; + + // Get model of view and clear it + codecStore = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(codecTreeView))); gtk_list_store_clear(codecStore); + // Insert codecs + int i; for(i = 0; i < codec_list_get_size(); i++) { - codec_t* c = codec_list_get_nth(i); + codec_t *c = codec_list_get_nth(i); printf("%s\n", c->name); if(c) { gtk_list_store_append(codecStore, &iter); gtk_list_store_set(codecStore, &iter, - 0, c->is_active, // Active - 1, c->name, // Name - 2, c->sample_rate, // Sample rate - 3, "bandwith", // Bandwith - 4, "frequency", // Frequency + COLUMN_CODEC_ACTIVE, c->is_active, // Active + COLUMN_CODEC_NAME, c->name, // Name + COLUMN_CODEC_FREQUENCY, g_strdup_printf("%d kHz", c->sample_rate/1000), // Frequency (kHz) + COLUMN_CODEC_BITRATE, g_strdup_printf("%.1f kbps", c->_bitrate), // Bitrate (kbps) + COLUMN_CODEC_BANDWIDTH, g_strdup_printf("%.1f kbps", c->_bandwidth), // Bandwidth (kpbs) -1); } } @@ -115,25 +133,13 @@ config_window_fill_codec_list() } /** - * SEE deprecated + * TODO */ -/*void -config_window_fill_rate_list() +void +config_window_fill_audio_manager_list() { - if(dialogOpen) - { - GtkTreeIter iter; - int i=0; - gchar** ratelist = (gchar**)dbus_get_sample_rate_list(); - while(ratelist[i]!=NULL) - { - printf("%s\n", ratelist[i]); - gtk_list_store_append (rate_store, &iter); - gtk_list_store_set(rate_store, &iter,0,ratelist[i],-1); - i++; - } - } -}*/ + +} /** * TODO @@ -223,67 +229,154 @@ select_account(GtkTreeSelection *selection, GtkTreeModel *model) if(selectedAccount) { - gtk_widget_set_sensitive( GTK_WIDGET(editButton), TRUE); - gtk_widget_set_sensitive( GTK_WIDGET(deleteButton), TRUE); - gtk_widget_set_sensitive( GTK_WIDGET(defaultButton), TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(editButton), TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(deleteButton), TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(defaultButton), TRUE); } g_print("select"); } +/** + * Toggle move buttons on if a codec is selected, off elsewise + */ static void -codec_active_toggled(GtkCellRendererToggle * renderer, gchar * path, GtkListStore * store) +select_codec(GtkTreeSelection *selection, GtkTreeModel *model) { GtkTreeIter iter; - GValue val; + + if(!gtk_tree_selection_get_selected(selection, &model, &iter)) + { + gtk_widget_set_sensitive(GTK_WIDGET(moveUpButton), FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(moveDownButton), FALSE); + } + else + { + gtk_widget_set_sensitive(GTK_WIDGET(moveUpButton), TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(moveDownButton), TRUE); + } } /** - * TODO Change for tree model and tree selection as in precedent function + * Toggle active value of codec on click and update changes to the deamon + * and in configuration files */ static void -select_codec(GtkTreeSelection * selection, GtkTreeModel * model) +codec_active_toggled(GtkCellRendererToggle *renderer, gchar *path, gpointer data) { GtkTreeIter iter; + GtkTreePath *treePath; + GtkTreeModel *model; + gboolean active; + char* name; - if(!gtk_tree_selection_get_selected(selection, &model, &iter)) - { - return; - } - //guint item = gtk_combo_box_get_active(wid); - /* now we want this selected codec to be used as the preferred codec */ - /* ie first in the list in the user config */ - //codec_set_prefered_order(item); - //dbus_set_prefered_codec(codec_list_get_nth(0)->name); + // Get path of clicked codec active toggle box + treePath = gtk_tree_path_new_from_string(path); + model = gtk_tree_view_get_model(GTK_TREE_VIEW(data)); + gtk_tree_model_get_iter(model, &iter, treePath); + + // Get active value and name at iteration + gtk_tree_model_get(model, &iter, + COLUMN_CODEC_ACTIVE, &active, + COLUMN_CODEC_NAME, &name, + -1); + + printf("%s\n", name); + + // Toggle active value + active = !active; + + // Store value + gtk_list_store_set(GTK_LIST_STORE(model), &iter, + COLUMN_CODEC_ACTIVE, active, + -1); + + gtk_tree_path_free(treePath); + + // Modify codec queue to represent change + if(active) + codec_set_active(name); + else + codec_set_inactive(name); + + // TODO Perpetuate changes to the deamon } /** - * Move codec in list depending on direction and selected codec + * Move codec in list depending on direction and selected codec and + * update changes in the deamon list and the configuration files */ static void -moveCodec(gboolean moveUp, GtkListStore * codecListStore) +codec_move(gboolean moveUp, gpointer data) { - // TODO - printf("Button pressed"); + GtkTreeIter iter; + GtkTreeIter *iter2; + GtkTreeView *treeView; + GtkTreeModel *model; + GtkTreeSelection *selection; + GtkTreePath *treePath; + gchar *path; + + // Get view, model and selection of codec store + treeView = GTK_TREE_VIEW(data); + model = gtk_tree_view_get_model(GTK_TREE_VIEW(treeView)); + selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeView)); + + // Find selected iteration and create a copy + gtk_tree_selection_get_selected(GTK_TREE_SELECTION(selection), &model, &iter); + iter2 = gtk_tree_iter_copy(&iter); + + // Find path of iteration + path = gtk_tree_model_get_string_from_iter(GTK_TREE_MODEL(model), &iter); + treePath = gtk_tree_path_new_from_string(path); + gint *indices = gtk_tree_path_get_indices(treePath); + gint indice = indices[0]; + + // Depending on button direction get new path + if(moveUp) + gtk_tree_path_prev(treePath); + else + gtk_tree_path_next(treePath); + gtk_tree_model_get_iter(model, &iter, treePath); + + // Swap iterations if valid + if(gtk_list_store_iter_is_valid(GTK_LIST_STORE(model), &iter)) + gtk_list_store_swap(GTK_LIST_STORE(model), &iter, iter2); + + // Scroll to new position + gtk_tree_view_scroll_to_cell(treeView, treePath, NULL, FALSE, 0, 0); + + // Free resources + gtk_tree_path_free(treePath); + gtk_tree_iter_free(iter2); + g_free(path); + + // Perpetuate changes in codec queue + if(moveUp) + codec_list_move_codec_up(indice); + else + codec_list_move_codec_down(indice); + + // TODO Perpetuate changes to the deamon } /** * Called from move up codec button signal */ static void -moveCodecUp(GtkListStore * codecListStore) +codec_move_up(GtkButton *button, gpointer data) { - moveCodec(TRUE, codecListStore); - printf("Button pressed"); + // Change tree view ordering and get indice changed + codec_move(TRUE, data); } /** - * Called from move up codec button signal + * Called from move down codec button signal */ static void -moveCodecDown(GtkListStore * codecListStore) +codec_move_down(GtkButton *button, gpointer data) { - moveCodec(FALSE, codecListStore); - printf("Button pressed"); + // Change tree view ordering and get indice changed + codec_move(FALSE, data); } /** @@ -296,10 +389,9 @@ bold_if_default_account(GtkTreeViewColumn *col, GtkTreeIter *iter, gpointer data) { - GValue val; - val.g_type = G_TYPE_POINTER; + GValue val = { 0, }; gtk_tree_model_get_value(tree_model, iter, 3, &val); - account_t* current = (account_t*) g_value_get_pointer(&val); + account_t *current = (account_t*)g_value_get_pointer(&val); g_value_unset(&val); if(g_strcasecmp(current->accountID, account_list_get_default()) == 0) g_object_set(G_OBJECT(rend), "weight", 800, NULL); @@ -308,11 +400,12 @@ bold_if_default_account(GtkTreeViewColumn *col, } /** - * TODO - */ + * TODO Action when restore default codecs is done + void default_codecs(GtkWidget* widget, gpointer data) { + GtkListStore *codecStore; int i = 0; int j = 0; gint * new_order; @@ -343,27 +436,25 @@ default_codecs(GtkWidget* widget, gpointer data) } printf("new_order[%i]=%i\n", i,j); i++; - } - gtk_list_store_reorder(codecStore, new_order); + } + codecStore = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(codecTreeView))); + gtk_list_store_reorder(codecStore, new_order); } - +*/ /** * Create table widget for codecs */ GtkWidget* create_codec_table() { - GtkWidget * ret; - GtkWidget * scrolledWindow; - GtkWidget * buttonBox; - GtkWidget * moveUpButton; - GtkWidget * moveDownButton; - - GtkWidget * treeView; - GtkCellRenderer * renderer; - GtkTreeSelection * treeSelection; - GtkTreeViewColumn * treeViewColumn; - GtkTreeIter iter; + GtkWidget *ret; + GtkWidget *scrolledWindow; + GtkWidget *buttonBox; + + GtkListStore *codecStore; + GtkCellRenderer *renderer; + GtkTreeSelection *treeSelection; + GtkTreeViewColumn *treeViewColumn; ret = gtk_hbox_new(FALSE, 10); gtk_container_set_border_width(GTK_CONTAINER(ret), 10); @@ -373,64 +464,68 @@ create_codec_table() gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledWindow), GTK_SHADOW_IN); gtk_box_pack_start(GTK_BOX(ret), scrolledWindow, TRUE, TRUE, 0); - codecStore = gtk_list_store_new(5, + codecStore = gtk_list_store_new(CODEC_COLUMN_COUNT, G_TYPE_BOOLEAN, // Active G_TYPE_STRING, // Name - G_TYPE_INT, // Bit rate - G_TYPE_STRING, // Bandwith - G_TYPE_STRING // Frequency + G_TYPE_STRING, // Frequency + G_TYPE_STRING, // Bit rate + G_TYPE_STRING // Bandwith ); - treeView = gtk_tree_view_new_with_model(GTK_TREE_MODEL(codecStore)); + // Create codec tree view with list store + codecTreeView = gtk_tree_view_new_with_model(GTK_TREE_MODEL(codecStore)); - treeSelection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeView)); + // Get tree selection manager + treeSelection = gtk_tree_view_get_selection(GTK_TREE_VIEW(codecTreeView)); g_signal_connect(G_OBJECT(treeSelection), "changed", G_CALLBACK (select_codec), - codecStore); // TODO ONLY for disabling or enabling move buttons + codecStore); // Active column renderer = gtk_cell_renderer_toggle_new(); - treeViewColumn = gtk_tree_view_column_new_with_attributes("", renderer, "active", 0, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(treeView), treeViewColumn); - g_signal_connect(G_OBJECT(renderer), "toggled", G_CALLBACK(codec_active_toggled), codecStore); - - // TODO toggle on clicked + treeViewColumn = gtk_tree_view_column_new_with_attributes("", renderer, "active", COLUMN_CODEC_ACTIVE, NULL); + gtk_tree_view_append_column(GTK_TREE_VIEW(codecTreeView), treeViewColumn); + + // Toggle codec active property on clicked + g_signal_connect(G_OBJECT(renderer), "toggled", G_CALLBACK(codec_active_toggled), (gpointer)codecTreeView); // Name column renderer = gtk_cell_renderer_text_new(); - treeViewColumn = gtk_tree_view_column_new_with_attributes("Name", renderer, "markup", 1, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(treeView), treeViewColumn); + treeViewColumn = gtk_tree_view_column_new_with_attributes("Name", renderer, "markup", COLUMN_CODEC_NAME, NULL); + gtk_tree_view_append_column(GTK_TREE_VIEW(codecTreeView), treeViewColumn); // Bit rate column renderer = gtk_cell_renderer_text_new(); - treeViewColumn = gtk_tree_view_column_new_with_attributes("Bit rate", renderer, "text", 2, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(treeView), treeViewColumn); + treeViewColumn = gtk_tree_view_column_new_with_attributes("Frequency", renderer, "text", COLUMN_CODEC_FREQUENCY, NULL); + gtk_tree_view_append_column(GTK_TREE_VIEW(codecTreeView), treeViewColumn); // Bandwith column renderer = gtk_cell_renderer_text_new(); - treeViewColumn = gtk_tree_view_column_new_with_attributes("Bandwith", renderer, "text", 3, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(treeView), treeViewColumn); + treeViewColumn = gtk_tree_view_column_new_with_attributes("Bitrate", renderer, "text", COLUMN_CODEC_BITRATE, NULL); + gtk_tree_view_append_column(GTK_TREE_VIEW(codecTreeView), treeViewColumn); // Frequency column renderer = gtk_cell_renderer_text_new(); - treeViewColumn = gtk_tree_view_column_new_with_attributes("Frequency", renderer, "text", 4, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(treeView), treeViewColumn); + treeViewColumn = gtk_tree_view_column_new_with_attributes("Bandwidth", renderer, "text", COLUMN_CODEC_BANDWIDTH, NULL); + gtk_tree_view_append_column(GTK_TREE_VIEW(codecTreeView), treeViewColumn); g_object_unref(G_OBJECT(codecStore)); - gtk_container_add(GTK_CONTAINER(scrolledWindow), treeView); + gtk_container_add(GTK_CONTAINER(scrolledWindow), codecTreeView); // Create button box buttonBox = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(buttonBox), 10); gtk_box_pack_start(GTK_BOX(ret), buttonBox, FALSE, FALSE, 0); - moveUpButton = gtk_button_new_with_label("Move up"); + moveUpButton = gtk_button_new_from_stock(GTK_STOCK_GO_UP); + gtk_widget_set_sensitive(GTK_WIDGET(moveUpButton), FALSE); gtk_box_pack_start(GTK_BOX(buttonBox), moveUpButton, FALSE, FALSE, 0); - g_signal_connect(G_OBJECT(moveUpButton), "clicked", G_CALLBACK(moveCodecUp), codecStore); + g_signal_connect(G_OBJECT(moveUpButton), "clicked", G_CALLBACK(codec_move_up), codecTreeView); - moveDownButton = gtk_button_new_with_label("Move down"); + moveDownButton = gtk_button_new_from_stock(GTK_STOCK_GO_DOWN); + gtk_widget_set_sensitive(GTK_WIDGET(moveDownButton), FALSE); gtk_box_pack_start(GTK_BOX(buttonBox), moveDownButton, FALSE, FALSE, 0); - g_signal_connect(G_OBJECT(moveDownButton), "clicked", G_CALLBACK(moveCodecDown), codecStore); + g_signal_connect(G_OBJECT(moveDownButton), "clicked", G_CALLBACK(codec_move_down), codecTreeView); config_window_fill_codec_list(); @@ -452,13 +547,10 @@ create_accounts_tab() GtkTreeSelection *treeSelection; GtkWidget *label; - GValue val; - val.g_type = G_TYPE_POINTER; - selectedAccount = NULL; ret = gtk_vbox_new(FALSE, 10); - gtk_container_set_border_width (GTK_CONTAINER (ret), 10); + gtk_container_set_border_width(GTK_CONTAINER (ret), 10); label = gtk_label_new("This is the list of accounts previously setup."); @@ -561,50 +653,48 @@ create_accounts_tab() GtkWidget* create_audio_tab () { - GtkWidget * ret; - - GtkWidget * deviceLabel; - GtkWidget * deviceBox; - GtkWidget * deviceTable; - GtkWidget * codecLabel; - GtkWidget * codecBox; - - GtkWidget * attributeBox; - GtkWidget * titleLabel; - GtkWidget * comboBox; - GtkWidget * refreshButton; - GtkCellRenderer * renderer; + GtkWidget *ret; + + GtkWidget *deviceLabel; + GtkWidget *deviceBox; + GtkWidget *deviceTable; + GtkWidget *codecLabel; + GtkWidget *codecBox; + + GtkWidget *titleLabel; + GtkWidget *comboBox; + GtkWidget *refreshButton; + GtkCellRenderer *renderer; GtkTreeIter iter; + GtkWidget *codecTable; + // Main widget ret = gtk_vbox_new(FALSE, 10); gtk_container_set_border_width(GTK_CONTAINER(ret), 10); // Device section label - deviceLabel = gtk_label_new("Devices"); + deviceLabel = gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(deviceLabel), "<b>Devices</b>"); gtk_label_set_line_wrap(GTK_LABEL(deviceLabel), TRUE); gtk_misc_set_alignment(GTK_MISC(deviceLabel), 0, 0.5); gtk_label_set_justify(GTK_LABEL(deviceLabel), GTK_JUSTIFY_LEFT); gtk_box_pack_start(GTK_BOX(ret), deviceLabel, FALSE, FALSE, 0); - gtk_widget_show(deviceLabel); // Main device widget deviceBox = gtk_hbox_new(FALSE, 10); gtk_box_pack_start(GTK_BOX(ret), deviceBox, FALSE, FALSE, 0); - gtk_widget_show(codecBox); - - // TODO Create margin instead of column // Main device widget deviceTable = gtk_table_new(4, 3, FALSE); gtk_table_set_col_spacing(GTK_TABLE(deviceTable), 0, 40); - gtk_box_set_spacing(GTK_BOX(deviceTable), 0); // SEE GAIM_HIG_BOX_SPACE + gtk_box_set_spacing(GTK_BOX(deviceTable), 0); gtk_box_pack_start(GTK_BOX(deviceBox), deviceTable, TRUE, TRUE, 0); gtk_widget_show(deviceTable); // Device : Audio manager // Create title label - titleLabel = gtk_label_new("Audio manager:"); + titleLabel = gtk_label_new("Audio manager"); gtk_misc_set_alignment(GTK_MISC(titleLabel), 0, 0.5); gtk_table_attach(GTK_TABLE(deviceTable), titleLabel, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0); gtk_widget_show(titleLabel); @@ -621,10 +711,6 @@ create_audio_tab () gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(comboBox), renderer, "text", 0, NULL); gtk_table_attach(GTK_TABLE(deviceTable), comboBox, 2, 3, 0, 1, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0); gtk_widget_show(comboBox); - // Create refresh button - refreshButton = gtk_button_new_from_stock(GTK_STOCK_REFRESH); - gtk_table_attach(GTK_TABLE(deviceTable), refreshButton, 3, 4, 0, 1, GTK_EXPAND, GTK_SHRINK, 0, 0); - gtk_widget_show(refreshButton); // Device : Output device // Create title label @@ -645,9 +731,6 @@ create_audio_tab () gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(comboBox), renderer, "text", 0, NULL); gtk_table_attach(GTK_TABLE(deviceTable), comboBox, 2, 3, 1, 2, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0); gtk_widget_show(comboBox); - // Create refresh button - refreshButton = gtk_button_new_from_stock(GTK_STOCK_REFRESH); - gtk_table_attach(GTK_TABLE(deviceTable), refreshButton, 3, 4, 1, 2, GTK_EXPAND, GTK_SHRINK, 0, 0); // Device : Input device // Create title label @@ -668,12 +751,15 @@ create_audio_tab () gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(comboBox), renderer, "text", 0, NULL); gtk_table_attach(GTK_TABLE(deviceTable), comboBox, 2, 3, 2, 3, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0); gtk_widget_show(comboBox); - // Create refresh button - refreshButton = gtk_button_new_from_stock(GTK_STOCK_REFRESH); - gtk_table_attach(GTK_TABLE(deviceTable), refreshButton, 3, 4, 2, 3, GTK_EXPAND, GTK_SHRINK, 0, 0); - + + // Create detect button + refreshButton = gtk_button_new_with_label("Detect all"); + gtk_button_set_image(GTK_BUTTON(refreshButton), gtk_image_new_from_stock(GTK_STOCK_REFRESH, GTK_ICON_SIZE_BUTTON)); + gtk_table_attach(GTK_TABLE(deviceTable), refreshButton, 3, 4, 0, 3, GTK_EXPAND, GTK_EXPAND, 0, 0); + // Codec section label - codecLabel = gtk_label_new("Codecs"); + codecLabel = gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(codecLabel), "<b>Codecs</b>"); gtk_label_set_line_wrap(GTK_LABEL(codecLabel), TRUE); gtk_misc_set_alignment(GTK_MISC(codecLabel), 0, 0.5); gtk_label_set_justify(GTK_LABEL(codecLabel), GTK_JUSTIFY_LEFT); @@ -686,8 +772,8 @@ create_audio_tab () gtk_widget_show(codecBox); // Codec : List - GtkWidget * codecTable; codecTable = create_codec_table(); + gtk_widget_set_size_request(GTK_WIDGET(codecTable), -1, 150); gtk_box_pack_start(GTK_BOX(codecBox), codecTable, TRUE, TRUE, 0); gtk_widget_show(codecTable); @@ -697,101 +783,6 @@ create_audio_tab () return ret; } -/** - * Main video tab creation - * Temporary code that was in audio tab before - */ -/*GtkWidget* -create_video_tab () -{ - GtkWidget * ret; - GtkWidget * label; - GtkWidget * codecBox; - GtkWidget * rate_box; - //GtkWidget * image; - GtkWidget * hbox1; - //GtkTreeIter iter; - GtkCellRenderer *renderer; - - ret = gtk_vbox_new(FALSE, 10); - gtk_container_set_border_width (GTK_CONTAINER (ret), 10); - - label = gtk_label_new("Set your video preferences."); - gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); - gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); - gtk_box_pack_start(GTK_BOX(ret), label, FALSE, FALSE, 0); - gtk_widget_show(label); - - codecBox = gtk_hbutton_box_new(); - gtk_box_set_spacing(GTK_BOX(codecBox), 10); //GAIM_HIG_BOX_SPACE - gtk_button_box_set_layout(GTK_BUTTON_BOX(codecBox), GTK_BUTTONBOX_SPREAD); - gtk_box_pack_start(GTK_BOX(ret), codecBox, FALSE, FALSE, 0); - gtk_widget_show (codecBox); - - hbox1 = gtk_label_new("Codec:"); - gtk_misc_set_alignment(GTK_MISC(hbox1), 0, 0.5); - gtk_box_pack_start(GTK_BOX(codecBox), hbox1, FALSE, FALSE, 0); - gtk_widget_show(hbox1); - codec_store = gtk_list_store_new(1, G_TYPE_STRING); - - combo_box = gtk_combo_box_new_with_model(GTK_TREE_MODEL (codec_store)); - gtk_label_set_mnemonic_widget(GTK_LABEL(hbox1), combo_box); - renderer = gtk_cell_renderer_text_new(); - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo_box), renderer, TRUE); - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo_box), renderer, "text",0,NULL); - gtk_box_pack_start(GTK_BOX(codecBox), combo_box, FALSE, FALSE,0); - - - g_signal_connect (G_OBJECT (combo_box), "changed", - G_CALLBACK (select_codec), - NULL); - gtk_widget_show(combo_box); - - restoreButton = gtk_button_new_from_stock(GTK_STOCK_REFRESH); - gtk_box_pack_start(GTK_BOX(codecBox), restoreButton, FALSE, FALSE,10); - //g_signal_connect(G_OBJECT(restoreButton), "clicked", G_CALLBACK(default_codecs), NULL); - gtk_widget_show(restoreButton); - - codecBox = gtk_hbutton_box_new(); - gtk_box_set_spacing(GTK_BOX(codecBox), 10); //GAIM_HIG_BOX_SPACE - gtk_button_box_set_layout(GTK_BUTTON_BOX(codecBox), GTK_BUTTONBOX_SPREAD); - gtk_box_pack_start(GTK_BOX(ret), codecBox, FALSE, FALSE, 0); - gtk_widget_show (codecBox); - - hbox1 = gtk_label_new("Sample Rate:"); - gtk_misc_set_alignment(GTK_MISC(hbox1), 0, 0.5); - gtk_box_pack_start(GTK_BOX(codecBox), hbox1, FALSE, FALSE, 0); - gtk_widget_show(hbox1); - rate_store = gtk_list_store_new(1, G_TYPE_STRING); - - rate_box = gtk_combo_box_new_with_model(GTK_TREE_MODEL(rate_store)); - gtk_label_set_mnemonic_widget(GTK_LABEL(hbox1), rate_box); - renderer = gtk_cell_renderer_text_new(); - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(rate_box), renderer, TRUE); - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(rate_box), renderer, "text",0,NULL); - gtk_box_pack_start(GTK_BOX(codecBox), rate_box, FALSE, FALSE,0); - - - //g_signal_connect (G_OBJECT (combo_box), "changed", - // G_CALLBACK (select_codec), - // NULL); - gtk_widget_show(rate_box); - restoreButton = gtk_button_new_from_stock(GTK_STOCK_REFRESH); - gtk_box_pack_start(GTK_BOX(codecBox), restoreButton, FALSE, FALSE,0); - //g_signal_connect(G_OBJECT(restoreButton), "clicked", G_CALLBACK(default_codecs), NULL); - gtk_widget_show(restoreButton); - - - gtk_widget_show_all(ret); - config_window_fill_codec_list(); - config_window_fill_rate_list(); - gtk_combo_box_set_active(GTK_COMBO_BOX(rate_box), 0); - //gtk_combo_box_set_active(rate_box, 0); - - return ret; -}*/ - /** * Show configuration window with tabs */ @@ -811,16 +802,17 @@ show_config_window () GTK_RESPONSE_ACCEPT, NULL)); + // Set window properties gtk_dialog_set_has_separator(dialog, FALSE); gtk_window_set_default_size(GTK_WINDOW(dialog), 400, 400); gtk_container_set_border_width(GTK_CONTAINER(dialog), 0); + // Create tabs container notebook = gtk_notebook_new(); gtk_box_pack_start(GTK_BOX (dialog->vbox), notebook, TRUE, TRUE, 0); gtk_container_set_border_width(GTK_CONTAINER(notebook), 10); gtk_widget_show(notebook); - /* Create tabs */ // Accounts tab tab = create_accounts_tab(); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), tab, gtk_label_new("Accounts")); @@ -831,11 +823,6 @@ show_config_window () gtk_notebook_append_page(GTK_NOTEBOOK(notebook), tab, gtk_label_new("Audio Settings")); gtk_notebook_page_num(GTK_NOTEBOOK(notebook), tab); - // Video tab -/* tab = create_video_tab(); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), tab, gtk_label_new("Video Settings")); - gtk_notebook_page_num(GTK_NOTEBOOK(notebook), tab); -*/ gtk_dialog_run(dialog); dialogOpen = FALSE; diff --git a/sflphone-gtk/src/configwindow.h b/sflphone-gtk/src/configwindow.h index 819e19211fbfa0d21e97a530ba0503662b6ca967..3597e5cbc370999af6305b89b11b9e3e5ad4b0bc 100644 --- a/sflphone-gtk/src/configwindow.h +++ b/sflphone-gtk/src/configwindow.h @@ -16,16 +16,28 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - + #ifndef __CONFIGWINDOW_H__ #define __CONFIGWINDOW_H__ #include <calllist.h> -/** @file configwindow.h - * @brief The Preferences window. - */ -void show_config_window ( ); -void config_window_fill_account_list ( ); +/** + * @file configwindow.h + * @brief The Preferences window. + */ +void config_window_fill_account_list(); +void config_window_fill_codec_list(); +void show_config_window(); +void config_window_fill_audio_manager_list(); +void config_window_fill_output_audio_device_list(); +void config_window_fill_input_audio_device_list(); +void default_account(GtkWidget *widget, gpointer data); +void bold_if_default_account(GtkTreeViewColumn *col, GtkCellRenderer *rend, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data); +void default_codecs(GtkWidget* widget, gpointer data); +GtkWidget * create_codec_table(); +GtkWidget * create_accounts_tab(); +GtkWidget * create_audio_tab(); +void show_config_window(); #endif diff --git a/sflphone-gtk/src/dbus.c b/sflphone-gtk/src/dbus.c index b549e190f79fe0ceea40e23eaa7300e3ac0b098f..af6fded7a4e17dac1787438112205eed46c16b37 100644 --- a/sflphone-gtk/src/dbus.c +++ b/sflphone-gtk/src/dbus.c @@ -661,13 +661,13 @@ dbus_unregister(int pid) } -gchar ** +gchar** dbus_codec_list() { g_print("Before"); GError *error = NULL; - char ** array; + gchar** array; org_sflphone_SFLphone_ConfigurationManager_get_codec_list ( configurationManagerProxy, &array, @@ -688,82 +688,84 @@ dbus_codec_list() return array; } -gchar ** -dbus_default_codec_list() +gchar** +dbus_codec_details( int payload ) { g_print("Before"); GError *error = NULL; - char ** array; - org_sflphone_SFLphone_ConfigurationManager_get_default_codec_list ( + gchar ** array; + org_sflphone_SFLphone_ConfigurationManager_get_codec_details ( configurationManagerProxy, + payload, &array, &error); g_print("After"); if (error) { - g_printerr ("Failed to call get_default_codec_list() on ConfigurationManager: %s\n", + g_printerr ("Failed to call get_codec_details() on ConfigurationManager: %s\n", error->message); g_error_free (error); } else { - g_print ("DBus called get_default_codec_list() on ConfigurationManager\n"); + g_print ("DBus called get_codec_details() on ConfigurationManager\n"); } return array; } -void -dbus_set_prefered_codec(const gchar* codec) + + +gchar** +dbus_get_active_codec_list() { g_print("Before"); + gchar ** array; GError *error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_codec_prefered_order ( + org_sflphone_SFLphone_ConfigurationManager_get_active_codec_list ( configurationManagerProxy, - codec, + &array, &error); g_print("After"); if (error) { - g_printerr ("Failed to call set_prefered_codec() on ConfigurationManager: %s\n", + g_printerr ("Failed to call get_active_codec_list() on ConfigurationManager: %s\n", error->message); g_error_free (error); } else { - g_print ("DBus called set_prefered_codec() on ConfigurationManager\n"); + g_print ("DBus called get_active_codec_list() on ConfigurationManager\n"); } + return array; } - -gchar** -dbus_get_sample_rate_list() +void +dbus_set_active_codec_list(const gchar** list) { g_print("Before"); - gchar ** array; GError *error = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_sample_rate_list ( + org_sflphone_SFLphone_ConfigurationManager_set_active_codec_list ( configurationManagerProxy, - &array, + list, &error); g_print("After"); if (error) { - g_printerr ("Failed to call get_sample_rate_list() on ConfigurationManager: %s\n", + g_printerr ("Failed to call set_active_codec_list() on ConfigurationManager: %s\n", error->message); g_error_free (error); } else { - g_print ("DBus called get_sample_rate_list() on ConfigurationManager\n"); + g_print ("DBus called set_active_codec_list() on ConfigurationManager\n"); } - return array; } diff --git a/sflphone-gtk/src/dbus.h b/sflphone-gtk/src/dbus.h index e3f34e631b733c86d0e31b6280a94906e713fffb..9014090b6d5b2ffc7c9bc22246d115f7e09818a2 100644 --- a/sflphone-gtk/src/dbus.h +++ b/sflphone-gtk/src/dbus.h @@ -54,9 +54,10 @@ 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_codec_details(int payload); gchar** dbus_default_codec_list(); -gchar** dbus_get_sample_rate_list(); - +void dbus_set_active_codec_list( const gchar** list ); +gchar** dbus_get_active_codec_list( void ); /* Instance */ void dbus_register( int pid, gchar * name); diff --git a/src/Makefile.am b/src/Makefile.am index c71caf57c586c2cd19ef172746c4ebd6796ca323..89b1e5b302c77a3df15474dae0878a41f61fc93b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,5 +1,6 @@ +sflcodecdir = ($libdir)/sflphone/codecs bin_PROGRAMS = sflphoned -#bin_SCRIPTS = sflphone + if USE_ZEROCONF ZEROCONFDIR = zeroconf @@ -40,7 +41,8 @@ sflphoned_CXXFLAGS = -DPREFIX=\"$(prefix)\" -DPROGSHAREDIR=\"${datadir}/sflphone #sflphoned_LDFLAGS = -static sflphoned_LDADD = ./libsflphone.la $(SFLPHONE_LIBS) $(ZEROCONFLIB) $(LIB_DNSSD) $(IAX_LIBS) $(EXOSIP_LIBS) -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/libs $(libccext2_CFLAGS) $(libccgnu2_CFLAGS) $(IAX_CFLAGS) $(USER_INCLUDES) $(libdbuscpp_CFLAGS) +AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/libs $(libccext2_CFLAGS) $(libccgnu2_CFLAGS) $(IAX_CFLAGS) $(USER_INCLUDES) $(libdbuscpp_CFLAGS) \ + -DCODECS_DIR=\""$(sflcodecdir)"\" # libsflphone_la_LDFLAGS= -version-info 0:1:0 diff --git a/src/audio/Makefile.am b/src/audio/Makefile.am index ea2038f50a32e28a44bce998302ebdbd127d00a4..5621175377d55490fe5bb48a6c6a13ad3fcc4e25 100644 --- a/src/audio/Makefile.am +++ b/src/audio/Makefile.am @@ -1,6 +1,19 @@ -#SUBDIRS = gsm +sflcodecdir = $(libdir)/sflphone/codecs/ noinst_LTLIBRARIES = libaudio.la +noinst_PROGRAMS = libcodec_ulaw.so libcodec_alaw.so libcodec_gsm.so + +libcodec_ulaw_so_SOURCES = ulaw.cpp +libcodec_ulaw_so_CFLAGS = -fPIC -g -Wall +libcodec_ulaw_so_LDFLAGS = -shared + +libcodec_alaw_so_SOURCES = alaw.cpp +libcodec_alaw_so_CFLAGS = -fPIC -g -Wall +libcodec_alaw_so_LDFLAGS = -shared + +libcodec_gsm_so_SOURCES = gsmcodec.cpp +libcodec_gsm_so_CFLAGS = -fPIC -g -Wall +libcodec_gsm_so_LDFLAGS = -shared -lgsm if USE_SPEEX SPEEX_SOURCES_CPP=CodecSpeex.cpp @@ -17,13 +30,31 @@ audiortp.cpp dtmf.cpp tone.cpp audiolayer.cpp audiodevice.cpp dtmfge tonegenerator.cpp codecDescriptor.cpp \ audioloop.cpp ringbuffer.cpp $(SPEEX_SOURCES_CPP) -AM_CXXFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/libs $(libccext2_CFLAGS) $(libdbuscpp_CFLAGS) $(libccrtp1_CFLAGS) $(USER_INCLUDES) -#libaudio_la_LIBADD = gsm/libgsm.la $(SPEEX_LIB) +AM_CXXFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/libs $(libccext2_CFLAGS) $(libdbuscpp_CFLAGS) $(libccrtp1_CFLAGS) $(USER_INCLUDES) \ + -DCODECS_DIR=\""$(sflcodecdir)"\" libaudio_la_CPPFLAGS = $(SPEEX_FLAG) - noinst_HEADERS = audioloop.h common.h ringbuffer.h audiofile.h \ tonelist.h audiortp.h audiocodec.h audiolayer.h audiodevice.h \ dtmfgenerator.h tonegenerator.h \ codecDescriptor.h dtmf.h tone.h \ CodecSpeex.h + +install-exec-local: install-libcodec_ulaw_so install-libcodec_alaw_so install-libcodec_gsm_so +uninstall-local: uninstall-libcodec_ulaw_so uninstall-libcodec_alaw_so uninstall-libcodec_gsm_so + +install-libcodec_ulaw_so: libcodec_ulaw.so + mkdir -p $(sflcodecdir) + $(INSTALL_PROGRAM) libcodec_ulaw.so $(sflcodecdir) +install-libcodec_alaw_so: libcodec_alaw.so + $(INSTALL_PROGRAM) libcodec_alaw.so $(sflcodecdir) +install-libcodec_gsm_so: libcodec_gsm.so + $(INSTALL_PROGRAM) libcodec_gsm.so $(sflcodecdir) + +uninstall-libcodec_ulaw_so: + rm -f $(sflcodecdir)/libcodec_ulaw.so +uninstall-libcodec_alaw_so: + rm -f $(sflcodecdir)/libcodec_alaw.so +uninstall-libcodec_gsm_so: + rm -f $(sflcodecdir)/libcodec_gsm.so + rm -rf $(sflcodecdir) diff --git a/src/audio/NOTES b/src/audio/NOTES new file mode 100644 index 0000000000000000000000000000000000000000..515353165c94ee678521b564890e9b33869508ca --- /dev/null +++ b/src/audio/NOTES @@ -0,0 +1,24 @@ +How to build the codec shared libraries +--------------------------------------- + +CODEC_ALAW: + gcc -fPIC -g -c -Wall ulaw.cpp +-------> gives you the object file ulaw.o. +-------> option -g to include debug information +-------> option -Wall to generate warnings +-------> option -fPIC to enable position independant code generation + + gcc -shared -o libcodec_ulaw.so ulaw.o -lc +-------> creates the shared library + +CODEC ALAW: + idem + +CODEC_GSM: + gcc -fPIC -g -c -Wall gsmcodec.cpp + gcc -shared -o -libcodec_gsm.so gsmcodec.o -lc -lgsm +-------> You need the standard library libgsm1 installed (with dev package). + +REFERENCES: http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html + +The shared library should be installed in $(libdir)/sflphone/codecs where libdir=$(PREFIX)/lib. diff --git a/src/audio/audiocodec.cpp b/src/audio/audiocodec.cpp deleted file mode 100644 index 4e0899b69dd82018a95340f995435f5248996594..0000000000000000000000000000000000000000 --- a/src/audio/audiocodec.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright (C) 2004-2005 Savoir-Faire Linux inc. - * Author: Yan Morin <yan.morin@savoirfairelinux.com> - * Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com> - * - * This is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 3, - * or (at your option) any later version. - * - * This is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with dpkg; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include <iostream> -#include <string> - -#include "audiocodec.h" - -AudioCodec::AudioCodec (int payload, const std::string &codecName) - : _codecName(codecName) -{ - _payload = payload; - _clockRate = 8000; // default - _channel = 1; // default - _active = false; - - _hasDynamicPayload = (_payload >= 96 && _payload <= 127) ? true : false; -} - -AudioCodec::~AudioCodec (void) -{ -} diff --git a/src/audio/audiofile.cpp b/src/audio/audiofile.cpp index d96dc3852e0fbc15011c14e626d9f68251cf4f30..7e4dca105cf94a598382566f8242c905fcc1c0b2 100644 --- a/src/audio/audiofile.cpp +++ b/src/audio/audiofile.cpp @@ -31,12 +31,11 @@ AudioFile::AudioFile() : AudioLoop() { // could vary later... - //_ulaw = new Ulaw(PAYLOAD_CODEC_ULAW); _start = false; using std::cout; using std::cerr; - void* codec = dlopen("codec_ulaw.so", RTLD_LAZY); + void* codec = dlopen( CODECS_DIR "/libcodec_ulaw.so", RTLD_LAZY); if(!codec){ cerr<<"cannot load library: "<< dlerror() <<'\n'; } diff --git a/src/audio/audiortp.cpp b/src/audio/audiortp.cpp index dbf7a5aeaa5e9259df786b6f88f9c7c449d03ad5..13c787961de894b357fe694c2a480ee62e8f5c87 100644 --- a/src/audio/audiortp.cpp +++ b/src/audio/audiortp.cpp @@ -259,16 +259,16 @@ AudioRtpRTX::loadCodec(int payload) switch(payload){ case 0: - handle_codec = dlopen("codec_ulaw.so", RTLD_LAZY); + handle_codec = dlopen( CODECS_DIR "/libcodec_ulaw.so", RTLD_LAZY); break; case 3: - handle_codec = dlopen("codec_gsm.so", RTLD_LAZY); + handle_codec = dlopen(CODECS_DIR "/libcodec_gsm.so", RTLD_LAZY); break; case 8: - handle_codec = dlopen("codec_alaw.so", RTLD_LAZY); + handle_codec = dlopen(CODECS_DIR "/libcodec_alaw.so", RTLD_LAZY); break; case 97: - handle_codec = dlopen("codec_ilbc.so", RTLD_LAZY); + handle_codec = dlopen(CODECS_DIR "/libcodec_ilbc.so", RTLD_LAZY); break; } diff --git a/src/audio/codecDescriptor.cpp b/src/audio/codecDescriptor.cpp index feb00971b0eed5e804cfcec46f832478d10d22a5..4df2ac0f288936ca0f580256286cce49291cd7f6 100644 --- a/src/audio/codecDescriptor.cpp +++ b/src/audio/codecDescriptor.cpp @@ -20,6 +20,7 @@ */ #include <iostream> +#include <cstdlib> #include "audiocodec.h" #include "codecDescriptor.h" @@ -29,25 +30,30 @@ CodecDescriptor::CodecDescriptor() { - // Default codecs + init(); +//#ifdef HAVE_SPEEX + //_codecMap[PAYLOAD_CODEC_SPEEX] = new CodecSpeex(PAYLOAD_CODEC_SPEEX); // TODO: this is a variable payload! +//#endif +} + +void +CodecDescriptor::init() +{ + // init list of all codecs supported codecs _codecMap[PAYLOAD_CODEC_ULAW] = "PCMU"; _codecMap[PAYLOAD_CODEC_GSM] = "GSM"; _codecMap[PAYLOAD_CODEC_ALAW] = "PCMA"; -#ifdef HAVE_SPEEX - _codecMap[PAYLOAD_CODEC_SPEEX] = new CodecSpeex(PAYLOAD_CODEC_SPEEX); // TODO: this is a variable payload! -#endif -// theses one are not implemented yet.. -// _codecMap[PAYLOAD_CODEC_ILBC_20] = "iLBC"; -// _codecMap[PAYLOAD_CODEC_SPEEX] = Speex(); + _codecMap[PAYLOAD_CODEC_ILBC_20] = "iLBC"; + } void -CodecDescriptor::init() +CodecDescriptor::setDefaultOrder() { - _codecMap[PAYLOAD_CODEC_ULAW] = "PCMU"; - _codecMap[PAYLOAD_CODEC_GSM] = "GSM"; - _codecMap[PAYLOAD_CODEC_ALAW] = "PCMA"; -// _codecMap[PAYLOAD_CODEC_ILBC_20] = "iLBC"; + _codecOrder.clear(); + _codecOrder.push_back(PAYLOAD_CODEC_ULAW); + _codecOrder.push_back(PAYLOAD_CODEC_ALAW); + _codecOrder.push_back(PAYLOAD_CODEC_GSM); } std::string& @@ -57,7 +63,7 @@ CodecDescriptor::getCodecName(CodecType payload) if (iter!=_codecMap.end()) { return (iter->second); } - //return ; + //return std::string(""); } bool @@ -100,7 +106,9 @@ double CodecDescriptor::getBitRate(CodecType payload) { switch(payload){ - case PAYLOAD_CODEC_ULAW | PAYLOAD_CODEC_ALAW: + case PAYLOAD_CODEC_ULAW: + return 64; + case PAYLOAD_CODEC_ALAW: return 64; case PAYLOAD_CODEC_GSM: return 13.3; @@ -117,7 +125,9 @@ double CodecDescriptor::getBandwidthPerCall(CodecType payload) { switch(payload){ - case PAYLOAD_CODEC_ULAW | PAYLOAD_CODEC_ALAW: + case PAYLOAD_CODEC_ULAW: + return 80; + case PAYLOAD_CODEC_ALAW: return 80; case PAYLOAD_CODEC_GSM: return 28.6; @@ -132,15 +142,39 @@ int CodecDescriptor::getSampleRate(CodecType payload) { switch(payload){ - case PAYLOAD_CODEC_ULAW | PAYLOAD_CODEC_ALAW | PAYLOAD_CODEC_GSM | PAYLOAD_CODEC_ILBC_20: + case PAYLOAD_CODEC_ULAW: + printf("PAYLOAD = %i\n", payload); + return 8000; + case PAYLOAD_CODEC_ALAW: + printf("PAYLOAD = %i\n", payload); + return 8000; + case PAYLOAD_CODEC_GSM: + printf("PAYLOAD = %i\n", payload); return 8000; + case PAYLOAD_CODEC_ILBC_20: + printf("PAYLOAD = %i\n", payload); + return 8000; + default: + return -1; } - return -1; + return -1; } - - - - +void +CodecDescriptor::saveActiveCodecs(const std::vector<std::string>& list) +{ + _codecOrder.clear(); + // list contains the ordered payload of active codecs picked by the user + // we used the CodecOrder vector to save the order. + int i=0; + int payload; + size_t size = list.size(); + while(i<size) + { + payload = std::atoi(list[i].data()); + _codecOrder.push_back((CodecType)payload); + i++; + } +} diff --git a/src/audio/codecDescriptor.h b/src/audio/codecDescriptor.h index 7dfac68acef862faf236691c8fa6939af17f9eaa..4cb9be9a5c03c88ef58b6c653ce77958b7aa7053 100644 --- a/src/audio/codecDescriptor.h +++ b/src/audio/codecDescriptor.h @@ -25,6 +25,7 @@ #include <string> #include <map> +#include <vector> #include "../global.h" typedef enum { @@ -51,6 +52,8 @@ typedef enum { /* A codec is identified by its payload. A payload is associated with a name. */ typedef std::map<CodecType, std::string> CodecMap; +/* The struct to reflect the order the user wants to use the codecs */ +typedef std::vector<CodecType> CodecOrder; class CodecDescriptor { public: @@ -60,6 +63,7 @@ public: CodecDescriptor(); ~CodecDescriptor() {}; CodecMap& getCodecMap() { return _codecMap; } + CodecOrder& getActiveCodecs() { return _codecOrder; } /** * Get codec with is associated payload @@ -69,8 +73,16 @@ public: */ std::string& getCodecName(CodecType payload); + /** + * Initialiaze the map with all the supported codecs, even those inactive + */ void init(); + /** + * Set the default codecs order + */ + void setDefaultOrder(); + /** * Check in the map codec if the specified codec is supported * @param payload unique identifier of a codec (RFC) @@ -114,8 +126,16 @@ public: * @return int The clock rate of the specified codec */ int getSampleRate(CodecType payload); + +/** + * Set the order of codecs by their payload + * @param list The ordered list sent by DBus + */ + void saveActiveCodecs(const std::vector<std::string>& list); + private: CodecMap _codecMap; + CodecOrder _codecOrder; }; #endif // __CODEC_DESCRIPTOR_H__ diff --git a/src/audio/codec_alaw.so b/src/audio/codec_alaw.so deleted file mode 100755 index 9c1a8446e9dd3b0662deef9bce208deadac3401e..0000000000000000000000000000000000000000 Binary files a/src/audio/codec_alaw.so and /dev/null differ diff --git a/src/audio/codec_gsm.so b/src/audio/codec_gsm.so deleted file mode 100755 index 16846e53f4752c1f9bd4569ee056bd7aaec04782..0000000000000000000000000000000000000000 Binary files a/src/audio/codec_gsm.so and /dev/null differ diff --git a/src/audio/codec_ilbc.so b/src/audio/codec_ilbc.so deleted file mode 100755 index 28b1ae6dc3b2f617159f698be82fa514184492ee..0000000000000000000000000000000000000000 Binary files a/src/audio/codec_ilbc.so and /dev/null differ diff --git a/src/audio/codec_ulaw.so b/src/audio/codec_ulaw.so deleted file mode 100755 index 3cdfe0f32e8905a4dd86b4f2f8ce6597ca364655..0000000000000000000000000000000000000000 Binary files a/src/audio/codec_ulaw.so and /dev/null differ diff --git a/src/audio/g711.cpp b/src/audio/g711.cpp deleted file mode 100644 index a9520b7660dccd2638d5012abe63f5dc6382b417..0000000000000000000000000000000000000000 --- a/src/audio/g711.cpp +++ /dev/null @@ -1,279 +0,0 @@ -/** - * Copyright (C) 2005 Savoir-Faire Linux inc. - * Author: Yan Morin <yan.morin@savoirfairelinux.com> - * - Implementation of ITU-T (formerly CCITT) Recomendation G711 - - Copyright (C) 2004 J.D.Medhurst (a.k.a. Tixy) - - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public - * License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - * MA 02111-1307, USA. - * - */ -#include "common.h" -#include "g711.h" - - -/* -Members of class G711 -*/ - - -uint8 G711::ALawEncode(int16 pcm16) - { - int p = pcm16; - uint a; // A-law value we are forming - if(p<0) - { - // -ve value - // Note, ones compliment is here used here as this keeps encoding symetrical - - // and equal spaced around zero cross-over, (it also matches the standard). - p = ~p; - a = 0x00; // sign = 0 - } - else - { - // +ve value - a = 0x80; // sign = 1 - } - - // Calculate segment and interval numbers - p >>= 4; - if(p>=0x20) - { - if(p>=0x100) - { - p >>= 4; - a += 0x40; - } - if(p>=0x40) - { - p >>= 2; - a += 0x20; - } - if(p>=0x20) - { - p >>= 1; - a += 0x10; - } - } - // a&0x70 now holds segment value and 'p' the interval number - - a += p; // a now equal to encoded A-law value - - return a^0x55; // A-law has alternate bits inverted for transmission - } - - -int G711::ALawDecode(uint8 alaw) - { - alaw ^= 0x55; // A-law has alternate bits inverted for transmission - - uint sign = alaw&0x80; - - int linear = alaw&0x1f; - linear <<= 4; - linear += 8; // Add a 'half' bit (0x08) to place PCM value in middle of range - - alaw &= 0x7f; - if(alaw>=0x20) - { - linear |= 0x100; // Put in MSB - uint shift = (alaw>>4)-1; - linear <<= shift; - } - - if(!sign) - return -linear; - else - return linear; - } - - -uint8 G711::ULawEncode(int16 pcm16) - { - int p = pcm16; - uint u; // u-law value we are forming - - if(p<0) - { - // -ve value - // Note, ones compliment is here used here as this keeps encoding symetrical - // and equal spaced around zero cross-over, (it also matches the standard). - p = ~p; - u = 0x80^0x10^0xff; // Sign bit = 1 (^0x10 because this will get inverted later) ^0xff ^0xff to invert final u-Law code - } - else - { - // +ve value - u = 0x00^0x10^0xff; // Sign bit = 0 (-0x10 because this amount extra will get added later) ^0xff to invert final u-Law code - } - - p += 0x84; // Add uLaw bias - - if(p>0x7f00) - p = 0x7f00; // Clip to 15 bits - - // Calculate segment and interval numbers - p >>= 3; // Shift down to 13bit - if(p>=0x100) - { - p >>= 4; - u ^= 0x40; - } - if(p>=0x40) - { - p >>= 2; - u ^= 0x20; - } - if(p>=0x20) - { - p >>= 1; - u ^= 0x10; - } - // (u^0x10)&0x70 now equal to the segment value and 'p' the interval number (^0x10) - - u ^= p; // u now equal to encoded u-law value (with all bits inverted) - - return u; - } - - -int G711::ULawDecode(uint8 ulaw) - { - ulaw ^= 0xff; // u-law has all bits inverted for transmission - - int linear = ulaw&0x0f; - linear <<= 3; - linear |= 0x84; // Set MSB (0x80) and a 'half' bit (0x04) to place PCM value in middle of range - - uint shift = ulaw>>4; - shift &= 7; - linear <<= shift; - - linear -= 0x84; // Subract uLaw bias - - if(ulaw&0x80) - return -linear; - else - return linear; - } - - -uint8 G711::ALawToULaw(uint8 alaw) - { - uint8 sign=alaw&0x80; - alaw ^= sign; - alaw ^= 0x55; - uint ulaw; - if(alaw<45) - { - if(alaw<24) - ulaw = (alaw<8) ? (alaw<<1)+1 : alaw+8; - else - ulaw = (alaw<32) ? (alaw>>1)+20 : alaw+4; - } - else - { - if(alaw<63) - ulaw = (alaw<47) ? alaw+3 : alaw+2; - else - ulaw = (alaw<79) ? alaw+1 : alaw; - } - ulaw ^= sign; - return ulaw^0x7f; - } - - -uint8 G711::ULawToALaw(uint8 ulaw) - { - uint8 sign=ulaw&0x80; - ulaw ^= sign; - ulaw ^= 0x7f; - uint alaw; - if(ulaw<48) - { - if(ulaw<=32) - alaw = (ulaw<=15) ? ulaw>>1 : ulaw-8; - else - alaw = (ulaw<=35) ? (ulaw<<1)-40 : ulaw-4; - } - else - { - if(ulaw<=63) - alaw = (ulaw==48) ? ulaw-3 : ulaw-2; - else - alaw = (ulaw<=79) ? ulaw-1 : ulaw; - } - alaw ^= sign; - return alaw^0x55; - } - - -uint G711::ALawEncode(uint8* dst, int16* src, uint srcSize) - { - srcSize >>= 1; - uint8* end = dst+srcSize; - while(dst<end) - *dst++ = ALawEncode(*src++); - return srcSize; - } - - -uint G711::ALawDecode(int16* dst, uint8* src, uint srcSize) - { - int16* end = dst+srcSize; - while(dst<end) - *dst++ = ALawDecode(*src++); - return srcSize<<1; - } - - -uint G711::ULawEncode(uint8* dst, int16* src, uint srcSize) - { - srcSize >>= 1; - uint8* end = dst+srcSize; - while(dst<end) - *dst++ = ULawEncode(*src++); - return srcSize; - } - - -uint G711::ULawDecode(int16* dst, uint8* src, uint srcSize) - { - int16* end = dst+srcSize; - while(dst<end) - *dst++ = ULawDecode(*src++); - return srcSize<<1; - } - - -uint G711::ALawToULaw(uint8* dst, uint8* src, uint srcSize) - { - uint8* end = dst+srcSize; - while(dst<end) - *dst++ = ALawToULaw(*src++); - return srcSize; - } - - -uint G711::ULawToALaw(uint8* dst, uint8* src, uint srcSize) - { - uint8* end = dst+srcSize; - while(dst<end) - *dst++ = ULawToALaw(*src++); - return srcSize; - } diff --git a/src/audio/g711.h b/src/audio/g711.h deleted file mode 100644 index c3d6b56dd678c6e57bea27a54ab40f0b102f9db5..0000000000000000000000000000000000000000 --- a/src/audio/g711.h +++ /dev/null @@ -1,145 +0,0 @@ -/** - * Copyright (C) 2005 Savoir-Faire Linux inc. - * Author: Yan Morin <yan.morin@savoirfairelinux.com> - * - Implementation of ITU-T (formerly CCITT) Recomendation G711 - - Copyright (C) 2004 J.D.Medhurst (a.k.a. Tixy) - - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Library General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public - * License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - * MA 02111-1307, USA. - * - */ -#ifndef __G711_H__ -#define __G711_H__ - -#include "common.h" - -/** -A class which implements ITU-T (formerly CCITT) Recomendation G711 -"Pulse Code Modulation (PCM) of Voice Frequencies" - -This encodes and decodes uniform PCM values to/from 8 bit A-law and u-Law values. - -Note, the methods in this class use uniform PCM values which are of 16 bits precision, -these are 'left justified' values corresponding to the 13 and 14 bit values described -in G711. -*/ -class G711 - { -public: - /** - Encode a 16 bit uniform PCM value into an A-Law value - @param pcm16 A 16 bit uniform PCM value (sign extented into an int). - If the value doesn't lie in the range -32768 to 32767 then the - result is undefined. - @return The A-Law encoded value corresponding to pcm16 - */ - static uint8 ALawEncode(int16 pcm16); - - /** - Encode an A-Law value into a 16 bit uniform PCM value - @param alaw An A-Law encoded value - @return The 16 bit uniform PCM value corresponding to alaw - */ - static int ALawDecode(uint8 alaw); - - /** - Encode a 16 bit uniform PCM value into an u-Law value - @param pcm16 A 16 bit uniform PCM value (sign extented into an int) - If the value doesn't lie in the range -32768 to 32767 then the - result is undefined. - @return The u-Law encoded value corresponding to pcm16 - */ - static uint8 ULawEncode(int16 pcm16); - - /** - Encode an u-Law value into a 16 bit uniform PCM value - @param ulaw An u-Law encoded value - @return The 16 bit uniform PCM value corresponding to ulaw - */ - static int ULawDecode(uint8 ulaw); - - /** - Convert an A-Law value into a u-law value. - @param alaw An A-Law encoded value - @return The u-law value. - */ - static uint8 ALawToULaw(uint8 alaw); - - /** - Convert a u-Law value into an A-law value. - @param ulaw An u-Law encoded value - @return The A-Law value - */ - static uint8 ULawToALaw(uint8 ulaw); - - /** - Encode a buffer of 16 bit uniform PCM values into A-Law values - @param dst Pointer to location to store A-Law encoded values - @param src Pointer to the buffer of 16 bit uniform PCM values to be encoded - @param srcSize The size in bytes of the src buffer - @return The number of bytes which were stored at dst (equal to srcSize>>1) - */ - static uint ALawEncode(uint8* dst, int16* src, uint srcSize); - - /** - Decode a buffer of A-Law values into 16 bit uniform PCM values - @param dst Pointer to location to store decoded 16 bit uniform PCM values - @param src Pointer to the buffer of A-Law values to be decoded - @param srcSize The size in bytes of the src buffer - @return The number of bytes which were stored at dst (equal to srcSize<<1) - */ - static uint ALawDecode(int16* dst, uint8* src, uint srcSize); - - /** - Encode a buffer of 16 bit uniform PCM values into u-Law values - @param dst Pointer to location to store u-Law encoded values - @param src Pointer to the buffer of 16 bit uniform PCM values to be encoded - @param srcSize The size in bytes of the src buffer - @return The number of bytes which were stored at dst (equal to srcSize>>1) - */ - static uint ULawEncode(uint8* dst, int16* src, uint srcSize); - - /** - Decode a buffer of u-Law values into 16 bit uniform PCM values - @param dst Pointer to location to store decoded 16 bit uniform PCM values - @param src Pointer to the buffer of u-Law values to be decoded - @param srcSize The size in bytes of the src buffer - @return The number of bytes which were stored at dst (equal to srcSize<<1) - */ - static uint ULawDecode(int16* dst, uint8* src, uint srcSize); - - /** - Convert a buffer of A-Law value into u-law values. - @param dst Pointer to location to store u-law values - @param src Pointer to the buffer of A-Law values to be converted - @param srcSize The size in bytes of the src buffer - @return The number of bytes which were stored at dst (equal to srcSize) - */ - static uint ALawToULaw(uint8* dst, uint8* src, uint srcSize); - - /** - Convert a buffer of u-Law value into A-law values. - @param dst Pointer to location to store A-law values - @param src Pointer to the buffer of u-Law values to be converted - @param srcSize The size in bytes of the src buffer - @return The number of bytes which were stored at dst (equal to srcSize) - */ - static uint ULawToALaw(uint8* dst, uint8* src, uint srcSize); - }; - -#endif - diff --git a/src/dbus/README b/src/dbus/README index ccd008ad3730184c69d8bafdf360992398bf1204..de2648e52d55e3d23da74b1b116a8458e7d42df5 100644 --- a/src/dbus/README +++ b/src/dbus/README @@ -3,3 +3,6 @@ To build a new dbus interface: 1. Define the API with a xml file. 2. Generate the glue.h header by running "dbusxx-xml2cpp file.xml --adaptor=file.h" 3. Inheritate from that glue.h class in your code. + +Example with configurationManager: +dbusxx-xml2cpp configurationmanager-introspec.xml --adaptor=configurationmanager-glue.h diff --git a/src/dbus/configurationmanager-glue.h b/src/dbus/configurationmanager-glue.h index 3c6f92d5cd95d482b8fa5666e428d155bff3a85e..79841461a1bd8d88c6caa635696c884bd39860c6 100644 --- a/src/dbus/configurationmanager-glue.h +++ b/src/dbus/configurationmanager-glue.h @@ -25,18 +25,17 @@ public: register_method(ConfigurationManager, addAccount, _addAccount_stub); register_method(ConfigurationManager, removeAccount, _removeAccount_stub); register_method(ConfigurationManager, getAccountList, _getAccountList_stub); + register_method(ConfigurationManager, getDefaultAccount, _getDefaultAccount_stub); + register_method(ConfigurationManager, setDefaultAccount, _setDefaultAccount_stub); + register_method(ConfigurationManager, getToneLocaleList, _getToneLocaleList_stub); 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); register_method(ConfigurationManager, getPlaybackDeviceList, _getPlaybackDeviceList_stub); register_method(ConfigurationManager, getRecordDeviceList, _getRecordDeviceList_stub); - register_method(ConfigurationManager, getSampleRateList, _getSampleRateList_stub); - register_method(ConfigurationManager, getDefaultAccount, _getDefaultAccount_stub); - register_method(ConfigurationManager, setDefaultAccount, _setDefaultAccount_stub); + register_method(ConfigurationManager, getCodecList, _getCodecList_stub); + register_method(ConfigurationManager, getCodecDetails, _getCodecDetails_stub); + register_method(ConfigurationManager, getActiveCodecList, _getActiveCodecList_stub); + register_method(ConfigurationManager, setActiveCodecList, _setActiveCodecList_stub); } ::DBus::IntrospectedInterface* const introspect() const @@ -68,24 +67,14 @@ public: { "list", "as", false }, { 0, 0, 0 } }; - static ::DBus::IntrospectedArgument getVersion_args[] = - { - { "version", "s", false }, - { 0, 0, 0 } - }; - static ::DBus::IntrospectedArgument getRingtoneList_args[] = - { - { "list", "as", false }, - { 0, 0, 0 } - }; - static ::DBus::IntrospectedArgument getCodecList_args[] = + static ::DBus::IntrospectedArgument getDefaultAccount_args[] = { - { "list", "as", false }, + { "accountID", "s", false }, { 0, 0, 0 } }; - static ::DBus::IntrospectedArgument getDefaultCodecList_args[] = + static ::DBus::IntrospectedArgument setDefaultAccount_args[] = { - { "list", "as", false }, + { "accountID", "s", true }, { 0, 0, 0 } }; static ::DBus::IntrospectedArgument getToneLocaleList_args[] = @@ -93,14 +82,14 @@ public: { "list", "as", false }, { 0, 0, 0 } }; - static ::DBus::IntrospectedArgument setCodecPreferedOrder_args[] = + static ::DBus::IntrospectedArgument getVersion_args[] = { - { "codec_name", "s", true }, + { "version", "s", false }, { 0, 0, 0 } }; - static ::DBus::IntrospectedArgument getCodecPreferedOrder_args[] = + static ::DBus::IntrospectedArgument getRingtoneList_args[] = { - { "codec_name", "s", false }, + { "list", "as", false }, { 0, 0, 0 } }; static ::DBus::IntrospectedArgument getPlaybackDeviceList_args[] = @@ -113,19 +102,25 @@ public: { "list", "as", false }, { 0, 0, 0 } }; - static ::DBus::IntrospectedArgument getSampleRateList_args[] = + static ::DBus::IntrospectedArgument getCodecList_args[] = { { "list", "as", false }, { 0, 0, 0 } }; - static ::DBus::IntrospectedArgument getDefaultAccount_args[] = + static ::DBus::IntrospectedArgument getCodecDetails_args[] = { - { "accountID", "s", false }, + { "payload", "i", true }, + { "details", "as", false }, { 0, 0, 0 } }; - static ::DBus::IntrospectedArgument setDefaultAccount_args[] = + static ::DBus::IntrospectedArgument getActiveCodecList_args[] = { - { "accountID", "s", true }, + { "list", "as", false }, + { 0, 0, 0 } + }; + static ::DBus::IntrospectedArgument setActiveCodecList_args[] = + { + { "list", "as", true }, { 0, 0, 0 } }; static ::DBus::IntrospectedArgument parametersChanged_args[] = @@ -144,18 +139,17 @@ public: { "addAccount", addAccount_args }, { "removeAccount", removeAccount_args }, { "getAccountList", getAccountList_args }, + { "getDefaultAccount", getDefaultAccount_args }, + { "setDefaultAccount", setDefaultAccount_args }, + { "getToneLocaleList", getToneLocaleList_args }, { "getVersion", getVersion_args }, { "getRingtoneList", getRingtoneList_args }, - { "getCodecList", getCodecList_args }, - { "getDefaultCodecList", getDefaultCodecList_args }, - { "getToneLocaleList", getToneLocaleList_args }, - { "setCodecPreferedOrder", setCodecPreferedOrder_args }, - { "getCodecPreferedOrder", getCodecPreferedOrder_args }, { "getPlaybackDeviceList", getPlaybackDeviceList_args }, { "getRecordDeviceList", getRecordDeviceList_args }, - { "getSampleRateList", getSampleRateList_args }, - { "getDefaultAccount", getDefaultAccount_args }, - { "setDefaultAccount", setDefaultAccount_args }, + { "getCodecList", getCodecList_args }, + { "getCodecDetails", getCodecDetails_args }, + { "getActiveCodecList", getActiveCodecList_args }, + { "setActiveCodecList", setActiveCodecList_args }, { 0, 0 } }; static ::DBus::IntrospectedMethod ConfigurationManager_signals[] = @@ -194,18 +188,17 @@ public: virtual void addAccount( const std::map< ::DBus::String, ::DBus::String >& details ) = 0; virtual void removeAccount( const ::DBus::String& accoundID ) = 0; virtual std::vector< ::DBus::String > getAccountList( ) = 0; + virtual ::DBus::String getDefaultAccount( ) = 0; + virtual void setDefaultAccount( const ::DBus::String& accountID ) = 0; + virtual std::vector< ::DBus::String > getToneLocaleList( ) = 0; 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; virtual std::vector< ::DBus::String > getPlaybackDeviceList( ) = 0; virtual std::vector< ::DBus::String > getRecordDeviceList( ) = 0; - virtual std::vector< ::DBus::String > getSampleRateList( ) = 0; - virtual ::DBus::String getDefaultAccount( ) = 0; - virtual void setDefaultAccount( const ::DBus::String& accountID ) = 0; + virtual std::vector< ::DBus::String > getCodecList( ) = 0; + virtual std::vector< ::DBus::String > getCodecDetails( const ::DBus::Int32& payload ) = 0; + virtual std::vector< ::DBus::String > getActiveCodecList( ) = 0; + virtual void setActiveCodecList( const std::vector< ::DBus::String >& list ) = 0; public: @@ -277,121 +270,112 @@ private: wi << argout1; return reply; } - ::DBus::Message _getVersion_stub( const ::DBus::CallMessage& call ) + ::DBus::Message _getDefaultAccount_stub( const ::DBus::CallMessage& call ) { ::DBus::MessageIter ri = call.reader(); - ::DBus::String argout1 = getVersion(); + ::DBus::String argout1 = getDefaultAccount(); ::DBus::ReturnMessage reply(call); ::DBus::MessageIter wi = reply.writer(); wi << argout1; return reply; } - ::DBus::Message _getRingtoneList_stub( const ::DBus::CallMessage& call ) + ::DBus::Message _setDefaultAccount_stub( const ::DBus::CallMessage& call ) { ::DBus::MessageIter ri = call.reader(); - std::vector< ::DBus::String > argout1 = getRingtoneList(); + ::DBus::String argin1; ri >> argin1; + setDefaultAccount(argin1); ::DBus::ReturnMessage reply(call); - ::DBus::MessageIter wi = reply.writer(); - wi << argout1; return reply; } - ::DBus::Message _getCodecList_stub( const ::DBus::CallMessage& call ) + ::DBus::Message _getToneLocaleList_stub( const ::DBus::CallMessage& call ) { ::DBus::MessageIter ri = call.reader(); - std::vector< ::DBus::String > argout1 = getCodecList(); + std::vector< ::DBus::String > argout1 = getToneLocaleList(); ::DBus::ReturnMessage reply(call); ::DBus::MessageIter wi = reply.writer(); wi << argout1; return reply; } - ::DBus::Message _getDefaultCodecList_stub( const ::DBus::CallMessage& call ) + ::DBus::Message _getVersion_stub( const ::DBus::CallMessage& call ) { ::DBus::MessageIter ri = call.reader(); - std::vector< ::DBus::String > argout1 = getDefaultCodecList(); + ::DBus::String argout1 = getVersion(); ::DBus::ReturnMessage reply(call); ::DBus::MessageIter wi = reply.writer(); wi << argout1; return reply; } - ::DBus::Message _getToneLocaleList_stub( const ::DBus::CallMessage& call ) + ::DBus::Message _getRingtoneList_stub( const ::DBus::CallMessage& call ) { ::DBus::MessageIter ri = call.reader(); - std::vector< ::DBus::String > argout1 = getToneLocaleList(); + std::vector< ::DBus::String > argout1 = getRingtoneList(); ::DBus::ReturnMessage reply(call); ::DBus::MessageIter wi = reply.writer(); wi << argout1; return reply; } - ::DBus::Message _setCodecPreferedOrder_stub( const ::DBus::CallMessage& call ) - { - ::DBus::MessageIter ri = call.reader(); - - ::DBus::String argin1; ri >> argin1; - setCodecPreferedOrder(argin1); - ::DBus::ReturnMessage reply(call); - return reply; - } - ::DBus::Message _getCodecPreferedOrder_stub( const ::DBus::CallMessage& call ) + ::DBus::Message _getPlaybackDeviceList_stub( const ::DBus::CallMessage& call ) { ::DBus::MessageIter ri = call.reader(); - ::DBus::String argout1 = getCodecPreferedOrder(); + std::vector< ::DBus::String > argout1 = getPlaybackDeviceList(); ::DBus::ReturnMessage reply(call); ::DBus::MessageIter wi = reply.writer(); wi << argout1; return reply; } - ::DBus::Message _getPlaybackDeviceList_stub( const ::DBus::CallMessage& call ) + ::DBus::Message _getRecordDeviceList_stub( const ::DBus::CallMessage& call ) { ::DBus::MessageIter ri = call.reader(); - std::vector< ::DBus::String > argout1 = getPlaybackDeviceList(); + std::vector< ::DBus::String > argout1 = getRecordDeviceList(); ::DBus::ReturnMessage reply(call); ::DBus::MessageIter wi = reply.writer(); wi << argout1; return reply; } - ::DBus::Message _getRecordDeviceList_stub( const ::DBus::CallMessage& call ) + ::DBus::Message _getCodecList_stub( const ::DBus::CallMessage& call ) { ::DBus::MessageIter ri = call.reader(); - std::vector< ::DBus::String > argout1 = getRecordDeviceList(); + std::vector< ::DBus::String > argout1 = getCodecList(); ::DBus::ReturnMessage reply(call); ::DBus::MessageIter wi = reply.writer(); wi << argout1; return reply; } - ::DBus::Message _getSampleRateList_stub( const ::DBus::CallMessage& call ) + ::DBus::Message _getCodecDetails_stub( const ::DBus::CallMessage& call ) { ::DBus::MessageIter ri = call.reader(); - std::vector< ::DBus::String > argout1 = getSampleRateList(); + ::DBus::Int32 argin1; ri >> argin1; + std::vector< ::DBus::String > argout1 = getCodecDetails(argin1); ::DBus::ReturnMessage reply(call); ::DBus::MessageIter wi = reply.writer(); wi << argout1; return reply; } - ::DBus::Message _getDefaultAccount_stub( const ::DBus::CallMessage& call ) + ::DBus::Message _getActiveCodecList_stub( const ::DBus::CallMessage& call ) { ::DBus::MessageIter ri = call.reader(); - ::DBus::String argout1 = getDefaultAccount(); + std::vector< ::DBus::String > argout1 = getActiveCodecList(); ::DBus::ReturnMessage reply(call); ::DBus::MessageIter wi = reply.writer(); wi << argout1; return reply; } - ::DBus::Message _setDefaultAccount_stub( const ::DBus::CallMessage& call ) + ::DBus::Message _setActiveCodecList_stub( const ::DBus::CallMessage& call ) { ::DBus::MessageIter ri = call.reader(); - ::DBus::String argin1; ri >> argin1; - setDefaultAccount(argin1); + std::vector< ::DBus::String > argin1; ri >> argin1; + setActiveCodecList(argin1); ::DBus::ReturnMessage reply(call); return reply; } diff --git a/src/dbus/configurationmanager-introspec.xml b/src/dbus/configurationmanager-introspec.xml index 4102085477b163979c2a3a215587bbce617c2906..6248a58a231354b351f30dba1e5fda7d9d946610 100644 --- a/src/dbus/configurationmanager-introspec.xml +++ b/src/dbus/configurationmanager-introspec.xml @@ -1,7 +1,8 @@ <?xml version="1.0" ?> <node name="/org/sflphone/SFLphone"> <interface name="org.sflphone.SFLphone.ConfigurationManager"> - + + <!-- Accounts-related methods --> <method name="getAccountDetails"> <arg type="s" name="accountID" direction="in"/> <arg type="a{ss}" name="details" direction="out"/> @@ -23,36 +24,32 @@ <method name="getAccountList"> <arg type="as" name="list" direction="out"/> </method> - - <method name="getVersion"> - <arg type="s" name="version" direction="out"/> - </method> - - <method name="getRingtoneList"> - <arg type="as" name="list" direction="out"/> - </method> - - <method name="getCodecList"> - <arg type="as" name="list" direction="out"/> + + <method name="getDefaultAccount"> + <arg type="s" name="accountID" direction="out"/> </method> - <method name="getDefaultCodecList"> - <arg type="as" name="list" direction="out"/> + <method name="setDefaultAccount"> + <arg type="s" name="accountID" direction="in"/> </method> + + <!-- /////////////////////// --> + <!-- Various audio-related methods --> + <method name="getToneLocaleList"> <arg type="as" name="list" direction="out"/> </method> - - <method name="setCodecPreferedOrder"> - <arg type="s" name="codec_name" direction="in"/> + + <method name="getVersion"> + <arg type="s" name="version" direction="out"/> </method> - <method name="getCodecPreferedOrder"> - <arg type="s" name="codec_name" direction="out"/> + <method name="getRingtoneList"> + <arg type="as" name="list" direction="out"/> </method> - - <method name="getPlaybackDeviceList"> + + <method name="getPlaybackDeviceList"> <arg type="as" name="list" direction="out"/> </method> @@ -60,18 +57,30 @@ <arg type="as" name="list" direction="out"/> </method> - <method name="getSampleRateList"> + <!-- /////////////////////// --> + + <!-- Codecs-related methods --> + + <method name="getCodecList"> <arg type="as" name="list" direction="out"/> </method> - - <method name="getDefaultAccount"> - <arg type="s" name="accountID" direction="out"/> + + <method name="getCodecDetails"> + <arg type="i" name="payload" direction="in"/> + <arg type="as" name="details" direction="out"/> + </method> + + <method name="getActiveCodecList"> + <arg type="as" name="list" direction="out"/> </method> - - <method name="setDefaultAccount"> - <arg type="s" name="accountID" direction="in"/> + + <method name="setActiveCodecList"> + <arg type="as" name="list" direction="in"/> </method> + + <!-- ///////////////////////////// --> + <signal name="parametersChanged"> <arg type="a{ss}" name="list" direction="out"/> </signal> diff --git a/src/dbus/configurationmanager.cpp b/src/dbus/configurationmanager.cpp index f80991218770ba45edbf3055c803e237ffe0f341..5c62f4134f94610372a66512f012e62c5b04fb52 100644 --- a/src/dbus/configurationmanager.cpp +++ b/src/dbus/configurationmanager.cpp @@ -96,7 +96,7 @@ ConfigurationManager::getRingtoneList( ) - std::vector< ::DBus::String > + std::vector< ::DBus::String > ConfigurationManager::getCodecList( ) { _debug("ConfigurationManager::getCodecList received\n"); @@ -104,29 +104,26 @@ ConfigurationManager::getCodecList( ) } std::vector< ::DBus::String > -ConfigurationManager::getDefaultCodecList( ) +ConfigurationManager::getCodecDetails( const ::DBus::Int32& payload ) { - _debug("ConfigurationManager::getDefaultCodecList received\n"); - return Manager::instance().getDefaultCodecList(); + _debug("ConfigurationManager::getCodecList received\n"); + return Manager::instance().getCodecDetails( payload ); } -void -ConfigurationManager::setCodecPreferedOrder( const ::DBus::String& codec_name ) + std::vector< ::DBus::String > +ConfigurationManager::getActiveCodecList( ) { - - _debug("ConfigurationManager::setCodecPreferedOrder received\n"); - Manager::instance().setPreferedCodec(codec_name); + _debug("ConfigurationManager::getActiveCodecList received\n"); + return Manager::instance().getActiveCodecList(); } - - ::DBus::String -ConfigurationManager::getCodecPreferedOrder( ) + void +ConfigurationManager::setActiveCodecList( const std::vector< ::DBus::String >& list ) { - _debug("ConfigurationManager::getCodecPreferedOrder received\n"); - return Manager::instance().getPreferedCodec(); + _debug("ConfigurationManager::setActiveCodecList received\n"); + Manager::instance().setActiveCodecList(list); } - std::vector< ::DBus::String > ConfigurationManager::getPlaybackDeviceList( ) { @@ -139,14 +136,6 @@ ConfigurationManager::getRecordDeviceList( ) { _debug("ConfigurationManager::getRecordDeviceList received\n"); -} - - std::vector< ::DBus::String > -ConfigurationManager::getSampleRateList( ) -{ - _debug("ConfigurationManager::getSampleRateList received\n"); - return Manager::instance().getSampleRateList(); - } ::DBus::String diff --git a/src/dbus/configurationmanager.h b/src/dbus/configurationmanager.h index 6b49c01390d4d739b157187d7abccd164f928442..35bbbfd6fc7ee7ca7318dc69fc64aad010413f6b 100644 --- a/src/dbus/configurationmanager.h +++ b/src/dbus/configurationmanager.h @@ -43,18 +43,19 @@ public: void addAccount( const std::map< ::DBus::String, ::DBus::String >& details ); void removeAccount( const ::DBus::String& accoundID ); std::vector< ::DBus::String > getAccountList( ); - ::DBus::String getVersion( ); - std::vector< ::DBus::String > getRingtoneList( ); - std::vector< ::DBus::String > getCodecList( ); - std::vector< ::DBus::String > getDefaultCodecList( ); + ::DBus::String getDefaultAccount( ); + void setDefaultAccount( const ::DBus::String& accountID ); + + std::vector< ::DBus::String > getCodecList( ); + std::vector< ::DBus::String > getCodecDetails( const ::DBus::Int32& payload ); + std::vector< ::DBus::String > getActiveCodecList( ); + void setActiveCodecList( const std::vector< ::DBus::String >& list ); + std::vector< ::DBus::String > getToneLocaleList( ); - void setCodecPreferedOrder( const ::DBus::String& codec_name ); - ::DBus::String getCodecPreferedOrder( ); std::vector< ::DBus::String > getPlaybackDeviceList( ); std::vector< ::DBus::String > getRecordDeviceList( ); - std::vector< ::DBus::String > getSampleRateList( ); - ::DBus::String getDefaultAccount( ); - void setDefaultAccount( const ::DBus::String& accountID ); + ::DBus::String getVersion( ); + std::vector< ::DBus::String > getRingtoneList( ); }; diff --git a/src/iaxvoiplink.cpp b/src/iaxvoiplink.cpp index 517e32ff075bfa373b5f510d6e299baefb6fe351..4e4738deb1d51cee566c0b46c6161c1e03d86c2b 100644 --- a/src/iaxvoiplink.cpp +++ b/src/iaxvoiplink.cpp @@ -236,16 +236,16 @@ IAXVoIPLink::loadCodec(int payload) switch(payload) { case 0: - handle_codec = dlopen("codec_ulaw.so", RTLD_LAZY); + handle_codec = dlopen(CODECS_DIR "/libcodec_ulaw.so", RTLD_LAZY); break; case 3: - handle_codec = dlopen("codec_gsm.so", RTLD_LAZY); + handle_codec = dlopen(CODECS_DIR "/libcodec_gsm.so", RTLD_LAZY); break; case 8: - handle_codec = dlopen("codec_alaw.so", RTLD_LAZY); + handle_codec = dlopen(CODECS_DIR "/libcodec_alaw.so", RTLD_LAZY); break; case 97: - handle_codec = dlopen("codec_ilbc.so", RTLD_LAZY); + handle_codec = dlopen(CODECS_DIR "/libcodec_ilbc.so", RTLD_LAZY); break; } if(!handle_codec){ diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index 26d99bc9dc013d58ff9045d08b261028752f4c2c..455583de6384776960e6e10b45c68368acb901aa 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -34,6 +34,8 @@ #include <ccrtp/rtp.h> // why do I need this here? #include <cc++/file.h> +#include <boost/tokenizer.hpp> + #include "manager.h" #include "account.h" #include "audio/audiolayer.h" @@ -1058,9 +1060,6 @@ ManagerImpl::initConfigFile (void) fill_config_int(DRIVER_NAME_OUT, DFT_DRIVER_STR); fill_config_int(DRIVER_SAMPLE_RATE, DFT_SAMPLE_RATE); fill_config_int(DRIVER_FRAME_SIZE, DFT_FRAME_SIZE); - //fill_config_str(CODEC1, DFT_CODEC1); - //fill_config_str(CODEC2, DFT_CODEC2); - //fill_config_str(CODEC3, DFT_CODEC3); fill_config_str(RING_CHOICE, DFT_RINGTONE); fill_config_int(VOLUME_SPKR, DFT_VOL_SPKR_STR); fill_config_int(VOLUME_MICRO, DFT_VOL_MICRO_STR); @@ -1088,97 +1087,125 @@ void ManagerImpl::initAudioCodec (void) { _debugInit("Active Codecs List"); + // init list of all supported codecs _codecDescriptorMap.init(); + // if the user never set the codec list, use the default one + if(getConfigString(AUDIO, "Activecodecs") == ""){ + _codecDescriptorMap.setDefaultOrder(); + } + // else retrieve the one he set in the config file + else{ + std::vector<std::string> active_list = retrieveActiveCodecs(); + setActiveCodecList(active_list); + } +} + +std::vector<std::string> +ManagerImpl::retrieveActiveCodecs() +{ + std::vector<std::string> order; + std::string list; + std::string s = getConfigString(AUDIO, "ActiveCodecs"); + typedef boost::tokenizer<boost::char_separator<char> > tokenizer; + boost::char_separator<char> slash("/"); + tokenizer tokens(s, slash); + for(tokenizer::iterator tok_iter = tokens.begin(); tok_iter!= tokens.end(); ++tok_iter) + { + printf("%s\n", (*tok_iter).c_str()); + order.push_back(*tok_iter); + } + return order; } void -ManagerImpl::setPreferedCodec(const ::DBus::String& codec_name) -{ _debug("Set Prefered Order\n"); - /* - std::vector<std::string> list = getCodecList(); - std::string tmp; - int i=0; - while(list[i] != codec_name) - i++; - tmp = list[0]; - list[0] = list[i]; - list[i] = tmp; - setConfig("Audio", "Codecs.codec1", list[0]); - setConfig("Audio", "Codecs.codec2", list[1]); - setConfig("Audio", "Codecs.codec3", list[2]); -*/ +ManagerImpl::setActiveCodecList(const std::vector<std::string>& list) +{ + _debug("Set active codecs list"); + _codecDescriptorMap.saveActiveCodecs(list); + // setConfig + std::string s = serialize(list); + printf("%s\n", s.c_str()); + setConfig("Audio", "ActiveCodecs", s); } std::string -ManagerImpl::getPreferedCodec() +ManagerImpl::serialize(std::vector<std::string> v) { - return getConfigString(AUDIO, "Codecs.codec1"); + int i; + std::string res; + for(i=0;i<v.size();i++) + { + res += v[i] + "/"; + } + return res; } + std::vector <std::string> -ManagerImpl::getDefaultCodecList( void ) +ManagerImpl::getActiveCodecList( void ) { + _debug("Get Active codecs list"); std::vector< std::string > v; - std::string desc=DFT_CODEC1; - //std::string rate=""+clockRate(desc); - //printf("%s\n",rate.c_str()); - v.push_back(DFT_CODEC1); // G711u - v.push_back(DFT_CODEC2); // G711a - v.push_back(DFT_CODEC3); // GSM + CodecOrder active = _codecDescriptorMap.getActiveCodecs(); + int i=0; + size_t size = active.size(); + while(i<size) + { + std::stringstream ss; + ss << active[i]; + v.push_back((ss.str()).data()); + i++; + } return v; } -unsigned int -ManagerImpl::clockRate(std::string& name) -{/* + +/** + * Send the list of codecs to the client through DBus. + */ +std::vector< std::string > +ManagerImpl::getCodecList( void ) +{ + std::vector<std::string> list; CodecMap codecs = _codecDescriptorMap.getCodecMap(); + CodecOrder order = _codecDescriptorMap.getActiveCodecs(); CodecMap::iterator iter = codecs.begin(); + while(iter!=codecs.end()) { - if(iter->second!=NULL) + std::stringstream ss; + if(iter->first!=-1) { - if(iter->second == name) - //return iter->second->getClockRate(); - return 1; - } + ss << iter->first; + list.push_back((ss.str()).data()); + } iter++; - }*/ - return -1; + } + return list; } -/** - * Send the list of codecs to the client through DBus. - */ -std::vector< std::string > -ManagerImpl::getCodecList( void ) +std::vector<std::string> +ManagerImpl::getCodecDetails( const ::DBus::Int32& payload ) { - - std::vector< std::string > v; - CodecMap codecs = _codecDescriptorMap.getCodecMap(); - CodecMap::iterator iter = codecs.begin(); - while(iter!=codecs.end()) - { - if(iter->first!=-1) - { - printf("codec: %s\n", iter->second.data()); - v.push_back(iter->second.data()); - } - iter++; - } - return v; -} + std::vector<std::string> v; + std::stringstream ss; + + v.push_back(_codecDescriptorMap.getCodecName((CodecType)payload)); + ss << _codecDescriptorMap.getSampleRate((CodecType)payload); + v.push_back((ss.str()).data()); + ss.str(""); + ss << _codecDescriptorMap.getBitRate((CodecType)payload); + v.push_back((ss.str()).data()); + ss.str(""); + ss << _codecDescriptorMap.getBandwidthPerCall((CodecType)payload); + v.push_back((ss.str()).data()); + ss.str(""); -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; + return v; } + /** * Initialization: Main Thread */ diff --git a/src/managerimpl.h b/src/managerimpl.h index 38d25a22c884ddb8b9537b9cdc2cb0ec9a23666c..cb3ec8a31447c07cde2aba3547402302e1c88820 100644 --- a/src/managerimpl.h +++ b/src/managerimpl.h @@ -261,45 +261,37 @@ public: */ std::string getDefaultAccount(); - /** - * Set the prefered order for codecs. - * Called by D-Bus command: "setCodecPreferedOrder" - * - * @param codec_name The name of the prefered codec. - */ - void setPreferedCodec(const ::DBus::String& codec_name); - -/** - * Get the prefered codec - * @return The description of the prefered codec - */ - std::string getPreferedCodec( ); /** - * Get the list of codecs we supports, ordered by the user + * Get the list of codecs we supports, not ordered * @return The list of the codecs */ - std::vector< ::DBus::String > getCodecList( void ); - + std::vector< ::DBus::String > getCodecList( void ); /** - * Get the default list of codecs we supports - * @ return The list of the codecs - */ - std::vector< ::DBus::String > getDefaultCodecList( void ); + * Get the info about one codec + * Name / CLock rate / bitrate / bandwidth + * @param payload The payload of the codec + * @return The information + */ + std::vector< ::DBus::String > getCodecDetails( const ::DBus::Int32& payload); -/** - * Get the sample rate of a codec - * @param name: The description of the codec - * @return The sample rate of the specified codec - */ - unsigned int clockRate(std::string& name); + /** + * Convert a list of payload in a special format, readable by the server. + * Required format: payloads separated with one slash. + * @return std::string The serializabled string + */ + std::string serialize(std::vector<std::string> v); -/** - * Get the list of the standart sound sample rates - * Values: { 44100 , 44000 , 96000 } - * @return The list of the sample rates - */ - std::vector< ::DBus::String> getSampleRateList( void ); + /** + * Inverse of serialize + */ + std::vector<std::string> retrieveActiveCodecs( void ); + + /** + * Get and set the list of the active codecs + */ + std::vector< ::DBus::String > getActiveCodecList( void ); + void setActiveCodecList( const std::vector< ::DBus::String >& list); /* * Set an account as default diff --git a/src/user_cfg.h b/src/user_cfg.h index d6ad4ae94dc11680745c7e580f2be9255fe7eae5..a70f3858d84ce3216913bb4b83241e042a37ff8d 100644 --- a/src/user_cfg.h +++ b/src/user_cfg.h @@ -63,11 +63,7 @@ #define DRIVER_NAME_OUT "Drivers.driverNameOut" #define DRIVER_SAMPLE_RATE "Drivers.sampleRate" #define DRIVER_FRAME_SIZE "Drivers.framesize" -#define NB_CODEC "Codecs.nbCodec" -#define CODEC1 "Codecs.codec1" -#define CODEC2 "Codecs.codec2" -#define CODEC3 "Codecs.codec3" -#define CODEC4 "Codecs.codec4" +#define CODECS "ActiveCodecs" #define RING_CHOICE "Rings.ringChoice" #define ACCOUNT_SIP_COUNT_DEFAULT 4 #define ACCOUNT_IAX_COUNT_DEFAULT 4 @@ -97,11 +93,7 @@ #define DFT_VOL_SPKR_STR "100" #define DFT_VOL_MICRO_STR "100" - -#define DFT_CODEC1 "G711u" -#define DFT_CODEC2 "G711a" -#define DFT_CODEC3 "GSM" -#define DFT_CODEC4 "iLBC" +#define DFT_CODECS "0/8/3" // liste ordonnée de payload #define DFT_RINGTONE "konga.ul" #define DFT_SKIN "metal" #define DFT_ZONE "North America"