Commit 8d298068 authored by Alexandre Bourget's avatar Alexandre Bourget
Browse files

Clean-up codec names, add a description.

Ébauche de l'implémentation du call D-Bus "setCodecPreferedOrder" dans managerimpl.cpp
parent ab8f15c7
......@@ -23,6 +23,8 @@
CodecSpeex::CodecSpeex(int payload)
: AudioCodec(payload, "speex")
{
_description = "Speex";
_clockRate = 8000;
_channel = 1;
initSpeex();
......
......@@ -23,8 +23,10 @@
// 8 PCMA A 8000 1 [RFC3551]
Alaw::Alaw(int payload)
: AudioCodec(payload, "G711a")
: AudioCodec(payload, "PCMA")
{
_description = "G711a";
_clockRate = 8000;
_channel = 1;
}
......
......@@ -24,7 +24,7 @@
#include "audiocodec.h"
AudioCodec::AudioCodec (int payload, const std::string &codecName)
: _codecName(codecName), _officialName(codecName)
: _codecName(codecName)
{
_payload = payload;
_clockRate = 8000; // default
......
......@@ -39,7 +39,10 @@ public:
virtual int codecDecode(short *, unsigned char *, unsigned int) = 0;
virtual int codecEncode(unsigned char *, short *, unsigned int) = 0;
std::string getOfficialName() { return _officialName; }
/** Returns description for GUI usage */
std::string getDescription() { return _description; }
/** Value used for SDP negotiation */
std::string getCodecName() { return _codecName; }
int getPayload() { return _payload; }
bool hasDynamicPayload() { return _hasDynamicPayload; }
......@@ -49,8 +52,10 @@ public:
void setActive(bool active) { _active = active; }
protected:
/** Holds SDP-compliant codec name */
std::string _codecName; // what we put inside sdp
std::string _officialName; // what we display to the user
/** Holds the GUI-style codec description */
std::string _description; // what we display to the user
/**
* Clock rate or sample rate of the codec, in Hz
......
......@@ -53,12 +53,12 @@ CodecDescriptorMap::getCodec(CodecType payload)
}
void
CodecDescriptorMap::setActive(const std::string& officialName)
CodecDescriptorMap::setActive(const std::string& codecDescription)
{
CodecMap::iterator iter = _codecMap.begin();
while(iter!=_codecMap.end()) {
if (iter->second!=0) {
if (iter->second->getOfficialName() == officialName) {
if (iter->second->getDescription() == codecDescription) {
iter->second->setActive(true);
break;
}
......
......@@ -66,11 +66,11 @@ public:
/**
* Get codec with is associated payload
* Put a codec active, with is codecName
* Put a codec active, with it's codec's _description
* O(n) if not found where n is the number of element
* @param codecName the same that getCodec(number)->getCodecName()
* @param codecDescription is the same as with getCodec(number)->getDescription()
*/
void setActive(const std::string& officialName);
void setActive(const std::string& codecDescription);
private:
CodecMap _codecMap;
};
......
......@@ -25,6 +25,8 @@
// 3 GSM A 8000 1 [RFC3551]
Gsm::Gsm(int payload) : AudioCodec(payload, "GSM")
{
_description = "GSM";
_clockRate = 8000;
_channel = 1;
if (!(_decode_gsmhandle = gsm_create() ))
......
......@@ -23,8 +23,10 @@
// 0 PCMU A 8000 1 [RFC3551]
Ulaw::Ulaw(int payload)
: AudioCodec(payload, "G711u")
: AudioCodec(payload, "PCMU")
{
_description = "G711u";
_clockRate = 8000;
_channel = 1;
}
......
......@@ -62,7 +62,7 @@ ConfigurationManager::removeAccount( const ::DBus::String& accoundID )
return Manager::instance().removeAccount(accoundID);
}
std::vector< ::DBus::String >
std::vector< ::DBus::String >
ConfigurationManager::getAccountList( )
{
_debug("ConfigurationManager::getAccountList received\n");
......@@ -70,7 +70,7 @@ ConfigurationManager::getAccountList( )
}
std::vector< ::DBus::String >
std::vector< ::DBus::String >
ConfigurationManager::getToneLocaleList( )
{
_debug("ConfigurationManager::getToneLocaleList received\n");
......@@ -104,11 +104,12 @@ ConfigurationManager::getCodecList( )
}
void
ConfigurationManager::setCodecPreferedOrder( const std::vector< ::DBus::String >& ringtone )
void
ConfigurationManager::setCodecPreferedOrder( const std::vector< ::DBus::String >& codecList )
{
_debug("ConfigurationManager::setCodecPreferedOrder received\n");
_debug("ConfigurationManager::setCodecPreferedOrder received\n");
return Manager::instance().setCodecsOrder(codecList);
}
......
......@@ -47,7 +47,7 @@ public:
std::vector< ::DBus::String > getRingtoneList( );
std::vector< ::DBus::String > getCodecList( );
std::vector< ::DBus::String > getToneLocaleList( );
void setCodecPreferedOrder( const std::vector< ::DBus::String >& ringtone );
void setCodecPreferedOrder( const std::vector< ::DBus::String >& codecList );
std::vector< ::DBus::String > getCodecPreferedOrder( );
std::vector< ::DBus::String > getPlaybackDeviceList( );
std::vector< ::DBus::String > getRecordDeviceList( );
......
......@@ -1087,6 +1087,16 @@ ManagerImpl::initAudioCodec (void)
_codecDescriptorMap.setActive(getConfigString(AUDIO, CODEC3));
}
/**
* Set prefered codec order
*/
void
ManagerImpl::setCodecsOrder(const std::vector< ::DBus::String >& codecs)
{
// TODO: set codecs using the list.
_debug("Set codecs preferred order: UNIMPLEMENTED YET :)\n");
}
/**
* Initialization: Main Thread
......@@ -1403,7 +1413,7 @@ ManagerImpl::getConfigList(const std::string& sequenceId, const std::string& nam
strType << iter->first;
tk.push_back(strType.str());
if (iter->second) {
tk.push_back(iter->second->getOfficialName());
tk.push_back(iter->second->getDescription());
} else {
tk.push_back(strType.str());
}
......
......@@ -399,7 +399,16 @@ private:
* Initialize audiocodec with config setting
*/
void initAudioCodec(void);
/**
* Set the prefered order for codecs.
* Called by D-Bus command: "setCodecPreferedOrder"
*
* @param codecs A list of strings ("codecName"s) of the codecs.
*/
void setCodecsOrder(const std::vector< ::DBus::String >& codecs);
/*
* Initialize audiodriver
*/
......
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