Added API for getting the send-side estimated bandwidth.

BUG=
TEST=

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1591 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
stefan@webrtc.org 2012-02-02 08:37:48 +00:00
parent ac7e89ff1c
commit 07b45a5dc4
12 changed files with 95 additions and 12 deletions

View File

@ -566,6 +566,12 @@ public:
WebRtc_UWord32* fecRate,
WebRtc_UWord32* nackRate) const = 0;
/*
* Get the send-side estimate of the available bandwidth.
*/
virtual int EstimatedBandwidth(
WebRtc_UWord32* available_bandwidth) const = 0;
/*
* Used by the codec module to deliver a video or audio frame for packetization
*

View File

@ -1,3 +1,13 @@
/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "../testing/gmock/include/gmock/gmock.h"
#include "modules/interface/module.h"
@ -132,6 +142,8 @@ class MockRtpRtcp : public RtpRtcp {
bool());
MOCK_CONST_METHOD4(BitrateSent,
void(WebRtc_UWord32* totalRate, WebRtc_UWord32* videoRate, WebRtc_UWord32* fecRate, WebRtc_UWord32* nackRate));
MOCK_CONST_METHOD1(EstimatedBandwidth,
int(WebRtc_UWord32* available_bandwidth));
MOCK_METHOD7(SendOutgoingData,
WebRtc_Word32(const FrameType frameType, const WebRtc_Word8 payloadType, const WebRtc_UWord32 timeStamp, const WebRtc_UWord8* payloadData, const WebRtc_UWord32 payloadSize, const RTPFragmentationHeader* fragmentation, const RTPVideoHeader* rtpVideoHdr));
MOCK_METHOD1(RegisterIncomingRTCPCallback,

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -182,6 +182,19 @@ WebRtc_Word32 BandwidthManagement::UpdatePacketLoss(
return 0;
}
WebRtc_Word32 BandwidthManagement::AvailableBandwidth(
WebRtc_UWord32* bandwidthKbit) const {
CriticalSectionScoped cs(_critsect);
if (_bitRate == 0) {
return -1;
}
if (!bandwidthKbit) {
return -1;
}
*bandwidthKbit = _bitRate;
return 0;
}
/* Calculate the rate that TCP-Friendly Rate Control (TFRC) would apply.
* The formula in RFC 3448, Section 3.1, is used.
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -41,7 +41,9 @@ public:
WebRtc_UWord32* newBitrate,
WebRtc_Word64 nowMS);
WebRtc_Word32 AvailableBandwidth(WebRtc_UWord16* bandwidthKbit) const;
// If no bandwidth estimate is available or if |bandwidthKbit| is NULL,
// -1 is returned.
WebRtc_Word32 AvailableBandwidth(WebRtc_UWord32* bandwidthKbit) const;
void SetSendBitrate(const WebRtc_UWord32 startBitrate,
const WebRtc_UWord16 minBitrateKbit,

View File

@ -2501,6 +2501,11 @@ void ModuleRtpRtcpImpl::BitrateSent(WebRtc_UWord32* totalRate,
*nackRate = _rtpSender.NackOverheadRate();
}
int ModuleRtpRtcpImpl::EstimatedBandwidth(
WebRtc_UWord32* available_bandwidth) const {
return _bandwidthManagement.AvailableBandwidth(available_bandwidth);
}
// for lip sync
void ModuleRtpRtcpImpl::OnReceivedNTP() {
// don't do anything if we are the audio module

View File

@ -491,6 +491,8 @@ public:
WebRtc_UWord32* fecRate,
WebRtc_UWord32* nackRate) const;
virtual int EstimatedBandwidth(WebRtc_UWord32* available_bandwidth) const;
virtual void SetRemoteSSRC(const WebRtc_UWord32 SSRC);
virtual WebRtc_UWord32 SendTimeOfSendReport(const WebRtc_UWord32 sendReport);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -242,6 +242,12 @@ class WEBRTC_DLLEXPORT ViERTP_RTCP {
unsigned int& fec_bitrate_sent,
unsigned int& nackBitrateSent) const = 0;
// This function gets the send-side estimated bandwidth available for video,
// including overhead, in bits/s.
virtual int GetEstimatedBandwidth(
const int video_channel,
unsigned int* estimated_bandwidth) const = 0;
// This function enables or disables an RTP keep-alive mechanism which can
// be used to maintain an existing Network Address Translator (NAT) mapping
// while regular RTP is no longer transmitted.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -221,6 +221,11 @@ void ViEAutoTest::ViERtpRtcpStandardTest()
EXPECT_GT(recJitter, 0u);
EXPECT_GT(recRttMs, 0);
unsigned int estimated_bandwidth = 0;
EXPECT_EQ(0, ViE.rtp_rtcp->GetEstimatedBandwidth(tbChannel.videoChannel,
&estimated_bandwidth));
EXPECT_GT(estimated_bandwidth, 0u);
// Check that rec stats extended max is greater than what we've sent.
EXPECT_GE(recExtendedMax, sentExtendedMax);
EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel));

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -560,6 +560,13 @@ WebRtc_Word32 ViEEncoder::SendCodecStatistics(
return 0;
}
WebRtc_Word32 ViEEncoder::EstimatedBandwidth(
WebRtc_UWord32* available_bandwidth) const {
WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_), "%s",
__FUNCTION__);
return default_rtp_rtcp_.EstimatedBandwidth(available_bandwidth);
}
WebRtc_Word32 ViEEncoder::UpdateProtectionMethod() {
bool fec_enabled = false;
WebRtc_UWord8 dummy_ptype_red = 0;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -88,6 +88,7 @@ class ViEEncoder
WebRtc_Word32 SendKeyFrame();
WebRtc_Word32 SendCodecStatistics(WebRtc_UWord32& num_key_frames,
WebRtc_UWord32& num_delta_frames);
WebRtc_Word32 EstimatedBandwidth(WebRtc_UWord32* available_bandwidth) const;
// Loss protection.
WebRtc_Word32 UpdateProtectionMethod();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -733,6 +733,26 @@ int ViERTP_RTCPImpl::GetBandwidthUsage(const int video_channel,
return 0;
}
int ViERTP_RTCPImpl::GetEstimatedBandwidth(
const int video_channel,
unsigned int* estimated_bandwidth) const {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(channel: %d)", __FUNCTION__, video_channel);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEEncoder* vie_encoder = cs.Encoder(video_channel);
if (!vie_encoder) {
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: Could not get encoder for channel %d", __FUNCTION__,
video_channel);
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1;
}
return vie_encoder->EstimatedBandwidth(
static_cast<WebRtc_UWord32*>(estimated_bandwidth));
}
int ViERTP_RTCPImpl::SetRTPKeepAliveStatus(
const int video_channel,
bool enable,

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -87,9 +87,13 @@ class ViERTP_RTCPImpl
unsigned int& video_bitrate_sent,
unsigned int& fec_bitrate_sent,
unsigned int& nackBitrateSent) const;
virtual int SetRTPKeepAliveStatus(const int video_channel,
bool enable,
const char unknown_payload_type,
virtual int GetEstimatedBandwidth(
const int video_channel,
unsigned int* estimated_bandwidth) const;
virtual int SetRTPKeepAliveStatus(
const int video_channel,
bool enable,
const char unknown_payload_type,
const unsigned int delta_transmit_time_seconds);
virtual int GetRTPKeepAliveStatus(
const int video_channel,