Remove unused TypingMonitor class.

BUG=webrtc:4690

Review URL: https://codereview.webrtc.org/1327033002

Cr-Commit-Position: refs/heads/master@{#9884}
diff --git a/talk/libjingle.gyp b/talk/libjingle.gyp
index 10a7cbd..cdd05b3 100755
--- a/talk/libjingle.gyp
+++ b/talk/libjingle.gyp
@@ -689,8 +689,6 @@
         'session/media/rtcpmuxfilter.h',
         'session/media/srtpfilter.cc',
         'session/media/srtpfilter.h',
-        'session/media/typingmonitor.cc',
-        'session/media/typingmonitor.h',
         'session/media/voicechannel.h',
       ],
     },  # target libjingle_p2p
diff --git a/talk/session/media/channel.cc b/talk/session/media/channel.cc
index f65579f..4288291 100644
--- a/talk/session/media/channel.cc
+++ b/talk/session/media/channel.cc
@@ -31,7 +31,6 @@
 #include "talk/media/base/rtputils.h"
 #include "webrtc/p2p/base/transportchannel.h"
 #include "talk/session/media/channelmanager.h"
-#include "talk/session/media/typingmonitor.h"
 #include "webrtc/base/bind.h"
 #include "webrtc/base/buffer.h"
 #include "webrtc/base/byteorder.h"
@@ -1384,26 +1383,6 @@
   return (audio_monitor_.get() != NULL);
 }
 
-void VoiceChannel::StartTypingMonitor(const TypingMonitorOptions& settings) {
-  typing_monitor_.reset(new TypingMonitor(this, worker_thread(), settings));
-  SignalAutoMuted.repeat(typing_monitor_->SignalMuted);
-}
-
-void VoiceChannel::StopTypingMonitor() {
-  typing_monitor_.reset();
-}
-
-bool VoiceChannel::IsTypingMonitorRunning() const {
-  return typing_monitor_;
-}
-
-bool VoiceChannel::MuteStream_w(uint32 ssrc, bool mute) {
-  bool ret = BaseChannel::MuteStream_w(ssrc, mute);
-  if (typing_monitor_ && mute)
-    typing_monitor_->OnChannelMuted();
-  return ret;
-}
-
 int VoiceChannel::GetInputLevel_w() {
   return media_engine_->GetInputLevel();
 }
diff --git a/talk/session/media/channel.h b/talk/session/media/channel.h
index 5f51c07..c09d51c 100644
--- a/talk/session/media/channel.h
+++ b/talk/session/media/channel.h
@@ -53,8 +53,6 @@
 
 struct CryptoParams;
 class MediaContentDescription;
-struct TypingMonitorOptions;
-class TypingMonitor;
 struct ViewRequest;
 
 enum SinkType {
@@ -163,9 +161,6 @@
   // Used for latency measurements.
   sigslot::signal1<BaseChannel*> SignalFirstPacketReceived;
 
-  // Used to alert UI when the muted status changes, perhaps autonomously.
-  sigslot::repeater2<BaseChannel*, bool> SignalAutoMuted;
-
   // Made public for easier testing.
   void SetReadyToSend(TransportChannel* channel, bool ready);
 
@@ -232,7 +227,7 @@
 
   void EnableMedia_w();
   void DisableMedia_w();
-  virtual bool MuteStream_w(uint32 ssrc, bool mute);
+  bool MuteStream_w(uint32 ssrc, bool mute);
   bool IsStreamMuted_w(uint32 ssrc);
   void ChannelWritable_w();
   void ChannelNotWritable_w();
@@ -383,13 +378,6 @@
   bool IsAudioMonitorRunning() const;
   sigslot::signal2<VoiceChannel*, const AudioInfo&> SignalAudioMonitor;
 
-  void StartTypingMonitor(const TypingMonitorOptions& settings);
-  void StopTypingMonitor();
-  bool IsTypingMonitorRunning() const;
-
-  // Overrides BaseChannel::MuteStream_w.
-  virtual bool MuteStream_w(uint32 ssrc, bool mute);
-
   int GetInputLevel_w();
   int GetOutputLevel_w();
   void GetActiveStreams_w(AudioInfo::StreamList* actives);
@@ -439,7 +427,6 @@
   bool received_media_;
   rtc::scoped_ptr<VoiceMediaMonitor> media_monitor_;
   rtc::scoped_ptr<AudioMonitor> audio_monitor_;
-  rtc::scoped_ptr<TypingMonitor> typing_monitor_;
 
   // Last AudioSendParameters sent down to the media_channel() via
   // SetSendParameters.
diff --git a/talk/session/media/channel_unittest.cc b/talk/session/media/channel_unittest.cc
index 03f33a4..6d56792e 100644
--- a/talk/session/media/channel_unittest.cc
+++ b/talk/session/media/channel_unittest.cc
@@ -35,7 +35,6 @@
 #include "talk/media/base/testutils.h"
 #include "webrtc/p2p/base/fakesession.h"
 #include "talk/session/media/channel.h"
-#include "talk/session/media/typingmonitor.h"
 #include "webrtc/base/fileutils.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/helpers.h"
@@ -136,8 +135,6 @@
         rtcp_packet_(reinterpret_cast<const char*>(rtcp_data), rtcp_len),
         media_info_callbacks1_(),
         media_info_callbacks2_(),
-        mute_callback_recved_(false),
-        mute_callback_value_(false),
         ssrc_(0),
         error_(T::MediaChannel::ERROR_NONE) {
   }
@@ -181,8 +178,6 @@
         this, &ChannelTest<T>::OnMediaChannelError);
     channel2_->SignalMediaError.connect(
         this, &ChannelTest<T>::OnMediaChannelError);
