Commit 8d3ec12c authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Get bit rate and bandwidth inplemented for each audio codec

parent 847b8bef
......@@ -7,7 +7,7 @@ Dependencies to compile SFLphone daemon
`--------------------`----------`-----------------------------------------------------
Program Version Notes
--------------------------------------------------------------------------------------
libiax2 0.2.3 http://svncommunity.digium.com/view/libiax2/trunk/[svn repos] SFLphone maintains it's own copy
libiax2 0.2.3 http://svncommunity.digium.com/view/libiax2/trunk/[svn repos] Source code included in the git repository.
Common C++2 1.3.21 http://sourceforge.net/projects/cplusplus/[website]
ccRTP 1.3.5 http://sourceforge.net/projects/cplusplus/[website]
libeXosip2 ** 2.2.2 http://savannah.nongnu.org/projects/exosip/[website]
......@@ -16,9 +16,8 @@ portaudio v19 http://www.portaudio.com/[website]
portaudio C++ binds. http://www.portaudio.com/archives/pa_snapshot_v19.tar.gz[archive]
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 See Build notes.
dbus-c++-1 0.5 Source code included in the git repository. See Build notes.
libexpat1 1.95.8 Packaged with your favorite distribution.
libgsm1 1.0.10 Ubuntu package - Necessary to use GSM codec.
--------------------------------------------------------------------------------------
......@@ -35,3 +34,11 @@ dbus-glib 0.35
gnome-common
--------------------------------------------------------------------------------------
Dependencies to use audio codecs
------------------------------------
`--------------------`----------`-----------------------------------------------------
Program Version Notes
--------------------------------------------------------------------------------------
libgsm1 1.0.10 Standard package - Necessary to use GSM codec
--------------------------------------------------------------------------------------
......@@ -32,12 +32,12 @@ CodecDescriptor::CodecDescriptor()
// Default codecs
_codecMap[PAYLOAD_CODEC_ULAW] = "PCMU";
_codecMap[PAYLOAD_CODEC_GSM] = "GSM";
//_codecMap[PAYLOAD_CODEC_ALAW] = "PCMA";
_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] = "iLBC";
// _codecMap[PAYLOAD_CODEC_ILBC_20] = "iLBC";
// _codecMap[PAYLOAD_CODEC_SPEEX] = Speex();
}
......@@ -47,7 +47,7 @@ CodecDescriptor::init()
_codecMap[PAYLOAD_CODEC_ULAW] = "PCMU";
_codecMap[PAYLOAD_CODEC_GSM] = "GSM";
_codecMap[PAYLOAD_CODEC_ALAW] = "PCMA";
_codecMap[PAYLOAD_CODEC_ILBC] = "iLBC";
// _codecMap[PAYLOAD_CODEC_ILBC_20] = "iLBC";
}
std::string&
......@@ -96,4 +96,51 @@ CodecDescriptor::addCodec(CodecType payload)
{
}
double
CodecDescriptor::getBitRate(CodecType payload)
{
switch(payload){
case PAYLOAD_CODEC_ULAW | PAYLOAD_CODEC_ALAW:
return 64;
case PAYLOAD_CODEC_GSM:
return 13.3;
case PAYLOAD_CODEC_ILBC_20:
return 15.2;
case PAYLOAD_CODEC_ILBC_30:
return 15.2;
}
return -1;
}
double
CodecDescriptor::getBandwidthPerCall(CodecType payload)
{
switch(payload){
case PAYLOAD_CODEC_ULAW | PAYLOAD_CODEC_ALAW:
return 80;
case PAYLOAD_CODEC_GSM:
return 28.6;
case PAYLOAD_CODEC_ILBC_20:
return 30.8;
}
return -1;
}
int
CodecDescriptor::getSampleRate(CodecType payload)
{
switch(payload){
case PAYLOAD_CODEC_ULAW | PAYLOAD_CODEC_ALAW | PAYLOAD_CODEC_GSM | PAYLOAD_CODEC_ILBC_20:
return 8000;
}
return -1;
}
......@@ -38,7 +38,8 @@ typedef enum {
PAYLOAD_CODEC_ALAW = 8,
// http://www.ietf.org/rfc/rfc3952.txt
// 97 iLBC/8000
PAYLOAD_CODEC_ILBC = 97,
PAYLOAD_CODEC_ILBC_20 = 97,
PAYLOAD_CODEC_ILBC_30 = 98,
// http://www.speex.org/drafts/draft-herlein-speex-rtp-profile-00.txt
// 97 speex/8000
// http://support.xten.com/viewtopic.php?p=8684&sid=3367a83d01fdcad16c7459a79859b08e
......@@ -85,11 +86,34 @@ public:
void removeCodec(CodecType payload);
/**
* Add a codec in the list
* Add a codec in the list.
* @param payload the codec to add
*/
void addCodec(CodecType payload);
/**
* Get the bit rate of the specified codec.
* @param payload The payload of the codec
* @return double The bit rate
*/
double getBitRate(CodecType payload);
/**
* Get the bandwidth for one call with the specified codec.
* The value has been calculated with the further information:
* RTp communication, SIP protocol (the value with IAX2 is very close), no RTCP, one simultaneous call, for one channel (the incoming one).
* @param payload The payload of the codec
* @return double The bandwidth
*/
double getBandwidthPerCall(CodecType payload);
/**
* Get the clock rate of the specified codec
* @param payload The payload of the codec
* @return int The clock rate of the specified codec
*/
int getSampleRate(CodecType payload);
private:
CodecMap _codecMap;
};
......
......@@ -42,7 +42,7 @@ IAXCall::setFormat(int format)
case AST_FORMAT_ALAW:
setAudioCodec(_codecMap.getCodec(PAYLOAD_CODEC_ALAW)); break;
case AST_FORMAT_ILBC:
setAudioCodec(_codecMap.getCodec(PAYLOAD_CODEC_ILBC)); break;
setAudioCodec(_codecMap.getCodec(PAYLOAD_CODEC_ILBC_20)); break;
case AST_FORMAT_SPEEX:
setAudioCodec(_codecMap.getCodec(PAYLOAD_CODEC_SPEEX)); break;*/
case AST_FORMAT_ULAW:
......@@ -52,7 +52,7 @@ IAXCall::setFormat(int format)
case AST_FORMAT_ALAW:
setAudioCodec(PAYLOAD_CODEC_ALAW); break;
case AST_FORMAT_ILBC:
setAudioCodec(PAYLOAD_CODEC_ILBC); break;
setAudioCodec(PAYLOAD_CODEC_ILBC_20); break;
case AST_FORMAT_SPEEX:
setAudioCodec(PAYLOAD_CODEC_SPEEX); break;
default:
......@@ -77,7 +77,7 @@ IAXCall::getSupportedFormat()
format |= AST_FORMAT_GSM; break;
case PAYLOAD_CODEC_ALAW:
format |= AST_FORMAT_ALAW; break;
case PAYLOAD_CODEC_ILBC:
case PAYLOAD_CODEC_ILBC_20:
format |= AST_FORMAT_ILBC; break;
case PAYLOAD_CODEC_SPEEX:
format |= AST_FORMAT_SPEEX; break;
......@@ -105,7 +105,7 @@ IAXCall::getFirstMatchingFormat(int needles)
format = AST_FORMAT_GSM; break;
case PAYLOAD_CODEC_ALAW:
format = AST_FORMAT_ALAW; break;
case PAYLOAD_CODEC_ILBC:
case PAYLOAD_CODEC_ILBC_20:
format = AST_FORMAT_ILBC; break;
case PAYLOAD_CODEC_SPEEX:
format = AST_FORMAT_SPEEX; break;
......
Markdown is supported
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