Convert logs in rtp rtcp module from WEBRTC_TRACE into LOG.

Clean some logs and add asserts in the way.

BUG=3153
R=mflodman@webrtc.org, stefan@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5861 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
andresp@webrtc.org 2014-04-08 11:06:12 +00:00
parent b287d968d9
commit dc80bae2a6
44 changed files with 227 additions and 792 deletions

View File

@ -18,7 +18,7 @@ namespace webrtc {
class FecReceiver {
public:
static FecReceiver* Create(int32_t id, RtpData* callback);
static FecReceiver* Create(RtpData* callback);
virtual ~FecReceiver() {}

View File

@ -54,8 +54,7 @@ class RTPPayloadStrategy {
class RTPPayloadRegistry {
public:
// The registry takes ownership of the strategy.
RTPPayloadRegistry(const int32_t id,
RTPPayloadStrategy* rtp_payload_strategy);
RTPPayloadRegistry(RTPPayloadStrategy* rtp_payload_strategy);
~RTPPayloadRegistry();
int32_t RegisterReceivePayload(
@ -153,7 +152,6 @@ class RTPPayloadRegistry {
scoped_ptr<CriticalSectionWrapper> crit_sect_;
ModuleRTPUtility::PayloadTypeMap payload_type_map_;
int32_t id_;
scoped_ptr<RTPPayloadStrategy> rtp_payload_strategy_;
int8_t red_payload_type_;
int8_t ulpfec_payload_type_;

View File

@ -16,20 +16,19 @@
#include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
#include "webrtc/system_wrappers/interface/trace.h"
#include "webrtc/system_wrappers/interface/logging.h"
// RFC 5109
namespace webrtc {
FecReceiver* FecReceiver::Create(int32_t id, RtpData* callback) {
return new FecReceiverImpl(id, callback);
FecReceiver* FecReceiver::Create(RtpData* callback) {
return new FecReceiverImpl(callback);
}
FecReceiverImpl::FecReceiverImpl(const int32_t id, RtpData* callback)
: id_(id),
crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
FecReceiverImpl::FecReceiverImpl(RtpData* callback)
: crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
recovered_packet_callback_(callback),
fec_(new ForwardErrorCorrection(id)) {}
fec_(new ForwardErrorCorrection()) {}
FecReceiverImpl::~FecReceiverImpl() {
while (!received_packet_list_.empty()) {
@ -103,8 +102,7 @@ int32_t FecReceiverImpl::AddReceivedRedPacket(
if (timestamp_offset != 0) {
// |timestampOffset| should be 0. However, it's possible this is the first
// location a corrupt payload can be caught, so don't assert.
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, id_,
"Corrupt payload found in %s", __FUNCTION__);
LOG(LS_WARNING) << "Corrupt payload found.";
delete received_packet;
return -1;
}

View File

@ -25,7 +25,7 @@ class CriticalSectionWrapper;
class FecReceiverImpl : public FecReceiver {
public:
FecReceiverImpl(const int32_t id, RtpData* callback);
FecReceiverImpl(RtpData* callback);
virtual ~FecReceiverImpl();
virtual int32_t AddReceivedRedPacket(const RTPHeader& rtp_header,
@ -36,7 +36,6 @@ class FecReceiverImpl : public FecReceiver {
virtual int32_t ProcessReceivedFec() OVERRIDE;
private:
int id_;
scoped_ptr<CriticalSectionWrapper> crit_sect_;
RtpData* recovered_packet_callback_;
ForwardErrorCorrection* fec_;

View File

@ -39,8 +39,8 @@ class MockRtpData : public RtpData {
class ReceiverFecTest : public ::testing::Test {
protected:
virtual void SetUp() {
fec_ = new ForwardErrorCorrection(0);
receiver_fec_ = FecReceiver::Create(0, &rtp_data_callback_);
fec_ = new ForwardErrorCorrection();
receiver_fec_ = FecReceiver::Create(&rtp_data_callback_);
generator_ = new FrameGenerator();
}

View File

@ -20,7 +20,7 @@
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
#include "webrtc/modules/rtp_rtcp/source/forward_error_correction_internal.h"
#include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
#include "webrtc/system_wrappers/interface/trace.h"
#include "webrtc/system_wrappers/interface/logging.h"
namespace webrtc {
@ -82,9 +82,8 @@ ForwardErrorCorrection::ReceivedPacket::~ReceivedPacket() {}
ForwardErrorCorrection::RecoveredPacket::RecoveredPacket() {}
ForwardErrorCorrection::RecoveredPacket::~RecoveredPacket() {}
ForwardErrorCorrection::ForwardErrorCorrection(int32_t id)
: id_(id),
generated_fec_packets_(kMaxMediaPackets),
ForwardErrorCorrection::ForwardErrorCorrection()
: generated_fec_packets_(kMaxMediaPackets),
fec_packet_received_(false) {}
ForwardErrorCorrection::~ForwardErrorCorrection() {}
@ -112,43 +111,23 @@ int32_t ForwardErrorCorrection::GenerateFEC(const PacketList& media_packet_list,
bool use_unequal_protection,
FecMaskType fec_mask_type,
PacketList* fec_packet_list) {
if (media_packet_list.empty()) {
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, id_,
"%s media packet list is empty", __FUNCTION__);
return -1;
}
if (!fec_packet_list->empty()) {
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, id_,
"%s FEC packet list is not empty", __FUNCTION__);
return -1;
}
const uint16_t num_media_packets = media_packet_list.size();
// Sanity check arguments.
assert(num_media_packets > 0);
assert(num_important_packets >= 0 &&
num_important_packets <= num_media_packets);
assert(fec_packet_list->empty());
if (num_media_packets > kMaxMediaPackets) {
LOG(LS_WARNING) << "Can't protect " << num_media_packets
<< " media packets per frame. Max is " << kMaxMediaPackets;
return -1;
}
bool l_bit = (num_media_packets > 8 * kMaskSizeLBitClear);
int num_maskBytes = l_bit ? kMaskSizeLBitSet : kMaskSizeLBitClear;
if (num_media_packets > kMaxMediaPackets) {
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, id_,
"%s can only protect %d media packets per frame; %d requested",
__FUNCTION__, kMaxMediaPackets, num_media_packets);
return -1;
}
// Error checking on the number of important packets.
// Can't have more important packets than media packets.
if (num_important_packets > num_media_packets) {
WEBRTC_TRACE(
kTraceError, kTraceRtpRtcp, id_,
"Number of important packets (%d) greater than number of media "
"packets (%d)",
num_important_packets, num_media_packets);
return -1;
}
if (num_important_packets < 0) {
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, id_,
"Number of important packets (%d) less than zero",
num_important_packets);
return -1;
}
// Do some error checking on the media packets.
PacketList::const_iterator media_list_it = media_packet_list.begin();
while (media_list_it != media_packet_list.end()) {
@ -156,20 +135,16 @@ int32_t ForwardErrorCorrection::GenerateFEC(const PacketList& media_packet_list,
assert(media_packet);
if (media_packet->length < kRtpHeaderSize) {
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, id_,
"%s media packet (%d bytes) is smaller than RTP header",
__FUNCTION__, media_packet->length);
LOG(LS_WARNING) << "Media packet " << media_packet->length << " bytes "
<< "is smaller than RTP header.";
return -1;
}
// Ensure our FEC packets will fit in a typical MTU.
if (media_packet->length + PacketOverhead() + kTransportOverhead >
IP_PACKET_SIZE) {
WEBRTC_TRACE(
kTraceError, kTraceRtpRtcp, id_,
"%s media packet (%d bytes) with overhead is larger than MTU(%d)",
__FUNCTION__, media_packet->length, IP_PACKET_SIZE);
return -1;
LOG(LS_WARNING) << "Media packet " << media_packet->length << " bytes "
<< "with overhead is larger than " << IP_PACKET_SIZE;
}
media_list_it++;
}
@ -582,9 +557,7 @@ void ForwardErrorCorrection::InsertFECPacket(
}
if (fec_packet->protected_pkt_list.empty()) {
// All-zero packet mask; we can discard this FEC packet.
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, id_,
"FEC packet %u has an all-zero packet mask.",
fec_packet->seq_num, __FUNCTION__);
LOG(LS_WARNING) << "FEC packet has an all-zero packet mask.";
delete fec_packet;
} else {
AssignRecoveredPackets(fec_packet, recovered_packet_list);

View File

@ -117,8 +117,7 @@ class ForwardErrorCorrection {
typedef std::list<ReceivedPacket*> ReceivedPacketList;
typedef std::list<RecoveredPacket*> RecoveredPacketList;
// \param[in] id Module ID
ForwardErrorCorrection(int32_t id);
ForwardErrorCorrection();
virtual ~ForwardErrorCorrection();
@ -304,7 +303,6 @@ class ForwardErrorCorrection {
static void DiscardOldPackets(RecoveredPacketList* recovered_packet_list);
static uint16_t ParseSequenceNumber(uint8_t* packet);
int32_t id_;
std::vector<Packet> generated_fec_packets_;
FecPacketList fec_packet_list_;
bool fec_packet_received_;

View File

@ -164,7 +164,7 @@ class RtxLoopBackTransport : public webrtc::Transport {
class RtpRtcpRtxNackTest : public ::testing::Test {
protected:
RtpRtcpRtxNackTest()
: rtp_payload_registry_(0, RTPPayloadStrategy::CreateStrategy(false)),
: rtp_payload_registry_(RTPPayloadStrategy::CreateStrategy(false)),
rtp_rtcp_module_(NULL),
transport_(kTestSsrc + 1),
receiver_(),

View File

@ -39,7 +39,7 @@ void VerifyHeader(uint16_t seq_num,
class ProducerFecTest : public ::testing::Test {
protected:
virtual void SetUp() {
fec_ = new ForwardErrorCorrection(0);
fec_ = new ForwardErrorCorrection();
producer_ = new ProducerFec(fec_);
generator_ = new FrameGenerator;
}

View File

@ -11,7 +11,7 @@
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h"
#include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
#include "webrtc/system_wrappers/interface/trace.h"
#include "webrtc/system_wrappers/interface/logging.h"
namespace webrtc {
namespace rtcp {
@ -233,8 +233,7 @@ void SenderReport::Create(uint8_t* packet,
uint16_t* len,
uint16_t max_len) const {
if (*len + Length() > max_len) {
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, -1,
"Max packet size reached, skipped SR.");
LOG(LS_WARNING) << "Max packet size reached.";
return;
}
CreateSenderReport(sr_, packet, len);
@ -244,8 +243,7 @@ void SenderReport::Create(uint8_t* packet,
void SenderReport::WithReportBlock(ReportBlock* block) {
assert(block);
if (report_blocks_.size() >= kMaxNumberOfReportBlocks) {
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, -1,
"Max report block size reached.");
LOG(LS_WARNING) << "Max report blocks reached.";
return;
}
report_blocks_.push_back(block);
@ -256,8 +254,7 @@ void ReceiverReport::Create(uint8_t* packet,
uint16_t* len,
uint16_t max_len) const {
if (*len + Length() > max_len) {
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, -1,
"Max packet size reached, skipped RR.");
LOG(LS_WARNING) << "Max packet size reached.";
return;
}
CreateReceiverReport(rr_, packet, len);
@ -267,8 +264,7 @@ void ReceiverReport::Create(uint8_t* packet,
void ReceiverReport::WithReportBlock(ReportBlock* block) {
assert(block);
if (report_blocks_.size() >= kMaxNumberOfReportBlocks) {
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, -1,
"Max report block size reached.");
LOG(LS_WARNING) << "Max report blocks reached.";
return;
}
report_blocks_.push_back(block);
@ -277,8 +273,7 @@ void ReceiverReport::WithReportBlock(ReportBlock* block) {
void Bye::Create(uint8_t* packet, uint16_t* len, uint16_t max_len) const {
if (*len + Length() > max_len) {
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, -1,
"Max packet size reached, skipped BYE.");
LOG(LS_WARNING) << "Max packet size reached.";
return;
}
CreateBye(bye_, csrcs_, packet, len);
@ -286,8 +281,7 @@ void Bye::Create(uint8_t* packet, uint16_t* len, uint16_t max_len) const {
void Bye::WithCsrc(uint32_t csrc) {
if (csrcs_.size() >= kMaxNumberOfCsrcs) {
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, -1,
"Max CSRC size reached.");
LOG(LS_WARNING) << "Max CSRC size reached.";
return;
}
csrcs_.push_back(csrc);
@ -295,8 +289,7 @@ void Bye::WithCsrc(uint32_t csrc) {
void Fir::Create(uint8_t* packet, uint16_t* len, uint16_t max_len) const {
if (*len + Length() > max_len) {
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, -1,
"Max packet size reached, skipped FIR.");
LOG(LS_WARNING) << "Max packet size reached.";
return;
}
CreateFirRequest(fir_, fir_item_, packet, len);

View File

@ -18,7 +18,7 @@
#include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
#include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h"
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
#include "webrtc/system_wrappers/interface/trace.h"
#include "webrtc/system_wrappers/interface/logging.h"
#include "webrtc/system_wrappers/interface/trace_event.h"
namespace webrtc {
@ -57,7 +57,6 @@ RTCPReceiver::RTCPReceiver(const int32_t id, Clock* clock,
_lastIncreasedSequenceNumberMs(0),
stats_callback_(NULL) {
memset(&_remoteSenderInfo, 0, sizeof(_remoteSenderInfo));
WEBRTC_TRACE(kTraceMemory, kTraceRtpRtcp, id, "%s created", __FUNCTION__);
}
RTCPReceiver::~RTCPReceiver() {
@ -82,8 +81,6 @@ RTCPReceiver::~RTCPReceiver() {
delete first->second;
_receivedCnameMap.erase(first);
}
WEBRTC_TRACE(kTraceMemory, kTraceRtpRtcp, _id,
"%s deleted", __FUNCTION__);
}
void
@ -178,8 +175,7 @@ int32_t RTCPReceiver::ResetRTT(const uint32_t remoteSSRC) {
RTCPReportBlockInformation* reportBlock =
GetReportBlockInformation(remoteSSRC);
if (reportBlock == NULL) {
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id,
"\tfailed to GetReportBlockInformation(%u)", remoteSSRC);
LOG(LS_WARNING) << "Failed to reset rtt for ssrc " << remoteSSRC;
return -1;
}
reportBlock->RTT = 0;
@ -282,22 +278,14 @@ bool RTCPReceiver::LastReceivedXrReferenceTimeInfo(
return true;
}
int32_t
RTCPReceiver::SenderInfoReceived(RTCPSenderInfo* senderInfo) const
{
if(senderInfo == NULL)
{
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id, "%s invalid argument", __FUNCTION__);
return -1;
}
CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
if(_lastReceivedSRNTPsecs == 0)
{
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, _id, "%s No received SR", __FUNCTION__);
return -1;
}
memcpy(senderInfo, &(_remoteSenderInfo), sizeof(RTCPSenderInfo));
return 0;
int32_t RTCPReceiver::SenderInfoReceived(RTCPSenderInfo* senderInfo) const {
assert(senderInfo);
CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
if (_lastReceivedSRNTPsecs == 0) {
return -1;
}
memcpy(senderInfo, &(_remoteSenderInfo), sizeof(RTCPSenderInfo));
return 0;
}
// statistics
@ -518,8 +506,8 @@ void RTCPReceiver::HandleReportBlock(
RTCPReportBlockInformation* reportBlock =
CreateReportBlockInformation(remoteSSRC);
if (reportBlock == NULL) {
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id,
"\tfailed to CreateReportBlockInformation(%u)", remoteSSRC);
LOG(LS_WARNING) << "Failed to CreateReportBlockInformation("
<< remoteSSRC << ")";
return;
}
@ -779,9 +767,6 @@ int32_t RTCPReceiver::BoundingSet(bool &tmmbrOwner, TMMBRSet* boundingSetRec) {
}
RTCPReceiveInformation* receiveInfo = receiveInfoIt->second;
if (receiveInfo == NULL) {
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id,
"%s failed to get RTCPReceiveInformation",
__FUNCTION__);
return -1;
}
if (receiveInfo->TmmbnBoundingSet.lengthOfSet() > 0) {
@ -1348,8 +1333,7 @@ int32_t RTCPReceiver::UpdateTMMBR() {
TMMBRSet* boundingSet = NULL;
numBoundingSet = FindTMMBRBoundingSet(boundingSet);
if (numBoundingSet == -1) {
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, _id,
"Failed to find TMMBR bounding set.");
LOG(LS_WARNING) << "Failed to find TMMBR bounding set.";
return -1;
}
// Set bounding set
@ -1369,8 +1353,6 @@ int32_t RTCPReceiver::UpdateTMMBR() {
CriticalSectionScoped lock(_criticalSectionFeedbacks);
if (_cbRtcpBandwidthObserver) {
_cbRtcpBandwidthObserver->OnReceivedEstimatedBitrate(bitrate * 1000);
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, _id,
"Set TMMBR request:%d kbps", bitrate);
}
}
return 0;
@ -1395,9 +1377,6 @@ void RTCPReceiver::TriggerCallbacksFromRTCPPacket(
// Process TMMBR and REMB first to avoid multiple callbacks
// to OnNetworkChanged.
if (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpTmmbr) {
WEBRTC_TRACE(kTraceStateInfo, kTraceRtpRtcp, _id,
"SIG [RTCP] Incoming TMMBR to id:%d", _id);
// Might trigger a OnReceivedBandwidthEstimateUpdate.
UpdateTMMBR();
}
@ -1412,9 +1391,8 @@ void RTCPReceiver::TriggerCallbacksFromRTCPPacket(
}
if (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpNack) {
if (rtcpPacketInformation.nackSequenceNumbers.size() > 0) {
WEBRTC_TRACE(kTraceStateInfo, kTraceRtpRtcp, _id,
"SIG [RTCP] Incoming NACK length:%d",
rtcpPacketInformation.nackSequenceNumbers.size());
LOG(LS_INFO) << "Incoming NACK length: "
<< rtcpPacketInformation.nackSequenceNumbers.size();
_rtpRtcp.OnReceivedNACK(rtcpPacketInformation.nackSequenceNumbers);
}
}
@ -1429,13 +1407,11 @@ void RTCPReceiver::TriggerCallbacksFromRTCPPacket(
if ((rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpPli) ||
(rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpFir)) {
if (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpPli) {
WEBRTC_TRACE(kTraceStateInfo, kTraceRtpRtcp, _id,
"SIG [RTCP] Incoming PLI from SSRC:0x%x",
rtcpPacketInformation.remoteSSRC);
LOG(LS_INFO) << "Incoming PLI from SSRC "
<< rtcpPacketInformation.remoteSSRC;
} else {
WEBRTC_TRACE(kTraceStateInfo, kTraceRtpRtcp, _id,
"SIG [RTCP] Incoming FIR from SSRC:0x%x",
rtcpPacketInformation.remoteSSRC);
LOG(LS_INFO) << "Incoming FIR from SSRC "
<< rtcpPacketInformation.remoteSSRC;
}
_cbRtcpIntraFrameObserver->OnReceivedIntraFrameRequest(local_ssrc);
}
@ -1450,9 +1426,8 @@ void RTCPReceiver::TriggerCallbacksFromRTCPPacket(
}
if (_cbRtcpBandwidthObserver) {
if (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpRemb) {
WEBRTC_TRACE(kTraceStateInfo, kTraceRtpRtcp, _id,
"SIG [RTCP] Incoming REMB:%d",
rtcpPacketInformation.receiverEstimatedMaxBitrate);
LOG(LS_INFO) << "Incoming REMB: "
<< rtcpPacketInformation.receiverEstimatedMaxBitrate;
_cbRtcpBandwidthObserver->OnReceivedEstimatedBitrate(
rtcpPacketInformation.receiverEstimatedMaxBitrate);
}
@ -1548,9 +1523,6 @@ int32_t RTCPReceiver::TMMBRReceived(const uint32_t size,
while (receiveInfoIt != _receivedInfoMap.end()) {
RTCPReceiveInformation* receiveInfo = receiveInfoIt->second;
if(receiveInfo == NULL) {
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id,
"%s failed to get RTCPReceiveInformation",
__FUNCTION__);
return -1;
}
num += receiveInfo->TmmbrSet.lengthOfSet();

View File

@ -19,7 +19,7 @@
#include "webrtc/common_types.h"
#include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h"
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
#include "webrtc/system_wrappers/interface/trace.h"
#include "webrtc/system_wrappers/interface/logging.h"
#include "webrtc/system_wrappers/interface/trace_event.h"
namespace webrtc {
@ -161,8 +161,6 @@ RTCPSender::RTCPSender(const int32_t id,
memset(_CNAME, 0, sizeof(_CNAME));
memset(_lastSendReport, 0, sizeof(_lastSendReport));
memset(_lastRTCPTime, 0, sizeof(_lastRTCPTime));
WEBRTC_TRACE(kTraceMemory, kTraceRtpRtcp, id, "%s created", __FUNCTION__);
}
RTCPSender::~RTCPSender() {
@ -187,8 +185,6 @@ RTCPSender::~RTCPSender() {
}
delete _criticalSectionTransport;
delete _criticalSectionRTCPSender;
WEBRTC_TRACE(kTraceMemory, kTraceRtpRtcp, _id, "%s deleted", __FUNCTION__);
}
int32_t
@ -427,7 +423,8 @@ RTCPSender::SetCameraDelay(const int32_t delayMS)
CriticalSectionScoped lock(_criticalSectionRTCPSender);
if(delayMS > 1000 || delayMS < -1000)
{
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id, "%s invalid argument, delay can't be larger than 1 sec", __FUNCTION__);
LOG(LS_WARNING) << "Delay can't be larger than 1 second: "
<< delayMS << " ms";
return -1;
}
_cameraDelayMS = delayMS;
@ -631,15 +628,10 @@ int32_t RTCPSender::AddReportBlock(
uint32_t SSRC,
std::map<uint32_t, RTCPReportBlock*>* report_blocks,
const RTCPReportBlock* reportBlock) {
if (reportBlock == NULL) {
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id,
"%s invalid argument", __FUNCTION__);
return -1;
}
assert(reportBlock);
if (report_blocks->size() >= RTCP_MAX_REPORT_BLOCKS) {
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id,
"%s invalid argument", __FUNCTION__);
LOG(LS_WARNING) << "Too many report blocks.";
return -1;
}
std::map<uint32_t, RTCPReportBlock*>::iterator it =
@ -677,7 +669,7 @@ int32_t RTCPSender::BuildSR(const FeedbackState& feedback_state,
// sanity
if(pos + 52 >= IP_PACKET_SIZE)
{
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id, "%s invalid argument", __FUNCTION__);
LOG(LS_WARNING) << "Failed to build Sender Report.";
return -2;
}
uint32_t RTPtime;
@ -760,8 +752,7 @@ int32_t RTCPSender::BuildSDEC(uint8_t* rtcpbuffer, int& pos) {
// sanity
if(pos + 12 + lengthCname >= IP_PACKET_SIZE) {
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id,
"%s invalid argument", __FUNCTION__);
LOG(LS_WARNING) << "Failed to build SDEC.";
return -2;
}
// SDEC Source Description
@ -913,7 +904,9 @@ RTCPSender::BuildExtendedJitterReport(
{
if (external_report_blocks_.size() > 0)
{
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, _id, "Not implemented.");
// TODO(andresp): Remove external report blocks since they are not
// supported.
LOG(LS_ERROR) << "Handling of external report blocks not implemented.";
return 0;
}
@ -1317,7 +1310,7 @@ RTCPSender::BuildTMMBN(uint8_t* rtcpbuffer, int& pos)
// sanity
if(pos + 12 + boundingSet->lengthOfSet()*8 >= IP_PACKET_SIZE)
{
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id, "%s invalid argument", __FUNCTION__);
LOG(LS_WARNING) << "Failed to build TMMBN.";
return -2;
}
uint8_t FMT = 4;
@ -1384,12 +1377,12 @@ RTCPSender::BuildAPP(uint8_t* rtcpbuffer, int& pos)
// sanity
if(_appData == NULL)
{
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, _id, "%s invalid state", __FUNCTION__);
LOG(LS_WARNING) << "Failed to build app specific.";
return -1;
}
if(pos + 12 + _appLength >= IP_PACKET_SIZE)
{
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id, "%s invalid argument", __FUNCTION__);
LOG(LS_WARNING) << "Failed to build app specific.";
return -2;
}
rtcpbuffer[pos++]=(uint8_t)0x80 + _appSubType;
@ -1425,7 +1418,7 @@ RTCPSender::BuildNACK(uint8_t* rtcpbuffer,
// sanity
if(pos + 16 >= IP_PACKET_SIZE)
{
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id, "%s invalid argument", __FUNCTION__);
LOG(LS_WARNING) << "Failed to build NACK.";
return -2;
}
@ -1478,8 +1471,7 @@ RTCPSender::BuildNACK(uint8_t* rtcpbuffer,
numOfNackFields++;
}
if (i != nackSize) {
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, _id,
"Nack list to large for one packet.");
LOG(LS_WARNING) << "Nack list to large for one packet.";
}
rtcpbuffer[nackSizePos] = static_cast<uint8_t>(2 + numOfNackFields);
*nackString = stringBuilder.GetResult();
@ -1715,8 +1707,7 @@ int32_t RTCPSender::SendRTCP(const FeedbackState& feedback_state,
CriticalSectionScoped lock(_criticalSectionRTCPSender);
if(_method == kRtcpOff)
{
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, _id,
"%s invalid state", __FUNCTION__);
LOG(LS_WARNING) << "Can't send rtcp if it is disabled.";
return -1;
}
}
@ -2128,13 +2119,7 @@ int32_t
RTCPSender::SetCSRCs(const uint32_t arrOfCSRC[kRtpCsrcSize],
const uint8_t arrLength)
{
if(arrLength > kRtpCsrcSize)
{
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id, "%s invalid argument", __FUNCTION__);
assert(false);
return -1;
}
assert(arrLength <= kRtpCsrcSize);
CriticalSectionScoped lock(_criticalSectionRTCPSender);
for(int i = 0; i < arrLength;i++)
@ -2153,7 +2138,7 @@ RTCPSender::SetApplicationSpecificData(const uint8_t subType,
{
if(length %4 != 0)
{
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id, "%s invalid argument", __FUNCTION__);
LOG(LS_ERROR) << "Failed to SetApplicationSpecificData.";
return -1;
}
CriticalSectionScoped lock(_criticalSectionRTCPSender);
@ -2199,17 +2184,10 @@ int32_t RTCPSender::WriteAllReportBlocksToBuffer(
uint8_t& numberOfReportBlocks,
const uint32_t NTPsec,
const uint32_t NTPfrac) {
// sanity one block
if(pos + 24 >= IP_PACKET_SIZE) {
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id,
"%s invalid argument", __FUNCTION__);
return -1;
}
numberOfReportBlocks = external_report_blocks_.size();
numberOfReportBlocks += internal_report_blocks_.size();
if ((pos + numberOfReportBlocks * 24) >= IP_PACKET_SIZE) {
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id,
"%s invalid argument", __FUNCTION__);
LOG(LS_WARNING) << "Can't fit all report blocks.";
return -1;
}
pos = WriteReportBlocksToBuffer(rtcpbuffer, pos, internal_report_blocks_);

View File

@ -278,7 +278,7 @@ class RtcpSenderTest : public ::testing::Test {
: over_use_detector_options_(),
clock_(1335900000),
rtp_payload_registry_(new RTPPayloadRegistry(
0, RTPPayloadStrategy::CreateStrategy(false))),
RTPPayloadStrategy::CreateStrategy(false))),
remote_bitrate_observer_(),
remote_bitrate_estimator_(
RemoteBitrateEstimatorFactory().Create(

View File

@ -41,7 +41,7 @@ template <typename T> void ClearList(std::list<T*>* my_list) {
class RtpFecTest : public ::testing::Test {
protected:
RtpFecTest()
: fec_(new ForwardErrorCorrection(0)), ssrc_(rand()), fec_seq_num_(0) {}
: fec_(new ForwardErrorCorrection()), ssrc_(rand()), fec_seq_num_(0) {}
ForwardErrorCorrection* fec_;
int ssrc_;
@ -86,43 +86,6 @@ class RtpFecTest : public ::testing::Test {
void TearDown();
};
// TODO(marpan): Consider adding table for input/output to simplify tests.
TEST_F(RtpFecTest, HandleIncorrectInputs) {
int kNumImportantPackets = 0;
bool kUseUnequalProtection = false;
uint8_t kProtectionFactor = 60;
// Media packet list is empty.
EXPECT_EQ(-1, fec_->GenerateFEC(media_packet_list_, kProtectionFactor,
kNumImportantPackets, kUseUnequalProtection,
webrtc::kFecMaskBursty, &fec_packet_list_));
int num_media_packets = 10;
ConstructMediaPackets(num_media_packets);
kNumImportantPackets = -1;
// Number of important packets below 0.
EXPECT_EQ(-1, fec_->GenerateFEC(media_packet_list_, kProtectionFactor,
kNumImportantPackets, kUseUnequalProtection,
webrtc::kFecMaskBursty, &fec_packet_list_));
kNumImportantPackets = 12;
// Number of important packets greater than number of media packets.
EXPECT_EQ(-1, fec_->GenerateFEC(media_packet_list_, kProtectionFactor,
kNumImportantPackets, kUseUnequalProtection,
webrtc::kFecMaskBursty, &fec_packet_list_));
num_media_packets = kMaxNumberMediaPackets + 1;
ConstructMediaPackets(num_media_packets);
kNumImportantPackets = 0;
// Number of media packet is above maximum allowed (kMaxNumberMediaPackets).
EXPECT_EQ(-1, fec_->GenerateFEC(media_packet_list_, kProtectionFactor,
kNumImportantPackets, kUseUnequalProtection,
webrtc::kFecMaskBursty, &fec_packet_list_));
}
TEST_F(RtpFecTest, FecRecoveryNoLoss) {
const int kNumImportantPackets = 0;
const bool kUseUnequalProtection = false;

View File

@ -13,7 +13,6 @@
#include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
#include "webrtc/system_wrappers/interface/trace.h"
namespace webrtc {
@ -60,8 +59,6 @@ bool RtpHeaderParserImpl::Parse(const uint8_t* packet, int length,
const bool valid_rtpheader = rtp_parser.Parse(*header, &map);
if (!valid_rtpheader) {
WEBRTC_TRACE(kTraceDebug, kTraceRtpRtcp, -1,
"IncomingPacket invalid RTP header");
return false;
}
return true;

View File

@ -18,7 +18,7 @@
#include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
#include "webrtc/system_wrappers/interface/trace.h"
#include "webrtc/system_wrappers/interface/logging.h"
namespace webrtc {
@ -33,13 +33,21 @@ RTPPacketHistory::RTPPacketHistory(Clock* clock)
}
RTPPacketHistory::~RTPPacketHistory() {
Free();
{
CriticalSectionScoped cs(critsect_);
Free();
}
delete critsect_;
}
void RTPPacketHistory::SetStorePacketsStatus(bool enable,
uint16_t number_to_store) {
CriticalSectionScoped cs(critsect_);
if (enable) {
if (store_) {
LOG(LS_WARNING) << "Purging packet history in order to re-set status.";
Free();
}
Allocate(number_to_store);
} else {
Free();
@ -48,16 +56,7 @@ void RTPPacketHistory::SetStorePacketsStatus(bool enable,
void RTPPacketHistory::Allocate(uint16_t number_to_store) {
assert(number_to_store > 0);
CriticalSectionScoped cs(critsect_);
if (store_) {
if (number_to_store != stored_packets_.size()) {
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, -1,
"SetStorePacketsStatus already set, number: %d",
number_to_store);
}
return;
}
assert(!store_);
store_ = true;
stored_packets_.resize(number_to_store);
stored_seq_nums_.resize(number_to_store);
@ -68,7 +67,6 @@ void RTPPacketHistory::Allocate(uint16_t number_to_store) {
}
void RTPPacketHistory::Free() {
CriticalSectionScoped cs(critsect_);
if (!store_) {
return;
}
@ -133,8 +131,8 @@ int32_t RTPPacketHistory::PutRTPPacket(const uint8_t* packet,
VerifyAndAllocatePacketLength(max_packet_length);
if (packet_length > max_packet_length_) {
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, -1,
"Failed to store RTP packet, length: %d", packet_length);
LOG(LS_WARNING) << "Failed to store RTP packet with length: "
<< packet_length;
return -1;
}
@ -169,25 +167,20 @@ int32_t RTPPacketHistory::ReplaceRTPHeader(const uint8_t* packet,
assert(packet);
assert(rtp_header_length > 3);
if (rtp_header_length > max_packet_length_) {
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, -1,
"Failed to replace RTP packet, length: %d", rtp_header_length);
return -1;
}
assert(rtp_header_length <= max_packet_length_);
int32_t index = 0;
bool found = FindSeqNum(sequence_number, &index);
if (!found) {
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, -1,
"No match for getting seqNum %u", sequence_number);
LOG(LS_WARNING)
<< "Failed to replace RTP packet due to missing sequence number.";
return -1;
}
uint16_t length = stored_lengths_.at(index);
if (length == 0 || length > max_packet_length_) {
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, -1,
"No match for getting seqNum %u, len %d", sequence_number, length);
LOG(LS_WARNING) << "No match for getting seqNum " << sequence_number
<< ", len " << length;
return -1;
}
assert(stored_seq_nums_[index] == sequence_number);
@ -225,6 +218,7 @@ bool RTPPacketHistory::GetPacketAndSetSendTime(uint16_t sequence_number,
uint8_t* packet,
uint16_t* packet_length,
int64_t* stored_time_ms) {
assert(*packet_length >= max_packet_length_);
CriticalSectionScoped cs(critsect_);
if (!store_) {
return false;
@ -233,21 +227,15 @@ bool RTPPacketHistory::GetPacketAndSetSendTime(uint16_t sequence_number,
int32_t index = 0;
bool found = FindSeqNum(sequence_number, &index);
if (!found) {
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, -1,
"No match for getting seqNum %u", sequence_number);
LOG(LS_WARNING) << "No match for getting seqNum " << sequence_number;
return false;
}
uint16_t length = stored_lengths_.at(index);
if (length == 0 || length > max_packet_length_) {
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, -1,
"No match for getting seqNum %u, len %d", sequence_number, length);
return false;
}
if (length > *packet_length) {
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, -1,
"Input buffer too short for packet %u", sequence_number);
assert(length <= max_packet_length_);
if (length == 0) {
LOG(LS_WARNING) << "No match for getting seqNum " << sequence_number
<< ", len " << length;
return false;
}
@ -255,8 +243,6 @@ bool RTPPacketHistory::GetPacketAndSetSendTime(uint16_t sequence_number,
int64_t now = clock_->TimeInMilliseconds();
if (min_elapsed_time_ms > 0 &&
((now - stored_send_times_.at(index)) < min_elapsed_time_ms)) {
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, -1,
"Skip getting packet %u, packet recently resent.", sequence_number);
return false;
}

View File

@ -18,6 +18,7 @@
#include "webrtc/modules/interface/module_common_types.h"
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
#include "webrtc/typedefs.h"
#include "webrtc/system_wrappers/interface/thread_annotations.h"
namespace webrtc {
@ -74,8 +75,8 @@ class RTPPacketHistory {
private:
void GetPacket(int index, uint8_t* packet, uint16_t* packet_length,
int64_t* stored_time_ms) const;
void Allocate(uint16_t number_to_store);
void Free();
void Allocate(uint16_t number_to_store) EXCLUSIVE_LOCKS_REQUIRED(*critsect_);
void Free() EXCLUSIVE_LOCKS_REQUIRED(*critsect_);
void VerifyAndAllocatePacketLength(uint16_t packet_length);
bool FindSeqNum(uint16_t sequence_number, int32_t* index) const;
int FindBestFittingPacket(uint16_t size) const;

View File

@ -103,19 +103,6 @@ TEST_F(RtpPacketHistoryTest, PutRtpPacket_TooLargePacketLength) {
kAllowRetransmission));
}
TEST_F(RtpPacketHistoryTest, GetRtpPacket_TooSmallBuffer) {
hist_->SetStorePacketsStatus(true, 10);
uint16_t len = 0;
int64_t capture_time_ms = fake_clock_.TimeInMilliseconds();
CreateRtpPacket(kSeqNum, kSsrc, kPayload, kTimestamp, packet_, &len);
EXPECT_EQ(0, hist_->PutRTPPacket(packet_, len, kMaxPacketLength,
capture_time_ms, kAllowRetransmission));
uint16_t len_out = len - 1;
int64_t time;
EXPECT_FALSE(hist_->GetPacketAndSetSendTime(kSeqNum, 0, false, packet_,
&len_out, &time));
}
TEST_F(RtpPacketHistoryTest, GetRtpPacket_NotStored) {
hist_->SetStorePacketsStatus(true, 10);
uint16_t len = kMaxPacketLength;
@ -161,8 +148,8 @@ TEST_F(RtpPacketHistoryTest, ReplaceRtpHeader) {
uint16_t len = 0;
int64_t capture_time_ms = 1;
CreateRtpPacket(kSeqNum, kSsrc, kPayload, kTimestamp, packet_, &len);
// Replace should fail, packet is not stored.
EXPECT_EQ(-1, hist_->ReplaceRTPHeader(packet_, kSeqNum, len));
EXPECT_EQ(0, hist_->PutRTPPacket(packet_, len, kMaxPacketLength,
capture_time_ms, kAllowRetransmission));
@ -181,10 +168,6 @@ TEST_F(RtpPacketHistoryTest, ReplaceRtpHeader) {
EXPECT_EQ(packet_[i], packet_out_[i]);
}
// Replace should fail, too large length.
EXPECT_EQ(-1, hist_->ReplaceRTPHeader(packet_, kSeqNum,
kMaxPacketLength + 1));
// Replace should fail, packet is not stored.
len = 0;
CreateRtpPacket(kSeqNum + 1, kSsrc, kPayload, kTimestamp, packet_, &len);
@ -236,10 +219,10 @@ TEST_F(RtpPacketHistoryTest, MinResendTime) {
capture_time_ms, kAllowRetransmission));
int64_t time;
len = kMaxPacketLength;
EXPECT_TRUE(hist_->GetPacketAndSetSendTime(kSeqNum, 100, false, packet_, &len,
&time));
fake_clock_.AdvanceTimeMilliseconds(100);
// Time has elapsed.
len = kMaxPacketLength;
EXPECT_TRUE(hist_->GetPacketAndSetSendTime(kSeqNum, 100, false, packet_, &len,

View File

@ -10,15 +10,13 @@
#include "webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h"
#include "webrtc/system_wrappers/interface/trace.h"
#include "webrtc/system_wrappers/interface/logging.h"
namespace webrtc {
RTPPayloadRegistry::RTPPayloadRegistry(
const int32_t id,
RTPPayloadStrategy* rtp_payload_strategy)
: crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
id_(id),
rtp_payload_strategy_(rtp_payload_strategy),
red_payload_type_(-1),
ulpfec_payload_type_(-1),
@ -60,9 +58,8 @@ int32_t RTPPayloadRegistry::RegisterReceivePayload(
case 77: // 205 Transport layer FB message.
case 78: // 206 Payload-specific FB message.
case 79: // 207 Extended report.
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, id_,
"%s invalid payloadtype:%d",
__FUNCTION__, payload_type);
LOG(LS_ERROR) << "Can't register invalid receiver payload type: "
<< payload_type;
return -1;
default:
break;
@ -94,9 +91,7 @@ int32_t RTPPayloadRegistry::RegisterReceivePayload(
return 0;
}
}
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, id_,
"%s invalid argument payload_type:%d already registered",
__FUNCTION__, payload_type);
LOG(LS_ERROR) << "Payload type already registered: " << payload_type;
return -1;
}
@ -138,14 +133,8 @@ int32_t RTPPayloadRegistry::DeRegisterReceivePayload(
const int8_t payload_type) {
CriticalSectionScoped cs(crit_sect_.get());
ModuleRTPUtility::PayloadTypeMap::iterator it =
payload_type_map_.find(payload_type);
if (it == payload_type_map_.end()) {
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, id_,
"%s failed to find payload_type:%d",
__FUNCTION__, payload_type);
return -1;
}
payload_type_map_.find(payload_type);
assert(it != payload_type_map_.end());
delete it->second;
payload_type_map_.erase(it);
return 0;
@ -194,11 +183,7 @@ int32_t RTPPayloadRegistry::ReceivePayloadType(
const uint8_t channels,
const uint32_t rate,
int8_t* payload_type) const {
if (payload_type == NULL) {
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, id_,
"%s invalid argument", __FUNCTION__);
return -1;
}
assert(payload_type);
size_t payload_name_length = strlen(payload_name);
CriticalSectionScoped cs(crit_sect_.get());
@ -296,8 +281,7 @@ bool RTPPayloadRegistry::RestoreOriginalPacket(uint8_t** restored_packet,
(*restored_packet)[1] |= kRtpMarkerBitMask; // Marker bit is set.
}
} else {
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, id_,
"Incorrect RTX configuration, dropping packet.");
LOG(LS_WARNING) << "Incorrect RTX configuration, dropping packet.";
return false;
}
}

View File

@ -32,8 +32,7 @@ class RtpPayloadRegistryTest : public ::testing::Test {
void SetUp() {
// Note: the payload registry takes ownership of the strategy.
mock_payload_strategy_ = new testing::NiceMock<MockRTPPayloadStrategy>();
rtp_payload_registry_.reset(
new RTPPayloadRegistry(123, mock_payload_strategy_));
rtp_payload_registry_.reset(new RTPPayloadRegistry(mock_payload_strategy_));
}
protected:

View File

@ -15,7 +15,7 @@
#include <string.h> // memcpy()
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
#include "webrtc/system_wrappers/interface/trace.h"
#include "webrtc/system_wrappers/interface/logging.h"
#include "webrtc/system_wrappers/interface/trace_event.h"
namespace webrtc {
@ -277,11 +277,8 @@ int32_t RTPReceiverAudio::InvokeOnInitializeDecoder(
specific_payload.Audio.frequency,
specific_payload.Audio.channels,
specific_payload.Audio.rate)) {
WEBRTC_TRACE(kTraceError,
kTraceRtpRtcp,
id,
"Failed to create video decoder for payload type:%d",
payload_type);
LOG(LS_ERROR) << "Failed to create decoder for payload type: "
<< payload_name << "/" << payload_type;
return -1;
}
return 0;

View File

@ -18,7 +18,7 @@
#include "webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h"
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
#include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h"
#include "webrtc/system_wrappers/interface/trace.h"
#include "webrtc/system_wrappers/interface/logging.h"
namespace webrtc {
@ -39,7 +39,7 @@ RtpReceiver* RtpReceiver::CreateVideoReceiver(
return new RtpReceiverImpl(
id, clock, NullObjectRtpAudioFeedback(), incoming_messages_callback,
rtp_payload_registry,
RTPReceiverStrategy::CreateVideoStrategy(id, incoming_payload_callback));
RTPReceiverStrategy::CreateVideoStrategy(incoming_payload_callback));
}
RtpReceiver* RtpReceiver::CreateAudioReceiver(
@ -87,8 +87,6 @@ RtpReceiverImpl::RtpReceiverImpl(int32_t id,
assert(incoming_messages_callback);
memset(current_remote_csrc_, 0, sizeof(current_remote_csrc_));
WEBRTC_TRACE(kTraceMemory, kTraceRtpRtcp, id, "%s created", __FUNCTION__);
}
RtpReceiverImpl::~RtpReceiverImpl() {
@ -96,7 +94,6 @@ RtpReceiverImpl::~RtpReceiverImpl() {
cb_rtp_feedback_->OnIncomingCSRCChanged(id_, current_remote_csrc_[i],
false);
}
WEBRTC_TRACE(kTraceMemory, kTraceRtpRtcp, id_, "%s deleted", __FUNCTION__);
}
RTPReceiverStrategy* RtpReceiverImpl::GetMediaReceiver() const {
@ -127,9 +124,8 @@ int32_t RtpReceiverImpl::RegisterReceivePayload(
if (created_new_payload) {
if (rtp_media_receiver_->OnNewPayloadTypeCreated(payload_name, payload_type,
frequency) != 0) {
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, id_,
"%s failed to register payload",
__FUNCTION__);
LOG(LS_ERROR) << "Failed to register payload: " << payload_name << "/"
<< payload_type;
return -1;
}
}
@ -182,19 +178,12 @@ bool RtpReceiverImpl::IncomingRtpPacket(
PayloadUnion payload_specific,
bool in_order) {
// Sanity check.
if (payload_length < 0) {
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, id_,
"%s invalid argument",
__FUNCTION__);
return false;
}
int8_t first_payload_byte = 0;
if (payload_length > 0) {
first_payload_byte = payload[0];
}
assert(payload_length >= 0);
// Trigger our callbacks.
CheckSSRCChanged(rtp_header);
int8_t first_payload_byte = payload_length > 0 ? payload[0] : 0;
bool is_red = false;
bool should_reset_statistics = false;
@ -205,14 +194,9 @@ bool RtpReceiverImpl::IncomingRtpPacket(
&should_reset_statistics) == -1) {
if (payload_length == 0) {
// OK, keep-alive packet.
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, id_,
"%s received keepalive",
__FUNCTION__);
return true;
}
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, id_,
"%s received invalid payloadtype",
__FUNCTION__);
LOG(LS_WARNING) << "Receiving invalid payload type.";
return false;
}
@ -347,9 +331,8 @@ void RtpReceiverImpl::CheckSSRCChanged(const RTPHeader& rtp_header) {
id_, rtp_header.payloadType, payload_name,
rtp_header.payload_type_frequency, channels, rate)) {
// New stream, same codec.
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, id_,
"Failed to create decoder for payload type:%d",
rtp_header.payloadType);
LOG(LS_ERROR) << "Failed to create decoder for payload type: "
<< rtp_header.payloadType;
}
}
}

View File

@ -26,8 +26,7 @@ class TelephoneEventHandler;
// This class is not thread-safe and must be protected by its caller.
class RTPReceiverStrategy {
public:
static RTPReceiverStrategy* CreateVideoStrategy(int32_t id,
RtpData* data_callback);
static RTPReceiverStrategy* CreateVideoStrategy(RtpData* data_callback);
static RTPReceiverStrategy* CreateAudioStrategy(
int32_t id, RtpData* data_callback,
RtpAudioFeedback* incoming_messages_callback);

View File

@ -17,19 +17,18 @@
#include "webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.h"
#include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
#include "webrtc/system_wrappers/interface/trace.h"
#include "webrtc/system_wrappers/interface/logging.h"
#include "webrtc/system_wrappers/interface/trace_event.h"
namespace webrtc {
RTPReceiverStrategy* RTPReceiverStrategy::CreateVideoStrategy(
int32_t id, RtpData* data_callback) {
return new RTPReceiverVideo(id, data_callback);
RtpData* data_callback) {
return new RTPReceiverVideo(data_callback);
}
RTPReceiverVideo::RTPReceiverVideo(int32_t id, RtpData* data_callback)
: RTPReceiverStrategy(data_callback),
id_(id) {}
RTPReceiverVideo::RTPReceiverVideo(RtpData* data_callback)
: RTPReceiverStrategy(data_callback) {}
RTPReceiverVideo::~RTPReceiverVideo() {
}
@ -93,11 +92,8 @@ int32_t RTPReceiverVideo::InvokeOnInitializeDecoder(
// For video we just go with default values.
if (-1 == callback->OnInitializeDecoder(
id, payload_type, payload_name, kVideoPayloadTypeFrequency, 1, 0)) {
WEBRTC_TRACE(kTraceError,
kTraceRtpRtcp,
id,
"Failed to create video decoder for payload type:%d",
payload_type);
LOG(LS_ERROR) << "Failed to created decoder for payload type: "
<< payload_type;
return -1;
}
return 0;
@ -111,13 +107,6 @@ int32_t RTPReceiverVideo::ParseVideoCodecSpecific(
RtpVideoCodecTypes video_type,
int64_t now_ms,
bool is_first_packet) {
WEBRTC_TRACE(kTraceStream,
kTraceRtpRtcp,
id_,
"%s(timestamp:%u)",
__FUNCTION__,
rtp_header->header.timestamp);
switch (rtp_header->type.Video.codec) {
case kRtpVideoGeneric:
rtp_header->type.Video.isFirstPacket = is_first_packet;
@ -170,13 +159,8 @@ int32_t RTPReceiverVideo::ReceiveVp8Codec(WebRtcRTPHeader* rtp_header,
const uint8_t* payload_data,
uint16_t payload_data_length) {
ModuleRTPUtility::RTPPayload parsed_packet;
uint32_t id;
{
CriticalSectionScoped cs(crit_sect_.get());
id = id_;
}
ModuleRTPUtility::RTPPayloadParser rtp_payload_parser(
kRtpVideoVp8, payload_data, payload_data_length, id);
kRtpVideoVp8, payload_data, payload_data_length);
if (!rtp_payload_parser.Parse(parsed_packet))
return -1;

View File

@ -22,7 +22,7 @@ namespace webrtc {
class RTPReceiverVideo : public RTPReceiverStrategy {
public:
RTPReceiverVideo(const int32_t id, RtpData* data_callback);
RTPReceiverVideo(RtpData* data_callback);
virtual ~RTPReceiverVideo();
@ -80,8 +80,6 @@ class RTPReceiverVideo : public RTPReceiverStrategy {
RtpVideoCodecTypes video_type,
int64_t now_ms,
bool is_first_packet);
int32_t id_;
};
} // namespace webrtc

View File

@ -110,13 +110,9 @@ ModuleRtpRtcpImpl::ModuleRtpRtcpImpl(const Configuration& configuration)
uint32_t SSRC = rtp_sender_.SSRC();
rtcp_sender_.SetSSRC(SSRC);
SetRtcpReceiverSsrcs(SSRC);
WEBRTC_TRACE(kTraceMemory, kTraceRtpRtcp, id_, "%s created", __FUNCTION__);
}
ModuleRtpRtcpImpl::~ModuleRtpRtcpImpl() {
WEBRTC_TRACE(kTraceMemory, kTraceRtpRtcp, id_, "%s deleted", __FUNCTION__);
// All child modules MUST be deleted before deleting the default.
assert(child_modules_.empty());
@ -134,12 +130,6 @@ ModuleRtpRtcpImpl::~ModuleRtpRtcpImpl() {
}
void ModuleRtpRtcpImpl::RegisterChildModule(RtpRtcp* module) {
WEBRTC_TRACE(kTraceModuleCall,
kTraceRtpRtcp,
id_,
"RegisterChildModule(module:0x%x)",
module);
CriticalSectionScoped lock(
critical_section_module_ptrs_.get());
CriticalSectionScoped double_lock(
@ -153,11 +143,6 @@ void ModuleRtpRtcpImpl::RegisterChildModule(RtpRtcp* module) {
}
void ModuleRtpRtcpImpl::DeRegisterChildModule(RtpRtcp* remove_module) {
WEBRTC_TRACE(kTraceModuleCall,
kTraceRtpRtcp,
id_,
"DeRegisterChildModule(module:0x%x)", remove_module);
CriticalSectionScoped lock(
critical_section_module_ptrs_.get());
CriticalSectionScoped double_lock(
@ -282,29 +267,12 @@ void ModuleRtpRtcpImpl::SetRtxSendPayloadType(int payload_type) {
int32_t ModuleRtpRtcpImpl::IncomingRtcpPacket(
const uint8_t* rtcp_packet,
const uint16_t length) {
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, -1,
"IncomingRtcpPacket(packet_length:%u)", length);
// Minimum RTP is 12 bytes.
// Minimum RTCP is 8 bytes (RTCP BYE).
if (length == 8) {
WEBRTC_TRACE(kTraceDebug, kTraceRtpRtcp, -1,
"IncomingRtcpPacket invalid length");
return false;
}
// Check RTP version.
const uint8_t version = rtcp_packet[0] >> 6;
if (version != 2) {
WEBRTC_TRACE(kTraceDebug, kTraceRtpRtcp, -1,
"IncomingRtcpPacket invalid RTP version");
return false;
}
// Allow receive of non-compound RTCP packets.
RTCPUtility::RTCPParserV2 rtcp_parser(rtcp_packet, length, true);
const bool valid_rtcpheader = rtcp_parser.IsValid();
if (!valid_rtcpheader) {
WEBRTC_TRACE(kTraceDebug, kTraceRtpRtcp, id_,
"IncomingRtcpPacket invalid RTCP packet");
LOG(LS_WARNING) << "Incoming invalid RTCP packet";
return -1;
}
RTCPHelp::RTCPPacketInformation rtcp_packet_information;
@ -318,14 +286,6 @@ int32_t ModuleRtpRtcpImpl::IncomingRtcpPacket(
int32_t ModuleRtpRtcpImpl::RegisterSendPayload(
const CodecInst& voice_codec) {
WEBRTC_TRACE(kTraceModuleCall,
kTraceRtpRtcp,
id_,
"RegisterSendPayload(pl_name:%s pl_type:%d frequency:%u)",
voice_codec.plname,
voice_codec.pltype,
voice_codec.plfreq);
return rtp_sender_.RegisterPayload(
voice_codec.plname,
voice_codec.pltype,
@ -336,13 +296,6 @@ int32_t ModuleRtpRtcpImpl::RegisterSendPayload(
int32_t ModuleRtpRtcpImpl::RegisterSendPayload(
const VideoCodec& video_codec) {
WEBRTC_TRACE(kTraceModuleCall,
kTraceRtpRtcp,
id_,
"RegisterSendPayload(pl_name:%s pl_type:%d)",
video_codec.plName,
video_codec.plType);
send_video_codec_ = video_codec;
{
// simulcast_ is accessed when accessing child_modules_, so this write needs
@ -359,11 +312,6 @@ int32_t ModuleRtpRtcpImpl::RegisterSendPayload(
int32_t ModuleRtpRtcpImpl::DeRegisterSendPayload(
const int8_t payload_type) {
WEBRTC_TRACE(kTraceModuleCall,
kTraceRtpRtcp,
id_,
"DeRegisterSendPayload(%d)", payload_type);
return rtp_sender_.DeRegisterSendPayload(payload_type);
}
@ -372,53 +320,34 @@ int8_t ModuleRtpRtcpImpl::SendPayloadType() const {
}
uint32_t ModuleRtpRtcpImpl::StartTimestamp() const {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "StartTimestamp()");
return rtp_sender_.StartTimestamp();
}
// Configure start timestamp, default is a random number.
int32_t ModuleRtpRtcpImpl::SetStartTimestamp(
const uint32_t timestamp) {
WEBRTC_TRACE(kTraceModuleCall,
kTraceRtpRtcp,
id_,
"SetStartTimestamp(%d)",
timestamp);
rtcp_sender_.SetStartTimestamp(timestamp);
rtp_sender_.SetStartTimestamp(timestamp, true);
return 0; // TODO(pwestin): change to void.
}
uint16_t ModuleRtpRtcpImpl::SequenceNumber() const {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "SequenceNumber()");
return rtp_sender_.SequenceNumber();
}
// Set SequenceNumber, default is a random number.
int32_t ModuleRtpRtcpImpl::SetSequenceNumber(
const uint16_t seq_num) {
WEBRTC_TRACE(kTraceModuleCall,
kTraceRtpRtcp,
id_,
"SetSequenceNumber(%d)",
seq_num);
rtp_sender_.SetSequenceNumber(seq_num);
return 0; // TODO(pwestin): change to void.
}
uint32_t ModuleRtpRtcpImpl::SSRC() const {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "SSRC()");
return rtp_sender_.SSRC();
}
// Configure SSRC, default is a random number.
int32_t ModuleRtpRtcpImpl::SetSSRC(const uint32_t ssrc) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "SetSSRC(%d)", ssrc);
rtp_sender_.SetSSRC(ssrc);
rtcp_sender_.SetSSRC(ssrc);
SetRtcpReceiverSsrcs(ssrc);
@ -434,20 +363,12 @@ int32_t ModuleRtpRtcpImpl::SetCSRCStatus(const bool include) {
int32_t ModuleRtpRtcpImpl::CSRCs(
uint32_t arr_of_csrc[kRtpCsrcSize]) const {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "CSRCs()");
return rtp_sender_.CSRCs(arr_of_csrc);
}
int32_t ModuleRtpRtcpImpl::SetCSRCs(
const uint32_t arr_of_csrc[kRtpCsrcSize],
const uint8_t arr_length) {
WEBRTC_TRACE(kTraceModuleCall,
kTraceRtpRtcp,
id_,
"SetCSRCs(arr_length:%d)",
arr_length);
if (IsDefaultModule()) {
// For default we need to update all child modules too.
CriticalSectionScoped lock(critical_section_module_ptrs_.get());
@ -461,10 +382,6 @@ int32_t ModuleRtpRtcpImpl::SetCSRCs(
it++;
}
} else {
for (int i = 0; i < arr_length; ++i) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "\tidx:%d CSRC:%u", i,
arr_of_csrc[i]);
}
rtcp_sender_.SetCSRCs(arr_of_csrc, arr_length);
rtp_sender_.SetCSRCs(arr_of_csrc, arr_length);
}
@ -472,35 +389,23 @@ int32_t ModuleRtpRtcpImpl::SetCSRCs(
}
uint32_t ModuleRtpRtcpImpl::PacketCountSent() const {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "PacketCountSent()");
return rtp_sender_.Packets();
}
uint32_t ModuleRtpRtcpImpl::ByteCountSent() const {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "ByteCountSent()");
return rtp_sender_.Bytes();
}
int ModuleRtpRtcpImpl::CurrentSendFrequencyHz() const {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_,
"CurrentSendFrequencyHz()");
return rtp_sender_.SendPayloadFrequency();
}
int32_t ModuleRtpRtcpImpl::SetSendingStatus(const bool sending) {
if (sending) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_,
"SetSendingStatus(sending)");
} else {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_,
"SetSendingStatus(stopped)");
}
if (rtcp_sender_.Sending() != sending) {
// Sends RTCP BYE when going from true to false
RTCPSender::FeedbackState feedback_state(this);
if (rtcp_sender_.SetSendingStatus(feedback_state, sending) != 0) {
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, id_,
"Failed to send RTCP BYE");
LOG(LS_WARNING) << "Failed to send RTCP BYE";
}
collision_detected_ = false;
@ -525,25 +430,15 @@ int32_t ModuleRtpRtcpImpl::SetSendingStatus(const bool sending) {
}
bool ModuleRtpRtcpImpl::Sending() const {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "Sending()");
return rtcp_sender_.Sending();
}
int32_t ModuleRtpRtcpImpl::SetSendingMediaStatus(const bool sending) {
if (sending) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_,
"SetSendingMediaStatus(sending)");
} else {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_,
"SetSendingMediaStatus(stopped)");
}
rtp_sender_.SetSendingMediaStatus(sending);
return 0;
}
bool ModuleRtpRtcpImpl::SendingMedia() const {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "Sending()");
if (!IsDefaultModule()) {
return rtp_sender_.SendingMedia();
}
@ -569,13 +464,6 @@ int32_t ModuleRtpRtcpImpl::SendOutgoingData(
uint32_t payload_size,
const RTPFragmentationHeader* fragmentation,
const RTPVideoHeader* rtp_video_hdr) {
WEBRTC_TRACE(
kTraceStream,
kTraceRtpRtcp,
id_,
"SendOutgoingData(frame_type:%d payload_type:%d time_stamp:%u size:%u)",
frame_type, payload_type, time_stamp, payload_size);
rtcp_sender_.SetLastRtpTime(time_stamp, capture_time_ms);
if (!IsDefaultModule()) {
@ -619,11 +507,6 @@ int32_t ModuleRtpRtcpImpl::SendOutgoingData(
if (it == child_modules_.end()) {
return -1;
}
WEBRTC_TRACE(kTraceModuleCall,
kTraceRtpRtcp,
id_,
"SendOutgoingData(SimulcastIdx:%u size:%u, ssrc:0x%x)",
idx, payload_size, (*it)->rtp_sender_.SSRC());
return (*it)->SendOutgoingData(frame_type,
payload_type,
time_stamp,
@ -656,13 +539,6 @@ bool ModuleRtpRtcpImpl::TimeToSendPacket(uint32_t ssrc,
uint16_t sequence_number,
int64_t capture_time_ms,
bool retransmission) {
WEBRTC_TRACE(
kTraceStream,
kTraceRtpRtcp,
id_,
"TimeToSendPacket(ssrc:0x%x sequence_number:%u capture_time_ms:%ll)",
ssrc, sequence_number, capture_time_ms);
if (!IsDefaultModule()) {
// Don't send from default module.
if (SendingMedia() && ssrc == rtp_sender_.SSRC()) {
@ -686,9 +562,6 @@ bool ModuleRtpRtcpImpl::TimeToSendPacket(uint32_t ssrc,
}
int ModuleRtpRtcpImpl::TimeToSendPadding(int bytes) {
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, id_, "TimeToSendPadding(bytes: %d)",
bytes);
if (!IsDefaultModule()) {
// Don't send from default module.
if (SendingMedia()) {
@ -721,16 +594,10 @@ bool ModuleRtpRtcpImpl::GetSendSideDelay(int* avg_send_delay_ms,
}
uint16_t ModuleRtpRtcpImpl::MaxPayloadLength() const {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "MaxPayloadLength()");
return rtp_sender_.MaxPayloadLength();
}
uint16_t ModuleRtpRtcpImpl::MaxDataPayloadLength() const {
WEBRTC_TRACE(kTraceModuleCall,
kTraceRtpRtcp,
id_,
"MaxDataPayloadLength()");
// Assuming IP/UDP.
uint16_t min_data_payload_length = IP_PACKET_SIZE - 28;
@ -763,13 +630,6 @@ int32_t ModuleRtpRtcpImpl::SetTransportOverhead(
const bool tcp,
const bool ipv6,
const uint8_t authentication_overhead) {
WEBRTC_TRACE(
kTraceModuleCall,
kTraceRtpRtcp,
id_,
"SetTransportOverhead(TCP:%d, IPV6:%d authentication_overhead:%u)",
tcp, ipv6, authentication_overhead);
uint16_t packet_overhead = 0;
if (ipv6) {
packet_overhead = 40;
@ -801,11 +661,8 @@ int32_t ModuleRtpRtcpImpl::SetTransportOverhead(
}
int32_t ModuleRtpRtcpImpl::SetMaxTransferUnit(const uint16_t mtu) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "SetMaxTransferUnit(%u)",
mtu);
if (mtu > IP_PACKET_SIZE) {
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, id_,
"Invalid in argument to SetMaxTransferUnit(%u)", mtu);
LOG(LS_ERROR) << "Invalid mtu: " << mtu;
return -1;
}
return rtp_sender_.SetMaxPayloadLength(mtu - packet_overhead_,
@ -813,7 +670,6 @@ int32_t ModuleRtpRtcpImpl::SetMaxTransferUnit(const uint16_t mtu) {
}
RTCPMethod ModuleRtpRtcpImpl::RTCP() const {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "RTCP()");
if (rtcp_sender_.Status() != kRtcpOff) {
return rtcp_receiver_.Status();
}
@ -822,8 +678,6 @@ RTCPMethod ModuleRtpRtcpImpl::RTCP() const {
// Configure RTCP status i.e on/off.
int32_t ModuleRtpRtcpImpl::SetRTCPStatus(const RTCPMethod method) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "SetRTCPStatus(%d)",
method);
if (rtcp_sender_.SetRTCPStatus(method) == 0) {
return rtcp_receiver_.SetRTCPStatus(method);
}
@ -837,34 +691,26 @@ uint32_t ModuleRtpRtcpImpl::LastSendReport(
}
int32_t ModuleRtpRtcpImpl::SetCNAME(const char c_name[RTCP_CNAME_SIZE]) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "SetCNAME(%s)", c_name);
return rtcp_sender_.SetCNAME(c_name);
}
int32_t ModuleRtpRtcpImpl::CNAME(char c_name[RTCP_CNAME_SIZE]) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "CNAME()");
return rtcp_sender_.CNAME(c_name);
}
int32_t ModuleRtpRtcpImpl::AddMixedCNAME(
const uint32_t ssrc,
const char c_name[RTCP_CNAME_SIZE]) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_,
"AddMixedCNAME(SSRC:%u)", ssrc);
return rtcp_sender_.AddMixedCNAME(ssrc, c_name);
}
int32_t ModuleRtpRtcpImpl::RemoveMixedCNAME(const uint32_t ssrc) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_,
"RemoveMixedCNAME(SSRC:%u)", ssrc);
return rtcp_sender_.RemoveMixedCNAME(ssrc);
}
int32_t ModuleRtpRtcpImpl::RemoteCNAME(
const uint32_t remote_ssrc,
char c_name[RTCP_CNAME_SIZE]) const {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_,
"RemoteCNAME(SSRC:%u)", remote_ssrc);
return rtcp_receiver_.CNAME(remote_ssrc, c_name);
}
@ -874,7 +720,6 @@ int32_t ModuleRtpRtcpImpl::RemoteNTP(
uint32_t* rtcp_arrival_time_secs,
uint32_t* rtcp_arrival_time_frac,
uint32_t* rtcp_timestamp) const {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "RemoteNTP()");
return rtcp_receiver_.NTP(received_ntpsecs,
received_ntpfrac,
rtcp_arrival_time_secs,
@ -888,21 +733,16 @@ int32_t ModuleRtpRtcpImpl::RTT(const uint32_t remote_ssrc,
uint16_t* avg_rtt,
uint16_t* min_rtt,
uint16_t* max_rtt) const {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "RTT()");
return rtcp_receiver_.RTT(remote_ssrc, rtt, avg_rtt, min_rtt, max_rtt);
}
// Reset RoundTripTime statistics.
int32_t ModuleRtpRtcpImpl::ResetRTT(const uint32_t remote_ssrc) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "ResetRTT(SSRC:%u)",
remote_ssrc);
return rtcp_receiver_.ResetRTT(remote_ssrc);
}
// Reset RTP data counters for the sending side.
int32_t ModuleRtpRtcpImpl::ResetSendDataCountersRTP() {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_,
"ResetSendDataCountersRTP()");
rtp_sender_.ResetDataCounters();
return 0; // TODO(pwestin): change to void.
}
@ -910,8 +750,6 @@ int32_t ModuleRtpRtcpImpl::ResetSendDataCountersRTP() {
// Force a send of an RTCP packet.
// Normal SR and RR are triggered via the process function.
int32_t ModuleRtpRtcpImpl::SendRTCP(uint32_t rtcp_packet_type) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "SendRTCP(0x%x)",
rtcp_packet_type);
RTCPSender::FeedbackState feedback_state(this);
return rtcp_sender_.SendRTCP(feedback_state, rtcp_packet_type);
}
@ -921,23 +759,16 @@ int32_t ModuleRtpRtcpImpl::SetRTCPApplicationSpecificData(
const uint32_t name,
const uint8_t* data,
const uint16_t length) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_,
"SetRTCPApplicationSpecificData(sub_type:%d name:0x%x)",
sub_type, name);
return rtcp_sender_.SetApplicationSpecificData(sub_type, name, data, length);
}
// (XR) VOIP metric.
int32_t ModuleRtpRtcpImpl::SetRTCPVoIPMetrics(
const RTCPVoIPMetric* voip_metric) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "SetRTCPVoIPMetrics()");
return rtcp_sender_.SetRTCPVoIPMetrics(voip_metric);
}
void ModuleRtpRtcpImpl::SetRtcpXrRrtrStatus(bool enable) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_,
"SetRtcpXrRrtrStatus(%s)", enable ? "true" : "false");
return rtcp_sender_.SendRtcpXrReceiverReferenceTime(enable);
}
@ -948,7 +779,6 @@ bool ModuleRtpRtcpImpl::RtcpXrRrtrStatus() const {
int32_t ModuleRtpRtcpImpl::DataCountersRTP(
uint32_t* bytes_sent,
uint32_t* packets_sent) const {
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, id_, "DataCountersRTP()");
if (bytes_sent) {
*bytes_sent = rtp_sender_.Bytes();
}
@ -959,27 +789,23 @@ int32_t ModuleRtpRtcpImpl::DataCountersRTP(
}
int32_t ModuleRtpRtcpImpl::RemoteRTCPStat(RTCPSenderInfo* sender_info) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "RemoteRTCPStat()");
return rtcp_receiver_.SenderInfoReceived(sender_info);
}
// Received RTCP report.
int32_t ModuleRtpRtcpImpl::RemoteRTCPStat(
std::vector<RTCPReportBlock>* receive_blocks) const {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "RemoteRTCPStat()");
return rtcp_receiver_.StatisticsReceived(receive_blocks);
}
int32_t ModuleRtpRtcpImpl::AddRTCPReportBlock(
const uint32_t ssrc,
const RTCPReportBlock* report_block) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "AddRTCPReportBlock()");
return rtcp_sender_.AddExternalReportBlock(ssrc, report_block);
}
int32_t ModuleRtpRtcpImpl::RemoveRTCPReportBlock(
const uint32_t ssrc) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "RemoveRTCPReportBlock()");
return rtcp_sender_.RemoveExternalReportBlock(ssrc);
}
@ -992,44 +818,25 @@ void ModuleRtpRtcpImpl::GetRtcpPacketTypeCounters(
// (REMB) Receiver Estimated Max Bitrate.
bool ModuleRtpRtcpImpl::REMB() const {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "REMB()");
return rtcp_sender_.REMB();
}
int32_t ModuleRtpRtcpImpl::SetREMBStatus(const bool enable) {
if (enable) {
WEBRTC_TRACE(kTraceModuleCall,
kTraceRtpRtcp,
id_,
"SetREMBStatus(enable)");
} else {
WEBRTC_TRACE(kTraceModuleCall,
kTraceRtpRtcp,
id_,
"SetREMBStatus(disable)");
}
return rtcp_sender_.SetREMBStatus(enable);
}
int32_t ModuleRtpRtcpImpl::SetREMBData(const uint32_t bitrate,
const uint8_t number_of_ssrc,
const uint32_t* ssrc) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_,
"SetREMBData(bitrate:%d,?,?)", bitrate);
return rtcp_sender_.SetREMBData(bitrate, number_of_ssrc, ssrc);
}
// (IJ) Extended jitter report.
bool ModuleRtpRtcpImpl::IJ() const {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "IJ()");
return rtcp_sender_.IJ();
}
int32_t ModuleRtpRtcpImpl::SetIJStatus(const bool enable) {
WEBRTC_TRACE(kTraceModuleCall,
kTraceRtpRtcp,
id_,
"SetIJStatus(%s)", enable ? "true" : "false");
return rtcp_sender_.SetIJStatus(enable);
}
@ -1046,23 +853,14 @@ int32_t ModuleRtpRtcpImpl::DeregisterSendRtpHeaderExtension(
// (TMMBR) Temporary Max Media Bit Rate.
bool ModuleRtpRtcpImpl::TMMBR() const {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "TMMBR()");
return rtcp_sender_.TMMBR();
}
int32_t ModuleRtpRtcpImpl::SetTMMBRStatus(const bool enable) {
if (enable) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_,
"SetTMMBRStatus(enable)");
} else {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_,
"SetTMMBRStatus(disable)");
}
return rtcp_sender_.SetTMMBRStatus(enable);
}
int32_t ModuleRtpRtcpImpl::SetTMMBN(const TMMBRSet* bounding_set) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "SetTMMBN()");
uint32_t max_bitrate_kbit =
rtp_sender_.MaxConfiguredBitrateVideo() / 1000;
return rtcp_sender_.SetTMMBN(bounding_set, max_bitrate_kbit);
@ -1070,32 +868,18 @@ int32_t ModuleRtpRtcpImpl::SetTMMBN(const TMMBRSet* bounding_set) {
// Returns the currently configured retransmission mode.
int ModuleRtpRtcpImpl::SelectiveRetransmissions() const {
WEBRTC_TRACE(kTraceModuleCall,
kTraceRtpRtcp,
id_,
"SelectiveRetransmissions()");
return rtp_sender_.SelectiveRetransmissions();
}
// Enable or disable a retransmission mode, which decides which packets will
// be retransmitted if NACKed.
int ModuleRtpRtcpImpl::SetSelectiveRetransmissions(uint8_t settings) {
WEBRTC_TRACE(kTraceModuleCall,
kTraceRtpRtcp,
id_,
"SetSelectiveRetransmissions(%u)",
settings);
return rtp_sender_.SetSelectiveRetransmissions(settings);
}
// Send a Negative acknowledgment packet.
int32_t ModuleRtpRtcpImpl::SendNACK(const uint16_t* nack_list,
const uint16_t size) {
WEBRTC_TRACE(kTraceModuleCall,
kTraceRtpRtcp,
id_,
"SendNACK(size:%u)", size);
// Use RTT from RtcpRttStats class if provided.
uint16_t rtt = rtt_ms();
if (rtt == 0) {
@ -1149,14 +933,6 @@ int32_t ModuleRtpRtcpImpl::SendNACK(const uint16_t* nack_list,
int32_t ModuleRtpRtcpImpl::SetStorePacketsStatus(
const bool enable,
const uint16_t number_to_store) {
if (enable) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_,
"SetStorePacketsStatus(enable, number_to_store:%d)",
number_to_store);
} else {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_,
"SetStorePacketsStatus(disable)");
}
rtp_sender_.SetStorePacketsStatus(enable, number_to_store);
return 0; // TODO(pwestin): change to void.
}
@ -1180,19 +956,11 @@ int32_t ModuleRtpRtcpImpl::SendTelephoneEventOutband(
const uint8_t key,
const uint16_t time_ms,
const uint8_t level) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_,
"SendTelephoneEventOutband(key:%u, time_ms:%u, level:%u)", key,
time_ms, level);
return rtp_sender_.SendTelephoneEvent(key, time_ms, level);
}
bool ModuleRtpRtcpImpl::SendTelephoneEventActive(
int8_t& telephone_event) const {
WEBRTC_TRACE(kTraceModuleCall,
kTraceRtpRtcp,
id_,
"SendTelephoneEventActive()");
return rtp_sender_.SendTelephoneEventActive(&telephone_event);
}
@ -1200,40 +968,23 @@ bool ModuleRtpRtcpImpl::SendTelephoneEventActive(
// packet in silence (CNG).
int32_t ModuleRtpRtcpImpl::SetAudioPacketSize(
const uint16_t packet_size_samples) {
WEBRTC_TRACE(kTraceModuleCall,
kTraceRtpRtcp,
id_,
"SetAudioPacketSize(%u)",
packet_size_samples);
return rtp_sender_.SetAudioPacketSize(packet_size_samples);
}
int32_t ModuleRtpRtcpImpl::SetAudioLevel(
const uint8_t level_d_bov) {
WEBRTC_TRACE(kTraceModuleCall,
kTraceRtpRtcp,
id_,
"SetAudioLevel(level_d_bov:%u)",
level_d_bov);
return rtp_sender_.SetAudioLevel(level_d_bov);
}
// Set payload type for Redundant Audio Data RFC 2198.
int32_t ModuleRtpRtcpImpl::SetSendREDPayloadType(
const int8_t payload_type) {
WEBRTC_TRACE(kTraceModuleCall,
kTraceRtpRtcp,
id_,
"SetSendREDPayloadType(%d)",
payload_type);
return rtp_sender_.SetRED(payload_type);
}
// Get payload type for Redundant Audio Data RFC 2198.
int32_t ModuleRtpRtcpImpl::SendREDPayloadType(
int8_t& payload_type) const {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "SendREDPayloadType()");
return rtp_sender_.RED(&payload_type);
}
@ -1243,8 +994,6 @@ RtpVideoCodecTypes ModuleRtpRtcpImpl::SendVideoCodec() const {
void ModuleRtpRtcpImpl::SetTargetSendBitrate(
const std::vector<uint32_t>& stream_bitrates) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_,
"SetTargetSendBitrate: %ld streams", stream_bitrates.size());
if (IsDefaultModule()) {
CriticalSectionScoped lock(critical_section_module_ptrs_.get());
if (simulcast_) {
@ -1275,20 +1024,11 @@ void ModuleRtpRtcpImpl::SetTargetSendBitrate(
int32_t ModuleRtpRtcpImpl::SetKeyFrameRequestMethod(
const KeyFrameRequestMethod method) {
WEBRTC_TRACE(kTraceModuleCall,
kTraceRtpRtcp,
id_,
"SetKeyFrameRequestMethod(method:%u)",
method);
key_frame_req_method_ = method;
return 0;
}
int32_t ModuleRtpRtcpImpl::RequestKeyFrame() {
WEBRTC_TRACE(kTraceModuleCall,
kTraceRtpRtcp,
id_,
"RequestKeyFrame");
switch (key_frame_req_method_) {
case kKeyFrameReqFirRtp:
return rtp_sender_.SendRTPIntraRequest();
@ -1302,22 +1042,12 @@ int32_t ModuleRtpRtcpImpl::RequestKeyFrame() {
int32_t ModuleRtpRtcpImpl::SendRTCPSliceLossIndication(
const uint8_t picture_id) {
WEBRTC_TRACE(kTraceModuleCall,
kTraceRtpRtcp,
id_,
"SendRTCPSliceLossIndication (picture_id:%d)",
picture_id);
RTCPSender::FeedbackState feedback_state(this);
return rtcp_sender_.SendRTCP(
feedback_state, kRtcpSli, 0, 0, false, picture_id);
}
int32_t ModuleRtpRtcpImpl::SetCameraDelay(const int32_t delay_ms) {
WEBRTC_TRACE(kTraceModuleCall,
kTraceRtpRtcp,
id_,
"SetCameraDelay(%d)",
delay_ms);
if (IsDefaultModule()) {
CriticalSectionScoped lock(critical_section_module_ptrs_.get());
std::list<ModuleRtpRtcpImpl*>::iterator it = child_modules_.begin();
@ -1337,18 +1067,6 @@ int32_t ModuleRtpRtcpImpl::SetGenericFECStatus(
const bool enable,
const uint8_t payload_type_red,
const uint8_t payload_type_fec) {
if (enable) {
WEBRTC_TRACE(kTraceModuleCall,
kTraceRtpRtcp,
id_,
"SetGenericFECStatus(enable, %u)",
payload_type_red);
} else {
WEBRTC_TRACE(kTraceModuleCall,
kTraceRtpRtcp,
id_,
"SetGenericFECStatus(disable)");
}
return rtp_sender_.SetGenericFECStatus(enable,
payload_type_red,
payload_type_fec);
@ -1358,8 +1076,6 @@ int32_t ModuleRtpRtcpImpl::GenericFECStatus(
bool& enable,
uint8_t& payload_type_red,
uint8_t& payload_type_fec) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, id_, "GenericFECStatus()");
bool child_enabled = false;
if (IsDefaultModule()) {
// For default we need to check all child modules too.

View File

@ -15,7 +15,7 @@
#include "webrtc/modules/rtp_rtcp/source/rtp_sender_audio.h"
#include "webrtc/modules/rtp_rtcp/source/rtp_sender_video.h"
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
#include "webrtc/system_wrappers/interface/trace.h"
#include "webrtc/system_wrappers/interface/logging.h"
#include "webrtc/system_wrappers/interface/trace_event.h"
namespace webrtc {
@ -105,9 +105,8 @@ RTPSender::RTPSender(const int32_t id,
audio_ = new RTPSenderAudio(id, clock_, this);
audio_->RegisterAudioCallback(audio_feedback);
} else {
video_ = new RTPSenderVideo(id, clock_, this);
video_ = new RTPSenderVideo(clock_, this);
}
WEBRTC_TRACE(kTraceMemory, kTraceRtpRtcp, id, "%s created", __FUNCTION__);
}
RTPSender::~RTPSender() {
@ -126,8 +125,6 @@ RTPSender::~RTPSender() {
}
delete audio_;
delete video_;
WEBRTC_TRACE(kTraceMemory, kTraceRtpRtcp, id_, "%s deleted", __FUNCTION__);
}
void RTPSender::SetTargetSendBitrate(const uint32_t bits) {
@ -290,16 +287,12 @@ int32_t RTPSender::SetMaxPayloadLength(
const uint16_t packet_over_head) {
// Sanity check.
if (max_payload_length < 100 || max_payload_length > IP_PACKET_SIZE) {
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, id_, "%s invalid argument",
__FUNCTION__);
LOG(LS_ERROR) << "Invalid max payload length: " << max_payload_length;
return -1;
}
CriticalSectionScoped cs(send_critsect_);
max_payload_length_ = max_payload_length;
packet_over_head_ = packet_over_head;
WEBRTC_TRACE(kTraceInfo, kTraceRtpRtcp, id_, "SetMaxPayloadLength to %d.",
max_payload_length);
return 0;
}
@ -350,8 +343,7 @@ int32_t RTPSender::CheckPayloadType(const int8_t payload_type,
CriticalSectionScoped cs(send_critsect_);
if (payload_type < 0) {
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, id_, "\tinvalid payload_type (%d)",
payload_type);
LOG(LS_ERROR) << "Invalid payload_type " << payload_type;
return -1;
}
if (audio_configured_) {
@ -373,8 +365,7 @@ int32_t RTPSender::CheckPayloadType(const int8_t payload_type,
std::map<int8_t, ModuleRTPUtility::Payload *>::iterator it =
payload_type_map_.find(payload_type);
if (it == payload_type_map_.end()) {
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, id_,
"\tpayloadType:%d not registered", payload_type);
LOG(LS_WARNING) << "Payload type " << payload_type << " not registered.";
return -1;
}
payload_type_ = payload_type;
@ -403,9 +394,7 @@ int32_t RTPSender::SendOutgoingData(
}
RtpVideoCodecTypes video_type = kRtpVideoGeneric;
if (CheckPayloadType(payload_type, &video_type) != 0) {
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, id_,
"%s invalid argument failed to find payload_type:%d",
__FUNCTION__, payload_type);
LOG(LS_ERROR) << "Don't send data with unknown payload type.";
return -1;
}
@ -616,8 +605,6 @@ int32_t RTPSender::ReSendPacket(uint16_t packet_id, uint32_t min_resend_time) {
RTPHeader header;
if (!rtp_parser.Parse(header)) {
assert(false);
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, id_,
"Failed to parse RTP header of packet to be retransmitted.");
return -1;
}
if (!paced_sender_->SendPacket(PacedSender::kHighPriority,
@ -644,10 +631,9 @@ bool RTPSender::SendPacketToNetwork(const uint8_t *packet, uint32_t size) {
}
TRACE_EVENT_INSTANT2("webrtc_rtp", "RTPSender::SendPacketToNetwork",
"size", size, "sent", bytes_sent);
// TODO(pwesin): Add a separate bitrate for sent bitrate after pacer.
// TODO(pwestin): Add a separate bitrate for sent bitrate after pacer.
if (bytes_sent <= 0) {
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, id_,
"Transport failed to send packet");
LOG(LS_WARNING) << "Transport failed to send packet";
return false;
}
return true;
@ -676,11 +662,8 @@ void RTPSender::OnReceivedNACK(
// Enough bandwidth to send NACK?
if (!ProcessNACKBitRate(now)) {
WEBRTC_TRACE(kTraceStream,
kTraceRtpRtcp,
id_,
"NACK bitrate reached. Skip sending NACK response. Target %d",
target_bitrate_kbps);
LOG(LS_INFO) << "NACK bitrate reached. Skip sending NACK response. Target "
<< target_bitrate_kbps;
return;
}
@ -695,9 +678,8 @@ void RTPSender::OnReceivedNACK(
continue;
} else if (bytes_sent < 0) {
// Failed to send one Sequence number. Give up the rest in this nack.
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, id_,
"Failed resending RTP packet %d, Discard rest of packets",
*it);
LOG(LS_WARNING) << "Failed resending RTP packet " << *it
<< ", Discard rest of packets";
break;
}
// Delay bandwidth estimate (RTT * BW).
@ -1258,39 +1240,36 @@ bool RTPSender::UpdateTransmissionTimeOffset(
rtp_header_extension_map_.GetLengthUntilBlockStartInBytes(
kRtpExtensionTransmissionTimeOffset);
if (extension_block_pos < 0) {
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, id_,
"Failed to update transmission time offset, not registered.");
LOG(LS_WARNING)
<< "Failed to update transmission time offset, not registered.";
return false;
}
int block_pos = 12 + rtp_header.numCSRCs + extension_block_pos;
if (rtp_packet_length < block_pos + kTransmissionTimeOffsetLength ||
rtp_header.headerLength <
block_pos + kTransmissionTimeOffsetLength) {
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, id_,
"Failed to update transmission time offset, invalid length.");
LOG(LS_WARNING)
<< "Failed to update transmission time offset, invalid length.";
return false;
}
// Verify that header contains extension.
if (!((rtp_packet[12 + rtp_header.numCSRCs] == 0xBE) &&
(rtp_packet[12 + rtp_header.numCSRCs + 1] == 0xDE))) {
WEBRTC_TRACE(
kTraceStream, kTraceRtpRtcp, id_,
"Failed to update transmission time offset, hdr extension not found.");
LOG(LS_WARNING) << "Failed to update transmission time offset, hdr "
"extension not found.";
return false;
}
// Get id.
uint8_t id = 0;
if (rtp_header_extension_map_.GetId(kRtpExtensionTransmissionTimeOffset,
&id) != 0) {
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, id_,
"Failed to update transmission time offset, no id.");
LOG(LS_WARNING) << "Failed to update transmission time offset, no id.";
return false;
}
// Verify first byte in block.
const uint8_t first_block_byte = (id << 4) + 2;
if (rtp_packet[block_pos] != first_block_byte) {
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, id_,
"Failed to update transmission time offset.");
LOG(LS_WARNING) << "Failed to update transmission time offset.";
return false;
}
// Update transmission offset field (converting to a 90 kHz timestamp).
@ -1311,37 +1290,31 @@ bool RTPSender::UpdateAudioLevel(uint8_t *rtp_packet,
rtp_header_extension_map_.GetLengthUntilBlockStartInBytes(
kRtpExtensionAudioLevel);
if (extension_block_pos < 0) {
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, id_,
"Failed to update audio level, not registered.");
LOG(LS_WARNING) << "Failed to update audio level, not registered.";
return false;
}
int block_pos = 12 + rtp_header.numCSRCs + extension_block_pos;
if (rtp_packet_length < block_pos + kAudioLevelLength ||
rtp_header.headerLength < block_pos + kAudioLevelLength) {
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, id_,
"Failed to update audio level, invalid length.");
LOG(LS_WARNING) << "Failed to update audio level, invalid length.";
return false;
}
// Verify that header contains extension.
if (!((rtp_packet[12 + rtp_header.numCSRCs] == 0xBE) &&
(rtp_packet[12 + rtp_header.numCSRCs + 1] == 0xDE))) {
WEBRTC_TRACE(
kTraceStream, kTraceRtpRtcp, id_,
"Failed to update audio level, hdr extension not found.");
LOG(LS_WARNING) << "Failed to update audio level, hdr extension not found.";
return false;
}
// Get id.
uint8_t id = 0;
if (rtp_header_extension_map_.GetId(kRtpExtensionAudioLevel, &id) != 0) {
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, id_,
"Failed to update audio level, no id.");
LOG(LS_WARNING) << "Failed to update audio level, no id.";
return false;
}
// Verify first byte in block.
const uint8_t first_block_byte = (id << 4) + 0;
if (rtp_packet[block_pos] != first_block_byte) {
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, id_,
"Failed to update audio level.");
LOG(LS_WARNING) << "Failed to update audio level.";
return false;
}
rtp_packet[block_pos + 1] = (is_voiced ? 0x80 : 0x00) + (dBov & 0x7f);
@ -1358,38 +1331,33 @@ bool RTPSender::UpdateAbsoluteSendTime(
rtp_header_extension_map_.GetLengthUntilBlockStartInBytes(
kRtpExtensionAbsoluteSendTime);
if (extension_block_pos < 0) {
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, id_,
"Failed to update absolute send time, not registered.");
LOG(LS_WARNING) << "Failed to update absolute send time, not registered.";
return false;
}
int block_pos = 12 + rtp_header.numCSRCs + extension_block_pos;
if (rtp_packet_length < block_pos + kAbsoluteSendTimeLength ||
rtp_header.headerLength < block_pos + kAbsoluteSendTimeLength) {
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, id_,
"Failed to update absolute send time, invalid length.");
LOG(LS_WARNING) << "Failed to update absolute send time, invalid length.";
return false;
}
// Verify that header contains extension.
if (!((rtp_packet[12 + rtp_header.numCSRCs] == 0xBE) &&
(rtp_packet[12 + rtp_header.numCSRCs + 1] == 0xDE))) {
WEBRTC_TRACE(
kTraceStream, kTraceRtpRtcp, id_,
"Failed to update absolute send time, hdr extension not found.");
LOG(LS_WARNING)
<< "Failed to update absolute send time, hdr extension not found.";
return false;
}
// Get id.
uint8_t id = 0;
if (rtp_header_extension_map_.GetId(kRtpExtensionAbsoluteSendTime,
&id) != 0) {
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, id_,
"Failed to update absolute send time, no id.");
LOG(LS_WARNING) << "Failed to update absolute send time, no id.";
return false;
}
// Verify first byte in block.
const uint8_t first_block_byte = (id << 4) + 2;
if (rtp_packet[block_pos] != first_block_byte) {
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, id_,
"Failed to update absolute send time.");
LOG(LS_WARNING) << "Failed to update absolute send time.";
return false;
}
// Update absolute send time field (convert ms to 24-bit unsigned with 18 bit

View File

@ -20,7 +20,7 @@
#include "webrtc/modules/rtp_rtcp/source/rtp_format_vp8.h"
#include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
#include "webrtc/system_wrappers/interface/trace.h"
#include "webrtc/system_wrappers/interface/logging.h"
#include "webrtc/system_wrappers/interface/trace_event.h"
namespace webrtc {
@ -31,11 +31,9 @@ struct RtpPacket {
ForwardErrorCorrection::Packet* pkt;
};
RTPSenderVideo::RTPSenderVideo(const int32_t id,
Clock* clock,
RTPSenderVideo::RTPSenderVideo(Clock* clock,
RTPSenderInterface* rtpSender)
: _id(id),
_rtpSender(*rtpSender),
: _rtpSender(*rtpSender),
_sendVideoCritsect(CriticalSectionWrapper::CreateCriticalSection()),
_videoType(kRtpVideoGeneric),
_videoCodecInformation(NULL),
@ -43,7 +41,7 @@ RTPSenderVideo::RTPSenderVideo(const int32_t id,
_retransmissionSettings(kRetransmitBaseLayer),
// Generic FEC
_fec(id),
_fec(),
_fecEnabled(false),
_payloadTypeRED(-1),
_payloadTypeFEC(-1),
@ -329,8 +327,6 @@ RTPSenderVideo::SendVideo(const RtpVideoCodecTypes videoType,
{
return retVal;
}
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, _id, "%s(timestamp:%u)",
__FUNCTION__, captureTimeStamp);
return 0;
}
@ -476,9 +472,9 @@ RTPSenderVideo::SendVP8(const FrameType frameType,
rtpHeaderLength, captureTimeStamp,
capture_time_ms, storage, protect))
{
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id,
"RTPSenderVideo::SendVP8 failed to send packet number"
" %d", _rtpSender.SequenceNumber());
LOG(LS_WARNING)
<< "RTPSenderVideo::SendVP8 failed to send packet number "
<< _rtpSender.SequenceNumber();
}
}
TRACE_EVENT_ASYNC_END1("webrtc", "Video", capture_time_ms,

View File

@ -31,7 +31,7 @@ struct RtpPacket;
class RTPSenderVideo
{
public:
RTPSenderVideo(const int32_t id, Clock* clock,
RTPSenderVideo(Clock* clock,
RTPSenderInterface* rtpSender);
virtual ~RTPSenderVideo();
@ -112,7 +112,6 @@ private:
const RTPVideoTypeHeader* rtpTypeHdr);
private:
int32_t _id;
RTPSenderInterface& _rtpSender;
CriticalSectionWrapper* _sendVideoCritsect;

View File

@ -30,7 +30,7 @@
#endif
#include "webrtc/system_wrappers/interface/tick_util.h"
#include "webrtc/system_wrappers/interface/trace.h"
#include "webrtc/system_wrappers/interface/logging.h"
#if (defined(_DEBUG) && defined(_WIN32) && (_MSC_VER >= 1400))
#define DEBUG_PRINT(...) \
@ -464,22 +464,21 @@ void RTPHeaderParser::ParseOneByteExtensionHeader(
ptr++;
if (id == 15) {
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, -1,
"Ext id: 15 encountered, parsing terminated.");
LOG(LS_WARNING)
<< "RTP extension header 15 encountered. Terminate parsing.";
return;
}
RTPExtensionType type;
if (ptrExtensionMap->GetType(id, &type) != 0) {
// If we encounter an unknown extension, just skip over it.
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, -1,
"Failed to find extension id: %d", id);
LOG(LS_WARNING) << "Failed to find extension id: " << id;
} else {
switch (type) {
case kRtpExtensionTransmissionTimeOffset: {
if (len != 2) {
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, -1,
"Incorrect transmission time offset len: %d", len);
LOG(LS_WARNING) << "Incorrect transmission time offset len: "
<< len;
return;
}
// 0 1 2 3
@ -502,8 +501,7 @@ void RTPHeaderParser::ParseOneByteExtensionHeader(
}
case kRtpExtensionAudioLevel: {
if (len != 0) {
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, -1,
"Incorrect audio level len: %d", len);
LOG(LS_WARNING) << "Incorrect audio level len: " << len;
return;
}
// 0 1 2 3
@ -525,8 +523,7 @@ void RTPHeaderParser::ParseOneByteExtensionHeader(
}
case kRtpExtensionAbsoluteSendTime: {
if (len != 2) {
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, -1,
"Incorrect absolute send time len: %d", len);
LOG(LS_WARNING) << "Incorrect absolute send time len: " << len;
return;
}
// 0 1 2 3
@ -543,8 +540,7 @@ void RTPHeaderParser::ParseOneByteExtensionHeader(
break;
}
default: {
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, -1,
"Extension type not implemented.");
LOG(LS_WARNING) << "Extension type not implemented: " << type;
return;
}
}
@ -570,17 +566,12 @@ uint8_t RTPHeaderParser::ParsePaddingBytes(
return num_zero_bytes;
}
// RTP payload parser
RTPPayloadParser::RTPPayloadParser(const RtpVideoCodecTypes videoType,
const uint8_t* payloadData,
uint16_t payloadDataLength,
int32_t id)
:
_id(id),
_dataPtr(payloadData),
_dataLength(payloadDataLength),
_videoType(videoType) {
}
uint16_t payloadDataLength)
: _dataPtr(payloadData),
_dataLength(payloadDataLength),
_videoType(videoType) {}
RTPPayloadParser::~RTPPayloadParser() {
}
@ -655,8 +646,7 @@ bool RTPPayloadParser::ParseVP8(RTPPayload& parsedPacket) const {
}
if (dataLength <= 0) {
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id,
"Error parsing VP8 payload descriptor; payload too short");
LOG(LS_ERROR) << "Error parsing VP8 payload descriptor!";
return false;
}

View File

@ -166,8 +166,8 @@ namespace ModuleRTPUtility
public:
RTPPayloadParser(const RtpVideoCodecTypes payloadType,
const uint8_t* payloadData,
const uint16_t payloadDataLength, // Length w/o padding.
const int32_t id);
// Length w/o padding.
const uint16_t payloadDataLength);
~RTPPayloadParser();
@ -202,7 +202,6 @@ namespace ModuleRTPUtility
int dataLength) const;
private:
int32_t _id;
const uint8_t* _dataPtr;
const uint16_t _dataLength;
const RtpVideoCodecTypes _videoType;

View File

@ -76,7 +76,7 @@ TEST(ParseVP8Test, BasicHeader) {
payload[0] = 0x14; // Binary 0001 0100; S = 1, PartID = 4.
payload[1] = 0x01; // P frame.
RTPPayloadParser rtpPayloadParser(kRtpVideoVp8, payload, 4, 0);
RTPPayloadParser rtpPayloadParser(kRtpVideoVp8, payload, 4);
RTPPayload parsedPacket;
ASSERT_TRUE(rtpPayloadParser.Parse(parsedPacket));
@ -97,7 +97,7 @@ TEST(ParseVP8Test, PictureID) {
payload[1] = 0x80;
payload[2] = 17;
RTPPayloadParser rtpPayloadParser(kRtpVideoVp8, payload, 10, 0);
RTPPayloadParser rtpPayloadParser(kRtpVideoVp8, payload, 10);
RTPPayload parsedPacket;
ASSERT_TRUE(rtpPayloadParser.Parse(parsedPacket));
@ -117,7 +117,7 @@ TEST(ParseVP8Test, PictureID) {
// Re-use payload, but change to long PictureID.
payload[2] = 0x80 | 17;
payload[3] = 17;
RTPPayloadParser rtpPayloadParser2(kRtpVideoVp8, payload, 10, 0);
RTPPayloadParser rtpPayloadParser2(kRtpVideoVp8, payload, 10);
ASSERT_TRUE(rtpPayloadParser2.Parse(parsedPacket));
@ -136,7 +136,7 @@ TEST(ParseVP8Test, Tl0PicIdx) {
payload[1] = 0x40;
payload[2] = 17;
RTPPayloadParser rtpPayloadParser(kRtpVideoVp8, payload, 13, 0);
RTPPayloadParser rtpPayloadParser(kRtpVideoVp8, payload, 13);
RTPPayload parsedPacket;
ASSERT_TRUE(rtpPayloadParser.Parse(parsedPacket));
@ -159,7 +159,7 @@ TEST(ParseVP8Test, TIDAndLayerSync) {
payload[1] = 0x20;
payload[2] = 0x80; // TID(2) + LayerSync(false)
RTPPayloadParser rtpPayloadParser(kRtpVideoVp8, payload, 10, 0);
RTPPayloadParser rtpPayloadParser(kRtpVideoVp8, payload, 10);
RTPPayload parsedPacket;
ASSERT_TRUE(rtpPayloadParser.Parse(parsedPacket));
@ -183,7 +183,7 @@ TEST(ParseVP8Test, KeyIdx) {
payload[1] = 0x10; // K = 1.
payload[2] = 0x11; // KEYIDX = 17 decimal.
RTPPayloadParser rtpPayloadParser(kRtpVideoVp8, payload, 10, 0);
RTPPayloadParser rtpPayloadParser(kRtpVideoVp8, payload, 10);
RTPPayload parsedPacket;
ASSERT_TRUE(rtpPayloadParser.Parse(parsedPacket));
@ -209,7 +209,7 @@ TEST(ParseVP8Test, MultipleExtensions) {
payload[4] = 42; // Tl0PicIdx.
payload[5] = 0x40 | 0x20 | 0x11; // TID(1) + LayerSync(true) + KEYIDX(17).
RTPPayloadParser rtpPayloadParser(kRtpVideoVp8, payload, 10, 0);
RTPPayloadParser rtpPayloadParser(kRtpVideoVp8, payload, 10);
RTPPayload parsedPacket;
ASSERT_TRUE(rtpPayloadParser.Parse(parsedPacket));
@ -236,7 +236,7 @@ TEST(ParseVP8Test, TooShortHeader) {
payload[2] = 0x80 | 17; // ... but only 2 bytes PictureID is provided.
payload[3] = 17; // PictureID, low 8 bits.
RTPPayloadParser rtpPayloadParser(kRtpVideoVp8, payload, 4, 0);
RTPPayloadParser rtpPayloadParser(kRtpVideoVp8, payload, 4);
RTPPayload parsedPacket;
EXPECT_FALSE(rtpPayloadParser.Parse(parsedPacket));
@ -258,7 +258,7 @@ TEST(ParseVP8Test, TestWithPacketizer) {
ASSERT_EQ(0, packetizer.NextPacket(packet, &send_bytes, &last));
ASSERT_TRUE(last);
RTPPayloadParser rtpPayloadParser(kRtpVideoVp8, packet, send_bytes, 0);
RTPPayloadParser rtpPayloadParser(kRtpVideoVp8, packet, send_bytes);
RTPPayload parsedPacket;
ASSERT_TRUE(rtpPayloadParser.Parse(parsedPacket));

View File

@ -14,7 +14,6 @@
#include <stdlib.h>
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
#include "webrtc/system_wrappers/interface/trace.h"
#ifdef _WIN32
#include <windows.h>
@ -185,8 +184,6 @@ SSRCDatabase::SSRCDatabase()
_ssrcVector = new uint32_t[10];
#endif
_critSect = CriticalSectionWrapper::CreateCriticalSection();
WEBRTC_TRACE(kTraceMemory, kTraceRtpRtcp, -1, "%s created", __FUNCTION__);
}
SSRCDatabase::~SSRCDatabase()
@ -197,8 +194,6 @@ SSRCDatabase::~SSRCDatabase()
_ssrcMap.clear();
#endif
delete _critSect;
WEBRTC_TRACE(kTraceMemory, kTraceRtpRtcp, -1, "%s deleted", __FUNCTION__);
}
uint32_t SSRCDatabase::GenerateRandom()

View File

@ -34,7 +34,7 @@ class RtpRtcpAPITest : public ::testing::Test {
configuration.clock = &fake_clock;
module = RtpRtcp::CreateRtpRtcp(configuration);
rtp_payload_registry_.reset(new RTPPayloadRegistry(
test_id, RTPPayloadStrategy::CreateStrategy(true)));
RTPPayloadStrategy::CreateStrategy(true)));
rtp_receiver_.reset(RtpReceiver::CreateAudioReceiver(
test_id, &fake_clock, NULL, NULL, NULL, rtp_payload_registry_.get()));
}

View File

@ -122,9 +122,9 @@ class RtpRtcpAudioTest : public ::testing::Test {
receive_statistics2_.reset(ReceiveStatistics::Create(&fake_clock));
rtp_payload_registry1_.reset(new RTPPayloadRegistry(
test_id, RTPPayloadStrategy::CreateStrategy(true)));
RTPPayloadStrategy::CreateStrategy(true)));
rtp_payload_registry2_.reset(new RTPPayloadRegistry(
test_id, RTPPayloadStrategy::CreateStrategy(true)));
RTPPayloadStrategy::CreateStrategy(true)));
RtpRtcp::Configuration configuration;
configuration.id = test_id;

View File

@ -116,9 +116,9 @@ class RtpRtcpRtcpTest : public ::testing::Test {
configuration.intra_frame_callback = myRTCPFeedback1;
rtp_payload_registry1_.reset(new RTPPayloadRegistry(
test_id, RTPPayloadStrategy::CreateStrategy(true)));
RTPPayloadStrategy::CreateStrategy(true)));
rtp_payload_registry2_.reset(new RTPPayloadRegistry(
test_id, RTPPayloadStrategy::CreateStrategy(true)));
RTPPayloadStrategy::CreateStrategy(true)));
module1 = RtpRtcp::CreateRtpRtcp(configuration);
@ -280,7 +280,6 @@ TEST_F(RtpRtcpRtcpTest, RTCP) {
reportBlock.lastSR = 6;
// Set report blocks.
EXPECT_EQ(-1, module1->AddRTCPReportBlock(test_CSRC[0], NULL));
EXPECT_EQ(0, module1->AddRTCPReportBlock(test_CSRC[0], &reportBlock));
reportBlock.lastSR= 7;
@ -319,7 +318,6 @@ TEST_F(RtpRtcpRtcpTest, RTCP) {
// get all report blocks
std::vector<RTCPReportBlock> report_blocks;
EXPECT_EQ(-1, module1->RemoteRTCPStat(NULL));
EXPECT_EQ(0, module1->RemoteRTCPStat(&report_blocks));
ASSERT_EQ(1u, report_blocks.size());
const RTCPReportBlock& reportBlockReceived = report_blocks[0];

View File

@ -28,7 +28,7 @@ class RtpRtcpVideoTest : public ::testing::Test {
protected:
RtpRtcpVideoTest()
: test_id_(123),
rtp_payload_registry_(0, RTPPayloadStrategy::CreateStrategy(false)),
rtp_payload_registry_(RTPPayloadStrategy::CreateStrategy(false)),
test_ssrc_(3456),
test_timestamp_(4567),
test_sequence_number_(2345),

View File

@ -105,9 +105,7 @@ TEST(FecTest, FecTest) {
ASSERT_EQ(12, kMaxMediaPackets[1]) << "Max media packets for bursty mode not "
<< "equal to 12.";
uint32_t id = 0;
ForwardErrorCorrection fec(id);
ForwardErrorCorrection fec;
ForwardErrorCorrection::PacketList mediaPacketList;
ForwardErrorCorrection::PacketList fecPacketList;
ForwardErrorCorrection::ReceivedPacketList toDecodeList;

View File

@ -157,7 +157,7 @@ int MTRxTxTest(CmdArgs& args)
configuration.outgoing_transport = outgoingTransport;
RtpRtcp* rtp = RtpRtcp::CreateRtpRtcp(configuration);
scoped_ptr<RTPPayloadRegistry> registry(new RTPPayloadRegistry(
-1, RTPPayloadStrategy::CreateStrategy(false)));
RTPPayloadStrategy::CreateStrategy(false)));
scoped_ptr<RtpReceiver> rtp_receiver(
RtpReceiver::CreateVideoReceiver(-1, Clock::GetRealTimeClock(),
&dataCallback, NULL, registry.get()));

View File

@ -273,7 +273,7 @@ class SsrcHandlers {
LostPackets* lost_packets)
: rtp_header_parser_(RtpHeaderParser::Create()),
rtp_payload_registry_(new RTPPayloadRegistry(
0, RTPPayloadStrategy::CreateStrategy(false))),
RTPPayloadStrategy::CreateStrategy(false))),
rtp_module_(),
payload_sink_(),
ssrc_(ssrc),

View File

@ -54,8 +54,7 @@ class StreamObserver : public newapi::Transport, public RemoteBitrateObserver {
feedback_transport_(feedback_transport),
receive_stats_(ReceiveStatistics::Create(clock)),
payload_registry_(
new RTPPayloadRegistry(-1,
RTPPayloadStrategy::CreateStrategy(false))),
new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(false))),
clock_(clock),
expected_bitrate_bps_(0),
rtx_media_ssrcs_(rtx_media_ssrcs),

View File

@ -643,11 +643,6 @@ int ViEChannel::SetSenderBufferingMode(int target_delay_ms) {
nack_history_size_sender_ = kSendSidePacketHistorySize;
}
}
// Setting nack_history_size_.
// First disabling (forcing free) and then resetting to desired value.
if (rtp_rtcp_->SetStorePacketsStatus(false, 0) != 0) {
return -1;
}
if (rtp_rtcp_->SetStorePacketsStatus(true, nack_history_size_sender_) != 0) {
return -1;
}

View File

@ -35,13 +35,13 @@ ViEReceiver::ViEReceiver(const int32_t channel_id,
channel_id_(channel_id),
rtp_header_parser_(RtpHeaderParser::Create()),
rtp_payload_registry_(new RTPPayloadRegistry(
channel_id, RTPPayloadStrategy::CreateStrategy(false))),
RTPPayloadStrategy::CreateStrategy(false))),
rtp_receiver_(RtpReceiver::CreateVideoReceiver(
channel_id, Clock::GetRealTimeClock(), this, rtp_feedback,
rtp_payload_registry_.get())),
rtp_receive_statistics_(ReceiveStatistics::Create(
Clock::GetRealTimeClock())),
fec_receiver_(FecReceiver::Create(channel_id, this)),
fec_receiver_(FecReceiver::Create(this)),
rtp_rtcp_(NULL),
vcm_(module_vcm),
remote_bitrate_estimator_(remote_bitrate_estimator),

View File

@ -837,8 +837,7 @@ Channel::Channel(int32_t channelId,
_channelId(channelId),
rtp_header_parser_(RtpHeaderParser::Create()),
rtp_payload_registry_(
new RTPPayloadRegistry(channelId,
RTPPayloadStrategy::CreateStrategy(true))),
new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(true))),
rtp_receive_statistics_(ReceiveStatistics::Create(
Clock::GetRealTimeClock())),
rtp_receiver_(RtpReceiver::CreateAudioReceiver(