call_statistics.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (c) 2013 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. #ifndef MODULES_AUDIO_CODING_ACM2_CALL_STATISTICS_H_
  11. #define MODULES_AUDIO_CODING_ACM2_CALL_STATISTICS_H_
  12. #include "api/audio/audio_frame.h"
  13. #include "modules/audio_coding/include/audio_coding_module_typedefs.h"
  14. //
  15. // This class is for book keeping of calls to ACM. It is not useful to log API
  16. // calls which are supposed to be called every 10ms, e.g. PlayoutData10Ms(),
  17. // however, it is useful to know the number of such calls in a given time
  18. // interval. The current implementation covers calls to PlayoutData10Ms() with
  19. // detailed accounting of the decoded speech type.
  20. //
  21. // Thread Safety
  22. // =============
  23. // Please note that this class in not thread safe. The class must be protected
  24. // if different APIs are called from different threads.
  25. //
  26. namespace webrtc {
  27. namespace acm2 {
  28. class CallStatistics {
  29. public:
  30. CallStatistics() {}
  31. ~CallStatistics() {}
  32. // Call this method to indicate that NetEq engaged in decoding. |speech_type|
  33. // is the audio-type according to NetEq, and |muted| indicates if the decoded
  34. // frame was produced in muted state.
  35. void DecodedByNetEq(AudioFrame::SpeechType speech_type, bool muted);
  36. // Call this method to indicate that a decoding call resulted in generating
  37. // silence, i.e. call to NetEq is bypassed and the output audio is zero.
  38. void DecodedBySilenceGenerator();
  39. // Get statistics for decoding. The statistics include the number of calls to
  40. // NetEq and silence generator, as well as the type of speech pulled of off
  41. // NetEq, c.f. declaration of AudioDecodingCallStats for detailed description.
  42. const AudioDecodingCallStats& GetDecodingStatistics() const;
  43. private:
  44. // Reset the decoding statistics.
  45. void ResetDecodingStatistics();
  46. AudioDecodingCallStats decoding_stat_;
  47. };
  48. } // namespace acm2
  49. } // namespace webrtc
  50. #endif // MODULES_AUDIO_CODING_ACM2_CALL_STATISTICS_H_