Fixes a crash when sending SR reports from a sender only module.

BUG=
R=pbos@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4328 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
stefan@webrtc.org 2013-07-11 08:28:35 +00:00
parent aeba6e8740
commit e4736eee20
5 changed files with 26 additions and 9 deletions

View File

@ -69,5 +69,18 @@ class ReceiveStatistics : public Module {
virtual StreamStatistician* GetStatistician(uint32_t ssrc) const = 0;
};
class NullReceiveStatistics : public ReceiveStatistics {
public:
virtual void IncomingPacket(const RTPHeader& rtp_header, size_t bytes,
bool retransmitted, bool in_order) {}
virtual void GetActiveStatisticians(
StatisticianMap* statisticians) const { statisticians->clear(); }
virtual StreamStatistician* GetStatistician(uint32_t ssrc) const {
return NULL;
}
virtual int32_t TimeUntilNextProcess() { return 0; }
virtual int32_t Process() { return 0; }
};
} // namespace webrtc
#endif // WEBRTC_MODULES_RTP_RTCP_INTERFACE_RECEIVE_STATISTICS_H_

View File

@ -1689,14 +1689,12 @@ int RTCPSender::PrepareRTCP(
// If the data does not fit in the packet we fill it as much as possible.
int32_t buildVal = 0;
// We need to send our NTP even if we haven't received any reports.
_clock->CurrentNtp(NTPsec, NTPfrac);
if (ShouldSendReportBlocks(rtcpPacketTypeFlags)) {
ReceiveStatistics::StatisticianMap statisticians;
receive_statistics_->GetActiveStatisticians(&statisticians);
if (statisticians.empty()) {
// We need to send our NTP even if we dont have received any
// reports.
_clock->CurrentNtp(NTPsec, NTPfrac);
} else {
if (!statisticians.empty()) {
ReceiveStatistics::StatisticianMap::const_iterator it;
int i;
for (it = statisticians.begin(), i = 0; it != statisticians.end();
@ -1705,8 +1703,7 @@ int RTCPSender::PrepareRTCP(
if (PrepareReport(it->second, &report_block, &NTPsec, &NTPfrac))
AddReportBlock(it->first, &internal_report_blocks_, &report_block);
}
if (_IJ && !statisticians.empty())
{
if (_IJ && !statisticians.empty()) {
rtcpPacketTypeFlags |= kRtcpTransmissionTimeOffset;
}
_lastRTCPTime[0] = Clock::NtpToMs(NTPsec, NTPfrac);

View File

@ -41,7 +41,7 @@ RtpRtcp::Configuration::Configuration()
audio(false),
clock(NULL),
default_module(NULL),
receive_statistics(),
receive_statistics(NullObjectReceiveStatistics()),
outgoing_transport(NULL),
rtcp_feedback(NULL),
intra_frame_callback(NULL),

View File

@ -61,6 +61,11 @@ RtpAudioFeedback* NullObjectRtpAudioFeedback() {
return &null_rtp_audio_feedback;
}
ReceiveStatistics* NullObjectReceiveStatistics() {
static NullReceiveStatistics null_receive_statistics;
return &null_receive_statistics;
}
namespace ModuleRTPUtility {
enum {

View File

@ -14,6 +14,7 @@
#include <cstddef> // size_t, ptrdiff_t
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
#include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h"
#include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h"
#include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h"
#include "webrtc/typedefs.h"
@ -25,6 +26,7 @@ const uint8_t kRtpMarkerBitMask = 0x80;
RtpData* NullObjectRtpData();
RtpFeedback* NullObjectRtpFeedback();
RtpAudioFeedback* NullObjectRtpAudioFeedback();
ReceiveStatistics* NullObjectReceiveStatistics();
namespace ModuleRTPUtility
{