- fix opus codec usage
This commit is contained in:
parent
61be61b7e3
commit
9479a0f36f
|
|
@ -208,10 +208,13 @@ void AgentImpl::processStart(JsonCpp::Value& /*request*/, JsonCpp::Value &answer
|
||||||
PVariantMap priorityConfig = std::make_shared<VariantMap>();
|
PVariantMap priorityConfig = std::make_shared<VariantMap>();
|
||||||
MT::CodecList& cl = mTerminal->codeclist();
|
MT::CodecList& cl = mTerminal->codeclist();
|
||||||
for (int i=0; i<cl.count(); i++)
|
for (int i=0; i<cl.count(); i++)
|
||||||
if (cl.codecAt(i).payloadType() < 96)
|
priorityConfig->at(i) = i;
|
||||||
|
|
||||||
|
// Disable dynamic payload codec types - commented for now
|
||||||
|
/*if (cl.codecAt(i).payloadType() < 96)
|
||||||
priorityConfig->at(i) = i;
|
priorityConfig->at(i) = i;
|
||||||
else
|
else
|
||||||
priorityConfig->at(i) = -1;
|
priorityConfig->at(i) = -1;*/
|
||||||
|
|
||||||
config()[CONFIG_CODEC_PRIORITY] = priorityConfig;
|
config()[CONFIG_CODEC_PRIORITY] = priorityConfig;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ int ChannelConverter::stereoToMono(const void *source, int sourceLength, void *d
|
||||||
|
|
||||||
int ChannelConverter::monoToStereo(const void *source, int sourceLength, void *dest, int destLength)
|
int ChannelConverter::monoToStereo(const void *source, int sourceLength, void *dest, int destLength)
|
||||||
{
|
{
|
||||||
assert(destLength == sourceLength * 2);
|
assert (destLength == sourceLength * 2);
|
||||||
const short* input = (const short*)source;
|
const short* input = (const short*)source;
|
||||||
short* output = (short*)dest;
|
short* output = (short*)dest;
|
||||||
// Convert starting from the end of buffer to allow inplace conversion
|
// Convert starting from the end of buffer to allow inplace conversion
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@
|
||||||
|
|
||||||
// OPUS codec defines
|
// OPUS codec defines
|
||||||
// #define USE_OPUS_CODEC
|
// #define USE_OPUS_CODEC
|
||||||
#define MT_OPUS_CODEC_PT -1
|
#define MT_OPUS_CODEC_PT 106
|
||||||
|
|
||||||
// ILBC codec defines
|
// ILBC codec defines
|
||||||
#define MT_ILBC20_PAYLOADTYPE -1
|
#define MT_ILBC20_PAYLOADTYPE -1
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ AudioProvider::AudioProvider(UserAgent& agent, MT::Terminal& terminal)
|
||||||
if (mUserAgent.config().exists(CONFIG_CODEC_PRIORITY))
|
if (mUserAgent.config().exists(CONFIG_CODEC_PRIORITY))
|
||||||
mCodecPriority.setupFrom(mUserAgent.config()[CONFIG_CODEC_PRIORITY].asVMap());
|
mCodecPriority.setupFrom(mUserAgent.config()[CONFIG_CODEC_PRIORITY].asVMap());
|
||||||
mSrtpSuite = SRTP_NONE;
|
mSrtpSuite = SRTP_NONE;
|
||||||
setState((int)StreamState::SipRecv | (int)StreamState::SipSend | (int)StreamState::Receiving | (int)StreamState::Sending);
|
setStateImpl((int)StreamState::SipRecv | (int)StreamState::SipSend | (int)StreamState::Receiving | (int)StreamState::Sending);
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioProvider::~AudioProvider()
|
AudioProvider::~AudioProvider()
|
||||||
|
|
@ -182,6 +182,7 @@ void AudioProvider::sessionEstablished(int conntype)
|
||||||
{
|
{
|
||||||
RemoteCodec& rc = mAvailableCodecs.front();
|
RemoteCodec& rc = mAvailableCodecs.front();
|
||||||
mActiveStream->setTransmittingCodec(*rc.mFactory, rc.mRemotePayloadType);
|
mActiveStream->setTransmittingCodec(*rc.mFactory, rc.mRemotePayloadType);
|
||||||
|
auto codec = dynamic_cast<MT::AudioStream*>(mActiveStream.get())->transmittingCodec();
|
||||||
dynamic_cast<MT::AudioStream*>(mActiveStream.get())->setTelephoneCodec(mRemoteTelephoneCodec);
|
dynamic_cast<MT::AudioStream*>(mActiveStream.get())->setTelephoneCodec(mRemoteTelephoneCodec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -271,11 +272,10 @@ bool AudioProvider::processSdpOffer(const resip::SdpContents::Session::Medium& m
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AudioProvider::setState(unsigned state)
|
void AudioProvider::setState(unsigned state)
|
||||||
{
|
{
|
||||||
mState = state;
|
setStateImpl(state);
|
||||||
if (mActiveStream)
|
|
||||||
mActiveStream->setState(state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned AudioProvider::state()
|
unsigned AudioProvider::state()
|
||||||
|
|
@ -381,3 +381,10 @@ void AudioProvider::setupMirror(bool enable)
|
||||||
if (mActiveStream)
|
if (mActiveStream)
|
||||||
mActiveStream->setupMirror(enable);
|
mActiveStream->setupMirror(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudioProvider::setStateImpl(unsigned int state) {
|
||||||
|
mState = state;
|
||||||
|
if (mActiveStream)
|
||||||
|
mActiveStream->setState(state);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -65,7 +65,8 @@ public:
|
||||||
// myAnswer sets if the answer will be sent after.
|
// myAnswer sets if the answer will be sent after.
|
||||||
bool processSdpOffer(const resip::SdpContents::Session::Medium& media, SdpDirection sdpDirection);
|
bool processSdpOffer(const resip::SdpContents::Session::Medium& media, SdpDirection sdpDirection);
|
||||||
|
|
||||||
void setState(unsigned state);
|
|
||||||
|
void setState(unsigned state) override;
|
||||||
unsigned state();
|
unsigned state();
|
||||||
MT::Statistics getStatistics();
|
MT::Statistics getStatistics();
|
||||||
MT::PStream activeStream();
|
MT::PStream activeStream();
|
||||||
|
|
@ -112,6 +113,10 @@ protected:
|
||||||
std::string createCryptoAttribute(SrtpSuite suite);
|
std::string createCryptoAttribute(SrtpSuite suite);
|
||||||
SrtpSuite processCryptoAttribute(const resip::Data& value, ByteBuffer& key);
|
SrtpSuite processCryptoAttribute(const resip::Data& value, ByteBuffer& key);
|
||||||
void findRfc2833(const resip::SdpContents::Session::Medium::CodecContainer& codecs);
|
void findRfc2833(const resip::SdpContents::Session::Medium::CodecContainer& codecs);
|
||||||
|
|
||||||
|
// Implements setState() logic. This allows to be called from constructor (it is not virtual function)
|
||||||
|
void setStateImpl(unsigned state);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -726,7 +726,7 @@ void Session::buildSdp(resip::SdpContents &sdp, SdpDirection sdpDirection)
|
||||||
if (mUserAgent->mConfig[CONFIG_MULTIPLEXING].asBool())
|
if (mUserAgent->mConfig[CONFIG_MULTIPLEXING].asBool())
|
||||||
media.addAttribute("rtcp-mux");
|
media.addAttribute("rtcp-mux");
|
||||||
|
|
||||||
// Ask provider about specific information
|
// Ask provider about specific information - codecs are filled here
|
||||||
provider.updateSdpOffer(media, sdpDirection);
|
provider.updateSdpOffer(media, sdpDirection);
|
||||||
|
|
||||||
// Add ICE information
|
// Add ICE information
|
||||||
|
|
|
||||||
|
|
@ -402,6 +402,7 @@ PCodec OpusCodec::OpusFactory::create()
|
||||||
result->applyParams(mParams);
|
result->applyParams(mParams);
|
||||||
PCodec c(result);
|
PCodec c(result);
|
||||||
mCodecList.push_back(c);
|
mCodecList.push_back(c);
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,7 @@ void AudioStream::setDestination(const RtpPair<InternetAddress>& dest)
|
||||||
void AudioStream::setTransmittingCodec(Codec::Factory& factory, int payloadType)
|
void AudioStream::setTransmittingCodec(Codec::Factory& factory, int payloadType)
|
||||||
{
|
{
|
||||||
ICELogInfo(<< "Selected codec " << factory.name() << "/" << factory.samplerate() << " for transmitting");
|
ICELogInfo(<< "Selected codec " << factory.name() << "/" << factory.samplerate() << " for transmitting");
|
||||||
|
|
||||||
Lock l(mMutex);
|
Lock l(mMutex);
|
||||||
mTransmittingCodec = factory.create();
|
mTransmittingCodec = factory.create();
|
||||||
mTransmittingPayloadType = payloadType;
|
mTransmittingPayloadType = payloadType;
|
||||||
|
|
@ -145,9 +146,11 @@ void AudioStream::addData(const void* buffer, int bytes)
|
||||||
{
|
{
|
||||||
Lock l(mMutex);
|
Lock l(mMutex);
|
||||||
codec = mTransmittingCodec.get();
|
codec = mTransmittingCodec.get();
|
||||||
if (!codec)
|
if (nullptr == codec) {
|
||||||
|
ICELogDebug(<< "No transmitting codec selected.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Resample
|
// Resample
|
||||||
unsigned dstlen = unsigned(float(codec->samplerate() / float(AUDIO_SAMPLERATE)) * bytes);
|
unsigned dstlen = unsigned(float(codec->samplerate() / float(AUDIO_SAMPLERATE)) * bytes);
|
||||||
|
|
@ -202,7 +205,7 @@ void AudioStream::addData(const void* buffer, int bytes)
|
||||||
int packetTime = mPacketTime ? mPacketTime : codec->frameTime();
|
int packetTime = mPacketTime ? mPacketTime : codec->frameTime();
|
||||||
|
|
||||||
// Make stereo version if required
|
// Make stereo version if required
|
||||||
for (int i=0; i<mCapturedAudio.filled() / mTransmittingCodec->pcmLength(); i++)
|
for (int i=0; i<mCapturedAudio.filled() / codec->pcmLength(); i++)
|
||||||
{
|
{
|
||||||
if (mSendingDump)
|
if (mSendingDump)
|
||||||
mSendingDump->write((const char*)mCapturedAudio.data() + codec->pcmLength() * i, codec->pcmLength());
|
mSendingDump->write((const char*)mCapturedAudio.data() + codec->pcmLength() * i, codec->pcmLength());
|
||||||
|
|
@ -230,6 +233,7 @@ void AudioStream::addData(const void* buffer, int bytes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (processed > 0)
|
||||||
mCapturedAudio.erase(processed);
|
mCapturedAudio.erase(processed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ namespace MT
|
||||||
Audio::DataWindow mStereoCapturedAudio;
|
Audio::DataWindow mStereoCapturedAudio;
|
||||||
char mIncomingPcmBuffer[AUDIO_MIC_BUFFER_SIZE]; // Temporary buffer to allow reading from file
|
char mIncomingPcmBuffer[AUDIO_MIC_BUFFER_SIZE]; // Temporary buffer to allow reading from file
|
||||||
char mResampleBuffer[AUDIO_MIC_BUFFER_SIZE*8]; // Temporary buffer to hold data
|
char mResampleBuffer[AUDIO_MIC_BUFFER_SIZE*8]; // Temporary buffer to hold data
|
||||||
char mStereoBuffer[AUDIO_MIC_BUFFER_SIZE*8]; // Temporary buffer to hold data converted to stereo
|
char mStereoBuffer[AUDIO_MIC_BUFFER_SIZE*16]; // Temporary buffer to hold data converted to stereo
|
||||||
PCodec mTransmittingCodec; // Current encoding codec
|
PCodec mTransmittingCodec; // Current encoding codec
|
||||||
int mTransmittingPayloadType; // Payload type to mark outgoing packets
|
int mTransmittingPayloadType; // Payload type to mark outgoing packets
|
||||||
int mPacketTime; // Required packet time
|
int mPacketTime; // Required packet time
|
||||||
|
|
|
||||||
|
|
@ -128,12 +128,12 @@ CodecList::CodecList(const Settings& settings)
|
||||||
|
|
||||||
//mFactoryList.push_back(new IsacCodec::IsacFactory16K(mSettings.mIsac16KPayloadType));
|
//mFactoryList.push_back(new IsacCodec::IsacFactory16K(mSettings.mIsac16KPayloadType));
|
||||||
//mFactoryList.push_back(new IlbcCodec::IlbcFactory(mSettings.mIlbc20PayloadType, mSettings.mIlbc30PayloadType));
|
//mFactoryList.push_back(new IlbcCodec::IlbcFactory(mSettings.mIlbc20PayloadType, mSettings.mIlbc30PayloadType));
|
||||||
mFactoryList.push_back(new G711Codec::AlawFactory());
|
// mFactoryList.push_back(new G711Codec::AlawFactory());
|
||||||
mFactoryList.push_back(new G711Codec::UlawFactory());
|
// mFactoryList.push_back(new G711Codec::UlawFactory());
|
||||||
|
|
||||||
mFactoryList.push_back(new GsmCodec::GsmFactory(mSettings.mGsmFrPayloadLength == 32 ? GsmCodec::Type::Bytes_32 : GsmCodec::Type::Bytes_33, mSettings.mGsmFrPayloadType));
|
// mFactoryList.push_back(new GsmCodec::GsmFactory(mSettings.mGsmFrPayloadLength == 32 ? GsmCodec::Type::Bytes_32 : GsmCodec::Type::Bytes_33, mSettings.mGsmFrPayloadType));
|
||||||
mFactoryList.push_back(new G722Codec::G722Factory());
|
// mFactoryList.push_back(new G722Codec::G722Factory());
|
||||||
mFactoryList.push_back(new G729Codec::G729Factory());
|
// mFactoryList.push_back(new G729Codec::G729Factory());
|
||||||
#ifndef TARGET_ANDROID
|
#ifndef TARGET_ANDROID
|
||||||
mFactoryList.push_back(new GsmHrCodec::GsmHrFactory(mSettings.mGsmHrPayloadType));
|
mFactoryList.push_back(new GsmHrCodec::GsmHrFactory(mSettings.mGsmHrPayloadType));
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -231,7 +231,7 @@ void CodecListPriority::setupFrom(PVariantMap vmap)
|
||||||
{
|
{
|
||||||
Item item;
|
Item item;
|
||||||
item.mCodecIndex = i;
|
item.mCodecIndex = i;
|
||||||
item.mPriority = vmap->exists(i) ? vmap->at(i).asInt() : -1;
|
item.mPriority = vmap->exists(i) ? vmap->at(i).asInt() : 1000; // Non listed codecs will get lower priority
|
||||||
mPriorityList.push_back(item);
|
mPriorityList.push_back(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue