Commit fd517036 authored by Guillaume Carmel-Archambault's avatar Guillaume Carmel-Archambault
Browse files
parents 7ca27816 7e6428d4
......@@ -34,8 +34,11 @@ dbus-glib 0.35
gnome-common
--------------------------------------------------------------------------------------
Dependencies to use audio codecs
------------------------------------
--------------------------------
`--------------------`----------`-----------------------------------------------------
Program Version Notes
......
......@@ -580,21 +580,28 @@ 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** details;
gchar** pl;
for(pl=codecs; *codecs; codecs++)
{
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(*codecs);
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];
codec_set_active(details[0]);
c->sample_rate = atoi(details[1]);
c->_bitrate = atof(details[2]);
c->_bandwidth = atof(details[3]);
codec_list_add(c);
i++;
}
}
}
......
......@@ -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,21 @@ 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)
printf("entry point set active");
codec_t * c = codec_list_get(name);
if(c){
printf("blablabla");
c->is_active = TRUE;
}
printf("exit point set active");
}
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;
}
......@@ -67,7 +89,7 @@ codec_list_get_size()
{
return g_queue_get_length(codecQueue);
}
/*
codec_t*
codec_list_get( const gchar * name)
{
......@@ -77,6 +99,16 @@ codec_list_get( const gchar * name)
else
return NULL;
}
*/
codec_t*
codec_list_get( const gchar* name)
{
GList * c = g_queue_find_custom(codecQueue, name, is_name_codecstruct);
if(c)
return (codec_t *)c->data;
else
return NULL;
}
codec_t*
codec_list_get_nth(guint index)
......
......@@ -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);
/**
......
......@@ -109,9 +109,9 @@ config_window_fill_codec_list()
{
gtk_list_store_append(codecStore, &iter);
gtk_list_store_set(codecStore, &iter,
0, c->is_active, // Active
0, TRUE,//c->is_active, // Active
1, c->name, // Name
2, c->sample_rate, // Frequency
2, "sample rate",//c->sample_rate, // Frequency
3, "bit rate", // Bit rate
4, "bandwith", // Bandwith
-1);
......
......@@ -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,6 +688,35 @@ dbus_codec_list()
return array;
}
gchar**
dbus_codec_details( int payload )
{
g_print("Before");
GError *error = NULL;
gchar ** array;
org_sflphone_SFLphone_ConfigurationManager_get_codec_details (
configurationManagerProxy,
payload,
&array,
&error);
g_print("After");
if (error)
{
g_printerr ("Failed to call get_codec_details() on ConfigurationManager: %s\n",
error->message);
g_error_free (error);
}
else
{
g_print ("DBus called get_codec_details() on ConfigurationManager\n");
}
return array;
}
gchar **
dbus_default_codec_list()
{
......
......@@ -54,6 +54,7 @@ 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();
......
......@@ -36,9 +36,7 @@ CodecDescriptor::CodecDescriptor()
#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
......@@ -47,7 +45,7 @@ CodecDescriptor::init()
_codecMap[PAYLOAD_CODEC_ULAW] = "PCMU";
_codecMap[PAYLOAD_CODEC_GSM] = "GSM";
_codecMap[PAYLOAD_CODEC_ALAW] = "PCMA";
// _codecMap[PAYLOAD_CODEC_ILBC_20] = "iLBC";
_codecMap[PAYLOAD_CODEC_ILBC_20] = "iLBC";
}
std::string&
......@@ -57,7 +55,7 @@ CodecDescriptor::getCodecName(CodecType payload)
if (iter!=_codecMap.end()) {
return (iter->second);
}
//return ;
//return std::string("");
}
bool
......@@ -100,7 +98,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 +117,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,14 +134,40 @@ 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;
}
/*
int
CodecDescriptor::getSampleRate(CodecType payload)
{
std::string name = getCodecName(payload);
switch(name){
case "PCMU":
return 8000;
case "PCMA":
return 8000;
case "GSM":
return 8000;
case "iLBC":
return 8000;
}
}
*/
......
......@@ -25,6 +25,7 @@
#include <string>
#include <map>
#include <vector>
#include "../global.h"
typedef enum {
......@@ -51,6 +52,7 @@ typedef enum {
/* A codec is identified by its payload. A payload is associated with a name. */
typedef std::map<CodecType, std::string> CodecMap;
typedef std::vector<CodecType> CodecOrder;
class CodecDescriptor {
public:
......@@ -60,6 +62,7 @@ public:
CodecDescriptor();
~CodecDescriptor() {};
CodecMap& getCodecMap() { return _codecMap; }
CodecOrder& getCodecOrder() { return _codecOrder; }
/**
* Get codec with is associated payload
......@@ -116,6 +119,7 @@ public:
int getSampleRate(CodecType payload);
private:
CodecMap _codecMap;
CodecOrder _codecOrder;
};
#endif // __CODEC_DESCRIPTOR_H__
......@@ -25,18 +25,22 @@ 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, getSampleRateList, _getSampleRateList_stub);
register_method(ConfigurationManager, getPlaybackDeviceList, _getPlaybackDeviceList_stub);
register_method(ConfigurationManager, getRecordDeviceList, _getRecordDeviceList_stub);
register_method(ConfigurationManager, getCodecList, _getCodecList_stub);
register_method(ConfigurationManager, getCodecDetails, _getCodecDetails_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, getCodecBitRate, _getCodecBitRate_stub);
register_method(ConfigurationManager, getCodecBandwidth, _getCodecBandwidth_stub);
register_method(ConfigurationManager, getCodecClockRate, _getCodecClockRate_stub);
}
::DBus::IntrospectedInterface* const introspect() const
......@@ -68,6 +72,21 @@ public:
{ "list", "as", false },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument getDefaultAccount_args[] =
{
{ "accountID", "s", false },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument setDefaultAccount_args[] =
{
{ "accountID", "s", true },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument getToneLocaleList_args[] =
{
{ "list", "as", false },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument getVersion_args[] =
{
{ "version", "s", false },
......@@ -78,54 +97,63 @@ public:
{ "list", "as", false },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument getCodecList_args[] =
static ::DBus::IntrospectedArgument getSampleRateList_args[] =
{
{ "list", "as", false },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument getDefaultCodecList_args[] =
static ::DBus::IntrospectedArgument getPlaybackDeviceList_args[] =
{
{ "list", "as", false },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument getToneLocaleList_args[] =
static ::DBus::IntrospectedArgument getRecordDeviceList_args[] =
{
{ "list", "as", false },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument setCodecPreferedOrder_args[] =
static ::DBus::IntrospectedArgument getCodecList_args[] =
{
{ "codec_name", "s", true },
{ "list", "as", false },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument getCodecPreferedOrder_args[] =
static ::DBus::IntrospectedArgument getCodecDetails_args[] =
{
{ "codec_name", "s", false },
{ "payload", "i", true },
{ "details", "as", false },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument getPlaybackDeviceList_args[] =
static ::DBus::IntrospectedArgument getDefaultCodecList_args[] =
{
{ "list", "as", false },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument getRecordDeviceList_args[] =
static ::DBus::IntrospectedArgument setCodecPreferedOrder_args[] =
{
{ "list", "as", false },
{ "codec_name", "s", true },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument getSampleRateList_args[] =
static ::DBus::IntrospectedArgument getCodecPreferedOrder_args[] =
{
{ "list", "as", false },
{ "codec_name", "s", false },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument getDefaultAccount_args[] =
static ::DBus::IntrospectedArgument getCodecBitRate_args[] =
{
{ "accountID", "s", false },
{ "codec_name", "s", true },
{ "bitrate", "s", false },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument setDefaultAccount_args[] =
static ::DBus::IntrospectedArgument getCodecBandwidth_args[] =
{
{ "accountID", "s", true },
{ "codec_name", "s", true },
{ "bandwidth", "s", false },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument getCodecClockRate_args[] =
{
{ "codec_name", "s", true },
{ "clockrate", "s", false },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument parametersChanged_args[] =
......@@ -144,18 +172,22 @@ 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 },
{ "getSampleRateList", getSampleRateList_args },
{ "getPlaybackDeviceList", getPlaybackDeviceList_args },
{ "getRecordDeviceList", getRecordDeviceList_args },
{ "getCodecList", getCodecList_args },
{ "getCodecDetails", getCodecDetails_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 },
{ "getCodecBitRate", getCodecBitRate_args },
{ "getCodecBandwidth", getCodecBandwidth_args },
{ "getCodecClockRate", getCodecClockRate_args },
{ 0, 0 }
};
static ::DBus::IntrospectedMethod ConfigurationManager_signals[] =
......@@ -194,18 +226,22 @@ 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 > getSampleRateList( ) = 0;
virtual std::vector< ::DBus::String > getPlaybackDeviceList( ) = 0;
virtual std::vector< ::DBus::String > getRecordDeviceList( ) = 0;
virtual std::vector< ::DBus::String > getCodecList( ) = 0;
virtual std::vector< ::DBus::String > getCodecDetails( const ::DBus::Int32& payload ) = 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 ::DBus::String getCodecBitRate( const ::DBus::String& codec_name ) = 0;
virtual ::DBus::String getCodecBandwidth( const ::DBus::String& codec_name ) = 0;
virtual ::DBus::String getCodecClockRate( const ::DBus::String& codec_name ) = 0;
public:
......@@ -277,6 +313,35 @@ private:
wi << argout1;
return reply;
}
::DBus::Message _getDefaultAccount_stub( const ::DBus::CallMessage& call )
{
::DBus::MessageIter ri = call.reader();
::DBus::String argout1 = getDefaultAccount();
::DBus::ReturnMessage reply(call);
::DBus::MessageIter wi = reply.writer();
wi << argout1;
return reply;
}
::DBus::Message _setDefaultAccount_stub( const ::DBus::CallMessage& call )
{
::DBus::MessageIter ri = call.reader();
::DBus::String argin1; ri >> argin1;
setDefaultAccount(argin1);
::DBus::ReturnMessage reply(call);
return reply;
}
::DBus::Message _getToneLocaleList_stub( const ::DBus::CallMessage& call )
{
::DBus::MessageIter ri = call.reader();
std::vector< ::DBus::String > argout1 = getToneLocaleList();
::DBus::ReturnMessage reply(call);
::DBus::MessageIter wi = reply.writer();
wi << argout1;
return reply;
}
::DBus::Message _getVersion_stub( const ::DBus::CallMessage& call )
{
::DBus::MessageIter ri = call.reader();
......@@ -297,102 +362,117 @@ private:
wi << argout1;
return reply;
}
::DBus::Message _getCodecList_stub( const ::DBus::CallMessage& call )
::DBus::Message _getSampleRateList_stub( const ::DBus::CallMessage& call )
{
::DBus::MessageIter ri = call.reader();
std::vector< ::DBus::String > argout1 = getCodecList();
std::vector< ::DBus::String > argout1 = getSampleRateList();
::DBus::ReturnMessage reply(call);
::DBus::MessageIter wi = reply.writer();
wi << argout1;
return reply;
}
::DBus::Message _getDefaultCodecList_stub( const ::DBus::CallMessage& call )
::DBus::Message _getPlaybackDeviceList_stub( const ::DBus::CallMessage& call )