Move SetTargetSendBitrates logic from default module to payload router.

This cl just moves the logic form the default module
SetTargetSendBitrates to PayloadRouter. There might be glitch / mismatch
in size between trate the vector and rtp modules. This was the same in
the default module and is quite hard to protect from before we have the
new video API.

I also removed some test form rtp_rtcp_impl_unittest that were affected
by this change. The test tests code that isn't implemented, hence the
DISABLED_, and this will never be implemented in the RTP module, rather
the payload router in the future.

BUG=769
R=pbos@webrtc.org

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

Cr-Commit-Position: refs/heads/master@{#8453}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8453 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/video_engine/payload_router_unittest.cc b/webrtc/video_engine/payload_router_unittest.cc
index ff4f9b3..1a479d9 100644
--- a/webrtc/video_engine/payload_router_unittest.cc
+++ b/webrtc/video_engine/payload_router_unittest.cc
@@ -116,6 +116,7 @@
   EXPECT_TRUE(payload_router_->RoutePayload(frame_type_2, payload_type_2, 0, 0,
                                             &payload_2, 1, NULL, &rtp_hdr_2));
 
+  // Inactive.
   payload_router_->set_active(false);
   EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _))
       .Times(0);
@@ -125,6 +126,16 @@
                                              &payload_1, 1, NULL, &rtp_hdr_1));
   EXPECT_FALSE(payload_router_->RoutePayload(frame_type_2, payload_type_2, 0, 0,
                                              &payload_2, 1, NULL, &rtp_hdr_2));
+
+  // Invalid simulcast index.
+  payload_router_->set_active(true);
+  EXPECT_CALL(rtp_1, SendOutgoingData(_, _, _, _, _, _, _, _))
+      .Times(0);
+  EXPECT_CALL(rtp_2, SendOutgoingData(_, _, _, _, _, _, _, _))
+      .Times(0);
+  rtp_hdr_1.simulcastIdx = 2;
+  EXPECT_FALSE(payload_router_->RoutePayload(frame_type_1, payload_type_1, 0, 0,
+                                             &payload_1, 1, NULL, &rtp_hdr_1));
 }
 
 TEST_F(PayloadRouterTest, MaxPayloadLength) {
@@ -257,7 +268,6 @@
   modules.push_back(&rtp_2);
   payload_router_->SetSendingRtpModules(modules);
 
-
   // Default configuration, sending padding on the first sending module.
   const size_t requested_padding_bytes = 1000;
   const size_t sent_padding_bytes = 890;
@@ -302,4 +312,39 @@
   EXPECT_EQ(static_cast<size_t>(0),
             payload_router_->TimeToSendPadding(requested_padding_bytes));
 }
+
+TEST_F(PayloadRouterTest, SetTargetSendBitrates) {
+  MockRtpRtcp rtp_1;
+  MockRtpRtcp rtp_2;
+  std::list<RtpRtcp*> modules;
+  modules.push_back(&rtp_1);
+  modules.push_back(&rtp_2);
+  payload_router_->SetSendingRtpModules(modules);
+
+  const uint32_t bitrate_1 = 10000;
+  const uint32_t bitrate_2 = 76543;
+  std::vector<uint32_t> bitrates (2, bitrate_1);
+  bitrates[1] = bitrate_2;
+  EXPECT_CALL(rtp_1, SetTargetSendBitrate(bitrate_1))
+      .Times(1);
+  EXPECT_CALL(rtp_2, SetTargetSendBitrate(bitrate_2))
+      .Times(1);
+  payload_router_->SetTargetSendBitrates(bitrates);
+
+  bitrates.resize(1);
+  EXPECT_CALL(rtp_1, SetTargetSendBitrate(bitrate_1))
+      .Times(0);
+  EXPECT_CALL(rtp_2, SetTargetSendBitrate(bitrate_2))
+      .Times(0);
+  payload_router_->SetTargetSendBitrates(bitrates);
+
+  bitrates.resize(3);
+  bitrates[1] = bitrate_2;
+  bitrates[2] = bitrate_1 + bitrate_2;
+  EXPECT_CALL(rtp_1, SetTargetSendBitrate(bitrate_1))
+      .Times(1);
+  EXPECT_CALL(rtp_2, SetTargetSendBitrate(bitrate_2))
+      .Times(1);
+  payload_router_->SetTargetSendBitrates(bitrates);
+  }
 }  // namespace webrtc