-    channel1_->SignalAutoMuted.connect(
-        this, &ChannelTest<T>::OnMediaMuted);
     if ((flags1 & DTLS) && (flags2 & DTLS)) {
       flags1 = (flags1 & ~SECURE);
       flags2 = (flags2 & ~SECURE);
@@ -527,11 +522,6 @@
     error_ = error;
   }
 
-  void OnMediaMuted(cricket::BaseChannel* channel, bool muted) {
-    mute_callback_recved_ = true;
-    mute_callback_value_ = muted;
-  }
-
   void AddLegacyStreamInContent(uint32 ssrc, int flags,
                         typename T::Content* content) {
     // Base implementation.
@@ -1798,8 +1788,6 @@
   std::string rtcp_packet_;
   int media_info_callbacks1_;
   int media_info_callbacks2_;
-  bool mute_callback_recved_;
-  bool mute_callback_value_;
 
   uint32 ssrc_;
   typename T::MediaChannel::Error error_;
@@ -2132,38 +2120,10 @@
 TEST_F(VoiceChannelTest, TestVoiceSpecificMuteStream) {
   CreateChannels(0, 0);
   EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
-  EXPECT_FALSE(mute_callback_recved_);
   EXPECT_TRUE(channel1_->MuteStream(0, true));
   EXPECT_TRUE(media_channel1_->IsStreamMuted(0));
-  EXPECT_FALSE(mute_callback_recved_);
   EXPECT_TRUE(channel1_->MuteStream(0, false));
   EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
-  EXPECT_FALSE(mute_callback_recved_);
-}
-
-// Test that keyboard automute works correctly and signals upwards.
-TEST_F(VoiceChannelTest, DISABLED_TestKeyboardMute) {
-  CreateChannels(0, 0);
-  EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
-  EXPECT_EQ(cricket::VoiceMediaChannel::ERROR_NONE, error_);
-
-  cricket::VoiceMediaChannel::Error e =
-      cricket::VoiceMediaChannel::ERROR_REC_TYPING_NOISE_DETECTED;
-
-  // Typing doesn't mute automatically unless typing monitor has been installed
-  media_channel1_->TriggerError(0, e);
-  rtc::Thread::Current()->ProcessMessages(0);
-  EXPECT_EQ(e, error_);
-  EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
-  EXPECT_FALSE(mute_callback_recved_);
-
-  cricket::TypingMonitorOptions o = {0};
-  o.mute_period = 1500;
-  channel1_->StartTypingMonitor(o);
-  media_channel1_->TriggerError(0, e);
-  rtc::Thread::Current()->ProcessMessages(0);
-  EXPECT_TRUE(media_channel1_->IsStreamMuted(0));
-  EXPECT_TRUE(mute_callback_recved_);
 }
 
 // Test that PressDTMF properly forwards to the media channel.
diff --git a/talk/session/media/typingmonitor.cc b/talk/session/media/typingmonitor.cc
index ee0f92a..48226d6 100644
--- a/talk/session/media/typingmonitor.cc
+++ b/talk/session/media/typingmonitor.cc
@@ -25,99 +25,6 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+ // TODO(solenberg): Remove this file when it's no longer built in Chromium.
+
 #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();
-
-    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
diff --git a/talk/session/media/typingmonitor.h b/talk/session/media/typingmonitor.h
index 4beb8ec..76446c2 100644
--- a/talk/session/media/typingmonitor.h
+++ b/talk/session/media/typingmonitor.h
@@ -25,60 +25,4 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TALK_SESSION_MEDIA_TYPINGMONITOR_H_
-#define TALK_SESSION_MEDIA_TYPINGMONITOR_H_
-
-#include "talk/media/base/mediachannel.h"
-#include "webrtc/base/messagehandler.h"
-
-namespace rtc {
-class Thread;
-}
-
-namespace cricket {
-
-class VoiceChannel;
-class BaseChannel;
-
-struct TypingMonitorOptions {
-  int cost_per_typing;
-  int mute_period;
-  int penalty_decay;
-  int reporting_threshold;
-  int time_window;
-  int type_event_delay;
-  size_t min_participants;
-};
-
-/**
- * An object that observes a channel and listens for typing detection warnings,
- * which can be configured to mute audio capture of that channel for some period
- * of time.  The purpose is to automatically mute someone if they are disturbing
- * a conference with loud keystroke audio signals.
- */
-class TypingMonitor
-    : public rtc::MessageHandler, public sigslot::has_slots<> {
- public:
-  TypingMonitor(VoiceChannel* channel, rtc::Thread* worker_thread,
-                const TypingMonitorOptions& params);
-  ~TypingMonitor();
-
-  sigslot::signal2<BaseChannel*, bool> SignalMuted;
-
-  void OnChannelMuted();
-
- private:
-  void OnVoiceChannelError(uint32 ssrc, VoiceMediaChannel::Error error);
-  void OnMessage(rtc::Message* msg);
-
-  VoiceChannel* channel_;
-  rtc::Thread* worker_thread_;
-  int mute_period_;
-  int muted_at_;
-  bool has_pending_unmute_;
-};
-
-}  // namespace cricket
-
-#endif  // TALK_SESSION_MEDIA_TYPINGMONITOR_H_
-
+ // TODO(solenberg): Remove this file when it's no longer built in Chromium.
diff --git a/talk/session/media/typingmonitor_unittest.cc b/talk/session/media/typingmonitor_unittest.cc
deleted file mode 100644
index 66e2401..0000000
--- a/talk/session/media/typingmonitor_unittest.cc
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * libjingle
- * Copyright 2004 Google Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *  1. Redistributions of source code must retain the above copyright notice,
- *     this list of conditions and the following disclaimer.
- *  2. Redistributions in binary form must reproduce the above copyright notice,
- *     this list of conditions and the following disclaimer in the documentation
- *     and/or other materials provided with the distribution.
- *  3. The name of the author may not be used to endorse or promote products
- *     derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "talk/media/base/fakemediaengine.h"
-#include "webrtc/p2p/base/fakesession.h"
-#include "talk/session/media/channel.h"
-#include "talk/session/media/currentspeakermonitor.h"
-#include "talk/session/media/typingmonitor.h"
-#include "webrtc/base/gunit.h"
-
-namespace cricket {
-
-class TypingMonitorTest : public testing::Test {
- protected:
-  TypingMonitorTest() : session_(true) {
-    vc_.reset(new VoiceChannel(rtc::Thread::Current(), &engine_,
-                               engine_.CreateChannel(), &session_, "", false));
-    engine_.GetVoiceChannel(0)->set_time_since_last_typing(1000);
-
-    TypingMonitorOptions settings = {10, 20, 30, 40, 50};
-    monitor_.reset(new TypingMonitor(vc_.get(),
-                                     rtc::Thread::Current(),
-                                     settings));
-  }
-
-  void TearDown() {
-    vc_.reset();
-  }
-
-  rtc::scoped_ptr<TypingMonitor> monitor_;
-  rtc::scoped_ptr<VoiceChannel> vc_;
-  FakeMediaEngine engine_;
-  FakeSession session_;
-};
-
-TEST_F(TypingMonitorTest, TestTriggerMute) {
-  EXPECT_FALSE(vc_->IsStreamMuted(0));
-  EXPECT_FALSE(engine_.GetVoiceChannel(0)->IsStreamMuted(0));
-
-  engine_.GetVoiceChannel(0)->TriggerError(0, VoiceMediaChannel::ERROR_OTHER);
-  EXPECT_FALSE(vc_->IsStreamMuted(0));
-  EXPECT_FALSE(engine_.GetVoiceChannel(0)->IsStreamMuted(0));
-
-  engine_.GetVoiceChannel(0)->TriggerError(
-      0, VoiceMediaChannel::ERROR_REC_TYPING_NOISE_DETECTED);
-  EXPECT_TRUE(vc_->IsStreamMuted(0));
-  EXPECT_TRUE(engine_.GetVoiceChannel(0)->IsStreamMuted(0));
-
-  EXPECT_TRUE_WAIT(!vc_->IsStreamMuted(0) &&
-                   !engine_.GetVoiceChannel(0)->IsStreamMuted(0), 100);
-}
-
-TEST_F(TypingMonitorTest, TestResetMonitor) {
-  engine_.GetVoiceChannel(0)->set_time_since_last_typing(1000);
-  EXPECT_FALSE(vc_->IsStreamMuted(0));
-  EXPECT_FALSE(engine_.GetVoiceChannel(0)->IsStreamMuted(0));
-
-  engine_.GetVoiceChannel(0)->TriggerError(
-      0, VoiceMediaChannel::ERROR_REC_TYPING_NOISE_DETECTED);
-  EXPECT_TRUE(vc_->IsStreamMuted(0));
-  EXPECT_TRUE(engine_.GetVoiceChannel(0)->IsStreamMuted(0));
-
-  monitor_.reset();
-  EXPECT_FALSE(vc_->IsStreamMuted(0));
-  EXPECT_FALSE(engine_.GetVoiceChannel(0)->IsStreamMuted(0));
-}
-
-}  // namespace cricket