Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Side by Side Diff: webrtc/modules/audio_processing/include/audio_processing.h

Issue 2458993002: Reland of New statistics interface for APM (Closed)
Patch Set: Added implementation of the new non-pure interface function. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 virtual int StartDebugRecordingForPlatformFile(rtc::PlatformFile handle) = 0; 462 virtual int StartDebugRecordingForPlatformFile(rtc::PlatformFile handle) = 0;
463 463
464 // Stops recording debugging information, and closes the file. Recording 464 // Stops recording debugging information, and closes the file. Recording
465 // cannot be resumed in the same file (without overwriting it). 465 // cannot be resumed in the same file (without overwriting it).
466 virtual int StopDebugRecording() = 0; 466 virtual int StopDebugRecording() = 0;
467 467
468 // Use to send UMA histograms at end of a call. Note that all histogram 468 // Use to send UMA histograms at end of a call. Note that all histogram
469 // specific member variables are reset. 469 // specific member variables are reset.
470 virtual void UpdateHistogramsOnCallEnd() = 0; 470 virtual void UpdateHistogramsOnCallEnd() = 0;
471 471
472 // TODO(ivoc): Remove when the calling code no longer uses the old Statistics
473 // API.
474 struct Statistic {
475 int instant = 0; // Instantaneous value.
476 int average = 0; // Long-term average.
477 int maximum = 0; // Long-term maximum.
478 int minimum = 0; // Long-term minimum.
479 };
480
481 struct Stat {
482 void Set(const Statistic& other) {
483 Set(other.instant, other.average, other.maximum, other.minimum);
484 }
485 void Set(float instant, float average, float maximum, float minimum) {
486 RTC_DCHECK_LE(instant, maximum);
487 RTC_DCHECK_GE(instant, minimum);
488 RTC_DCHECK_LE(average, maximum);
489 RTC_DCHECK_GE(average, minimum);
490 instant_ = instant;
491 average_ = average;
492 maximum_ = maximum;
493 minimum_ = minimum;
494 }
495 float instant() const { return instant_; }
496 float average() const { return average_; }
497 float maximum() const { return maximum_; }
498 float minimum() const { return minimum_; }
499
500 private:
501 float instant_ = 0.0f; // Instantaneous value.
502 float average_ = 0.0f; // Long-term average.
503 float maximum_ = 0.0f; // Long-term maximum.
504 float minimum_ = 0.0f; // Long-term minimum.
505 };
506
507 struct AudioProcessingStatistics {
508 // AEC Statistics.
509 // RERL = ERL + ERLE
510 Stat residual_echo_return_loss;
511 // ERL = 10log_10(P_far / P_echo)
512 Stat echo_return_loss;
513 // ERLE = 10log_10(P_echo / P_out)
514 Stat echo_return_loss_enhancement;
515 // (Pre non-linear processing suppression) A_NLP = 10log_10(P_echo / P_a)
516 Stat a_nlp;
517 // Fraction of time that the AEC linear filter is divergent, in a 1-second
518 // non-overlapped aggregation window.
519 float divergent_filter_fraction = 0.0f;
520
521 // The delay metrics consists of the delay median and standard deviation. It
522 // also consists of the fraction of delay estimates that can make the echo
523 // cancellation perform poorly. The values are aggregated until the first
524 // call to |GetStatistics()| and afterwards aggregated and updated every
525 // second. Note that if there are several clients pulling metrics from
526 // |GetStatistics()| during a session the first call from any of them will
527 // change to one second aggregation window for all.
528 int delay_median = 0;
529 int delay_standard_deviation = 0;
530 float fraction_poor_delays = 0.0f;
531
532 // Residual echo detector likelihood. This value is not yet calculated and
533 // is currently always set to zero.
534 // TODO(ivoc): Implement this stat.
535 float residual_echo_likelihood = 0.0f;
536 };
537
538 // TODO(ivoc): Make this pure virtual when all subclasses have been updated.
539 virtual AudioProcessingStatistics GetStatistics() const;
540
472 // These provide access to the component interfaces and should never return 541 // These provide access to the component interfaces and should never return
473 // NULL. The pointers will be valid for the lifetime of the APM instance. 542 // NULL. The pointers will be valid for the lifetime of the APM instance.
474 // The memory for these objects is entirely managed internally. 543 // The memory for these objects is entirely managed internally.
475 virtual EchoCancellation* echo_cancellation() const = 0; 544 virtual EchoCancellation* echo_cancellation() const = 0;
476 virtual EchoControlMobile* echo_control_mobile() const = 0; 545 virtual EchoControlMobile* echo_control_mobile() const = 0;
477 virtual GainControl* gain_control() const = 0; 546 virtual GainControl* gain_control() const = 0;
478 virtual HighPassFilter* high_pass_filter() const = 0; 547 virtual HighPassFilter* high_pass_filter() const = 0;
479 virtual LevelEstimator* level_estimator() const = 0; 548 virtual LevelEstimator* level_estimator() const = 0;
480 virtual NoiseSuppression* noise_suppression() const = 0; 549 virtual NoiseSuppression* noise_suppression() const = 0;
481 virtual VoiceDetection* voice_detection() const = 0; 550 virtual VoiceDetection* voice_detection() const = 0;
482 551
483 struct Statistic {
484 int instant; // Instantaneous value.
485 int average; // Long-term average.
486 int maximum; // Long-term maximum.
487 int minimum; // Long-term minimum.
488 };
489
490 enum Error { 552 enum Error {
491 // Fatal errors. 553 // Fatal errors.
492 kNoError = 0, 554 kNoError = 0,
493 kUnspecifiedError = -1, 555 kUnspecifiedError = -1,
494 kCreationFailedError = -2, 556 kCreationFailedError = -2,
495 kUnsupportedComponentError = -3, 557 kUnsupportedComponentError = -3,
496 kUnsupportedFunctionError = -4, 558 kUnsupportedFunctionError = -4,
497 kNullPointerError = -5, 559 kNullPointerError = -5,
498 kBadParameterError = -6, 560 kBadParameterError = -6,
499 kBadSampleRateError = -7, 561 kBadSampleRateError = -7,
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 AudioProcessing::Statistic echo_return_loss_enhancement; 763 AudioProcessing::Statistic echo_return_loss_enhancement;
702 764
703 // (Pre non-linear processing suppression) A_NLP = 10log_10(P_echo / P_a) 765 // (Pre non-linear processing suppression) A_NLP = 10log_10(P_echo / P_a)
704 AudioProcessing::Statistic a_nlp; 766 AudioProcessing::Statistic a_nlp;
705 767
706 // Fraction of time that the AEC linear filter is divergent, in a 1-second 768 // Fraction of time that the AEC linear filter is divergent, in a 1-second
707 // non-overlapped aggregation window. 769 // non-overlapped aggregation window.
708 float divergent_filter_fraction; 770 float divergent_filter_fraction;
709 }; 771 };
710 772
773 // Deprecated. Use GetStatistics on the AudioProcessing interface instead.
711 // TODO(ajm): discuss the metrics update period. 774 // TODO(ajm): discuss the metrics update period.
712 virtual int GetMetrics(Metrics* metrics) = 0; 775 virtual int GetMetrics(Metrics* metrics) = 0;
713 776
714 // Enables computation and logging of delay values. Statistics are obtained 777 // Enables computation and logging of delay values. Statistics are obtained
715 // through |GetDelayMetrics()|. 778 // through |GetDelayMetrics()|.
716 virtual int enable_delay_logging(bool enable) = 0; 779 virtual int enable_delay_logging(bool enable) = 0;
717 virtual bool is_delay_logging_enabled() const = 0; 780 virtual bool is_delay_logging_enabled() const = 0;
718 781
719 // The delay metrics consists of the delay |median| and the delay standard 782 // The delay metrics consists of the delay |median| and the delay standard
720 // deviation |std|. It also consists of the fraction of delay estimates 783 // deviation |std|. It also consists of the fraction of delay estimates
721 // |fraction_poor_delays| that can make the echo cancellation perform poorly. 784 // |fraction_poor_delays| that can make the echo cancellation perform poorly.
722 // The values are aggregated until the first call to |GetDelayMetrics()| and 785 // The values are aggregated until the first call to |GetDelayMetrics()| and
723 // afterwards aggregated and updated every second. 786 // afterwards aggregated and updated every second.
724 // Note that if there are several clients pulling metrics from 787 // Note that if there are several clients pulling metrics from
725 // |GetDelayMetrics()| during a session the first call from any of them will 788 // |GetDelayMetrics()| during a session the first call from any of them will
726 // change to one second aggregation window for all. 789 // change to one second aggregation window for all.
727 // TODO(bjornv): Deprecated, remove. 790 // Deprecated. Use GetStatistics on the AudioProcessing interface instead.
728 virtual int GetDelayMetrics(int* median, int* std) = 0; 791 virtual int GetDelayMetrics(int* median, int* std) = 0;
792 // Deprecated. Use GetStatistics on the AudioProcessing interface instead.
729 virtual int GetDelayMetrics(int* median, int* std, 793 virtual int GetDelayMetrics(int* median, int* std,
730 float* fraction_poor_delays) = 0; 794 float* fraction_poor_delays) = 0;
731 795
732 // Returns a pointer to the low level AEC component. In case of multiple 796 // Returns a pointer to the low level AEC component. In case of multiple
733 // channels, the pointer to the first one is returned. A NULL pointer is 797 // channels, the pointer to the first one is returned. A NULL pointer is
734 // returned when the AEC component is disabled or has not been initialized 798 // returned when the AEC component is disabled or has not been initialized
735 // successfully. 799 // successfully.
736 virtual struct AecCore* aec_core() const = 0; 800 virtual struct AecCore* aec_core() const = 0;
737 801
738 protected: 802 protected:
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 // This does not impact the size of frames passed to |ProcessStream()|. 1062 // This does not impact the size of frames passed to |ProcessStream()|.
999 virtual int set_frame_size_ms(int size) = 0; 1063 virtual int set_frame_size_ms(int size) = 0;
1000 virtual int frame_size_ms() const = 0; 1064 virtual int frame_size_ms() const = 0;
1001 1065
1002 protected: 1066 protected:
1003 virtual ~VoiceDetection() {} 1067 virtual ~VoiceDetection() {}
1004 }; 1068 };
1005 } // namespace webrtc 1069 } // namespace webrtc
1006 1070
1007 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_PROCESSING_H_ 1071 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_PROCESSING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698