- fix opus codec usage
This commit is contained in:
@@ -402,6 +402,7 @@ PCodec OpusCodec::OpusFactory::create()
|
||||
result->applyParams(mParams);
|
||||
PCodec c(result);
|
||||
mCodecList.push_back(c);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
@@ -110,6 +110,7 @@ void AudioStream::setDestination(const RtpPair<InternetAddress>& dest)
|
||||
void AudioStream::setTransmittingCodec(Codec::Factory& factory, int payloadType)
|
||||
{
|
||||
ICELogInfo(<< "Selected codec " << factory.name() << "/" << factory.samplerate() << " for transmitting");
|
||||
|
||||
Lock l(mMutex);
|
||||
mTransmittingCodec = factory.create();
|
||||
mTransmittingPayloadType = payloadType;
|
||||
@@ -145,8 +146,10 @@ void AudioStream::addData(const void* buffer, int bytes)
|
||||
{
|
||||
Lock l(mMutex);
|
||||
codec = mTransmittingCodec.get();
|
||||
if (!codec)
|
||||
if (nullptr == codec) {
|
||||
ICELogDebug(<< "No transmitting codec selected.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Resample
|
||||
@@ -202,7 +205,7 @@ void AudioStream::addData(const void* buffer, int bytes)
|
||||
int packetTime = mPacketTime ? mPacketTime : codec->frameTime();
|
||||
|
||||
// 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)
|
||||
mSendingDump->write((const char*)mCapturedAudio.data() + codec->pcmLength() * i, codec->pcmLength());
|
||||
@@ -230,7 +233,8 @@ void AudioStream::addData(const void* buffer, int bytes)
|
||||
}
|
||||
}
|
||||
}
|
||||
mCapturedAudio.erase(processed);
|
||||
if (processed > 0)
|
||||
mCapturedAudio.erase(processed);
|
||||
}
|
||||
|
||||
void AudioStream::copyDataTo(Audio::Mixer& mixer, int needed)
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace MT
|
||||
Audio::DataWindow mStereoCapturedAudio;
|
||||
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 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
|
||||
int mTransmittingPayloadType; // Payload type to mark outgoing packets
|
||||
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 IlbcCodec::IlbcFactory(mSettings.mIlbc20PayloadType, mSettings.mIlbc30PayloadType));
|
||||
mFactoryList.push_back(new G711Codec::AlawFactory());
|
||||
mFactoryList.push_back(new G711Codec::UlawFactory());
|
||||
// mFactoryList.push_back(new G711Codec::AlawFactory());
|
||||
// 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 G722Codec::G722Factory());
|
||||
mFactoryList.push_back(new G729Codec::G729Factory());
|
||||
// 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 G729Codec::G729Factory());
|
||||
#ifndef TARGET_ANDROID
|
||||
mFactoryList.push_back(new GsmHrCodec::GsmHrFactory(mSettings.mGsmHrPayloadType));
|
||||
#endif
|
||||
@@ -231,7 +231,7 @@ void CodecListPriority::setupFrom(PVariantMap vmap)
|
||||
{
|
||||
Item item;
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace MT
|
||||
|
||||
virtual void setDestination(const RtpPair<InternetAddress>& dest);
|
||||
|
||||
virtual void setTransmittingCodec(Codec::Factory& factory, int payloadType) = 0;
|
||||
virtual void setTransmittingCodec(Codec::Factory& factory, int payloadType) = 0;
|
||||
virtual void dataArrived(PDatagramSocket s, const void* buffer, int length, InternetAddress& source) = 0;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user