Moving the pacer and the pacer thread to ChannelGroup.

This means all channels within the same group will share the same pacing queue and scheduler. It also means padding will be computed and sent by a single pacer. To accomplish this I also introduce a PacketRouter which finds the RTP module which owns the packet to be paced out.

BUG=4323
R=mflodman@webrtc.org, pbos@webrtc.org

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

Cr-Commit-Position: refs/heads/master@{#8864}
This commit is contained in:
Stefan Holmer
2015-03-26 11:11:06 +01:00
parent 5225dd8180
commit e590416722
47 changed files with 928 additions and 687 deletions

View File

@ -172,147 +172,6 @@ TEST_F(PayloadRouterTest, MaxPayloadLength) {
EXPECT_EQ(kTestMinPayloadLength, payload_router_->MaxPayloadLength());
}
TEST_F(PayloadRouterTest, TimeToSendPacket) {
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 uint16_t kSsrc1 = 1234;
uint16_t sequence_number = 17;
uint64_t timestamp = 7890;
bool retransmission = false;
// Send on the first module by letting rtp_1 be sending with correct ssrc.
EXPECT_CALL(rtp_1, SendingMedia())
.Times(1)
.WillOnce(Return(true));
EXPECT_CALL(rtp_1, SSRC())
.Times(1)
.WillOnce(Return(kSsrc1));
EXPECT_CALL(rtp_1, TimeToSendPacket(kSsrc1, sequence_number, timestamp,
retransmission))
.Times(1)
.WillOnce(Return(true));
EXPECT_CALL(rtp_2, TimeToSendPacket(_, _, _, _))
.Times(0);
EXPECT_TRUE(payload_router_->TimeToSendPacket(
kSsrc1, sequence_number, timestamp, retransmission));
// Send on the second module by letting rtp_2 be sending, but not rtp_1.
++sequence_number;
timestamp += 30;
retransmission = true;
const uint16_t kSsrc2 = 4567;
EXPECT_CALL(rtp_1, SendingMedia())
.Times(1)
.WillOnce(Return(false));
EXPECT_CALL(rtp_2, SendingMedia())
.Times(1)
.WillOnce(Return(true));
EXPECT_CALL(rtp_2, SSRC())
.Times(1)
.WillOnce(Return(kSsrc2));
EXPECT_CALL(rtp_1, TimeToSendPacket(_, _, _, _))
.Times(0);
EXPECT_CALL(rtp_2, TimeToSendPacket(kSsrc2, sequence_number, timestamp,
retransmission))
.Times(1)
.WillOnce(Return(true));
EXPECT_TRUE(payload_router_->TimeToSendPacket(
kSsrc2, sequence_number, timestamp, retransmission));
// No module is sending, hence no packet should be sent.
EXPECT_CALL(rtp_1, SendingMedia())
.Times(1)
.WillOnce(Return(false));
EXPECT_CALL(rtp_1, TimeToSendPacket(_, _, _,_))
.Times(0);
EXPECT_CALL(rtp_2, SendingMedia())
.Times(1)
.WillOnce(Return(false));
EXPECT_CALL(rtp_2, TimeToSendPacket(_, _, _, _))
.Times(0);
EXPECT_TRUE(payload_router_->TimeToSendPacket(
kSsrc1, sequence_number, timestamp, retransmission));
// Add a packet with incorrect ssrc and test it's dropped in the router.
EXPECT_CALL(rtp_1, SendingMedia())
.Times(1)
.WillOnce(Return(true));
EXPECT_CALL(rtp_1, SSRC())
.Times(1)
.WillOnce(Return(kSsrc1));
EXPECT_CALL(rtp_2, SendingMedia())
.Times(1)
.WillOnce(Return(true));
EXPECT_CALL(rtp_2, SSRC())
.Times(1)
.WillOnce(Return(kSsrc2));
EXPECT_CALL(rtp_1, TimeToSendPacket(_, _, _,_))
.Times(0);
EXPECT_CALL(rtp_2, TimeToSendPacket(_, _, _, _))
.Times(0);
EXPECT_TRUE(payload_router_->TimeToSendPacket(
kSsrc1 + kSsrc2, sequence_number, timestamp, retransmission));
}
TEST_F(PayloadRouterTest, TimeToSendPadding) {
MockRtpRtcp rtp_1;
MockRtpRtcp rtp_2;
std::list<RtpRtcp*> modules;
modules.push_back(&rtp_1);
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;
EXPECT_CALL(rtp_1, SendingMedia())
.Times(1)
.WillOnce(Return(true));
EXPECT_CALL(rtp_1, TimeToSendPadding(requested_padding_bytes))
.Times(1)
.WillOnce(Return(sent_padding_bytes));
EXPECT_CALL(rtp_2, TimeToSendPadding(_))
.Times(0);
EXPECT_EQ(sent_padding_bytes,
payload_router_->TimeToSendPadding(requested_padding_bytes));
// Let only the second module be sending and verify the padding request is
// routed there.
EXPECT_CALL(rtp_1, SendingMedia())
.Times(1)
.WillOnce(Return(false));
EXPECT_CALL(rtp_1, TimeToSendPadding(requested_padding_bytes))
.Times(0);
EXPECT_CALL(rtp_2, SendingMedia())
.Times(1)
.WillOnce(Return(true));
EXPECT_CALL(rtp_2, TimeToSendPadding(_))
.Times(1)
.WillOnce(Return(sent_padding_bytes));
EXPECT_EQ(sent_padding_bytes,
payload_router_->TimeToSendPadding(requested_padding_bytes));
// No sending module at all.
EXPECT_CALL(rtp_1, SendingMedia())
.Times(1)
.WillOnce(Return(false));
EXPECT_CALL(rtp_1, TimeToSendPadding(requested_padding_bytes))
.Times(0);
EXPECT_CALL(rtp_2, SendingMedia())
.Times(1)
.WillOnce(Return(false));
EXPECT_CALL(rtp_2, TimeToSendPadding(_))
.Times(0);
EXPECT_EQ(static_cast<size_t>(0),
payload_router_->TimeToSendPadding(requested_padding_bytes));
}
TEST_F(PayloadRouterTest, SetTargetSendBitrates) {
MockRtpRtcp rtp_1;
MockRtpRtcp rtp_2;
@ -346,5 +205,5 @@ TEST_F(PayloadRouterTest, SetTargetSendBitrates) {
EXPECT_CALL(rtp_2, SetTargetSendBitrate(bitrate_2))
.Times(1);
payload_router_->SetTargetSendBitrates(bitrates);
}
}
} // namespace webrtc