Commit 08379a37 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Documentation on new methods

parent fc0ad705
......@@ -604,10 +604,7 @@ sflphone_fill_codec_list()
for(pl=codecs; *codecs; codecs++)
{
//codec_t * c = g_new0(codec_t, 1);
//c->_payload = atoi(*codecs);
details = (gchar **)dbus_codec_details(atoi(*codecs));
//c->name = details[0];
if(codec_list_get(details[0])!=NULL){
// does nothing - the codec is already in the list, so is active.
}
......@@ -624,11 +621,3 @@ sflphone_fill_codec_list()
}
}
......@@ -45,9 +45,16 @@ CodecDescriptor::init()
_codecMap[PAYLOAD_CODEC_ALAW] = "PCMA";
_codecMap[PAYLOAD_CODEC_ILBC_20] = "iLBC";
}
void
CodecDescriptor::setDefaultOrder()
{
_codecOrder.clear();
_codecOrder.push_back(PAYLOAD_CODEC_ULAW);
_codecOrder.push_back(PAYLOAD_CODEC_ALAW);
_codecOrder.push_back(PAYLOAD_CODEC_GSM);
}
std::string&
CodecDescriptor::getCodecName(CodecType payload)
......
......@@ -52,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;
/* The struct to reflect the order the user wants to use the codecs */
typedef std::vector<CodecType> CodecOrder;
class CodecDescriptor {
......@@ -72,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)
......
......@@ -1060,7 +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(CODECS, DFT_CODECS);
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);
......@@ -1090,8 +1089,15 @@ ManagerImpl::initAudioCodec (void)
_debugInit("Active Codecs List");
// init list of all supported codecs
_codecDescriptorMap.init();
std::vector<std::string> active_list = retrieveActiveCodecs();
setActiveCodecList(active_list);
// 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>
......@@ -1116,9 +1122,25 @@ ManagerImpl::setActiveCodecList(const std::vector<std::string>& list)
{
_debug("Set active codecs list");
_codecDescriptorMap.saveActiveCodecs(list);
//TODO setConfig
// setConfig
std::string s = serialize(list);
printf("%s\n", s.c_str());
setConfig("Audio", "ActiveCodecs", s);
}
std::string
ManagerImpl::serialize(std::vector<std::string> v)
{
int i;
std::string res;
for(i=0;i<v.size();i++)
{
res += v[i] + "/";
}
return res;
}
std::vector <std::string>
ManagerImpl::getActiveCodecList( void )
{
......@@ -1172,15 +1194,12 @@ ManagerImpl::getCodecDetails( const ::DBus::Int32& payload )
v.push_back(_codecDescriptorMap.getCodecName((CodecType)payload));
ss << _codecDescriptorMap.getSampleRate((CodecType)payload);
v.push_back((ss.str()).data());
printf("samplerate = %s\n", (ss.str()).data());
ss.str("");
ss << _codecDescriptorMap.getBitRate((CodecType)payload);
v.push_back((ss.str()).data());
printf("bitrate = %s\n", (ss.str()).data());
ss.str("");
ss << _codecDescriptorMap.getBandwidthPerCall((CodecType)payload);
v.push_back((ss.str()).data());
printf("bandwidth = %s\n", (ss.str()).data());
ss.str("");
return v;
......
......@@ -263,20 +263,35 @@ public:
/**
* 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 > getCodecDetails( const ::DBus::Int32& payload);
std::vector< ::DBus::String > getCodecList( 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 list of the active codecs
* @ return The list of the active codecs (their payload actually)
* 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);
/**
* 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);
std::vector<std::string> retrieveActiveCodecs( void );
/*
* Set an account as default
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment