Bug 1291714 - bool to enable dtmf tones in AudioConduit and setup dtmf payload type. r=bwc

MozReview-Commit-ID: IMneZx9wlhj

--HG--
extra : rebase_source : 0e65711f7a36f75c8956efb0860fd63f7890a279
This commit is contained in:
Michael Froman 2016-09-28 21:22:44 -05:00
parent 3888f9a621
commit d35956ee16
4 changed files with 34 additions and 0 deletions

View File

@ -26,6 +26,7 @@
#include "webrtc/common.h"
#include "webrtc/modules/audio_processing/include/audio_processing.h"
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h"
#include "webrtc/voice_engine/include/voe_dtmf.h"
#include "webrtc/voice_engine/include/voe_errors.h"
#include "webrtc/system_wrappers/interface/clock.h"
@ -220,6 +221,24 @@ bool WebrtcAudioConduit::GetRTCPSenderReport(DOMHighResTimeStamp* timestamp,
return result;
}
bool WebrtcAudioConduit::SetDtmfPayloadType(unsigned char type) {
CSFLogInfo(logTag, "%s : setting dtmf payload %d", __FUNCTION__, (int)type);
ScopedCustomReleasePtr<webrtc::VoEDtmf> mPtrVoEDtmf;
mPtrVoEDtmf = webrtc::VoEDtmf::GetInterface(mVoiceEngine);
if (!mPtrVoEDtmf) {
CSFLogError(logTag, "%s Unable to initialize VoEDtmf", __FUNCTION__);
return false;
}
int result = mPtrVoEDtmf->SetSendTelephoneEventPayloadType(mChannel, type);
if (result == -1) {
CSFLogError(logTag, "%s Failed call to SetSendTelephoneEventPayloadType",
__FUNCTION__);
}
return result != -1;
}
/*
* WebRTCAudioConduit Implementation
*/
@ -403,6 +422,8 @@ WebrtcAudioConduit::ConfigureSendMediaCodec(const AudioCodecConfig* codecConfig)
return kMediaConduitFECStatusError;
}
mDtmfEnabled = codecConfig->mDtmfEnabled;
if (codecConfig->mName == "opus" && codecConfig->mMaxPlaybackRate) {
if (mPtrVoECodec->SetOpusMaxPlaybackRate(
mChannel,

View File

@ -169,6 +169,7 @@ public:
mEngineTransmitting(false),
mEngineReceiving(false),
mChannel(-1),
mDtmfEnabled(false),
mCodecMutex("AudioConduit codec db"),
mCaptureDelay(150),
#if !defined(MOZILLA_EXTERNAL_LINKAGE)
@ -219,6 +220,8 @@ public:
unsigned int* packetsSent,
uint64_t* bytesSent) override;
bool SetDtmfPayloadType(unsigned char type) override;
private:
WebrtcAudioConduit(const WebrtcAudioConduit& other) = delete;
void operator=(const WebrtcAudioConduit& other) = delete;
@ -276,6 +279,7 @@ private:
AutoTArray<Processing,8> mProcessing;
int mChannel;
bool mDtmfEnabled;
RecvCodecList mRecvCodecList;
Mutex mCodecMutex; // protects mCurSendCodecConfig

View File

@ -485,6 +485,8 @@ public:
*/
virtual MediaConduitErrorCode EnableAudioLevelExtension(bool enabled, uint8_t id) = 0;
virtual bool SetDtmfPayloadType(unsigned char type) = 0;
};
}
#endif

View File

@ -747,6 +747,13 @@ MediaPipelineFactory::GetOrCreateAudioConduit(
conduit->SetLocalCNAME(aTrack.GetCNAME().c_str());
if (configs.values.size() > 1
&& configs.values.back()->mName == "telephone-event") {
// we have a telephone event codec, so we need to make sure
// the dynamic pt is set properly
conduit->SetDtmfPayloadType(configs.values.back()->mType);
}
auto error = conduit->ConfigureSendMediaCodec(configs.values[0]);
if (error) {
MOZ_MTLOG(ML_ERROR, "ConfigureSendMediaCodec failed: " << error);