Reduced execution time for CallTest::ReceivesPliAndRecovers, by dropping only one packet and made it predictable by removing rand().

Follow up steps is to support NackConfig.rtp_hostory_ms and/or increase fake encoder bitrate.

R=pbos@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/6109005

git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@5316 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/video/call_tests.cc b/video/call_tests.cc
index 3398717..f239a47 100644
--- a/video/call_tests.cc
+++ b/video/call_tests.cc
@@ -562,9 +562,8 @@
       : test::RtpRtcpObserver(kLongTimeoutMs),
         rtp_header_parser_(RtpHeaderParser::Create()),
         nack_enabled_(nack_enabled),
-        first_retransmitted_timestamp_(0),
-        last_send_timestamp_(0),
-        rendered_frame_(false),
+        highest_dropped_timestamp_(0),
+        frames_to_drop_(0),
         received_pli_(false) {}
 
   virtual Action OnSendRtp(const uint8_t* packet, size_t length) OVERRIDE {
@@ -572,19 +571,16 @@
     EXPECT_TRUE(
         rtp_header_parser_->Parse(packet, static_cast<int>(length), &header));
 
-    // Drop all NACK retransmissions. This is to force transmission of a PLI.
-    if (header.timestamp < last_send_timestamp_)
+    // Drop all retransmitted packets to force a PLI.
+    if (header.timestamp <= highest_dropped_timestamp_)
       return DROP_PACKET;
 
-    if (received_pli_) {
-      if (first_retransmitted_timestamp_ == 0) {
-        first_retransmitted_timestamp_ = header.timestamp;
-      }
-    } else if (rendered_frame_ && rand() % kInverseDropProbability == 0) {
+    if (frames_to_drop_ > 0) {
+      highest_dropped_timestamp_ = header.timestamp;
+      --frames_to_drop_;
       return DROP_PACKET;
     }
 
-    last_send_timestamp_ = header.timestamp;
     return SEND_PACKET;
   }
 
@@ -609,22 +605,20 @@
   virtual void RenderFrame(const I420VideoFrame& video_frame,
                            int time_to_render_ms) OVERRIDE {
     CriticalSectionScoped crit_(lock_.get());
-    if (first_retransmitted_timestamp_ != 0 &&
-        video_frame.timestamp() > first_retransmitted_timestamp_) {
-      EXPECT_TRUE(received_pli_);
+    if (received_pli_ && video_frame.timestamp() > highest_dropped_timestamp_) {
       observation_complete_->Set();
     }
-    rendered_frame_ = true;
+    if (!received_pli_)
+      frames_to_drop_ = kPacketsToDrop;
   }
 
  private:
+  static const int kPacketsToDrop = 1;
+
   scoped_ptr<RtpHeaderParser> rtp_header_parser_;
   bool nack_enabled_;
-
-  uint32_t first_retransmitted_timestamp_;
-  uint32_t last_send_timestamp_;
-
-  bool rendered_frame_;
+  uint32_t highest_dropped_timestamp_;
+  int frames_to_drop_;
   bool received_pli_;
 };