protected void ApplyVoiceBotParms(VoiceParmSet parmSet, bool reconfigure) { foreach (VoiceParm parm in parmSet.GetParmsOfKindOrDefault(VoiceParmKind.VoiceBot, reconfigure)) { log.DebugFormat(voiceMgr, "VoiceManager.ApplyVoiceBotParms: setting voice bot parm {0} to {1}", parm.name, parm.value); switch ((VoiceBotParm)(parm.ctlIndex)) { case VoiceBotParm.MaxWaitTilNextPlayback: maxWaitTilNextPlayback = parm.ret.iValue; break; default: log.ErrorFormat(voiceMgr, "VoiceManager.ApplyVoiceBotParms: Unknown voice parm '{0}', index {1}", parm.name, parm.ctlIndex); break; } } }
protected void ApplyTransmissionParms(VoiceParmSet parmSet, bool reconfigure) { foreach (VoiceParm parm in parmSet.GetParmsOfKindOrDefault(VoiceParmKind.Transmission, reconfigure)) { log.DebugFormat(voiceMgr, "VoiceManager.ApplyTransmissionParms: setting voice bot parm {0} to {1}", parm.name, parm.value); switch ((TransmissionParm)(parm.ctlIndex)) { case TransmissionParm.MaxSavedFrames: maxSavedFrames = parm.ret.iValue; break; case TransmissionParm.UsePowerThreshold: usePowerThreshold = parm.ret.bValue; break; case TransmissionParm.FramePowerThreshold: framePowerThreshold = parm.ret.fValue; break; default: log.ErrorFormat(voiceMgr, "VoiceManager.ApplyTransmissionParms: Unknown voice parm '{0}', index {1}", parm.name, parm.ctlIndex); break; } } }
protected void ApplyPreprocessorSettings(VoiceParmSet parmSet, bool reconfigure) { List<VoiceParm> parms = parmSet.GetParmsOfKindOrDefault(VoiceParmKind.Preprocessor, reconfigure); log.DebugFormat(voiceMgr, "BasicChannel.ApplyPreprocessorSettings: There are {0} settings", parms != null ? parms.Count : 0); if (parms != null) { foreach (VoiceParm parm in parms) { log.DebugFormat(voiceMgr, "BasicChannel.ApplyPreprocessorSettings: setting {0} to {1}", parm.name, parm.value); // DENOISE, MICLEVEL, FRAME_POWER_THRESHOLD // and SET_VAD require special treatment if (parm.ctlIndex == (int)PreprocessCtlCode.SPEEX_PREPROCESS_SET_DENOISE) CheckRetCode(parm, channelCodec.SetOnePreprocessorSetting((PreprocessCtlCode)parm.ctlIndex, (parm.ret.bValue ? 1 : 2))); else if (parm.ctlIndex == (int)PreprocessCtlCode.SPEEX_PREPROCESS_SET_AGC_LEVEL) SetMicLevel(parm.ret.iValue); else if (parm.ctlIndex == (int)PreprocessCtlCode.SPEEX_PREPROCESS_SET_VAD && usePowerThreshold) // Turn off VAD if we're using the power // threshold instead of preprocess VAD CheckRetCode(parm, channelCodec.SetOnePreprocessorSetting(PreprocessCtlCode.SPEEX_PREPROCESS_SET_VAD, 0)); else { switch (parm.valueKind) { case ValueKind.Int: CheckRetCode(parm, channelCodec.SetOnePreprocessorSetting((PreprocessCtlCode)parm.ctlIndex, parm.ret.iValue)); break; case ValueKind.Float: CheckRetCode(parm, channelCodec.SetOnePreprocessorSetting((PreprocessCtlCode)parm.ctlIndex, parm.ret.fValue)); break; case ValueKind.Bool: CheckRetCode(parm, channelCodec.SetOnePreprocessorSetting((PreprocessCtlCode)parm.ctlIndex, parm.ret.bValue)); break; default: log.Error(voiceMgr, "BasicChannel.ApplyPreprocessorSettings: Unknown parm.valueKind " + parm.valueKind); break; } } } } }
protected void ApplyJitterBufferSettings(VoiceParmSet parmSet, bool reconfigure) { List<VoiceParm> parms = parmSet.GetParmsOfKindOrDefault(VoiceParmKind.JitterBuffer, reconfigure); if (parms != null) { foreach (VoiceParm parm in parms) { log.DebugFormat(voiceMgr, "BasicChannel.ApplyJitterBufferSettings: setting {0} to {1}", parm.name, parm.value); CheckRetCode(parm, channelCodec.SetOneJitterBufferSetting((JitterBufferCtlCode)parm.ctlIndex, parm.ret.iValue)); } } }
protected void ApplyEncodecSettings(VoiceParmSet parmSet, bool reconfigure) { List<VoiceParm> parms = parmSet.GetParmsOfKindOrDefault(VoiceParmKind.Encodec, reconfigure); log.DebugFormat(voiceMgr, "BasicChannel.ApplyEncodecSettings: There are {0} settings", parms != null ? parms.Count : 0); if (parms != null) { foreach (VoiceParm parm in parms) { log.DebugFormat(voiceMgr, "BasicChannel.ApplyEncodecSettings: setting {0} to {1}", parm.name, parm.value); if (parm.valueKind == ValueKind.Float) { if (parm.ctlIndex == 0) voiceMgr.silentFrameCountDeallocationThreshold = (int)(framesPerSecond * parm.ret.fValue); else log.ErrorFormat(voiceMgr, "BasicChannel.ApplyEncodecSettings: unknown float parm, ctlIndex {0}", parm.ctlIndex); } // All the rest int parms, and none of them require special treatment else if (parm.valueKind != ValueKind.Int) log.ErrorFormat(voiceMgr, "BasicChannel.ApplyEncodecSettings: codec parm '{0}' is not int-valued; instead value type is '{1}'!", parm.name, parm.valueKind); else { SpeexCtlCode code = (SpeexCtlCode)parm.ctlIndex; if (code == SpeexCtlCode.SPEEX_SET_QUALITY) { int mode = 0; channelCodec.GetOneCodecSetting(true, SpeexCtlCode.SPEEX_GET_MODE, ref mode); log.DebugFormat(voiceMgr, "BasicChannel.ApplyEncodecSettings: Before setting quality to {0}, mode is {1}", parm.ret.iValue, mode); } CheckRetCode(parm, channelCodec.SetOneCodecSetting(true, code, parm.ret.iValue)); if (code == SpeexCtlCode.SPEEX_SET_QUALITY) { int mode = 0; channelCodec.GetOneCodecSetting(true, SpeexCtlCode.SPEEX_GET_MODE, ref mode); log.DebugFormat(voiceMgr, "BasicChannel.ApplyEncodecSettings: After setting quality to {0}, mode is {1}", parm.ret.iValue, mode); } } } } }
protected void ApplyDecodecSettings(VoiceParmSet parmSet, bool reconfigure) { List<VoiceParm> parms = parmSet.GetParmsOfKindOrDefault(VoiceParmKind.Decodec, reconfigure); log.DebugFormat(voiceMgr, "BasicChannel.ApplyDecodecSettings: There are {0} settings", parms != null ? parms.Count : 0); if (parms != null) { foreach (VoiceParm parm in parms) { log.DebugFormat(voiceMgr, "BasicChannel.ApplyDecodecSettings: setting {0} to {1}", parm.name, parm.value); // They are all int parms, and none of them require special treatment if (parm.valueKind != ValueKind.Int) log.ErrorFormat(voiceMgr, "BasicChannel.ApplyDecodecSettings: codec parm '{0}' is not int-valued; instead value type is '{1}'!", parm.name, parm.valueKind); else CheckRetCode(parm, channelCodec.SetOneCodecSetting(false, (SpeexCtlCode)parm.ctlIndex, parm.ret.iValue)); } } }