/// <summary> /// Raise the event that something non human was found on the line. /// </summary> /// <param name="toneDetected"></param> private void RaiseNonHumanDetected(ToneDetected toneDetected) { if (this.NonHumanDetected != null) { NonHumanDetected(this, toneDetected); } }
void DetectformDataChunk(byte[] chunk, int realLen) { int iterations = realLen / (DTMFConstanst.N); for (int i = 0; i < iterations; i++) { int x = decode(chunk.Skip(i * DTMFConstanst.N).Take(DTMFConstanst.N).ToArray()); bool newTone = false; if (x >= 0) { if (CurrentTone == x) { TC++; if (TC >= DTMFConstanst.FLUSH_TIME && x != DTMFConstanst.DSIL) { if (ToneDetected != null) { ToneDetected.BeginInvoke(this, new DTMFDetectedArgs(CurrentTone, (double)(TC * DTMFConstanst.N) / DTMFConstanst.FSAMPLE), null, null); } TC = 0; newTone = true; } else { if (x == DTMFConstanst.DSIL && DetectSilence && TC >= DTMFConstanst.FLUSH_TIME) { if (ToneDetected != null) { ToneDetected.BeginInvoke(this, new DTMFDetectedArgs(CurrentTone, (double)(TC * DTMFConstanst.N) / DTMFConstanst.FSAMPLE), null, null); } TC = 0; newTone = true; } } } else { TC++; if (ToneDetected != null) { newTone = true; if (ToneDetected != null) { ToneDetected.BeginInvoke(this, new DTMFDetectedArgs(CurrentTone, (double)(TC * DTMFConstanst.N) / DTMFConstanst.FSAMPLE), null, null); } } TC = 0; CurrentTone = x; } if (IsTokenBuildEnabled && newTone) { parser.Digest(x); } } } }
private void OnNonHumanDetected(object sender, ToneDetected tone) { RTCAudioWithToneDetect rtcAudioWithSip; if (sender is RTCAudioWithToneDetect) { rtcAudioWithSip = (RTCAudioWithToneDetect)sender; // if the delegate is hooked, raise the event. if (this.NonHumanDetected != null) { NonHumanDetected(this, rtcAudioWithSip.ChannelId, tone.ToString()); } } else { throw new ArgumentException("Object is not a RTCAudioWithSIP."); } }
void DetectformDataChunk(byte[] chunk, int realLen) { int iterations = realLen / DTMFConstanst.N; for (int i = 0; i < iterations; i++) { int x = decode(chunk.Skip(i * DTMFConstanst.N).Take(DTMFConstanst.N).ToArray()); if (x >= 0) { if (CurrentTone == x) { TC++; if (TC >= DTMFConstanst.FLUSH_TIME && x != DTMFConstanst.DSIL) { ToneDetected.BeginInvoke(this, new DTMFDetectedArgs(CurrentTone, (double)(TC * DTMFConstanst.N) / 8000), null, null); TC = 0; } else { if (x == DTMFConstanst.DSIL && DetectSilence && TC >= DTMFConstanst.FLUSH_TIME) { ToneDetected.BeginInvoke(this, new DTMFDetectedArgs(CurrentTone, (double)(TC * DTMFConstanst.N) / 8000), null, null); TC = 0; } } } else { TC++; if (ToneDetected != null) { ToneDetected.BeginInvoke(this, new DTMFDetectedArgs(CurrentTone, (double)(TC * DTMFConstanst.N) / 8000), null, null); } TC = 0; CurrentTone = x; } } } }
/// <summary> /// Raise the event that something non human was found on the line. /// </summary> /// <param name="toneDetected"></param> private void RaiseNonHumanDetected( ToneDetected toneDetected ) { if( this.NonHumanDetected != null ) { NonHumanDetected( this, toneDetected ); } }
private void OnNonHumanDetected( object sender, ToneDetected tone ) { RTCAudioWithToneDetect rtcAudioWithSip; if( sender is RTCAudioWithToneDetect ) { rtcAudioWithSip = (RTCAudioWithToneDetect)sender; // if the delegate is hooked, raise the event. if( this.NonHumanDetected != null ) { NonHumanDetected( this, rtcAudioWithSip.ChannelId ,tone.ToString()); } } else { throw new ArgumentException( "Object is not a RTCAudioWithSIP." ); } }