Commit 50812e13 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Bug fix: protection on loading user codecs config

Before loading the codecs the user set, check if this codec is loaded.
In fact, it could have been erased and causes gtk bug
parent 5a25698b
......@@ -182,9 +182,7 @@ AudioRtpRTX::initAudioRtpSession (void)
try {
if (_ca == 0) { return; }
_debug("codec name = ");
_audiocodec = Manager::instance().getCodecDescriptorMap().getCodec( _ca->getAudioCodec() );
_debug("%s\n", _audiocodec->getCodecName().c_str());
_codecSampleRate = _audiocodec->getClockRate();
_debug("Init audio RTP session\n");
......
......@@ -121,23 +121,7 @@ class AudioRtpRTX : public ost::Thread, public ost::TimerPort {
*/
int downSampleData(int, int);
/** Pointer on function to handle codecs **/
//void* handle_codec;
AudioCodec* _audiocodec;
CodecDescriptor _codecDesc;
/**
* Load dynamically a codec (.so library)
* @param payload The payload of the codec you want to load
* @return AudioCodec* A pointer on a audio codec object
*/
//void loadCodec(int payload);
/**
* Destroy and close dynamically a codec (.so library)
* @param audiocodec The audio codec you want to unload
*/
//void unloadCodec(void);
};
///////////////////////////////////////////////////////////////////////////////
......
......@@ -182,8 +182,10 @@ CodecDescriptor::saveActiveCodecs(const std::vector<std::string>& list)
while( i < size )
{
payload = std::atoi(list[i].data());
_codecOrder.push_back((CodecType)payload);
_CodecsMap.find((CodecType)payload)->second->setState( true );
if( isCodecLoaded( payload ) ) {
_codecOrder.push_back((CodecType)payload);
_CodecsMap.find((CodecType)payload)->second->setState( true );
}
i++;
}
}
......@@ -300,3 +302,21 @@ CodecDescriptor::alreadyInCache( std::string lib )
}
return false;
}
bool
CodecDescriptor::isCodecLoaded( int payload )
{
int i;
CodecsMap::iterator iter = _CodecsMap.begin();
while( iter != _CodecsMap.end())
{
if( iter -> first == payload)
return true;
iter++;
}
return false;
}
......@@ -205,6 +205,7 @@ private:
bool seemsValid( std::string );
bool alreadyInCache( std::string );
bool isCodecLoaded( int payload );
/*
* Map the payload of a codec and its name
*/
......
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