Adds support for combining RTX and FEC/RED.

This is accomplished by breaking out RTX and FEC/RED functionality from the RTP module and keeping track of the base payload type, that is the payload type received when not receiving RTX.

Enables retransmissions over RTX by default in the loopback test.

BUG=1811
TESTS=voe/vie_auto_test --automated and trybots.
R=mflodman@webrtc.org, pbos@webrtc.org, xians@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@4692 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/modules/rtp_rtcp/test/testAPI/test_api.cc b/modules/rtp_rtcp/test/testAPI/test_api.cc
index 6789e04..78df647 100644
--- a/modules/rtp_rtcp/test/testAPI/test_api.cc
+++ b/modules/rtp_rtcp/test/testAPI/test_api.cc
@@ -110,11 +110,11 @@
   EXPECT_FALSE(module->TMMBR());
 
   EXPECT_EQ(kNackOff, rtp_receiver_->NACK());
-  EXPECT_EQ(0, rtp_receiver_->SetNACKStatus(kNackRtcp, 450));
+  rtp_receiver_->SetNACKStatus(kNackRtcp);
   EXPECT_EQ(kNackRtcp, rtp_receiver_->NACK());
 }
 
-TEST_F(RtpRtcpAPITest, RTXSender) {
+TEST_F(RtpRtcpAPITest, RtxSender) {
   unsigned int ssrc = 0;
   RtxMode rtx_mode = kRtxOff;
   const int kRtxPayloadType = 119;
@@ -138,19 +138,20 @@
   EXPECT_EQ(kRtxPayloadType, payload_type);
 }
 
-TEST_F(RtpRtcpAPITest, RTXReceiver) {
-  bool enable = false;
-  unsigned int ssrc = 0;
+TEST_F(RtpRtcpAPITest, RtxReceiver) {
+  const uint32_t kRtxSsrc = 1;
   const int kRtxPayloadType = 119;
-  int payload_type = -1;
-  rtp_receiver_->SetRTXStatus(true, 1);
-  rtp_receiver_->SetRtxPayloadType(kRtxPayloadType);
-  rtp_receiver_->RTXStatus(&enable, &ssrc, &payload_type);
-  EXPECT_TRUE(enable);
-  EXPECT_EQ(1u, ssrc);
-  EXPECT_EQ(kRtxPayloadType ,payload_type);
-  rtp_receiver_->SetRTXStatus(false, 0);
-  rtp_receiver_->RTXStatus(&enable, &ssrc, &payload_type);
-  EXPECT_FALSE(enable);
-  EXPECT_EQ(kRtxPayloadType ,payload_type);
+  rtp_payload_registry_->SetRtxStatus(true, kRtxSsrc);
+  rtp_payload_registry_->SetRtxPayloadType(kRtxPayloadType);
+  EXPECT_TRUE(rtp_payload_registry_->RtxEnabled());
+  RTPHeader rtx_header;
+  rtx_header.ssrc = kRtxSsrc;
+  rtx_header.payloadType = kRtxPayloadType;
+  EXPECT_TRUE(rtp_payload_registry_->IsRtx(rtx_header));
+  rtx_header.ssrc = 0;
+  EXPECT_FALSE(rtp_payload_registry_->IsRtx(rtx_header));
+  rtp_payload_registry_->SetRtxStatus(false, kRtxSsrc);
+  EXPECT_FALSE(rtp_payload_registry_->RtxEnabled());
+  rtx_header.ssrc = kRtxSsrc;
+  EXPECT_FALSE(rtp_payload_registry_->IsRtx(rtx_header));
 }
diff --git a/modules/rtp_rtcp/test/testAPI/test_api.h b/modules/rtp_rtcp/test/testAPI/test_api.h
index 1a13ab9..8061ce0 100644
--- a/modules/rtp_rtcp/test/testAPI/test_api.h
+++ b/modules/rtp_rtcp/test/testAPI/test_api.h
@@ -60,8 +60,8 @@
         header.payloadType, &payload_specific)) {
       return -1;
     }
-    receive_statistics_->IncomingPacket(header, len, false, true);
-    if (!rtp_receiver_->IncomingRtpPacket(&header,
+    receive_statistics_->IncomingPacket(header, len, false);
+    if (!rtp_receiver_->IncomingRtpPacket(header,
                                           static_cast<const uint8_t*>(data),
                                           len, payload_specific, true)) {
       return -1;
diff --git a/modules/rtp_rtcp/test/testAPI/test_api_video.cc b/modules/rtp_rtcp/test/testAPI/test_api_video.cc
index 6291a34..6f065d5 100644
--- a/modules/rtp_rtcp/test/testAPI/test_api_video.cc
+++ b/modules/rtp_rtcp/test/testAPI/test_api_video.cc
@@ -52,7 +52,7 @@
 
     EXPECT_EQ(0, video_module_->SetRTCPStatus(kRtcpCompound));
     EXPECT_EQ(0, video_module_->SetSSRC(test_ssrc_));
-    EXPECT_EQ(0, rtp_receiver_->SetNACKStatus(kNackRtcp, 450));
+    rtp_receiver_->SetNACKStatus(kNackRtcp);
     EXPECT_EQ(0, video_module_->SetStorePacketsStatus(true, 600));
     EXPECT_EQ(0, video_module_->SetSendingStatus(true));
 
@@ -176,11 +176,13 @@
       PayloadUnion payload_specific;
       EXPECT_TRUE(rtp_payload_registry_.GetPayloadSpecifics(header.payloadType,
                                                            &payload_specific));
-      EXPECT_TRUE(rtp_receiver_->IncomingRtpPacket(&header, padding_packet,
-                                                   packet_size,
+      const uint8_t* payload = padding_packet + header.headerLength;
+      const int payload_length = packet_size - header.headerLength;
+      EXPECT_TRUE(rtp_receiver_->IncomingRtpPacket(header, payload,
+                                                   payload_length,
                                                    payload_specific, true));
       EXPECT_EQ(0, receiver_->payload_size());
-      EXPECT_EQ(packet_size - 12, receiver_->rtp_header().header.paddingLength);
+      EXPECT_EQ(payload_length, receiver_->rtp_header().header.paddingLength);
     }
     timestamp += 3000;
     fake_clock.AdvanceTimeMilliseconds(33);