Commit 2e2989d6 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Addons for support of ilbc codec.

Audio calls with ilbc codecs still not tested.
parent 66102047
......@@ -28,7 +28,7 @@ public:
Alaw(int payload=0)
: AudioCodec(payload, "PCMA")
{
_description = "G711a";
//_description = "G711a";
_clockRate = 8000;
_channel = 1;
......@@ -121,7 +121,7 @@ uint8 ALawEncode (int16 pcm16)
// the class factories
extern "C" AudioCodec* create() {
return new Alaw();
return new Alaw(8);
}
extern "C" void destroy(AudioCodec* a) {
......
......@@ -10,9 +10,6 @@ protected:
/** Holds SDP-compliant codec name */
std::string _codecName; // what we put inside sdp
/** 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 */
unsigned int _clockRate;
......@@ -20,7 +17,7 @@ protected:
unsigned int _channel;
private:
bool _active;
//bool _active;
int _payload;
bool _hasDynamicPayload;
......@@ -30,7 +27,7 @@ public:
_payload = payload;
_clockRate = 8000; // default
_channel = 1; // default
_active = false;
// _active = false;
_hasDynamicPayload = (_payload >= 96 && _payload <= 127) ? true : false;
}
......@@ -42,8 +39,6 @@ public:
*/
virtual int codecDecode(short *, unsigned char *, unsigned int) = 0;
virtual int codecEncode(unsigned char *, short *, unsigned int) = 0;
/** Returns description for GUI usage */
std::string getDescription() { return _description; }
/** Value used for SDP negotiation */
std::string getCodecName() { return _codecName; }
......@@ -51,8 +46,8 @@ public:
bool hasDynamicPayload() { return _hasDynamicPayload; }
unsigned int getClockRate() { return _clockRate; }
unsigned int getChannel() { return _channel; }
bool isActive() { return _active; }
void setActive(bool active) { _active = active; }
//bool isActive() { return _active; }
//void setActive(bool active) { _active = active; }
};
......
......@@ -68,7 +68,6 @@ AudioRtp::createNewSession (SIPCall *ca) {
// Start RTP Send/Receive threads
_symmetric = Manager::instance().getConfigInt(SIGNALISATION,SYMMETRIC) ? true : false;
_RTXThread = new AudioRtpRTX (ca, _symmetric);
printf("_sym=%i\n\n", _symmetric);
try {
if (_RTXThread->start() != 0) {
_debug("! ARTP Failure: unable to start RTX Thread\n");
......@@ -108,7 +107,6 @@ AudioRtpRTX::AudioRtpRTX (SIPCall *sipcall, bool sym)
// AudioRtpRTX should be close if we change sample rate
//_codecSampleRate = _ca->getAudioCodec()->getClockRate();
_codecSampleRate = 8000;
// TODO: Change bind address according to user settings.
......@@ -182,9 +180,15 @@ AudioRtpRTX::initBuffers()
void
AudioRtpRTX::initAudioRtpSession (void)
{
try {
if (_ca == 0) { return; }
_debug("AUDIOCODEC=%i\n", _ca->getAudioCodec());
AudioCodec* audiocodec = loadCodec(_ca->getAudioCodec());
_codecSampleRate = audiocodec->getClockRate();
_debug("Init audio RTP session\n");
ost::InetHostAddress remote_ip(_ca->getRemoteIp().c_str());
if (!remote_ip) {
......@@ -214,19 +218,14 @@ AudioRtpRTX::initAudioRtpSession (void)
return;
}
//AudioCodec* audiocodec = _ca->getAudioCodec();
CodecType audiocodec = _ca->getAudioCodec();
bool payloadIsSet = false;
if (audiocodec) {
/*if (audiocodec->hasDynamicPayload()) {
//payloadIsSet = _sessionRecv->setPayloadFormat(ost::DynamicPayloadFormat((ost::PayloadType) audiocodec->getPayload(), audiocodec->getClockRate()));
payloadIsSet = _sessionRecv->setPayloadFormat(ost::DynamicPayloadFormat((ost::PayloadType) audiocodec, 8000));
} else {*/
//payloadIsSet= _sessionRecv->setPayloadFormat(ost::StaticPayloadFormat((ost::StaticPayloadType) audiocodec->getPayload()));
//payloadIsSet = _sessionSend->setPayloadFormat(ost::StaticPayloadFormat((ost::StaticPayloadType) audiocodec->getPayload()));
payloadIsSet= _sessionRecv->setPayloadFormat(ost::StaticPayloadFormat((ost::StaticPayloadType) audiocodec));
payloadIsSet = _sessionSend->setPayloadFormat(ost::StaticPayloadFormat((ost::StaticPayloadType) audiocodec));
//}
if (audiocodec->hasDynamicPayload()) {
payloadIsSet = _sessionRecv->setPayloadFormat(ost::DynamicPayloadFormat((ost::PayloadType) audiocodec->getPayload(), audiocodec->getClockRate()));
} else {
payloadIsSet= _sessionRecv->setPayloadFormat(ost::StaticPayloadFormat((ost::StaticPayloadType) audiocodec->getPayload()));
payloadIsSet = _sessionSend->setPayloadFormat(ost::StaticPayloadFormat((ost::StaticPayloadType) audiocodec->getPayload()));
}
}
_sessionSend->setMark(true);
} else {
......@@ -237,18 +236,16 @@ AudioRtpRTX::initAudioRtpSession (void)
return;
}
//AudioCodec* audiocodec = _ca->getAudioCodec();
CodecType audiocodec = _ca->getAudioCodec();
bool payloadIsSet = false;
if (audiocodec) {
/*if (audiocodec->hasDynamicPayload()) {
if (audiocodec->hasDynamicPayload()) {
payloadIsSet = _session->setPayloadFormat(ost::DynamicPayloadFormat((ost::PayloadType) audiocodec->getPayload(), audiocodec->getClockRate()));
} else {*/
//payloadIsSet = _session->setPayloadFormat(ost::StaticPayloadFormat((ost::StaticPayloadType) audiocodec->getPayload()));
payloadIsSet = _session->setPayloadFormat(ost::StaticPayloadFormat((ost::StaticPayloadType) audiocodec));
//}
} else {
payloadIsSet = _session->setPayloadFormat(ost::StaticPayloadFormat((ost::StaticPayloadType) audiocodec->getPayload()));
}
}
}
unloadCodec(audiocodec);
} catch(...) {
_debugException("! ARTP Failure: initialisation failed");
throw;
......@@ -270,6 +267,9 @@ AudioRtpRTX::loadCodec(int payload)
case 8:
handle_codec = dlopen("codec_alaw.so", RTLD_LAZY);
break;
case 97:
handle_codec = dlopen("codec_ilbc.so", RTLD_LAZY);
break;
}
if(!handle_codec){
......@@ -527,12 +527,12 @@ AudioLayer *audiolayer = Manager::instance().getAudioDriver();
_layerFrameSize = audiolayer->getFrameSize(); // en ms
_layerSampleRate = audiolayer->getSampleRate();
initBuffers();
int step = (int)(_layerFrameSize * _codecSampleRate / 1000);
int step;
try {
// Init the session
initAudioRtpSession();
step = (int) (_layerFrameSize * _codecSampleRate / 1000);
// start running the packet queue scheduler.
//_debug("AudioRTP Thread started\n");
if (!_sym) {
......
No preview for this file type
No preview for this file type
......@@ -7,7 +7,6 @@ public:
Ulaw(int payload=0)
: AudioCodec(payload, "PCMU")
{
_description = "G711u";
_clockRate = 8000;
_channel = 1;
}
......@@ -89,7 +88,7 @@ public:
// the class factories
extern "C" AudioCodec* create() {
return new Ulaw();
return new Ulaw(0);
}
extern "C" void destroy(AudioCodec* a) {
......
......@@ -244,6 +244,9 @@ IAXVoIPLink::loadCodec(int payload)
case 8:
handle_codec = dlopen("codec_alaw.so", RTLD_LAZY);
break;
case 97:
handle_codec = dlopen("codec_ilbc.so", RTLD_LAZY);
break;
}
if(!handle_codec){
cerr<<"cannot load library: "<< dlerror() <<'\n';
......
......@@ -122,6 +122,7 @@ ManagerImpl::init()
initAudioDriver();
selectAudioDriver();
// Initialize the list of supported audio codecs
initAudioCodec();
AudioLayer *audiolayer = getAudioDriver();
......@@ -1086,7 +1087,7 @@ ManagerImpl::initConfigFile (void)
void
ManagerImpl::initAudioCodec (void)
{
_debugInit("Active Codecs");
_debugInit("Active Codecs List");
_codecDescriptorMap.init();
}
......@@ -1146,8 +1147,7 @@ ManagerImpl::clockRate(std::string& name)
}
/**
* Get the list of codecs.
* Contains all the codecs supported, with order set by the user.
* Send the list of codecs to the client through DBus.
*/
std::vector< std::string >
ManagerImpl::getCodecList( void )
......
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