webrtc_m130/modules/audio_processing/typing_detection.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

93 lines
3.3 KiB
C
Raw Normal View History

/*
* Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_AUDIO_PROCESSING_TYPING_DETECTION_H_
#define MODULES_AUDIO_PROCESSING_TYPING_DETECTION_H_
Reland "Reland "Export symbols needed by the Chromium component build (part 1)."" This reverts commit b49520bfc08f5c5832dda1d642125f0bb898f974. Reason for revert: Problem fixed in https://chromium-review.googlesource.com/c/chromium/src/+/1261398. Original change's description: > Revert "Reland "Export symbols needed by the Chromium component build (part 1)."" > > This reverts commit 588f4642d1a29f7beaf28265dbd08728191b4c52. > > Reason for revert: Breaks WebRTC Chromium FYI Win Builder (dbg). > lld-link: error: undefined symbol: "__declspec(dllimport) __thiscall webrtc::Config::Config(void)" (__imp_??0Config@webrtc@@QAE@XZ) > [...] > > Original change's description: > > Reland "Export symbols needed by the Chromium component build (part 1)." > > > > This reverts commit 2ea9af227517556136fd629dd2663c0d75d77c7b. > > > > Reason for revert: The problem will be fixed by > > https://chromium-review.googlesource.com/c/chromium/src/+/1261122. > > > > Original change's description: > > > Revert "Export symbols needed by the Chromium component build (part 1)." > > > > > > This reverts commit 9e24dcff167c4eb3555bf0ce6eaba090c10fbe53. > > > > > > Reason for revert: Breaks chromium.webrtc.fyi bots. > > > > > > Original change's description: > > > > Export symbols needed by the Chromium component build (part 1). > > > > > > > > This CL uses RTC_EXPORT (defined in rtc_base/system/rtc_export.h) > > > > to mark WebRTC symbols as visible from a shared library, this doesn't > > > > mean these symbols are part of the public API (please continue to refer > > > > to [1] for info about what is considered public WebRTC API). > > > > > > > > [1] - https://webrtc.googlesource.com/src/+/HEAD/native-api.md > > > > > > > > Bug: webrtc:9419 > > > > Change-Id: I802abd32874d42d3aa5ecd3c8022e7cf5e043d99 > > > > Reviewed-on: https://webrtc-review.googlesource.com/c/103505 > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Reviewed-by: Niels Moller <nisse@webrtc.org> > > > > Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#24969} > > > > > > TBR=mbonadei@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org > > > > > > Change-Id: I01f6e18f0d2c0f0309cdaa6c943c3927e1f1f49f > > > No-Presubmit: true > > > No-Tree-Checks: true > > > No-Try: true > > > Bug: webrtc:9419 > > > Reviewed-on: https://webrtc-review.googlesource.com/c/103720 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#24974} > > > > TBR=mbonadei@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org > > > > Change-Id: I83bbc7f550fc23e823c4d055e0a6f60c828960dd > > No-Presubmit: true > > No-Tree-Checks: true > > No-Try: true > > Bug: webrtc:9419 > > Reviewed-on: https://webrtc-review.googlesource.com/c/103740 > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24980} > > TBR=mbonadei@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org > > Change-Id: I4b7cfe492f2c8eeda5c8ac52520e0cfc95ade9b0 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9419 > Reviewed-on: https://webrtc-review.googlesource.com/c/103801 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24983} TBR=mbonadei@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org # Not skipping CQ checks because original CL landed > 1 day ago. Bug: webrtc:9419 Change-Id: Id986a0a03cdc2818690337784396882af067f7fa Reviewed-on: https://webrtc-review.googlesource.com/c/104602 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Niels Moller <nisse@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25049}
2018-10-08 11:10:10 +00:00
#include "rtc_base/system/rtc_export.h"
namespace webrtc {
Reland "Reland "Export symbols needed by the Chromium component build (part 1)."" This reverts commit b49520bfc08f5c5832dda1d642125f0bb898f974. Reason for revert: Problem fixed in https://chromium-review.googlesource.com/c/chromium/src/+/1261398. Original change's description: > Revert "Reland "Export symbols needed by the Chromium component build (part 1)."" > > This reverts commit 588f4642d1a29f7beaf28265dbd08728191b4c52. > > Reason for revert: Breaks WebRTC Chromium FYI Win Builder (dbg). > lld-link: error: undefined symbol: "__declspec(dllimport) __thiscall webrtc::Config::Config(void)" (__imp_??0Config@webrtc@@QAE@XZ) > [...] > > Original change's description: > > Reland "Export symbols needed by the Chromium component build (part 1)." > > > > This reverts commit 2ea9af227517556136fd629dd2663c0d75d77c7b. > > > > Reason for revert: The problem will be fixed by > > https://chromium-review.googlesource.com/c/chromium/src/+/1261122. > > > > Original change's description: > > > Revert "Export symbols needed by the Chromium component build (part 1)." > > > > > > This reverts commit 9e24dcff167c4eb3555bf0ce6eaba090c10fbe53. > > > > > > Reason for revert: Breaks chromium.webrtc.fyi bots. > > > > > > Original change's description: > > > > Export symbols needed by the Chromium component build (part 1). > > > > > > > > This CL uses RTC_EXPORT (defined in rtc_base/system/rtc_export.h) > > > > to mark WebRTC symbols as visible from a shared library, this doesn't > > > > mean these symbols are part of the public API (please continue to refer > > > > to [1] for info about what is considered public WebRTC API). > > > > > > > > [1] - https://webrtc.googlesource.com/src/+/HEAD/native-api.md > > > > > > > > Bug: webrtc:9419 > > > > Change-Id: I802abd32874d42d3aa5ecd3c8022e7cf5e043d99 > > > > Reviewed-on: https://webrtc-review.googlesource.com/c/103505 > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Reviewed-by: Niels Moller <nisse@webrtc.org> > > > > Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#24969} > > > > > > TBR=mbonadei@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org > > > > > > Change-Id: I01f6e18f0d2c0f0309cdaa6c943c3927e1f1f49f > > > No-Presubmit: true > > > No-Tree-Checks: true > > > No-Try: true > > > Bug: webrtc:9419 > > > Reviewed-on: https://webrtc-review.googlesource.com/c/103720 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#24974} > > > > TBR=mbonadei@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org > > > > Change-Id: I83bbc7f550fc23e823c4d055e0a6f60c828960dd > > No-Presubmit: true > > No-Tree-Checks: true > > No-Try: true > > Bug: webrtc:9419 > > Reviewed-on: https://webrtc-review.googlesource.com/c/103740 > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24980} > > TBR=mbonadei@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org > > Change-Id: I4b7cfe492f2c8eeda5c8ac52520e0cfc95ade9b0 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9419 > Reviewed-on: https://webrtc-review.googlesource.com/c/103801 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24983} TBR=mbonadei@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org # Not skipping CQ checks because original CL landed > 1 day ago. Bug: webrtc:9419 Change-Id: Id986a0a03cdc2818690337784396882af067f7fa Reviewed-on: https://webrtc-review.googlesource.com/c/104602 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Niels Moller <nisse@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25049}
2018-10-08 11:10:10 +00:00
class RTC_EXPORT TypingDetection {
public:
TypingDetection();
virtual ~TypingDetection();
// Run the detection algortihm. Shall be called every 10 ms. Returns true if
// typing is detected, or false if not, based on the update period as set with
// SetParameters(). See |report_detection_update_period_| description below.
bool Process(bool key_pressed, bool vad_activity);
// Gets the time in seconds since the last detection.
int TimeSinceLastDetectionInSeconds();
// Sets the algorithm parameters. A parameter value of 0 leaves it unchanged.
// See the correspondning member variables below for descriptions.
void SetParameters(int time_window,
int cost_per_typing,
int reporting_threshold,
int penalty_decay,
int type_event_delay,
int report_detection_update_period);
private:
int time_active_;
int time_since_last_typing_;
int penalty_counter_;
// Counter since last time the detection status reported by Process() was
// updated. See also |report_detection_update_period_|.
int counter_since_last_detection_update_;
// The detection status to report. Updated every
// |report_detection_update_period_| call to Process().
bool detection_to_report_;
// What |detection_to_report_| should be set to next time it is updated.
bool new_detection_to_report_;
// Settable threshold values.
// Number of 10 ms slots accepted to count as a hit.
int time_window_;
// Penalty added for a typing + activity coincide.
int cost_per_typing_;
// Threshold for |penalty_counter_|.
int reporting_threshold_;
// How much we reduce |penalty_counter_| every 10 ms.
int penalty_decay_;
// How old typing events we allow.
int type_event_delay_;
// Settable update period.
// Number of 10 ms slots between each update of the detection status returned
// by Process(). This inertia added to the algorithm is usually desirable and
// provided so that consumers of the class don't have to implement that
// themselves if they don't wish.
// If set to 1, each call to Process() will return the detection status for
// that 10 ms slot.
// If set to N (where N > 1), the detection status returned from Process()
// will remain the same until Process() has been called N times. Then, if none
// of the last N calls to Process() has detected typing for each respective
// 10 ms slot, Process() will return false. If at least one of the last N
// calls has detected typing, Process() will return true. And that returned
// status will then remain the same until the next N calls have been done.
int report_detection_update_period_;
};
} // namespace webrtc
#endif // #ifndef MODULES_AUDIO_PROCESSING_TYPING_DETECTION_H_