Index: talk/session/media/typingmonitor.cc |
diff --git a/talk/session/media/typingmonitor.cc b/talk/session/media/typingmonitor.cc |
index ee0f92a60af2446c75ea519c6f293a818f4153da..48226d6ea96317eff077b59b8c23020803a2c4c6 100644 |
--- a/talk/session/media/typingmonitor.cc |
+++ b/talk/session/media/typingmonitor.cc |
@@ -25,99 +25,6 @@ |
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
-#include "talk/session/media/typingmonitor.h" |
- |
-#include "talk/session/media/channel.h" |
-#include "webrtc/base/logging.h" |
-#include "webrtc/base/thread.h" |
- |
-namespace cricket { |
- |
-TypingMonitor::TypingMonitor(VoiceChannel* channel, |
- rtc::Thread* worker_thread, |
- const TypingMonitorOptions& settings) |
- : channel_(channel), |
- worker_thread_(worker_thread), |
- mute_period_(settings.mute_period), |
- muted_at_(0), |
- has_pending_unmute_(false) { |
- channel_->media_channel()->SignalMediaError.connect( |
- this, &TypingMonitor::OnVoiceChannelError); |
- channel_->media_channel()->SetTypingDetectionParameters( |
- settings.time_window, settings.cost_per_typing, |
- settings.reporting_threshold, settings.penalty_decay, |
- settings.type_event_delay); |
-} |
- |
-TypingMonitor::~TypingMonitor() { |
- // Shortcut any pending unmutes. |
- if (has_pending_unmute_) { |
- rtc::MessageList messages; |
- worker_thread_->Clear(this, 0, &messages); |
- ASSERT(messages.size() == 1); |
- channel_->MuteStream(0, false); |
- SignalMuted(channel_, false); |
- } |
-} |
- |
-void TypingMonitor::OnVoiceChannelError(uint32 ssrc, |
- VoiceMediaChannel::Error error) { |
- if (error == VoiceMediaChannel::ERROR_REC_TYPING_NOISE_DETECTED && |
- !channel_->IsStreamMuted(0)) { |
- // Please be careful and cognizant about threading issues when editing this |
- // code. The MuteStream() call below is a ::Send and is synchronous as well |
- // as the muted signal that comes from this. This function can be called |
- // from any thread. |
- |
- // TODO(perkj): Refactor TypingMonitor and the MediaChannel to handle |
- // multiple sending audio streams. SSRC 0 means the default sending audio |
- // channel. |
- channel_->MuteStream(0, true); |
- SignalMuted(channel_, true); |
- has_pending_unmute_ = true; |
- muted_at_ = rtc::Time(); |
+ // TODO(solenberg): Remove this file when it's no longer built in Chromium. |
- worker_thread_->PostDelayed(mute_period_, this, 0); |
- LOG(LS_INFO) << "Muting for at least " << mute_period_ << "ms."; |
- } |
-} |
- |
-/** |
- * If we mute due to detected typing and the user also mutes during our waiting |
- * period, we don't want to undo their mute. So, clear our callback. Should |
- * be called on the worker_thread. |
- */ |
-void TypingMonitor::OnChannelMuted() { |
- if (has_pending_unmute_) { |
- rtc::MessageList removed; |
- worker_thread_->Clear(this, 0, &removed); |
- ASSERT(removed.size() == 1); |
- has_pending_unmute_ = false; |
- } |
-} |
- |
-/** |
- * When the specified mute period has elapsed, unmute, or, if the user kept |
- * typing after the initial warning fired, wait for the remainder of time to |
- * elapse since they finished and try to unmute again. Should be called on the |
- * worker thread. |
- */ |
-void TypingMonitor::OnMessage(rtc::Message* msg) { |
- if (!channel_->IsStreamMuted(0) || !has_pending_unmute_) return; |
- int silence_period = channel_->media_channel()->GetTimeSinceLastTyping(); |
- int expiry_time = mute_period_ - silence_period; |
- if (silence_period < 0 || expiry_time < 50) { |
- LOG(LS_INFO) << "Mute timeout hit, last typing " << silence_period |
- << "ms ago, unmuting after " << rtc::TimeSince(muted_at_) |
- << "ms total."; |
- has_pending_unmute_ = false; |
- channel_->MuteStream(0, false); |
- SignalMuted(channel_, false); |
- } else { |
- LOG(LS_INFO) << "Mute timeout hit, last typing " << silence_period |
- << "ms ago, check again in " << expiry_time << "ms."; |
- rtc::Thread::Current()->PostDelayed(expiry_time, this, 0); |
- } |
-} |
- |
-} // namespace cricket |
+#include "talk/session/media/typingmonitor.h" |