We now require a manually set sender to send REMB packets.

BUG=
TEST=video_engine_unittests

Review URL: http://webrtc-codereview.appspot.com/348003

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1358 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
mflodman@webrtc.org 2012-01-09 16:16:49 +00:00
parent d9c87b2146
commit 0ab8ba313b
3 changed files with 34 additions and 45 deletions

View File

@ -369,11 +369,10 @@ bool ViEChannelManager::SetRembStatus(int channel_id, bool sender,
channel->EnableRemb(false); channel->EnableRemb(false);
} }
RtpRtcp* rtp_module = channel->rtp_rtcp(); RtpRtcp* rtp_module = channel->rtp_rtcp();
// TODO(mflodman) Add when implemented.
if (sender) { if (sender) {
// remb_->AddSendChannel(rtp_module); remb_->AddSendChannel(rtp_module);
} else { } else {
// remb_->RemoveSendChannel(rtp_module); remb_->RemoveSendChannel(rtp_module);
} }
if (receiver) { if (receiver) {
remb_->AddReceiveChannel(rtp_module); remb_->AddReceiveChannel(rtp_module);

View File

@ -61,7 +61,7 @@ void VieRemb::RemoveReceiveChannel(RtpRtcp* rtp_rtcp) {
unsigned int ssrc = rtp_rtcp->RemoteSSRC(); unsigned int ssrc = rtp_rtcp->RemoteSSRC();
for (RtpModules::iterator it = receive_modules_.begin(); for (RtpModules::iterator it = receive_modules_.begin();
it != receive_modules_.end(); ++it) { it != receive_modules_.end(); ++it) {
if ((*it)->RemoteSSRC() == ssrc) { if ((*it) == rtp_rtcp) {
receive_modules_.erase(it); receive_modules_.erase(it);
break; break;
} }
@ -73,16 +73,28 @@ void VieRemb::AddSendChannel(RtpRtcp* rtp_rtcp) {
WEBRTC_TRACE(kTraceStateInfo, kTraceVideo, engine_id_, WEBRTC_TRACE(kTraceStateInfo, kTraceVideo, engine_id_,
"VieRemb::AddSendChannel"); "VieRemb::AddSendChannel");
assert(rtp_rtcp); assert(rtp_rtcp);
assert(false);
return; CriticalSectionScoped cs(list_crit_.get());
// TODO(mflodman) Allow multiple senders.
assert(send_modules_.empty());
send_modules_.push_back(rtp_rtcp);
} }
void VieRemb::RemoveSendChannel(RtpRtcp* rtp_rtcp) { void VieRemb::RemoveSendChannel(RtpRtcp* rtp_rtcp) {
WEBRTC_TRACE(kTraceStateInfo, kTraceVideo, engine_id_, WEBRTC_TRACE(kTraceStateInfo, kTraceVideo, engine_id_,
"VieRemb::AddSendChannel"); "VieRemb::AddSendChannel");
assert(rtp_rtcp); assert(rtp_rtcp);
assert(false);
return; CriticalSectionScoped cs(list_crit_.get());
for (RtpModules::iterator it = send_modules_.begin();
it != send_modules_.end(); ++it) {
if ((*it) == rtp_rtcp) {
send_modules_.erase(it);
return;
}
}
} }
void VieRemb::OnReceiveBitrateChanged(unsigned int ssrc, unsigned int bitrate) { void VieRemb::OnReceiveBitrateChanged(unsigned int ssrc, unsigned int bitrate) {
@ -151,14 +163,6 @@ WebRtc_Word32 VieRemb::Process() {
RtpRtcp* sender = NULL; RtpRtcp* sender = NULL;
if (!send_modules_.empty()) { if (!send_modules_.empty()) {
sender = send_modules_.front(); sender = send_modules_.front();
} else {
for (RtpModules::iterator it = receive_modules_.begin();
it != receive_modules_.end(); ++it) {
if ((*it)->Sending()) {
sender = *it;
break;
}
}
} }
last_send_bitrate_ = total_bitrate; last_send_bitrate_ = total_bitrate;
list_crit_->Leave(); list_crit_->Leave();

View File

@ -47,10 +47,8 @@ class ViERembTest : public ::testing::Test {
TEST_F(ViERembTest, OneModuleTestForSendingRemb) TEST_F(ViERembTest, OneModuleTestForSendingRemb)
{ {
MockRtpRtcp rtp; MockRtpRtcp rtp;
EXPECT_CALL(rtp, Sending())
.WillRepeatedly(Return(true));
vie_remb_->AddReceiveChannel(&rtp); vie_remb_->AddReceiveChannel(&rtp);
vie_remb_->AddSendChannel(&rtp);
const unsigned int bitrate_estimate = 456; const unsigned int bitrate_estimate = 456;
unsigned int ssrc[] = { 1234 }; unsigned int ssrc[] = { 1234 };
@ -72,15 +70,14 @@ TEST_F(ViERembTest, OneModuleTestForSendingRemb)
vie_remb_->Process(); vie_remb_->Process();
vie_remb_->RemoveReceiveChannel(&rtp); vie_remb_->RemoveReceiveChannel(&rtp);
vie_remb_->RemoveSendChannel(&rtp);
} }
TEST_F(ViERembTest, LowerEstimateToSendRemb) TEST_F(ViERembTest, LowerEstimateToSendRemb)
{ {
MockRtpRtcp rtp; MockRtpRtcp rtp;
EXPECT_CALL(rtp, Sending())
.WillRepeatedly(Return(true));
vie_remb_->AddReceiveChannel(&rtp); vie_remb_->AddReceiveChannel(&rtp);
vie_remb_->AddSendChannel(&rtp);
unsigned int bitrate_estimate = 456; unsigned int bitrate_estimate = 456;
unsigned int ssrc[] = { 1234 }; unsigned int ssrc[] = { 1234 };
@ -101,13 +98,9 @@ TEST_F(ViERembTest, LowerEstimateToSendRemb)
TEST_F(ViERembTest, VerifyCombinedBitrateEstimate) TEST_F(ViERembTest, VerifyCombinedBitrateEstimate)
{ {
MockRtpRtcp rtp_0; MockRtpRtcp rtp_0;
EXPECT_CALL(rtp_0, Sending())
.WillRepeatedly(Return(true));
MockRtpRtcp rtp_1; MockRtpRtcp rtp_1;
EXPECT_CALL(rtp_1, Sending())
.WillRepeatedly(Return(true));
vie_remb_->AddReceiveChannel(&rtp_0); vie_remb_->AddReceiveChannel(&rtp_0);
vie_remb_->AddSendChannel(&rtp_0);
vie_remb_->AddReceiveChannel(&rtp_1); vie_remb_->AddReceiveChannel(&rtp_1);
unsigned int bitrate_estimate[] = { 456, 789 }; unsigned int bitrate_estimate[] = { 456, 789 };
@ -131,19 +124,16 @@ TEST_F(ViERembTest, VerifyCombinedBitrateEstimate)
vie_remb_->Process(); vie_remb_->Process();
vie_remb_->RemoveReceiveChannel(&rtp_0); vie_remb_->RemoveReceiveChannel(&rtp_0);
vie_remb_->RemoveSendChannel(&rtp_0);
vie_remb_->RemoveReceiveChannel(&rtp_1); vie_remb_->RemoveReceiveChannel(&rtp_1);
} }
TEST_F(ViERembTest, NoRembForIncreasedBitrate) TEST_F(ViERembTest, NoRembForIncreasedBitrate)
{ {
MockRtpRtcp rtp_0; MockRtpRtcp rtp_0;
EXPECT_CALL(rtp_0, Sending())
.WillRepeatedly(Return(true));
MockRtpRtcp rtp_1; MockRtpRtcp rtp_1;
EXPECT_CALL(rtp_1, Sending())
.WillRepeatedly(Return(true));
vie_remb_->AddReceiveChannel(&rtp_0); vie_remb_->AddReceiveChannel(&rtp_0);
vie_remb_->AddSendChannel(&rtp_0);
vie_remb_->AddReceiveChannel(&rtp_1); vie_remb_->AddReceiveChannel(&rtp_1);
unsigned int bitrate_estimate[] = { 456, 789 }; unsigned int bitrate_estimate[] = { 456, 789 };
@ -181,18 +171,15 @@ TEST_F(ViERembTest, NoRembForIncreasedBitrate)
vie_remb_->Process(); vie_remb_->Process();
vie_remb_->RemoveReceiveChannel(&rtp_1); vie_remb_->RemoveReceiveChannel(&rtp_1);
vie_remb_->RemoveReceiveChannel(&rtp_0); vie_remb_->RemoveReceiveChannel(&rtp_0);
vie_remb_->RemoveSendChannel(&rtp_0);
} }
TEST_F(ViERembTest, ChangeSendRtpModule) TEST_F(ViERembTest, ChangeSendRtpModule)
{ {
MockRtpRtcp rtp_0; MockRtpRtcp rtp_0;
EXPECT_CALL(rtp_0, Sending())
.WillRepeatedly(Return(true));
MockRtpRtcp rtp_1; MockRtpRtcp rtp_1;
EXPECT_CALL(rtp_1, Sending())
.WillRepeatedly(Return(true));
vie_remb_->AddReceiveChannel(&rtp_0); vie_remb_->AddReceiveChannel(&rtp_0);
vie_remb_->AddSendChannel(&rtp_0);
vie_remb_->AddReceiveChannel(&rtp_1); vie_remb_->AddReceiveChannel(&rtp_1);
unsigned int bitrate_estimate[] = { 456, 789 }; unsigned int bitrate_estimate[] = { 456, 789 };
@ -218,8 +205,8 @@ TEST_F(ViERembTest, ChangeSendRtpModule)
// Remove the sending module, add it again -> should get remb on the second // Remove the sending module, add it again -> should get remb on the second
// module. // module.
vie_remb_->RemoveReceiveChannel(&rtp_0); vie_remb_->RemoveSendChannel(&rtp_0);
vie_remb_->AddReceiveChannel(&rtp_0); vie_remb_->AddSendChannel(&rtp_1);
vie_remb_->OnReceiveBitrateChanged(ssrc[0], bitrate_estimate[0]); vie_remb_->OnReceiveBitrateChanged(ssrc[0], bitrate_estimate[0]);
bitrate_estimate[1] = bitrate_estimate[1] - 100; bitrate_estimate[1] = bitrate_estimate[1] - 100;
@ -231,18 +218,17 @@ TEST_F(ViERembTest, ChangeSendRtpModule)
vie_remb_->RemoveReceiveChannel(&rtp_0); vie_remb_->RemoveReceiveChannel(&rtp_0);
vie_remb_->RemoveReceiveChannel(&rtp_1); vie_remb_->RemoveReceiveChannel(&rtp_1);
vie_remb_->RemoveSendChannel(&rtp_1);
} }
TEST_F(ViERembTest, OnlyOneRembForDoubleProcess) TEST_F(ViERembTest, OnlyOneRembForDoubleProcess)
{ {
MockRtpRtcp rtp; MockRtpRtcp rtp;
EXPECT_CALL(rtp, Sending())
.WillRepeatedly(Return(true));
unsigned int bitrate_estimate = 456; unsigned int bitrate_estimate = 456;
unsigned int ssrc[] = { 1234 }; unsigned int ssrc[] = { 1234 };
vie_remb_->AddReceiveChannel(&rtp); vie_remb_->AddReceiveChannel(&rtp);
vie_remb_->AddSendChannel(&rtp);
vie_remb_->OnReceiveBitrateChanged(ssrc[0], bitrate_estimate); vie_remb_->OnReceiveBitrateChanged(ssrc[0], bitrate_estimate);
EXPECT_CALL(rtp, RemoteSSRC()) EXPECT_CALL(rtp, RemoteSSRC())
.WillRepeatedly(Return(ssrc[0])); .WillRepeatedly(Return(ssrc[0]));
@ -259,6 +245,7 @@ TEST_F(ViERembTest, OnlyOneRembForDoubleProcess)
.Times(0); .Times(0);
vie_remb_->Process(); vie_remb_->Process();
vie_remb_->RemoveReceiveChannel(&rtp); vie_remb_->RemoveReceiveChannel(&rtp);
vie_remb_->RemoveSendChannel(&rtp);
} }
TEST_F(ViERembTest, NoOnReceivedBitrateChangedCall) TEST_F(ViERembTest, NoOnReceivedBitrateChangedCall)
@ -268,6 +255,7 @@ TEST_F(ViERembTest, NoOnReceivedBitrateChangedCall)
.WillRepeatedly(Return(1234)); .WillRepeatedly(Return(1234));
vie_remb_->AddReceiveChannel(&rtp); vie_remb_->AddReceiveChannel(&rtp);
vie_remb_->AddSendChannel(&rtp);
// TODO(mflodman) Add fake clock. // TODO(mflodman) Add fake clock.
TestSleep(1010); TestSleep(1010);
// No bitrate estimate given, no callback expected. // No bitrate estimate given, no callback expected.
@ -276,14 +264,12 @@ TEST_F(ViERembTest, NoOnReceivedBitrateChangedCall)
vie_remb_->Process(); vie_remb_->Process();
vie_remb_->RemoveReceiveChannel(&rtp); vie_remb_->RemoveReceiveChannel(&rtp);
vie_remb_->RemoveSendChannel(&rtp);
} }
TEST_F(ViERembTest, NoSendingRtpModule) TEST_F(ViERembTest, NoSendingRtpModule)
{ {
MockRtpRtcp rtp; MockRtpRtcp rtp;
EXPECT_CALL(rtp, Sending())
.WillRepeatedly(Return(false));
vie_remb_->AddReceiveChannel(&rtp); vie_remb_->AddReceiveChannel(&rtp);
unsigned int bitrate_estimate = 456; unsigned int bitrate_estimate = 456;