Checking whether ACM uses codec internal or WebRTC DTX.

It was not clear how one could know if ACM is using DTX from WebRTC or codec internal DTX.

This CL makes better use of IsInternalDTXReplacedWithWebRtc() which was designed for G.729 to export such information.

Before
IsInternalDTXReplacedWithWebRtc() gives true only if codec == G729 and G729's internal DTX is replaced with WebRTC DTX.

Now
IsInternalDTXReplacedWithWebRtc() gives true also when codec does not have internal DTX, i.e., must use WebRTC DTX, which is much more logical.

BUG=
R=henrik.lundin@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/35459004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@7870 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
minyue@webrtc.org 2014-12-11 08:53:21 +00:00
parent 55d42c32a4
commit abe3f1879c
3 changed files with 29 additions and 48 deletions

View File

@ -815,7 +815,7 @@ int32_t ACMGenericCodec::IsInternalDTXReplaced(bool* internal_dtx_replaced) {
int32_t ACMGenericCodec::IsInternalDTXReplacedSafe( int32_t ACMGenericCodec::IsInternalDTXReplacedSafe(
bool* internal_dtx_replaced) { bool* internal_dtx_replaced) {
*internal_dtx_replaced = false; *internal_dtx_replaced = true;
return 0; return 0;
} }

View File

@ -507,8 +507,7 @@ class AudioCodingModule: public Module {
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// int32_t ReplaceInternalDTXWithWebRtc() // int32_t ReplaceInternalDTXWithWebRtc()
// Used to replace codec internal DTX scheme with WebRtc. This is only // Used to replace codec internal DTX scheme with WebRtc.
// supported for G729, where this call replaces AnnexB with WebRtc DTX.
// //
// Input: // Input:
// -use_webrtc_dtx : if false (default) the codec built-in DTX/VAD // -use_webrtc_dtx : if false (default) the codec built-in DTX/VAD
@ -524,8 +523,8 @@ class AudioCodingModule: public Module {
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// int32_t IsInternalDTXReplacedWithWebRtc() // int32_t IsInternalDTXReplacedWithWebRtc()
// Get status if the codec internal DTX (when such exists) is replaced with // Get status if the codec internal DTX is replaced with WebRtc DTX.
// WebRtc DTX. This is only supported for G729. // This should always be true if codec does not have an internal DTX.
// //
// Output: // Output:
// -uses_webrtc_dtx : is set to true if the codec internal DTX is // -uses_webrtc_dtx : is set to true if the codec internal DTX is

View File

@ -272,50 +272,36 @@ int16_t TestVADDTX::VerifyTest() {
uint8_t emptyFramePattern[6]; uint8_t emptyFramePattern[6];
CodecInst myCodecParam; CodecInst myCodecParam;
_acmA->SendCodec(&myCodecParam); _acmA->SendCodec(&myCodecParam);
bool dtxInUse = true;
bool isReplaced = false; // TODO(minyue): Remove these treatment on Opus when DTX is properly handled
if ((STR_CASE_CMP(myCodecParam.plname, "G729") == 0) // by ACMOpus.
|| (STR_CASE_CMP(myCodecParam.plname, "G723") == 0) if (STR_CASE_CMP(myCodecParam.plname, "opus") == 0) {
|| (STR_CASE_CMP(myCodecParam.plname, "AMR") == 0)
|| (STR_CASE_CMP(myCodecParam.plname, "AMR-wb") == 0)
|| (STR_CASE_CMP(myCodecParam.plname, "speex") == 0)) {
_acmA->IsInternalDTXReplacedWithWebRtc(&isReplaced);
if (!isReplaced) {
dtxInUse = false;
}
} else if (STR_CASE_CMP(myCodecParam.plname, "opus") == 0) {
if (_getStruct.statusDTX != false) {
// DTX status doesn't match expected.
vadPattern |= 4;
} else if (_getStruct.statusVAD != false) {
// Mismatch in VAD setting.
vadPattern |= 2;
} else {
_setStruct.statusDTX = false; _setStruct.statusDTX = false;
_setStruct.statusVAD = false; _setStruct.statusVAD = false;
} }
}
bool isReplaced = false;
_acmA->IsInternalDTXReplacedWithWebRtc(&isReplaced);
bool webRtcDtxInUse = _getStruct.statusDTX && isReplaced;
bool codecDtxInUse = _getStruct.statusDTX && !isReplaced;
// Check for error in VAD/DTX settings // Check for error in VAD/DTX settings
if (_getStruct.statusDTX != _setStruct.statusDTX) { if (_getStruct.statusDTX != _setStruct.statusDTX) {
// DTX status doesn't match expected // DTX status doesn't match expected.
vadPattern |= 1;
}
if (!_getStruct.statusVAD && webRtcDtxInUse) {
// WebRTC DTX cannot run without WebRTC VAD.
vadPattern |= 2;
}
if ((!_getStruct.statusDTX || codecDtxInUse) &&
(_getStruct.statusVAD != _setStruct.statusVAD)) {
// Using no DTX or codec Internal DTX should not affect setting of VAD.
vadPattern |= 4; vadPattern |= 4;
} }
if (_getStruct.statusDTX) {
if ((!_getStruct.statusVAD && dtxInUse)
|| (!dtxInUse && (_getStruct.statusVAD != _setStruct.statusVAD))) {
// Missmatch in VAD setting
vadPattern |= 2;
}
} else {
if (_getStruct.statusVAD != _setStruct.statusVAD) {
// VAD status doesn't match expected
vadPattern |= 2;
}
}
if (_getStruct.vadMode != _setStruct.vadMode) { if (_getStruct.vadMode != _setStruct.vadMode) {
// VAD Mode doesn't match expected // VAD Mode doesn't match expected.
vadPattern |= 1; vadPattern |= 8;
} }
// Set expected empty frame pattern // Set expected empty frame pattern
@ -332,14 +318,10 @@ int16_t TestVADDTX::VerifyTest() {
// 5 - "kPassiveDTXSWB". // 5 - "kPassiveDTXSWB".
emptyFramePattern[0] = 1; emptyFramePattern[0] = 1;
emptyFramePattern[1] = 1; emptyFramePattern[1] = 1;
emptyFramePattern[2] = (((!_getStruct.statusDTX && _getStruct.statusVAD) emptyFramePattern[2] = _getStruct.statusVAD && !webRtcDtxInUse;
|| (!dtxInUse && _getStruct.statusDTX))); emptyFramePattern[3] = webRtcDtxInUse && (_acmA->SendFrequency() == 8000);
emptyFramePattern[3] = ((_getStruct.statusDTX && dtxInUse emptyFramePattern[4] = webRtcDtxInUse && (_acmA->SendFrequency() == 16000);
&& (_acmA->SendFrequency() == 8000))); emptyFramePattern[5] = webRtcDtxInUse && (_acmA->SendFrequency() == 32000);
emptyFramePattern[4] = ((_getStruct.statusDTX && dtxInUse
&& (_acmA->SendFrequency() == 16000)));
emptyFramePattern[5] = ((_getStruct.statusDTX && dtxInUse
&& (_acmA->SendFrequency() == 32000)));
// Check pattern 1-5 (skip 0) // Check pattern 1-5 (skip 0)
for (int ii = 1; ii < 6; ii++) { for (int ii = 1; ii < 6; ii++) {