Add an interface for accepting keypress signals to AudioProcessing.
R=aluebs@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/8429004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@5529 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/modules/audio_processing/audio_processing_impl.cc b/webrtc/modules/audio_processing/audio_processing_impl.cc
index 8b9044f..377f78f 100644
--- a/webrtc/modules/audio_processing/audio_processing_impl.cc
+++ b/webrtc/modules/audio_processing/audio_processing_impl.cc
@@ -568,6 +568,14 @@
return delay_offset_ms_;
}
+void AudioProcessingImpl::set_stream_key_pressed(bool key_pressed) {
+ key_pressed_ = key_pressed;
+}
+
+bool AudioProcessingImpl::stream_key_pressed() const {
+ return key_pressed_;
+}
+
int AudioProcessingImpl::StartDebugRecording(
const char filename[AudioProcessing::kMaxFilenameSize]) {
CriticalSectionScoped crit_scoped(crit_);
diff --git a/webrtc/modules/audio_processing/audio_processing_impl.h b/webrtc/modules/audio_processing/audio_processing_impl.h
index 249b789..3b46ba8 100644
--- a/webrtc/modules/audio_processing/audio_processing_impl.h
+++ b/webrtc/modules/audio_processing/audio_processing_impl.h
@@ -76,6 +76,8 @@
virtual int stream_delay_ms() const OVERRIDE;
virtual void set_delay_offset_ms(int offset) OVERRIDE;
virtual int delay_offset_ms() const OVERRIDE;
+ virtual void set_stream_key_pressed(bool key_pressed) OVERRIDE;
+ virtual bool stream_key_pressed() const OVERRIDE;
virtual int StartDebugRecording(
const char filename[kMaxFilenameSize]) OVERRIDE;
virtual int StartDebugRecording(FILE* handle) OVERRIDE;
@@ -134,6 +136,8 @@
int num_reverse_channels_;
int num_input_channels_;
int num_output_channels_;
+
+ bool key_pressed_;
};
} // namespace webrtc
diff --git a/webrtc/modules/audio_processing/include/audio_processing.h b/webrtc/modules/audio_processing/include/audio_processing.h
index 09d4cd4..82e6e50 100644
--- a/webrtc/modules/audio_processing/include/audio_processing.h
+++ b/webrtc/modules/audio_processing/include/audio_processing.h
@@ -231,6 +231,11 @@
virtual int set_stream_delay_ms(int delay) = 0;
virtual int stream_delay_ms() const = 0;
+ // Call to signal that a key press occurred (true) or did not occur (false)
+ // with this chunk of audio.
+ virtual void set_stream_key_pressed(bool key_pressed) = 0;
+ virtual bool stream_key_pressed() const = 0;
+
// Sets a delay |offset| in ms to add to the values passed in through
// set_stream_delay_ms(). May be positive or negative.
//
diff --git a/webrtc/modules/audio_processing/include/mock_audio_processing.h b/webrtc/modules/audio_processing/include/mock_audio_processing.h
index 46520ab..9ef7904 100644
--- a/webrtc/modules/audio_processing/include/mock_audio_processing.h
+++ b/webrtc/modules/audio_processing/include/mock_audio_processing.h
@@ -209,6 +209,10 @@
int(int delay));
MOCK_CONST_METHOD0(stream_delay_ms,
int());
+ MOCK_METHOD1(set_stream_key_pressed,
+ void(bool key_pressed));
+ MOCK_CONST_METHOD0(stream_key_pressed,
+ bool());
MOCK_METHOD1(set_delay_offset_ms,
void(int offset));
MOCK_CONST_METHOD0(delay_offset_ms,
diff --git a/webrtc/voice_engine/transmit_mixer.cc b/webrtc/voice_engine/transmit_mixer.cc
index 22aabb7..e9394f7 100644
--- a/webrtc/voice_engine/transmit_mixer.cc
+++ b/webrtc/voice_engine/transmit_mixer.cc
@@ -362,7 +362,7 @@
}
// --- Near-end audio processing.
- ProcessAudio(totalDelayMS, clockDrift, currentMicLevel);
+ ProcessAudio(totalDelayMS, clockDrift, currentMicLevel, keyPressed);
if (swap_stereo_channels_ && stereo_codec_)
// Only bother swapping if we're using a stereo codec.
@@ -1309,7 +1309,7 @@
}
void TransmitMixer::ProcessAudio(int delay_ms, int clock_drift,
- int current_mic_level) {
+ int current_mic_level, bool key_pressed) {
if (audioproc_->set_stream_delay_ms(delay_ms) != 0) {
// A redundant warning is reported in AudioDevice, which we've throttled
// to avoid flooding the logs. Relegate this one to LS_VERBOSE to avoid
@@ -1328,6 +1328,8 @@
aec->set_stream_drift_samples(clock_drift);
}
+ audioproc_->set_stream_key_pressed(key_pressed);
+
int err = audioproc_->ProcessStream(&_audioFrame);
if (err != 0) {
LOG(LS_ERROR) << "ProcessStream() error: " << err;
diff --git a/webrtc/voice_engine/transmit_mixer.h b/webrtc/voice_engine/transmit_mixer.h
index 225d4ac..58bc73d 100644
--- a/webrtc/voice_engine/transmit_mixer.h
+++ b/webrtc/voice_engine/transmit_mixer.h
@@ -184,7 +184,8 @@
int32_t MixOrReplaceAudioWithFile(
int mixingFrequency);
- void ProcessAudio(int delay_ms, int clock_drift, int current_mic_level);
+ void ProcessAudio(int delay_ms, int clock_drift, int current_mic_level,
+ bool key_pressed);
#ifdef WEBRTC_VOICE_ENGINE_TYPING_DETECTION
void TypingDetection(bool keyPressed);