diff --git a/sflphone-gtk/src/actions.c b/sflphone-gtk/src/actions.c index 1188d0ad1c4c67be70b1fd1af8483acfc7aeea06..83a75171e67b0223e00335aa834e38ea6ae07b38 100644 --- a/sflphone-gtk/src/actions.c +++ b/sflphone-gtk/src/actions.c @@ -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() } } - - - - - - - - diff --git a/src/audio/codecDescriptor.cpp b/src/audio/codecDescriptor.cpp index 8e5a6d8b1a842c1d4659ed63b13eed0c709c5e4b..4df2ac0f288936ca0f580256286cce49291cd7f6 100644 --- a/src/audio/codecDescriptor.cpp +++ b/src/audio/codecDescriptor.cpp @@ -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) diff --git a/src/audio/codecDescriptor.h b/src/audio/codecDescriptor.h index d2ba2b03383cc4b4b991ffd02bc2292d2ed2c697..4cb9be9a5c03c88ef58b6c653ce77958b7aa7053 100644 --- a/src/audio/codecDescriptor.h +++ b/src/audio/codecDescriptor.h @@ -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) diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index ccdbc29c7d92d2f468f1818b3076ea7b6e3c53b8..455583de6384776960e6e10b45c68368acb901aa 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -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; diff --git a/src/managerimpl.h b/src/managerimpl.h index 8fbc1dedd96f45ada0573e4bcc237f4d00c587fe..cb3ec8a31447c07cde2aba3547402302e1c88820 100644 --- a/src/managerimpl.h +++ b/src/managerimpl.h @@ -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