| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license | |
| 5 * that can be found in the LICENSE file in the root of the source | |
| 6 * tree. An additional intellectual property rights grant can be found | |
| 7 * in the file PATENTS. All contributing project authors may | |
| 8 * be found in the AUTHORS file in the root of the source tree. | |
| 9 */ | |
| 10 | |
| 11 #ifndef WEBRTC_VOICE_ENGINE_DTMF_INBAND_H_ | |
| 12 #define WEBRTC_VOICE_ENGINE_DTMF_INBAND_H_ | |
| 13 | |
| 14 #include "webrtc/typedefs.h" | |
| 15 #include "webrtc/voice_engine/voice_engine_defines.h" | |
| 16 #include "webrtc/base/criticalsection.h" | |
| 17 | |
| 18 namespace webrtc { | |
| 19 | |
| 20 // TODO(solenberg): Used as a DTMF tone generator in voe::OutputMixer. Pull out | |
| 21 // the one in NetEq and use that instead? We don't need several | |
| 22 // implemenations of this. | |
| 23 class DtmfInband | |
| 24 { | |
| 25 public: | |
| 26 DtmfInband(int32_t id); | |
| 27 | |
| 28 virtual ~DtmfInband(); | |
| 29 | |
| 30 void Init(); | |
| 31 | |
| 32 int SetSampleRate(uint16_t frequency); | |
| 33 | |
| 34 int GetSampleRate(uint16_t& frequency); | |
| 35 | |
| 36 int AddTone(uint8_t eventCode, | |
| 37 int32_t lengthMs, | |
| 38 int32_t attenuationDb); | |
| 39 | |
| 40 int ResetTone(); | |
| 41 int StartTone(uint8_t eventCode, int32_t attenuationDb); | |
| 42 | |
| 43 int StopTone(); | |
| 44 | |
| 45 bool IsAddingTone(); | |
| 46 | |
| 47 int Get10msTone(int16_t output[320], uint16_t& outputSizeInSamples); | |
| 48 | |
| 49 uint32_t DelaySinceLastTone() const; | |
| 50 | |
| 51 void UpdateDelaySinceLastTone(); | |
| 52 | |
| 53 private: | |
| 54 void ReInit(); | |
| 55 int16_t DtmfFix_generate(int16_t* decoded, | |
| 56 int16_t value, | |
| 57 int16_t volume, | |
| 58 int16_t frameLen, | |
| 59 int16_t fs); | |
| 60 | |
| 61 private: | |
| 62 enum {kDtmfFrameSizeMs = 10}; | |
| 63 enum {kDtmfAmpHigh = 32768}; | |
| 64 enum {kDtmfAmpLow = 23171}; // 3 dB lower than the high frequency | |
| 65 | |
| 66 int16_t DtmfFix_generateSignal(int16_t a1_times2, | |
| 67 int16_t a2_times2, | |
| 68 int16_t volume, | |
| 69 int16_t* signal, | |
| 70 int16_t length); | |
| 71 | |
| 72 private: | |
| 73 rtc::CriticalSection _critSect; | |
| 74 int32_t _id; | |
| 75 uint16_t _outputFrequencyHz; // {8000, 16000, 32000} | |
| 76 int16_t _oldOutputLow[2]; // Data needed for oscillator model | |
| 77 int16_t _oldOutputHigh[2]; // Data needed for oscillator model | |
| 78 int16_t _frameLengthSamples; // {80, 160, 320} | |
| 79 int32_t _remainingSamples; | |
| 80 int16_t _eventCode; // [0, 15] | |
| 81 int16_t _attenuationDb; // [0, 36] | |
| 82 int32_t _lengthMs; | |
| 83 bool _reinit; // 'true' if the oscillator should be reinit for next event | |
| 84 bool _playing; | |
| 85 uint32_t _delaySinceLastToneMS; // time since last generated tone [ms] | |
| 86 }; | |
| 87 | |
| 88 } // namespace webrtc | |
| 89 | |
| 90 #endif // #ifndef WEBRTC_VOICE_ENGINE_DTMF_INBAND_H_ | |
| OLD | NEW |