Rtp-Rtcp sender cleanup.

Some setter functions from Rtp and Rtcp Sender never return negative values. Remove return results from those functions.

Also removed const on non-pointer/reference types for related files.

BUG=
R=henrika@webrtc.org, pbos@webrtc.org, stefan@webrtc.org

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

Patch from Changbin Shao <changbin.shao@intel.com>.

git-svn-id: http://webrtc.googlecode.com/svn/trunk@7962 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
pbos@webrtc.org 2014-12-19 13:49:55 +00:00
parent 556caffb36
commit d16e839c6d
27 changed files with 545 additions and 718 deletions

View File

@ -85,7 +85,7 @@ class RtpRtcp : public Module {
virtual int32_t IncomingRtcpPacket(const uint8_t* incoming_packet, virtual int32_t IncomingRtcpPacket(const uint8_t* incoming_packet,
size_t incoming_packet_length) = 0; size_t incoming_packet_length) = 0;
virtual void SetRemoteSSRC(const uint32_t ssrc) = 0; virtual void SetRemoteSSRC(uint32_t ssrc) = 0;
/************************************************************************** /**************************************************************************
* *
@ -100,7 +100,7 @@ class RtpRtcp : public Module {
* *
* return -1 on failure else 0 * return -1 on failure else 0
*/ */
virtual int32_t SetMaxTransferUnit(const uint16_t size) = 0; virtual int32_t SetMaxTransferUnit(uint16_t size) = 0;
/* /*
* set transtport overhead * set transtport overhead
@ -114,9 +114,9 @@ class RtpRtcp : public Module {
* return -1 on failure else 0 * return -1 on failure else 0
*/ */
virtual int32_t SetTransportOverhead( virtual int32_t SetTransportOverhead(
const bool TCP, bool TCP,
const bool IPV6, bool IPV6,
const uint8_t authenticationOverhead = 0) = 0; uint8_t authenticationOverhead = 0) = 0;
/* /*
* Get max payload length * Get max payload length
@ -161,20 +161,17 @@ class RtpRtcp : public Module {
* *
* return -1 on failure else 0 * return -1 on failure else 0
*/ */
virtual int32_t DeRegisterSendPayload( virtual int32_t DeRegisterSendPayload(int8_t payloadType) = 0;
const int8_t payloadType) = 0;
/* /*
* (De)register RTP header extension type and id. * (De)register RTP header extension type and id.
* *
* return -1 on failure else 0 * return -1 on failure else 0
*/ */
virtual int32_t RegisterSendRtpHeaderExtension( virtual int32_t RegisterSendRtpHeaderExtension(RTPExtensionType type,
const RTPExtensionType type, uint8_t id) = 0;
const uint8_t id) = 0;
virtual int32_t DeregisterSendRtpHeaderExtension( virtual int32_t DeregisterSendRtpHeaderExtension(RTPExtensionType type) = 0;
const RTPExtensionType type) = 0;
/* /*
* get start timestamp * get start timestamp
@ -185,11 +182,8 @@ class RtpRtcp : public Module {
* configure start timestamp, default is a random number * configure start timestamp, default is a random number
* *
* timestamp - start timestamp * timestamp - start timestamp
*
* return -1 on failure else 0
*/ */
virtual int32_t SetStartTimestamp( virtual void SetStartTimestamp(uint32_t timestamp) = 0;
const uint32_t timestamp) = 0;
/* /*
* Get SequenceNumber * Get SequenceNumber
@ -198,10 +192,8 @@ class RtpRtcp : public Module {
/* /*
* Set SequenceNumber, default is a random number * Set SequenceNumber, default is a random number
*
* return -1 on failure else 0
*/ */
virtual int32_t SetSequenceNumber(const uint16_t seq) = 0; virtual void SetSequenceNumber(uint16_t seq) = 0;
virtual void SetRtpStateForSsrc(uint32_t ssrc, virtual void SetRtpStateForSsrc(uint32_t ssrc,
const RtpState& rtp_state) = 0; const RtpState& rtp_state) = 0;
@ -214,10 +206,8 @@ class RtpRtcp : public Module {
/* /*
* configure SSRC, default is a random number * configure SSRC, default is a random number
*
* return -1 on failure else 0
*/ */
virtual void SetSSRC(const uint32_t ssrc) = 0; virtual void SetSSRC(uint32_t ssrc) = 0;
/* /*
* Set CSRC * Set CSRC
@ -253,7 +243,7 @@ class RtpRtcp : public Module {
* *
* return -1 on failure else 0 * return -1 on failure else 0
*/ */
virtual int32_t SetSendingStatus(const bool sending) = 0; virtual int32_t SetSendingStatus(bool sending) = 0;
/* /*
* get send status * get send status
@ -264,10 +254,8 @@ class RtpRtcp : public Module {
* Starts/Stops media packets, on by default * Starts/Stops media packets, on by default
* *
* sending - on/off * sending - on/off
*
* return -1 on failure else 0
*/ */
virtual int32_t SetSendingMediaStatus(const bool sending) = 0; virtual void SetSendingMediaStatus(bool sending) = 0;
/* /*
* get send status * get send status
@ -297,12 +285,12 @@ class RtpRtcp : public Module {
* return -1 on failure else 0 * return -1 on failure else 0
*/ */
virtual int32_t SendOutgoingData( virtual int32_t SendOutgoingData(
const FrameType frameType, FrameType frameType,
const int8_t payloadType, int8_t payloadType,
const uint32_t timeStamp, uint32_t timeStamp,
int64_t capture_time_ms, int64_t capture_time_ms,
const uint8_t* payloadData, const uint8_t* payloadData,
const size_t payloadSize, size_t payloadSize,
const RTPFragmentationHeader* fragmentation = NULL, const RTPFragmentationHeader* fragmentation = NULL,
const RTPVideoHeader* rtpVideoHdr = NULL) = 0; const RTPVideoHeader* rtpVideoHdr = NULL) = 0;
@ -337,10 +325,8 @@ class RtpRtcp : public Module {
* configure RTCP status i.e on(compound or non- compound)/off * configure RTCP status i.e on(compound or non- compound)/off
* *
* method - RTCP method to use * method - RTCP method to use
*
* return -1 on failure else 0
*/ */
virtual int32_t SetRTCPStatus(const RTCPMethod method) = 0; virtual void SetRTCPStatus(RTCPMethod method) = 0;
/* /*
* Set RTCP CName (i.e unique identifier) * Set RTCP CName (i.e unique identifier)
@ -354,8 +340,7 @@ class RtpRtcp : public Module {
* *
* return -1 on failure else 0 * return -1 on failure else 0
*/ */
virtual int32_t RemoteCNAME( virtual int32_t RemoteCNAME(uint32_t remoteSSRC,
const uint32_t remoteSSRC,
char cName[RTCP_CNAME_SIZE]) const = 0; char cName[RTCP_CNAME_SIZE]) const = 0;
/* /*
@ -375,8 +360,7 @@ class RtpRtcp : public Module {
* *
* return -1 on failure else 0 * return -1 on failure else 0
*/ */
virtual int32_t AddMixedCNAME( virtual int32_t AddMixedCNAME(uint32_t SSRC,
const uint32_t SSRC,
const char cName[RTCP_CNAME_SIZE]) = 0; const char cName[RTCP_CNAME_SIZE]) = 0;
/* /*
@ -384,18 +368,18 @@ class RtpRtcp : public Module {
* *
* return -1 on failure else 0 * return -1 on failure else 0
*/ */
virtual int32_t RemoveMixedCNAME(const uint32_t SSRC) = 0; virtual int32_t RemoveMixedCNAME(uint32_t SSRC) = 0;
/* /*
* Get RoundTripTime * Get RoundTripTime
* *
* return -1 on failure else 0 * return -1 on failure else 0
*/ */
virtual int32_t RTT(const uint32_t remoteSSRC, virtual int32_t RTT(uint32_t remoteSSRC,
uint16_t* RTT, uint16_t* RTT,
uint16_t* avgRTT, uint16_t* avgRTT,
uint16_t* minRTT, uint16_t* minRTT,
uint16_t* maxRTT) const = 0 ; uint16_t* maxRTT) const = 0;
/* /*
* Force a send of a RTCP packet * Force a send of a RTCP packet
@ -416,8 +400,7 @@ class RtpRtcp : public Module {
* Send a RTCP Slice Loss Indication (SLI) * Send a RTCP Slice Loss Indication (SLI)
* 6 least significant bits of pictureID * 6 least significant bits of pictureID
*/ */
virtual int32_t SendRTCPSliceLossIndication( virtual int32_t SendRTCPSliceLossIndication(uint8_t pictureID) = 0;
const uint8_t pictureID) = 0;
/* /*
* Reset RTP data counters for the sending side * Reset RTP data counters for the sending side
@ -462,8 +445,7 @@ class RtpRtcp : public Module {
* *
* return -1 on failure else 0 * return -1 on failure else 0
*/ */
virtual int32_t AddRTCPReportBlock( virtual int32_t AddRTCPReportBlock(uint32_t SSRC,
const uint32_t SSRC,
const RTCPReportBlock* receiveBlock) = 0; const RTCPReportBlock* receiveBlock) = 0;
/* /*
@ -471,7 +453,7 @@ class RtpRtcp : public Module {
* *
* return -1 on failure else 0 * return -1 on failure else 0
*/ */
virtual int32_t RemoveRTCPReportBlock(const uint32_t SSRC) = 0; virtual int32_t RemoveRTCPReportBlock(uint32_t SSRC) = 0;
/* /*
* Get number of sent and received RTCP packet types. * Get number of sent and received RTCP packet types.
@ -485,11 +467,10 @@ class RtpRtcp : public Module {
* *
* return -1 on failure else 0 * return -1 on failure else 0
*/ */
virtual int32_t SetRTCPApplicationSpecificData( virtual int32_t SetRTCPApplicationSpecificData(uint8_t subType,
const uint8_t subType, uint32_t name,
const uint32_t name,
const uint8_t* data, const uint8_t* data,
const uint16_t length) = 0; uint16_t length) = 0;
/* /*
* (XR) VOIP metric * (XR) VOIP metric
* *
@ -510,9 +491,9 @@ class RtpRtcp : public Module {
*/ */
virtual bool REMB() const = 0; virtual bool REMB() const = 0;
virtual int32_t SetREMBStatus(const bool enable) = 0; virtual void SetREMBStatus(bool enable) = 0;
virtual int32_t SetREMBData(const uint32_t bitrate, virtual void SetREMBData(uint32_t bitrate,
const std::vector<uint32_t>& ssrcs) = 0; const std::vector<uint32_t>& ssrcs) = 0;
/* /*
@ -520,18 +501,14 @@ class RtpRtcp : public Module {
*/ */
virtual bool IJ() const = 0; virtual bool IJ() const = 0;
virtual int32_t SetIJStatus(const bool enable) = 0; virtual void SetIJStatus(bool enable) = 0;
/* /*
* (TMMBR) Temporary Max Media Bit Rate * (TMMBR) Temporary Max Media Bit Rate
*/ */
virtual bool TMMBR() const = 0; virtual bool TMMBR() const = 0;
/* virtual void SetTMMBRStatus(bool enable) = 0;
*
* return -1 on failure else 0
*/
virtual int32_t SetTMMBRStatus(const bool enable) = 0;
/* /*
* (NACK) * (NACK)
@ -562,18 +539,13 @@ class RtpRtcp : public Module {
* *
* return -1 on failure else 0 * return -1 on failure else 0
*/ */
virtual int32_t SendNACK(const uint16_t* nackList, virtual int32_t SendNACK(const uint16_t* nackList, uint16_t size) = 0;
const uint16_t size) = 0;
/* /*
* Store the sent packets, needed to answer to a Negative acknowledgement * Store the sent packets, needed to answer to a Negative acknowledgement
* requests * requests
*
* return -1 on failure else 0
*/ */
virtual int32_t SetStorePacketsStatus( virtual void SetStorePacketsStatus(bool enable, uint16_t numberToStore) = 0;
const bool enable,
const uint16_t numberToStore) = 0;
// Returns true if the module is configured to store packets. // Returns true if the module is configured to store packets.
virtual bool StorePackets() const = 0; virtual bool StorePackets() const = 0;
@ -596,8 +568,7 @@ class RtpRtcp : public Module {
* *
* return -1 on failure else 0 * return -1 on failure else 0
*/ */
virtual int32_t SetAudioPacketSize( virtual int32_t SetAudioPacketSize(uint16_t packetSizeSamples) = 0;
const uint16_t packetSizeSamples) = 0;
/* /*
* SendTelephoneEventActive * SendTelephoneEventActive
@ -614,18 +585,16 @@ class RtpRtcp : public Module {
* *
* return -1 on failure else 0 * return -1 on failure else 0
*/ */
virtual int32_t SendTelephoneEventOutband( virtual int32_t SendTelephoneEventOutband(uint8_t key,
const uint8_t key, uint16_t time_ms,
const uint16_t time_ms, uint8_t level) = 0;
const uint8_t level) = 0;
/* /*
* Set payload type for Redundant Audio Data RFC 2198 * Set payload type for Redundant Audio Data RFC 2198
* *
* return -1 on failure else 0 * return -1 on failure else 0
*/ */
virtual int32_t SetSendREDPayloadType( virtual int32_t SetSendREDPayloadType(int8_t payloadType) = 0;
const int8_t payloadType) = 0;
/* /*
* Get payload type for Redundant Audio Data RFC 2198 * Get payload type for Redundant Audio Data RFC 2198
@ -643,7 +612,7 @@ class RtpRtcp : public Module {
* *
* return -1 on failure else 0. * return -1 on failure else 0.
*/ */
virtual int32_t SetAudioLevel(const uint8_t level_dBov) = 0; virtual int32_t SetAudioLevel(uint8_t level_dBov) = 0;
/************************************************************************** /**************************************************************************
* *
@ -656,7 +625,7 @@ class RtpRtcp : public Module {
* *
* return -1 on failure else 0 * return -1 on failure else 0
*/ */
virtual int32_t SetCameraDelay(const int32_t delayMS) = 0; virtual int32_t SetCameraDelay(int32_t delayMS) = 0;
/* /*
* Set the target send bitrate * Set the target send bitrate
@ -669,10 +638,9 @@ class RtpRtcp : public Module {
* *
* return -1 on failure else 0 * return -1 on failure else 0
*/ */
virtual int32_t SetGenericFECStatus( virtual int32_t SetGenericFECStatus(bool enable,
const bool enable, uint8_t payloadTypeRED,
const uint8_t payloadTypeRED, uint8_t payloadTypeFEC) = 0;
const uint8_t payloadTypeFEC) = 0;
/* /*
* Get generic FEC setting * Get generic FEC setting
@ -693,8 +661,7 @@ class RtpRtcp : public Module {
* *
* return -1 on failure else 0 * return -1 on failure else 0
*/ */
virtual int32_t SetKeyFrameRequestMethod( virtual int32_t SetKeyFrameRequestMethod(KeyFrameRequestMethod method) = 0;
const KeyFrameRequestMethod method) = 0;
/* /*
* send a request for a keyframe * send a request for a keyframe

View File

@ -79,12 +79,10 @@ class MockRtpRtcp : public RtpRtcp {
int32_t(const RTPExtensionType type)); int32_t(const RTPExtensionType type));
MOCK_CONST_METHOD0(StartTimestamp, MOCK_CONST_METHOD0(StartTimestamp,
uint32_t()); uint32_t());
MOCK_METHOD1(SetStartTimestamp, MOCK_METHOD1(SetStartTimestamp, void(const uint32_t timestamp));
int32_t(const uint32_t timestamp));
MOCK_CONST_METHOD0(SequenceNumber, MOCK_CONST_METHOD0(SequenceNumber,
uint16_t()); uint16_t());
MOCK_METHOD1(SetSequenceNumber, MOCK_METHOD1(SetSequenceNumber, void(const uint16_t seq));
int32_t(const uint16_t seq));
MOCK_METHOD2(SetRtpStateForSsrc, MOCK_METHOD2(SetRtpStateForSsrc,
void(uint32_t ssrc, const RtpState& rtp_state)); void(uint32_t ssrc, const RtpState& rtp_state));
MOCK_METHOD2(GetRtpStateForSsrc, bool(uint32_t ssrc, RtpState* rtp_state)); MOCK_METHOD2(GetRtpStateForSsrc, bool(uint32_t ssrc, RtpState* rtp_state));
@ -109,8 +107,7 @@ class MockRtpRtcp : public RtpRtcp {
int32_t(const bool sending)); int32_t(const bool sending));
MOCK_CONST_METHOD0(Sending, MOCK_CONST_METHOD0(Sending,
bool()); bool());
MOCK_METHOD1(SetSendingMediaStatus, MOCK_METHOD1(SetSendingMediaStatus, void(const bool sending));
int32_t(const bool sending));
MOCK_CONST_METHOD0(SendingMedia, MOCK_CONST_METHOD0(SendingMedia,
bool()); bool());
MOCK_CONST_METHOD4(BitrateSent, MOCK_CONST_METHOD4(BitrateSent,
@ -140,8 +137,7 @@ class MockRtpRtcp : public RtpRtcp {
RtcpBandwidthObserver* bandwidthCallback)); RtcpBandwidthObserver* bandwidthCallback));
MOCK_CONST_METHOD0(RTCP, MOCK_CONST_METHOD0(RTCP,
RTCPMethod()); RTCPMethod());
MOCK_METHOD1(SetRTCPStatus, MOCK_METHOD1(SetRTCPStatus, void(const RTCPMethod method));
int32_t(const RTCPMethod method));
MOCK_METHOD1(SetCNAME, MOCK_METHOD1(SetCNAME,
int32_t(const char cName[RTCP_CNAME_SIZE])); int32_t(const char cName[RTCP_CNAME_SIZE]));
MOCK_CONST_METHOD2(RemoteCNAME, MOCK_CONST_METHOD2(RemoteCNAME,
@ -192,18 +188,16 @@ class MockRtpRtcp : public RtpRtcp {
bool()); bool());
MOCK_CONST_METHOD0(REMB, MOCK_CONST_METHOD0(REMB,
bool()); bool());
MOCK_METHOD1(SetREMBStatus, MOCK_METHOD1(SetREMBStatus, void(const bool enable));
int32_t(const bool enable));
MOCK_METHOD2(SetREMBData, MOCK_METHOD2(SetREMBData,
int32_t(const uint32_t bitrate, const std::vector<uint32_t>& ssrcs)); void(const uint32_t bitrate,
const std::vector<uint32_t>& ssrcs));
MOCK_CONST_METHOD0(IJ, MOCK_CONST_METHOD0(IJ,
bool()); bool());
MOCK_METHOD1(SetIJStatus, MOCK_METHOD1(SetIJStatus, void(const bool));
int32_t(const bool));
MOCK_CONST_METHOD0(TMMBR, MOCK_CONST_METHOD0(TMMBR,
bool()); bool());
MOCK_METHOD1(SetTMMBRStatus, MOCK_METHOD1(SetTMMBRStatus, void(const bool enable));
int32_t(const bool enable));
MOCK_METHOD1(OnBandwidthEstimateUpdate, MOCK_METHOD1(OnBandwidthEstimateUpdate,
void(uint16_t bandWidthKbit)); void(uint16_t bandWidthKbit));
MOCK_CONST_METHOD0(NACK, MOCK_CONST_METHOD0(NACK,
@ -217,7 +211,7 @@ class MockRtpRtcp : public RtpRtcp {
MOCK_METHOD2(SendNACK, MOCK_METHOD2(SendNACK,
int32_t(const uint16_t* nackList, const uint16_t size)); int32_t(const uint16_t* nackList, const uint16_t size));
MOCK_METHOD2(SetStorePacketsStatus, MOCK_METHOD2(SetStorePacketsStatus,
int32_t(const bool enable, const uint16_t numberToStore)); void(const bool enable, const uint16_t numberToStore));
MOCK_CONST_METHOD0(StorePackets, bool()); MOCK_CONST_METHOD0(StorePackets, bool());
MOCK_METHOD1(RegisterRtcpStatisticsCallback, void(RtcpStatisticsCallback*)); MOCK_METHOD1(RegisterRtcpStatisticsCallback, void(RtcpStatisticsCallback*));
MOCK_METHOD0(GetRtcpStatisticsCallback, RtcpStatisticsCallback*()); MOCK_METHOD0(GetRtcpStatisticsCallback, RtcpStatisticsCallback*());

View File

@ -194,12 +194,12 @@ class RtpRtcpRtxNackTest : public ::testing::Test {
&rtp_payload_registry_)); &rtp_payload_registry_));
rtp_rtcp_module_->SetSSRC(kTestSsrc); rtp_rtcp_module_->SetSSRC(kTestSsrc);
EXPECT_EQ(0, rtp_rtcp_module_->SetRTCPStatus(kRtcpCompound)); rtp_rtcp_module_->SetRTCPStatus(kRtcpCompound);
rtp_receiver_->SetNACKStatus(kNackRtcp); rtp_receiver_->SetNACKStatus(kNackRtcp);
EXPECT_EQ(0, rtp_rtcp_module_->SetStorePacketsStatus(true, 600)); rtp_rtcp_module_->SetStorePacketsStatus(true, 600);
EXPECT_EQ(0, rtp_rtcp_module_->SetSendingStatus(true)); EXPECT_EQ(0, rtp_rtcp_module_->SetSendingStatus(true));
EXPECT_EQ(0, rtp_rtcp_module_->SetSequenceNumber(kTestSequenceNumber)); rtp_rtcp_module_->SetSequenceNumber(kTestSequenceNumber);
EXPECT_EQ(0, rtp_rtcp_module_->SetStartTimestamp(111111)); rtp_rtcp_module_->SetStartTimestamp(111111);
transport_.SetSendModule(rtp_rtcp_module_, &rtp_payload_registry_, transport_.SetSendModule(rtp_rtcp_module_, &rtp_payload_registry_,
rtp_receiver_.get()); rtp_receiver_.get());
@ -304,9 +304,9 @@ TEST_F(RtpRtcpRtxNackTest, LongNackList) {
uint32_t timestamp = 3000; uint32_t timestamp = 3000;
uint16_t nack_list[kNumPacketsToDrop]; uint16_t nack_list[kNumPacketsToDrop];
// Disable StorePackets to be able to set a larger packet history. // Disable StorePackets to be able to set a larger packet history.
EXPECT_EQ(0, rtp_rtcp_module_->SetStorePacketsStatus(false, 0)); rtp_rtcp_module_->SetStorePacketsStatus(false, 0);
// Enable StorePackets with a packet history of 2000 packets. // Enable StorePackets with a packet history of 2000 packets.
EXPECT_EQ(0, rtp_rtcp_module_->SetStorePacketsStatus(true, 2000)); rtp_rtcp_module_->SetStorePacketsStatus(true, 2000);
// Drop 900 packets from the second one so that we get a NACK list which is // Drop 900 packets from the second one so that we get a NACK list which is
// big enough to require 4 RTCP packets to be fully transmitted to the sender. // big enough to require 4 RTCP packets to be fully transmitted to the sender.
transport_.DropConsecutivePackets(2, kNumPacketsToDrop); transport_.DropConsecutivePackets(2, kNumPacketsToDrop);

View File

@ -109,20 +109,18 @@ void RtcpFormatRembTest::TearDown() {
delete test_transport_; delete test_transport_;
} }
TEST_F(RtcpFormatRembTest, TestBasicAPI) { TEST_F(RtcpFormatRembTest, TestRembStatus) {
EXPECT_FALSE(rtcp_sender_->REMB()); EXPECT_FALSE(rtcp_sender_->REMB());
EXPECT_EQ(0, rtcp_sender_->SetREMBStatus(true)); rtcp_sender_->SetREMBStatus(true);
EXPECT_TRUE(rtcp_sender_->REMB()); EXPECT_TRUE(rtcp_sender_->REMB());
EXPECT_EQ(0, rtcp_sender_->SetREMBStatus(false)); rtcp_sender_->SetREMBStatus(false);
EXPECT_FALSE(rtcp_sender_->REMB()); EXPECT_FALSE(rtcp_sender_->REMB());
EXPECT_EQ(0, rtcp_sender_->SetREMBData(1234, std::vector<uint32_t>()));
} }
TEST_F(RtcpFormatRembTest, TestNonCompund) { TEST_F(RtcpFormatRembTest, TestNonCompund) {
uint32_t SSRC = 456789; uint32_t SSRC = 456789;
EXPECT_EQ(0, rtcp_sender_->SetRTCPStatus(kRtcpNonCompound)); rtcp_sender_->SetRTCPStatus(kRtcpNonCompound);
EXPECT_EQ(0, rtcp_sender_->SetREMBData(1234, std::vector<uint32_t>(1, SSRC))); rtcp_sender_->SetREMBData(1234, std::vector<uint32_t>(1, SSRC));
RTCPSender::FeedbackState feedback_state = RTCPSender::FeedbackState feedback_state =
dummy_rtp_rtcp_impl_->GetFeedbackState(); dummy_rtp_rtcp_impl_->GetFeedbackState();
EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state, kRtcpRemb)); EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state, kRtcpRemb));
@ -130,9 +128,8 @@ TEST_F(RtcpFormatRembTest, TestNonCompund) {
TEST_F(RtcpFormatRembTest, TestCompund) { TEST_F(RtcpFormatRembTest, TestCompund) {
uint32_t SSRCs[2] = {456789, 98765}; uint32_t SSRCs[2] = {456789, 98765};
EXPECT_EQ(0, rtcp_sender_->SetRTCPStatus(kRtcpCompound)); rtcp_sender_->SetRTCPStatus(kRtcpCompound);
EXPECT_EQ(0, rtcp_sender_->SetREMBData( rtcp_sender_->SetREMBData(1234, std::vector<uint32_t>(SSRCs, SSRCs + 2));
1234, std::vector<uint32_t>(SSRCs, SSRCs + 2)));
RTCPSender::FeedbackState feedback_state = RTCPSender::FeedbackState feedback_state =
dummy_rtp_rtcp_impl_->GetFeedbackState(); dummy_rtp_rtcp_impl_->GetFeedbackState();
EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state, kRtcpRemb)); EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state, kRtcpRemb));

View File

@ -28,8 +28,7 @@ using namespace RTCPHelp;
// The number of RTCP time intervals needed to trigger a timeout. // The number of RTCP time intervals needed to trigger a timeout.
const int kRrTimeoutIntervals = 3; const int kRrTimeoutIntervals = 3;
RTCPReceiver::RTCPReceiver(const int32_t id, Clock* clock, RTCPReceiver::RTCPReceiver(int32_t id, Clock* clock, ModuleRtpRtcpImpl* owner)
ModuleRtpRtcpImpl* owner)
: TMMBRHelp(), : TMMBRHelp(),
_id(id), _id(id),
_clock(clock), _clock(clock),
@ -85,9 +84,7 @@ RTCPReceiver::~RTCPReceiver() {
} }
} }
void void RTCPReceiver::ChangeUniqueId(int32_t id) {
RTCPReceiver::ChangeUniqueId(const int32_t id)
{
_id = id; _id = id;
} }
@ -98,12 +95,9 @@ RTCPReceiver::Status() const
return _method; return _method;
} }
int32_t void RTCPReceiver::SetRTCPStatus(RTCPMethod method) {
RTCPReceiver::SetRTCPStatus(const RTCPMethod method)
{
CriticalSectionScoped lock(_criticalSectionRTCPReceiver); CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
_method = method; _method = method;
return 0;
} }
int64_t int64_t
@ -126,9 +120,7 @@ RTCPReceiver::LastReceivedReceiverReport() const {
return last_received_rr; return last_received_rr;
} }
int32_t int32_t RTCPReceiver::SetRemoteSSRC(uint32_t ssrc) {
RTCPReceiver::SetRemoteSSRC( const uint32_t ssrc)
{
CriticalSectionScoped lock(_criticalSectionRTCPReceiver); CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
// new SSRC reset old reports // new SSRC reset old reports
@ -466,8 +458,8 @@ RTCPReceiver::HandleSenderReceiverReport(RTCPUtility::RTCPParserV2& rtcpParser,
void RTCPReceiver::HandleReportBlock( void RTCPReceiver::HandleReportBlock(
const RTCPUtility::RTCPPacket& rtcpPacket, const RTCPUtility::RTCPPacket& rtcpPacket,
RTCPPacketInformation& rtcpPacketInformation, RTCPPacketInformation& rtcpPacketInformation,
const uint32_t remoteSSRC, uint32_t remoteSSRC,
const uint8_t numberOfReportBlocks) uint8_t numberOfReportBlocks)
EXCLUSIVE_LOCKS_REQUIRED(_criticalSectionRTCPReceiver) { EXCLUSIVE_LOCKS_REQUIRED(_criticalSectionRTCPReceiver) {
// This will be called once per report block in the RTCP packet. // This will be called once per report block in the RTCP packet.
// We filter out all report blocks that are not for us. // We filter out all report blocks that are not for us.
@ -1079,12 +1071,10 @@ RTCPReceiver::HandleTMMBR(RTCPUtility::RTCPParserV2& rtcpParser,
} }
// no need for critsect we have _criticalSectionRTCPReceiver // no need for critsect we have _criticalSectionRTCPReceiver
void void RTCPReceiver::HandleTMMBRItem(RTCPReceiveInformation& receiveInfo,
RTCPReceiver::HandleTMMBRItem(RTCPReceiveInformation& receiveInfo,
const RTCPUtility::RTCPPacket& rtcpPacket, const RTCPUtility::RTCPPacket& rtcpPacket,
RTCPPacketInformation& rtcpPacketInformation, RTCPPacketInformation& rtcpPacketInformation,
const uint32_t senderSSRC) uint32_t senderSSRC) {
{
if (main_ssrc_ == rtcpPacket.TMMBRItem.SSRC && if (main_ssrc_ == rtcpPacket.TMMBRItem.SSRC &&
rtcpPacket.TMMBRItem.MaxTotalMediaBitRate > 0) rtcpPacket.TMMBRItem.MaxTotalMediaBitRate > 0)
{ {
@ -1464,7 +1454,7 @@ void RTCPReceiver::TriggerCallbacksFromRTCPPacket(
} }
} }
int32_t RTCPReceiver::CNAME(const uint32_t remoteSSRC, int32_t RTCPReceiver::CNAME(uint32_t remoteSSRC,
char cName[RTCP_CNAME_SIZE]) const { char cName[RTCP_CNAME_SIZE]) const {
assert(cName); assert(cName);
@ -1479,8 +1469,8 @@ int32_t RTCPReceiver::CNAME(const uint32_t remoteSSRC,
} }
// no callbacks allowed inside this function // no callbacks allowed inside this function
int32_t RTCPReceiver::TMMBRReceived(const uint32_t size, int32_t RTCPReceiver::TMMBRReceived(uint32_t size,
const uint32_t accNumCandidates, uint32_t accNumCandidates,
TMMBRSet* candidateSet) const { TMMBRSet* candidateSet) const {
CriticalSectionScoped lock(_criticalSectionRTCPReceiver); CriticalSectionScoped lock(_criticalSectionRTCPReceiver);

View File

@ -29,22 +29,21 @@ class ModuleRtpRtcpImpl;
class RTCPReceiver : public TMMBRHelp class RTCPReceiver : public TMMBRHelp
{ {
public: public:
RTCPReceiver(const int32_t id, Clock* clock, RTCPReceiver(int32_t id, Clock* clock, ModuleRtpRtcpImpl* owner);
ModuleRtpRtcpImpl* owner);
virtual ~RTCPReceiver(); virtual ~RTCPReceiver();
void ChangeUniqueId(const int32_t id); void ChangeUniqueId(int32_t id);
RTCPMethod Status() const; RTCPMethod Status() const;
int32_t SetRTCPStatus(const RTCPMethod method); void SetRTCPStatus(RTCPMethod method);
int64_t LastReceived(); int64_t LastReceived();
int64_t LastReceivedReceiverReport() const; int64_t LastReceivedReceiverReport() const;
void SetSsrcs(uint32_t main_ssrc, void SetSsrcs(uint32_t main_ssrc,
const std::set<uint32_t>& registered_ssrcs); const std::set<uint32_t>& registered_ssrcs);
void SetRelaySSRC( const uint32_t ssrc); void SetRelaySSRC(uint32_t ssrc);
int32_t SetRemoteSSRC( const uint32_t ssrc); int32_t SetRemoteSSRC(uint32_t ssrc);
uint32_t RemoteSSRC() const; uint32_t RemoteSSRC() const;
uint32_t RelaySSRC() const; uint32_t RelaySSRC() const;
@ -59,8 +58,7 @@ public:
void TriggerCallbacksFromRTCPPacket(RTCPHelp::RTCPPacketInformation& rtcpPacketInformation); void TriggerCallbacksFromRTCPPacket(RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
// get received cname // get received cname
int32_t CNAME(const uint32_t remoteSSRC, int32_t CNAME(uint32_t remoteSSRC, char cName[RTCP_CNAME_SIZE]) const;
char cName[RTCP_CNAME_SIZE]) const;
// get received NTP // get received NTP
bool NTP(uint32_t* ReceivedNTPsecs, bool NTP(uint32_t* ReceivedNTPsecs,
@ -99,8 +97,8 @@ public:
bool RtcpRrSequenceNumberTimeout(int64_t rtcp_interval_ms); bool RtcpRrSequenceNumberTimeout(int64_t rtcp_interval_ms);
// Get TMMBR // Get TMMBR
int32_t TMMBRReceived(const uint32_t size, int32_t TMMBRReceived(uint32_t size,
const uint32_t accNumCandidates, uint32_t accNumCandidates,
TMMBRSet* candidateSet) const; TMMBRSet* candidateSet) const;
bool UpdateRTCPReceiveInformationTimers(); bool UpdateRTCPReceiveInformationTimers();
@ -113,21 +111,24 @@ public:
RtcpStatisticsCallback* GetRtcpStatisticsCallback(); RtcpStatisticsCallback* GetRtcpStatisticsCallback();
protected: protected:
RTCPUtility::RTCPCnameInformation* CreateCnameInformation(const uint32_t remoteSSRC); RTCPUtility::RTCPCnameInformation* CreateCnameInformation(uint32_t remoteSSRC);
RTCPUtility::RTCPCnameInformation* GetCnameInformation(const uint32_t remoteSSRC) const; RTCPUtility::RTCPCnameInformation* GetCnameInformation(
uint32_t remoteSSRC) const;
RTCPHelp::RTCPReceiveInformation* CreateReceiveInformation(const uint32_t remoteSSRC); RTCPHelp::RTCPReceiveInformation* CreateReceiveInformation(
RTCPHelp::RTCPReceiveInformation* GetReceiveInformation(const uint32_t remoteSSRC); uint32_t remoteSSRC);
RTCPHelp::RTCPReceiveInformation* GetReceiveInformation(uint32_t remoteSSRC);
void UpdateReceiveInformation( RTCPHelp::RTCPReceiveInformation& receiveInformation); void UpdateReceiveInformation( RTCPHelp::RTCPReceiveInformation& receiveInformation);
void HandleSenderReceiverReport(RTCPUtility::RTCPParserV2& rtcpParser, void HandleSenderReceiverReport(RTCPUtility::RTCPParserV2& rtcpParser,
RTCPHelp::RTCPPacketInformation& rtcpPacketInformation); RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
void HandleReportBlock(const RTCPUtility::RTCPPacket& rtcpPacket, void HandleReportBlock(
const RTCPUtility::RTCPPacket& rtcpPacket,
RTCPHelp::RTCPPacketInformation& rtcpPacketInformation, RTCPHelp::RTCPPacketInformation& rtcpPacketInformation,
const uint32_t remoteSSRC, uint32_t remoteSSRC,
const uint8_t numberOfReportBlocks); uint8_t numberOfReportBlocks);
void HandleSDES(RTCPUtility::RTCPParserV2& rtcpParser); void HandleSDES(RTCPUtility::RTCPParserV2& rtcpParser);
@ -189,7 +190,7 @@ protected:
void HandleTMMBRItem(RTCPHelp::RTCPReceiveInformation& receiveInfo, void HandleTMMBRItem(RTCPHelp::RTCPReceiveInformation& receiveInfo,
const RTCPUtility::RTCPPacket& rtcpPacket, const RTCPUtility::RTCPPacket& rtcpPacket,
RTCPHelp::RTCPPacketInformation& rtcpPacketInformation, RTCPHelp::RTCPPacketInformation& rtcpPacketInformation,
const uint32_t senderSSRC); uint32_t senderSSRC);
void HandleTMMBN(RTCPUtility::RTCPParserV2& rtcpParser, void HandleTMMBN(RTCPUtility::RTCPParserV2& rtcpParser,
RTCPHelp::RTCPPacketInformation& rtcpPacketInformation); RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);

View File

@ -76,18 +76,20 @@ RTCPSender::FeedbackState::FeedbackState()
remote_sr(0), remote_sr(0),
has_last_xr_rr(false) {} has_last_xr_rr(false) {}
RTCPSender::RTCPSender(const int32_t id, RTCPSender::RTCPSender(int32_t id,
const bool audio, bool audio,
Clock* clock, Clock* clock,
ReceiveStatistics* receive_statistics) : ReceiveStatistics* receive_statistics)
_id(id), : _id(id),
_audio(audio), _audio(audio),
_clock(clock), _clock(clock),
_method(kRtcpOff), _method(kRtcpOff),
_criticalSectionTransport(CriticalSectionWrapper::CreateCriticalSection()), _criticalSectionTransport(
CriticalSectionWrapper::CreateCriticalSection()),
_cbTransport(NULL), _cbTransport(NULL),
_criticalSectionRTCPSender(CriticalSectionWrapper::CreateCriticalSection()), _criticalSectionRTCPSender(
CriticalSectionWrapper::CreateCriticalSection()),
_usingNack(false), _usingNack(false),
_sending(false), _sending(false),
_sendTMMBN(false), _sendTMMBN(false),
@ -130,8 +132,7 @@ RTCPSender::RTCPSender(const int32_t id,
xrSendReceiverReferenceTimeEnabled_(false), xrSendReceiverReferenceTimeEnabled_(false),
_xrSendVoIPMetric(false), _xrSendVoIPMetric(false),
_xrVoIPMetric() _xrVoIPMetric() {
{
memset(_CNAME, 0, sizeof(_CNAME)); memset(_CNAME, 0, sizeof(_CNAME));
memset(_lastSendReport, 0, sizeof(_lastSendReport)); memset(_lastSendReport, 0, sizeof(_lastSendReport));
memset(_lastRTCPTime, 0, sizeof(_lastRTCPTime)); memset(_lastRTCPTime, 0, sizeof(_lastRTCPTime));
@ -175,24 +176,15 @@ RTCPSender::Status() const
return _method; return _method;
} }
int32_t void RTCPSender::SetRTCPStatus(RTCPMethod method) {
RTCPSender::SetRTCPStatus(const RTCPMethod method)
{
CriticalSectionScoped lock(_criticalSectionRTCPSender); CriticalSectionScoped lock(_criticalSectionRTCPSender);
if(method != kRtcpOff)
{
if(_audio)
{
_nextTimeToSendRTCP = _clock->TimeInMilliseconds() +
(RTCP_INTERVAL_AUDIO_MS/2);
} else
{
_nextTimeToSendRTCP = _clock->TimeInMilliseconds() +
(RTCP_INTERVAL_VIDEO_MS/2);
}
}
_method = method; _method = method;
return 0;
if (method == kRtcpOff)
return;
_nextTimeToSendRTCP =
_clock->TimeInMilliseconds() +
(_audio ? RTCP_INTERVAL_AUDIO_MS / 2 : RTCP_INTERVAL_VIDEO_MS / 2);
} }
bool bool
@ -233,18 +225,13 @@ RTCPSender::REMB() const
return _REMB; return _REMB;
} }
int32_t void RTCPSender::SetREMBStatus(bool enable) {
RTCPSender::SetREMBStatus(const bool enable)
{
CriticalSectionScoped lock(_criticalSectionRTCPSender); CriticalSectionScoped lock(_criticalSectionRTCPSender);
_REMB = enable; _REMB = enable;
return 0;
} }
int32_t void RTCPSender::SetREMBData(uint32_t bitrate,
RTCPSender::SetREMBData(const uint32_t bitrate, const std::vector<uint32_t>& ssrcs) {
const std::vector<uint32_t>& ssrcs)
{
CriticalSectionScoped lock(_criticalSectionRTCPSender); CriticalSectionScoped lock(_criticalSectionRTCPSender);
_rembBitrate = bitrate; _rembBitrate = bitrate;
remb_ssrcs_ = ssrcs; remb_ssrcs_ = ssrcs;
@ -253,7 +240,6 @@ RTCPSender::SetREMBData(const uint32_t bitrate,
// Send a REMB immediately if we have a new REMB. The frequency of REMBs is // Send a REMB immediately if we have a new REMB. The frequency of REMBs is
// throttled by the caller. // throttled by the caller.
_nextTimeToSendRTCP = _clock->TimeInMilliseconds(); _nextTimeToSendRTCP = _clock->TimeInMilliseconds();
return 0;
} }
bool bool
@ -263,12 +249,9 @@ RTCPSender::TMMBR() const
return _TMMBR; return _TMMBR;
} }
int32_t void RTCPSender::SetTMMBRStatus(bool enable) {
RTCPSender::SetTMMBRStatus(const bool enable)
{
CriticalSectionScoped lock(_criticalSectionRTCPSender); CriticalSectionScoped lock(_criticalSectionRTCPSender);
_TMMBR = enable; _TMMBR = enable;
return 0;
} }
bool bool
@ -278,12 +261,9 @@ RTCPSender::IJ() const
return _IJ; return _IJ;
} }
int32_t void RTCPSender::SetIJStatus(bool enable) {
RTCPSender::SetIJStatus(const bool enable)
{
CriticalSectionScoped lock(_criticalSectionRTCPSender); CriticalSectionScoped lock(_criticalSectionRTCPSender);
_IJ = enable; _IJ = enable;
return 0;
} }
void RTCPSender::SetStartTimestamp(uint32_t start_timestamp) { void RTCPSender::SetStartTimestamp(uint32_t start_timestamp) {
@ -303,9 +283,7 @@ void RTCPSender::SetLastRtpTime(uint32_t rtp_timestamp,
} }
} }
void void RTCPSender::SetSSRC(uint32_t ssrc) {
RTCPSender::SetSSRC( const uint32_t ssrc)
{
CriticalSectionScoped lock(_criticalSectionRTCPSender); CriticalSectionScoped lock(_criticalSectionRTCPSender);
if(_SSRC != 0) if(_SSRC != 0)
@ -324,9 +302,7 @@ void RTCPSender::SetRemoteSSRC(uint32_t ssrc)
_remoteSSRC = ssrc; _remoteSSRC = ssrc;
} }
int32_t int32_t RTCPSender::SetCameraDelay(int32_t delayMS) {
RTCPSender::SetCameraDelay(const int32_t delayMS)
{
CriticalSectionScoped lock(_criticalSectionRTCPSender); CriticalSectionScoped lock(_criticalSectionRTCPSender);
if(delayMS > 1000 || delayMS < -1000) if(delayMS > 1000 || delayMS < -1000)
{ {
@ -348,7 +324,7 @@ int32_t RTCPSender::SetCNAME(const char cName[RTCP_CNAME_SIZE]) {
return 0; return 0;
} }
int32_t RTCPSender::AddMixedCNAME(const uint32_t SSRC, int32_t RTCPSender::AddMixedCNAME(uint32_t SSRC,
const char cName[RTCP_CNAME_SIZE]) { const char cName[RTCP_CNAME_SIZE]) {
assert(cName); assert(cName);
CriticalSectionScoped lock(_criticalSectionRTCPSender); CriticalSectionScoped lock(_criticalSectionRTCPSender);
@ -362,7 +338,7 @@ int32_t RTCPSender::AddMixedCNAME(const uint32_t SSRC,
return 0; return 0;
} }
int32_t RTCPSender::RemoveMixedCNAME(const uint32_t SSRC) { int32_t RTCPSender::RemoveMixedCNAME(uint32_t SSRC) {
CriticalSectionScoped lock(_criticalSectionRTCPSender); CriticalSectionScoped lock(_criticalSectionRTCPSender);
std::map<uint32_t, RTCPCnameInformation*>::iterator it = std::map<uint32_t, RTCPCnameInformation*>::iterator it =
_csrcCNAMEs.find(SSRC); _csrcCNAMEs.find(SSRC);
@ -375,9 +351,7 @@ int32_t RTCPSender::RemoveMixedCNAME(const uint32_t SSRC) {
return 0; return 0;
} }
bool bool RTCPSender::TimeToSendRTCPReport(bool sendKeyframeBeforeRTP) const {
RTCPSender::TimeToSendRTCPReport(const bool sendKeyframeBeforeRTP) const
{
/* /*
For audio we use a fix 5 sec interval For audio we use a fix 5 sec interval
@ -473,9 +447,7 @@ RTCPSender::LastSendReport( uint32_t& lastRTCPTime)
return _lastSendReport[0]; return _lastSendReport[0];
} }
uint32_t uint32_t RTCPSender::SendTimeOfSendReport(uint32_t sendReport) {
RTCPSender::SendTimeOfSendReport(const uint32_t sendReport)
{
CriticalSectionScoped lock(_criticalSectionRTCPSender); CriticalSectionScoped lock(_criticalSectionRTCPSender);
// This is only saved when we are the sender // This is only saved when we are the sender
@ -732,12 +704,10 @@ int32_t RTCPSender::BuildSDEC(uint8_t* rtcpbuffer, int& pos) {
return 0; return 0;
} }
int32_t int32_t RTCPSender::BuildRR(uint8_t* rtcpbuffer,
RTCPSender::BuildRR(uint8_t* rtcpbuffer,
int& pos, int& pos,
const uint32_t NTPsec, uint32_t NTPsec,
const uint32_t NTPfrac) uint32_t NTPfrac) {
{
// sanity one block // sanity one block
if(pos + 32 >= IP_PACKET_SIZE) if(pos + 32 >= IP_PACKET_SIZE)
{ {
@ -901,9 +871,7 @@ int32_t RTCPSender::BuildFIR(uint8_t* rtcpbuffer,
| First | Number | PictureID | | First | Number | PictureID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/ */
int32_t int32_t RTCPSender::BuildSLI(uint8_t* rtcpbuffer, int& pos, uint8_t pictureID) {
RTCPSender::BuildSLI(uint8_t* rtcpbuffer, int& pos, const uint8_t pictureID)
{
// sanity // sanity
if(pos + 16 >= IP_PACKET_SIZE) if(pos + 16 >= IP_PACKET_SIZE)
{ {
@ -947,12 +915,10 @@ RTCPSender::BuildSLI(uint8_t* rtcpbuffer, int& pos, const uint8_t pictureID)
/* /*
* Note: not generic made for VP8 * Note: not generic made for VP8
*/ */
int32_t int32_t RTCPSender::BuildRPSI(uint8_t* rtcpbuffer,
RTCPSender::BuildRPSI(uint8_t* rtcpbuffer,
int& pos, int& pos,
const uint64_t pictureID, uint64_t pictureID,
const uint8_t payloadType) uint8_t payloadType) {
{
// sanity // sanity
if(pos + 24 >= IP_PACKET_SIZE) if(pos + 24 >= IP_PACKET_SIZE)
{ {
@ -1302,13 +1268,11 @@ RTCPSender::BuildAPP(uint8_t* rtcpbuffer, int& pos)
return 0; return 0;
} }
int32_t int32_t RTCPSender::BuildNACK(uint8_t* rtcpbuffer,
RTCPSender::BuildNACK(uint8_t* rtcpbuffer,
int& pos, int& pos,
const int32_t nackSize, int32_t nackSize,
const uint16_t* nackList, const uint16_t* nackList,
std::string* nackString) std::string* nackString) {
{
// sanity // sanity
if(pos + 16 >= IP_PACKET_SIZE) if(pos + 16 >= IP_PACKET_SIZE)
{ {
@ -1981,10 +1945,7 @@ bool RTCPSender::PrepareReport(const FeedbackState& feedback_state,
return true; return true;
} }
int32_t int32_t RTCPSender::SendToNetwork(const uint8_t* dataBuffer, size_t length) {
RTCPSender::SendToNetwork(const uint8_t* dataBuffer,
const size_t length)
{
CriticalSectionScoped lock(_criticalSectionTransport); CriticalSectionScoped lock(_criticalSectionTransport);
if(_cbTransport) if(_cbTransport)
{ {
@ -2002,12 +1963,10 @@ void RTCPSender::SetCsrcs(const std::vector<uint32_t>& csrcs) {
csrcs_ = csrcs; csrcs_ = csrcs;
} }
int32_t int32_t RTCPSender::SetApplicationSpecificData(uint8_t subType,
RTCPSender::SetApplicationSpecificData(const uint8_t subType, uint32_t name,
const uint32_t name,
const uint8_t* data, const uint8_t* data,
const uint16_t length) uint16_t length) {
{
if(length %4 != 0) if(length %4 != 0)
{ {
LOG(LS_ERROR) << "Failed to SetApplicationSpecificData."; LOG(LS_ERROR) << "Failed to SetApplicationSpecificData.";
@ -2050,12 +2009,11 @@ bool RTCPSender::RtcpXrReceiverReferenceTime() const {
} }
// called under critsect _criticalSectionRTCPSender // called under critsect _criticalSectionRTCPSender
int32_t RTCPSender::WriteAllReportBlocksToBuffer( int32_t RTCPSender::WriteAllReportBlocksToBuffer(uint8_t* rtcpbuffer,
uint8_t* rtcpbuffer,
int pos, int pos,
uint8_t& numberOfReportBlocks, uint8_t& numberOfReportBlocks,
const uint32_t NTPsec, uint32_t NTPsec,
const uint32_t NTPfrac) { uint32_t NTPfrac) {
numberOfReportBlocks = external_report_blocks_.size(); numberOfReportBlocks = external_report_blocks_.size();
numberOfReportBlocks += internal_report_blocks_.size(); numberOfReportBlocks += internal_report_blocks_.size();
if ((pos + numberOfReportBlocks * 24) >= IP_PACKET_SIZE) { if ((pos + numberOfReportBlocks * 24) >= IP_PACKET_SIZE) {
@ -2116,10 +2074,8 @@ int32_t RTCPSender::WriteReportBlocksToBuffer(
} }
// no callbacks allowed inside this function // no callbacks allowed inside this function
int32_t int32_t RTCPSender::SetTMMBN(const TMMBRSet* boundingSet,
RTCPSender::SetTMMBN(const TMMBRSet* boundingSet, uint32_t maxBitrateKbit) {
const uint32_t maxBitrateKbit)
{
CriticalSectionScoped lock(_criticalSectionRTCPSender); CriticalSectionScoped lock(_criticalSectionRTCPSender);
if (0 == _tmmbrHelp.SetTMMBRBoundingSetToSend(boundingSet, maxBitrateKbit)) if (0 == _tmmbrHelp.SetTMMBRBoundingSetToSend(boundingSet, maxBitrateKbit))

View File

@ -69,7 +69,8 @@ public:
// Used when generating TMMBR. // Used when generating TMMBR.
ModuleRtpRtcpImpl* module; ModuleRtpRtcpImpl* module;
}; };
RTCPSender(const int32_t id, const bool audio, RTCPSender(int32_t id,
bool audio,
Clock* clock, Clock* clock,
ReceiveStatistics* receive_statistics); ReceiveStatistics* receive_statistics);
virtual ~RTCPSender(); virtual ~RTCPSender();
@ -77,37 +78,36 @@ public:
int32_t RegisterSendTransport(Transport* outgoingTransport); int32_t RegisterSendTransport(Transport* outgoingTransport);
RTCPMethod Status() const; RTCPMethod Status() const;
int32_t SetRTCPStatus(const RTCPMethod method); void SetRTCPStatus(RTCPMethod method);
bool Sending() const; bool Sending() const;
int32_t SetSendingStatus(const FeedbackState& feedback_state, int32_t SetSendingStatus(const FeedbackState& feedback_state,
bool enabled); // combine the functions bool enabled); // combine the functions
int32_t SetNackStatus(const bool enable); int32_t SetNackStatus(bool enable);
void SetStartTimestamp(uint32_t start_timestamp); void SetStartTimestamp(uint32_t start_timestamp);
void SetLastRtpTime(uint32_t rtp_timestamp, void SetLastRtpTime(uint32_t rtp_timestamp,
int64_t capture_time_ms); int64_t capture_time_ms);
void SetSSRC( const uint32_t ssrc); void SetSSRC(uint32_t ssrc);
void SetRemoteSSRC(uint32_t ssrc); void SetRemoteSSRC(uint32_t ssrc);
int32_t SetCameraDelay(const int32_t delayMS); int32_t SetCameraDelay(int32_t delayMS);
int32_t SetCNAME(const char cName[RTCP_CNAME_SIZE]); int32_t SetCNAME(const char cName[RTCP_CNAME_SIZE]);
int32_t AddMixedCNAME(const uint32_t SSRC, int32_t AddMixedCNAME(uint32_t SSRC, const char cName[RTCP_CNAME_SIZE]);
const char cName[RTCP_CNAME_SIZE]);
int32_t RemoveMixedCNAME(const uint32_t SSRC); int32_t RemoveMixedCNAME(uint32_t SSRC);
uint32_t SendTimeOfSendReport(const uint32_t sendReport); uint32_t SendTimeOfSendReport(uint32_t sendReport);
bool SendTimeOfXrRrReport(uint32_t mid_ntp, int64_t* time_ms) const; bool SendTimeOfXrRrReport(uint32_t mid_ntp, int64_t* time_ms) const;
bool TimeToSendRTCPReport(const bool sendKeyframeBeforeRTP = false) const; bool TimeToSendRTCPReport(bool sendKeyframeBeforeRTP = false) const;
uint32_t LastSendReport(uint32_t& lastRTCPTime); uint32_t LastSendReport(uint32_t& lastRTCPTime);
@ -130,36 +130,34 @@ public:
*/ */
bool REMB() const; bool REMB() const;
int32_t SetREMBStatus(const bool enable); void SetREMBStatus(bool enable);
int32_t SetREMBData(const uint32_t bitrate, void SetREMBData(uint32_t bitrate, const std::vector<uint32_t>& ssrcs);
const std::vector<uint32_t>& ssrcs);
/* /*
* TMMBR * TMMBR
*/ */
bool TMMBR() const; bool TMMBR() const;
int32_t SetTMMBRStatus(const bool enable); void SetTMMBRStatus(bool enable);
int32_t SetTMMBN(const TMMBRSet* boundingSet, int32_t SetTMMBN(const TMMBRSet* boundingSet, uint32_t maxBitrateKbit);
const uint32_t maxBitrateKbit);
/* /*
* Extended jitter report * Extended jitter report
*/ */
bool IJ() const; bool IJ() const;
int32_t SetIJStatus(const bool enable); void SetIJStatus(bool enable);
/* /*
* *
*/ */
int32_t SetApplicationSpecificData(const uint8_t subType, int32_t SetApplicationSpecificData(uint8_t subType,
const uint32_t name, uint32_t name,
const uint8_t* data, const uint8_t* data,
const uint16_t length); uint16_t length);
int32_t SetRTCPVoIPMetrics(const RTCPVoIPMetric* VoIPMetric); int32_t SetRTCPVoIPMetrics(const RTCPVoIPMetric* VoIPMetric);
@ -174,13 +172,13 @@ public:
void GetPacketTypeCounter(RtcpPacketTypeCounter* packet_counter) const; void GetPacketTypeCounter(RtcpPacketTypeCounter* packet_counter) const;
private: private:
int32_t SendToNetwork(const uint8_t* dataBuffer, const size_t length); int32_t SendToNetwork(const uint8_t* dataBuffer, size_t length);
int32_t WriteAllReportBlocksToBuffer(uint8_t* rtcpbuffer, int32_t WriteAllReportBlocksToBuffer(uint8_t* rtcpbuffer,
int pos, int pos,
uint8_t& numberOfReportBlocks, uint8_t& numberOfReportBlocks,
const uint32_t NTPsec, uint32_t NTPsec,
const uint32_t NTPfrac) uint32_t NTPfrac)
EXCLUSIVE_LOCKS_REQUIRED(_criticalSectionRTCPSender); EXCLUSIVE_LOCKS_REQUIRED(_criticalSectionRTCPSender);
int32_t WriteReportBlocksToBuffer( int32_t WriteReportBlocksToBuffer(
@ -207,8 +205,8 @@ private:
int32_t BuildRR(uint8_t* rtcpbuffer, int32_t BuildRR(uint8_t* rtcpbuffer,
int& pos, int& pos,
const uint32_t NTPsec, uint32_t NTPsec,
const uint32_t NTPfrac) uint32_t NTPfrac)
EXCLUSIVE_LOCKS_REQUIRED(_criticalSectionRTCPSender); EXCLUSIVE_LOCKS_REQUIRED(_criticalSectionRTCPSender);
int PrepareRTCP( int PrepareRTCP(
@ -223,10 +221,9 @@ private:
bool ShouldSendReportBlocks(uint32_t rtcp_packet_type) const; bool ShouldSendReportBlocks(uint32_t rtcp_packet_type) const;
int32_t BuildExtendedJitterReport( int32_t BuildExtendedJitterReport(uint8_t* rtcpbuffer,
uint8_t* rtcpbuffer,
int& pos, int& pos,
const uint32_t jitterTransmissionTimeOffset) uint32_t jitterTransmissionTimeOffset)
EXCLUSIVE_LOCKS_REQUIRED(_criticalSectionRTCPSender); EXCLUSIVE_LOCKS_REQUIRED(_criticalSectionRTCPSender);
int32_t BuildSDEC(uint8_t* rtcpbuffer, int& pos) int32_t BuildSDEC(uint8_t* rtcpbuffer, int& pos)
@ -247,17 +244,17 @@ private:
EXCLUSIVE_LOCKS_REQUIRED(_criticalSectionRTCPSender); EXCLUSIVE_LOCKS_REQUIRED(_criticalSectionRTCPSender);
int32_t BuildFIR(uint8_t* rtcpbuffer, int& pos, bool repeat) int32_t BuildFIR(uint8_t* rtcpbuffer, int& pos, bool repeat)
EXCLUSIVE_LOCKS_REQUIRED(_criticalSectionRTCPSender); EXCLUSIVE_LOCKS_REQUIRED(_criticalSectionRTCPSender);
int32_t BuildSLI(uint8_t* rtcpbuffer, int& pos, const uint8_t pictureID) int32_t BuildSLI(uint8_t* rtcpbuffer, int& pos, uint8_t pictureID)
EXCLUSIVE_LOCKS_REQUIRED(_criticalSectionRTCPSender); EXCLUSIVE_LOCKS_REQUIRED(_criticalSectionRTCPSender);
int32_t BuildRPSI(uint8_t* rtcpbuffer, int32_t BuildRPSI(uint8_t* rtcpbuffer,
int& pos, int& pos,
const uint64_t pictureID, uint64_t pictureID,
const uint8_t payloadType) uint8_t payloadType)
EXCLUSIVE_LOCKS_REQUIRED(_criticalSectionRTCPSender); EXCLUSIVE_LOCKS_REQUIRED(_criticalSectionRTCPSender);
int32_t BuildNACK(uint8_t* rtcpbuffer, int32_t BuildNACK(uint8_t* rtcpbuffer,
int& pos, int& pos,
const int32_t nackSize, int32_t nackSize,
const uint16_t* nackList, const uint16_t* nackList,
std::string* nackString) std::string* nackString)
EXCLUSIVE_LOCKS_REQUIRED(_criticalSectionRTCPSender); EXCLUSIVE_LOCKS_REQUIRED(_criticalSectionRTCPSender);

View File

@ -340,15 +340,15 @@ class RtcpSenderTest : public ::testing::Test {
}; };
TEST_F(RtcpSenderTest, RtcpOff) { TEST_F(RtcpSenderTest, RtcpOff) {
EXPECT_EQ(0, rtcp_sender_->SetRTCPStatus(kRtcpOff)); rtcp_sender_->SetRTCPStatus(kRtcpOff);
RTCPSender::FeedbackState feedback_state = rtp_rtcp_impl_->GetFeedbackState(); RTCPSender::FeedbackState feedback_state = rtp_rtcp_impl_->GetFeedbackState();
EXPECT_EQ(-1, rtcp_sender_->SendRTCP(feedback_state, kRtcpSr)); EXPECT_EQ(-1, rtcp_sender_->SendRTCP(feedback_state, kRtcpSr));
} }
TEST_F(RtcpSenderTest, IJStatus) { TEST_F(RtcpSenderTest, IJStatus) {
ASSERT_FALSE(rtcp_sender_->IJ()); ASSERT_FALSE(rtcp_sender_->IJ());
EXPECT_EQ(0, rtcp_sender_->SetIJStatus(true)); rtcp_sender_->SetIJStatus(true);
ASSERT_TRUE(rtcp_sender_->IJ()); EXPECT_TRUE(rtcp_sender_->IJ());
} }
TEST_F(RtcpSenderTest, TestCompound) { TEST_F(RtcpSenderTest, TestCompound) {
@ -383,8 +383,8 @@ TEST_F(RtcpSenderTest, TestCompound) {
EXPECT_TRUE(rtp_receiver_->IncomingRtpPacket(header, packet_, packet_length, EXPECT_TRUE(rtp_receiver_->IncomingRtpPacket(header, packet_, packet_length,
payload_specific, true)); payload_specific, true));
EXPECT_EQ(0, rtcp_sender_->SetIJStatus(true)); rtcp_sender_->SetIJStatus(true);
EXPECT_EQ(0, rtcp_sender_->SetRTCPStatus(kRtcpCompound)); rtcp_sender_->SetRTCPStatus(kRtcpCompound);
RTCPSender::FeedbackState feedback_state = rtp_rtcp_impl_->GetFeedbackState(); RTCPSender::FeedbackState feedback_state = rtp_rtcp_impl_->GetFeedbackState();
EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state, kRtcpRr)); EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state, kRtcpRr));
@ -394,8 +394,8 @@ TEST_F(RtcpSenderTest, TestCompound) {
} }
TEST_F(RtcpSenderTest, TestCompound_NoRtpReceived) { TEST_F(RtcpSenderTest, TestCompound_NoRtpReceived) {
EXPECT_EQ(0, rtcp_sender_->SetIJStatus(true)); rtcp_sender_->SetIJStatus(true);
EXPECT_EQ(0, rtcp_sender_->SetRTCPStatus(kRtcpCompound)); rtcp_sender_->SetRTCPStatus(kRtcpCompound);
RTCPSender::FeedbackState feedback_state = rtp_rtcp_impl_->GetFeedbackState(); RTCPSender::FeedbackState feedback_state = rtp_rtcp_impl_->GetFeedbackState();
EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state, kRtcpRr)); EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state, kRtcpRr));
@ -405,7 +405,7 @@ TEST_F(RtcpSenderTest, TestCompound_NoRtpReceived) {
} }
TEST_F(RtcpSenderTest, TestXrReceiverReferenceTime) { TEST_F(RtcpSenderTest, TestXrReceiverReferenceTime) {
EXPECT_EQ(0, rtcp_sender_->SetRTCPStatus(kRtcpCompound)); rtcp_sender_->SetRTCPStatus(kRtcpCompound);
RTCPSender::FeedbackState feedback_state = rtp_rtcp_impl_->GetFeedbackState(); RTCPSender::FeedbackState feedback_state = rtp_rtcp_impl_->GetFeedbackState();
EXPECT_EQ(0, rtcp_sender_->SetSendingStatus(feedback_state, false)); EXPECT_EQ(0, rtcp_sender_->SetSendingStatus(feedback_state, false));
rtcp_sender_->SendRtcpXrReceiverReferenceTime(true); rtcp_sender_->SendRtcpXrReceiverReferenceTime(true);
@ -416,7 +416,7 @@ TEST_F(RtcpSenderTest, TestXrReceiverReferenceTime) {
} }
TEST_F(RtcpSenderTest, TestNoXrReceiverReferenceTimeIfSending) { TEST_F(RtcpSenderTest, TestNoXrReceiverReferenceTimeIfSending) {
EXPECT_EQ(0, rtcp_sender_->SetRTCPStatus(kRtcpCompound)); rtcp_sender_->SetRTCPStatus(kRtcpCompound);
RTCPSender::FeedbackState feedback_state = rtp_rtcp_impl_->GetFeedbackState(); RTCPSender::FeedbackState feedback_state = rtp_rtcp_impl_->GetFeedbackState();
EXPECT_EQ(0, rtcp_sender_->SetSendingStatus(feedback_state, true)); EXPECT_EQ(0, rtcp_sender_->SetSendingStatus(feedback_state, true));
rtcp_sender_->SendRtcpXrReceiverReferenceTime(true); rtcp_sender_->SendRtcpXrReceiverReferenceTime(true);
@ -427,7 +427,7 @@ TEST_F(RtcpSenderTest, TestNoXrReceiverReferenceTimeIfSending) {
} }
TEST_F(RtcpSenderTest, TestNoXrReceiverReferenceTimeIfNotEnabled) { TEST_F(RtcpSenderTest, TestNoXrReceiverReferenceTimeIfNotEnabled) {
EXPECT_EQ(0, rtcp_sender_->SetRTCPStatus(kRtcpCompound)); rtcp_sender_->SetRTCPStatus(kRtcpCompound);
RTCPSender::FeedbackState feedback_state = rtp_rtcp_impl_->GetFeedbackState(); RTCPSender::FeedbackState feedback_state = rtp_rtcp_impl_->GetFeedbackState();
EXPECT_EQ(0, rtcp_sender_->SetSendingStatus(feedback_state, false)); EXPECT_EQ(0, rtcp_sender_->SetSendingStatus(feedback_state, false));
rtcp_sender_->SendRtcpXrReceiverReferenceTime(false); rtcp_sender_->SendRtcpXrReceiverReferenceTime(false);
@ -438,7 +438,7 @@ TEST_F(RtcpSenderTest, TestNoXrReceiverReferenceTimeIfNotEnabled) {
} }
TEST_F(RtcpSenderTest, TestSendTimeOfXrRrReport) { TEST_F(RtcpSenderTest, TestSendTimeOfXrRrReport) {
EXPECT_EQ(0, rtcp_sender_->SetRTCPStatus(kRtcpCompound)); rtcp_sender_->SetRTCPStatus(kRtcpCompound);
RTCPSender::FeedbackState feedback_state = rtp_rtcp_impl_->GetFeedbackState(); RTCPSender::FeedbackState feedback_state = rtp_rtcp_impl_->GetFeedbackState();
EXPECT_EQ(0, rtcp_sender_->SetSendingStatus(feedback_state, false)); EXPECT_EQ(0, rtcp_sender_->SetSendingStatus(feedback_state, false));
rtcp_sender_->SendRtcpXrReceiverReferenceTime(true); rtcp_sender_->SendRtcpXrReceiverReferenceTime(true);
@ -475,7 +475,7 @@ TEST_F(RtcpSenderTest, TestSendTimeOfXrRrReport) {
// See http://code.google.com/p/webrtc/issues/detail?id=468 for one // See http://code.google.com/p/webrtc/issues/detail?id=468 for one
// situation where this caused confusion. // situation where this caused confusion.
TEST_F(RtcpSenderTest, SendsTmmbnIfSetAndEmpty) { TEST_F(RtcpSenderTest, SendsTmmbnIfSetAndEmpty) {
EXPECT_EQ(0, rtcp_sender_->SetRTCPStatus(kRtcpCompound)); rtcp_sender_->SetRTCPStatus(kRtcpCompound);
TMMBRSet bounding_set; TMMBRSet bounding_set;
EXPECT_EQ(0, rtcp_sender_->SetTMMBN(&bounding_set, 3)); EXPECT_EQ(0, rtcp_sender_->SetTMMBN(&bounding_set, 3));
ASSERT_EQ(0U, test_transport_->rtcp_packet_info_.rtcpPacketTypeFlags); ASSERT_EQ(0U, test_transport_->rtcp_packet_info_.rtcpPacketTypeFlags);
@ -494,7 +494,7 @@ TEST_F(RtcpSenderTest, SendsTmmbnIfSetAndEmpty) {
} }
TEST_F(RtcpSenderTest, SendsTmmbnIfSetAndValid) { TEST_F(RtcpSenderTest, SendsTmmbnIfSetAndValid) {
EXPECT_EQ(0, rtcp_sender_->SetRTCPStatus(kRtcpCompound)); rtcp_sender_->SetRTCPStatus(kRtcpCompound);
TMMBRSet bounding_set; TMMBRSet bounding_set;
bounding_set.VerifyAndAllocateSet(1); bounding_set.VerifyAndAllocateSet(1);
const uint32_t kSourceSsrc = 12345; const uint32_t kSourceSsrc = 12345;

View File

@ -321,11 +321,9 @@ uint32_t ModuleRtpRtcpImpl::StartTimestamp() const {
} }
// Configure start timestamp, default is a random number. // Configure start timestamp, default is a random number.
int32_t ModuleRtpRtcpImpl::SetStartTimestamp( void ModuleRtpRtcpImpl::SetStartTimestamp(const uint32_t timestamp) {
const uint32_t timestamp) {
rtcp_sender_.SetStartTimestamp(timestamp); rtcp_sender_.SetStartTimestamp(timestamp);
rtp_sender_.SetStartTimestamp(timestamp, true); rtp_sender_.SetStartTimestamp(timestamp, true);
return 0; // TODO(pwestin): change to void.
} }
uint16_t ModuleRtpRtcpImpl::SequenceNumber() const { uint16_t ModuleRtpRtcpImpl::SequenceNumber() const {
@ -333,10 +331,8 @@ uint16_t ModuleRtpRtcpImpl::SequenceNumber() const {
} }
// Set SequenceNumber, default is a random number. // Set SequenceNumber, default is a random number.
int32_t ModuleRtpRtcpImpl::SetSequenceNumber( void ModuleRtpRtcpImpl::SetSequenceNumber(const uint16_t seq_num) {
const uint16_t seq_num) {
rtp_sender_.SetSequenceNumber(seq_num); rtp_sender_.SetSequenceNumber(seq_num);
return 0; // TODO(pwestin): change to void.
} }
void ModuleRtpRtcpImpl::SetRtpStateForSsrc(uint32_t ssrc, void ModuleRtpRtcpImpl::SetRtpStateForSsrc(uint32_t ssrc,
@ -467,9 +463,8 @@ bool ModuleRtpRtcpImpl::Sending() const {
return rtcp_sender_.Sending(); return rtcp_sender_.Sending();
} }
int32_t ModuleRtpRtcpImpl::SetSendingMediaStatus(const bool sending) { void ModuleRtpRtcpImpl::SetSendingMediaStatus(const bool sending) {
rtp_sender_.SetSendingMediaStatus(sending); rtp_sender_.SetSendingMediaStatus(sending);
return 0;
} }
bool ModuleRtpRtcpImpl::SendingMedia() const { bool ModuleRtpRtcpImpl::SendingMedia() const {
@ -705,11 +700,9 @@ RTCPMethod ModuleRtpRtcpImpl::RTCP() const {
} }
// Configure RTCP status i.e on/off. // Configure RTCP status i.e on/off.
int32_t ModuleRtpRtcpImpl::SetRTCPStatus(const RTCPMethod method) { void ModuleRtpRtcpImpl::SetRTCPStatus(const RTCPMethod method) {
if (rtcp_sender_.SetRTCPStatus(method) == 0) { rtcp_sender_.SetRTCPStatus(method);
return rtcp_receiver_.SetRTCPStatus(method); rtcp_receiver_.SetRTCPStatus(method);
}
return -1;
} }
// Only for internal test. // Only for internal test.
@ -722,8 +715,7 @@ int32_t ModuleRtpRtcpImpl::SetCNAME(const char c_name[RTCP_CNAME_SIZE]) {
return rtcp_sender_.SetCNAME(c_name); return rtcp_sender_.SetCNAME(c_name);
} }
int32_t ModuleRtpRtcpImpl::AddMixedCNAME( int32_t ModuleRtpRtcpImpl::AddMixedCNAME(uint32_t ssrc,
const uint32_t ssrc,
const char c_name[RTCP_CNAME_SIZE]) { const char c_name[RTCP_CNAME_SIZE]) {
return rtcp_sender_.AddMixedCNAME(ssrc, c_name); return rtcp_sender_.AddMixedCNAME(ssrc, c_name);
} }
@ -859,13 +851,13 @@ bool ModuleRtpRtcpImpl::REMB() const {
return rtcp_sender_.REMB(); return rtcp_sender_.REMB();
} }
int32_t ModuleRtpRtcpImpl::SetREMBStatus(const bool enable) { void ModuleRtpRtcpImpl::SetREMBStatus(const bool enable) {
return rtcp_sender_.SetREMBStatus(enable); rtcp_sender_.SetREMBStatus(enable);
} }
int32_t ModuleRtpRtcpImpl::SetREMBData(const uint32_t bitrate, void ModuleRtpRtcpImpl::SetREMBData(const uint32_t bitrate,
const std::vector<uint32_t>& ssrcs) { const std::vector<uint32_t>& ssrcs) {
return rtcp_sender_.SetREMBData(bitrate, ssrcs); rtcp_sender_.SetREMBData(bitrate, ssrcs);
} }
// (IJ) Extended jitter report. // (IJ) Extended jitter report.
@ -873,8 +865,8 @@ bool ModuleRtpRtcpImpl::IJ() const {
return rtcp_sender_.IJ(); return rtcp_sender_.IJ();
} }
int32_t ModuleRtpRtcpImpl::SetIJStatus(const bool enable) { void ModuleRtpRtcpImpl::SetIJStatus(const bool enable) {
return rtcp_sender_.SetIJStatus(enable); rtcp_sender_.SetIJStatus(enable);
} }
int32_t ModuleRtpRtcpImpl::RegisterSendRtpHeaderExtension( int32_t ModuleRtpRtcpImpl::RegisterSendRtpHeaderExtension(
@ -893,8 +885,8 @@ bool ModuleRtpRtcpImpl::TMMBR() const {
return rtcp_sender_.TMMBR(); return rtcp_sender_.TMMBR();
} }
int32_t ModuleRtpRtcpImpl::SetTMMBRStatus(const bool enable) { void ModuleRtpRtcpImpl::SetTMMBRStatus(const bool enable) {
return rtcp_sender_.SetTMMBRStatus(enable); rtcp_sender_.SetTMMBRStatus(enable);
} }
int32_t ModuleRtpRtcpImpl::SetTMMBN(const TMMBRSet* bounding_set) { int32_t ModuleRtpRtcpImpl::SetTMMBN(const TMMBRSet* bounding_set) {
@ -972,11 +964,9 @@ bool ModuleRtpRtcpImpl::TimeToSendFullNackList(int64_t now) const {
// Store the sent packets, needed to answer to a Negative acknowledgment // Store the sent packets, needed to answer to a Negative acknowledgment
// requests. // requests.
int32_t ModuleRtpRtcpImpl::SetStorePacketsStatus( void ModuleRtpRtcpImpl::SetStorePacketsStatus(const bool enable,
const bool enable,
const uint16_t number_to_store) { const uint16_t number_to_store) {
rtp_sender_.SetStorePacketsStatus(enable, number_to_store); rtp_sender_.SetStorePacketsStatus(enable, number_to_store);
return 0; // TODO(pwestin): change to void.
} }
bool ModuleRtpRtcpImpl::StorePackets() const { bool ModuleRtpRtcpImpl::StorePackets() const {

View File

@ -42,7 +42,7 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
virtual int32_t IncomingRtcpPacket(const uint8_t* incoming_packet, virtual int32_t IncomingRtcpPacket(const uint8_t* incoming_packet,
size_t incoming_packet_length) OVERRIDE; size_t incoming_packet_length) OVERRIDE;
virtual void SetRemoteSSRC(const uint32_t ssrc) OVERRIDE; virtual void SetRemoteSSRC(uint32_t ssrc) OVERRIDE;
// Sender part. // Sender part.
@ -50,28 +50,27 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
virtual int32_t RegisterSendPayload(const VideoCodec& video_codec) OVERRIDE; virtual int32_t RegisterSendPayload(const VideoCodec& video_codec) OVERRIDE;
virtual int32_t DeRegisterSendPayload(const int8_t payload_type) OVERRIDE; virtual int32_t DeRegisterSendPayload(int8_t payload_type) OVERRIDE;
int8_t SendPayloadType() const; int8_t SendPayloadType() const;
// Register RTP header extension. // Register RTP header extension.
virtual int32_t RegisterSendRtpHeaderExtension( virtual int32_t RegisterSendRtpHeaderExtension(RTPExtensionType type,
const RTPExtensionType type, uint8_t id) OVERRIDE;
const uint8_t id) OVERRIDE;
virtual int32_t DeregisterSendRtpHeaderExtension( virtual int32_t DeregisterSendRtpHeaderExtension(
const RTPExtensionType type) OVERRIDE; RTPExtensionType type) OVERRIDE;
// Get start timestamp. // Get start timestamp.
virtual uint32_t StartTimestamp() const OVERRIDE; virtual uint32_t StartTimestamp() const OVERRIDE;
// Configure start timestamp, default is a random number. // Configure start timestamp, default is a random number.
virtual int32_t SetStartTimestamp(const uint32_t timestamp) OVERRIDE; virtual void SetStartTimestamp(uint32_t timestamp) OVERRIDE;
virtual uint16_t SequenceNumber() const OVERRIDE; virtual uint16_t SequenceNumber() const OVERRIDE;
// Set SequenceNumber, default is a random number. // Set SequenceNumber, default is a random number.
virtual int32_t SetSequenceNumber(const uint16_t seq) OVERRIDE; virtual void SetSequenceNumber(uint16_t seq) OVERRIDE;
virtual void SetRtpStateForSsrc(uint32_t ssrc, virtual void SetRtpStateForSsrc(uint32_t ssrc,
const RtpState& rtp_state) OVERRIDE; const RtpState& rtp_state) OVERRIDE;
@ -80,7 +79,7 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
virtual uint32_t SSRC() const OVERRIDE; virtual uint32_t SSRC() const OVERRIDE;
// Configure SSRC, default is a random number. // Configure SSRC, default is a random number.
virtual void SetSSRC(const uint32_t ssrc) OVERRIDE; virtual void SetSSRC(uint32_t ssrc) OVERRIDE;
virtual void SetCsrcs(const std::vector<uint32_t>& csrcs) OVERRIDE; virtual void SetCsrcs(const std::vector<uint32_t>& csrcs) OVERRIDE;
@ -88,7 +87,7 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
int CurrentSendFrequencyHz() const; int CurrentSendFrequencyHz() const;
virtual void SetRTXSendStatus(const int mode) OVERRIDE; virtual void SetRTXSendStatus(int mode) OVERRIDE;
virtual void RTXSendStatus(int* mode, uint32_t* ssrc, virtual void RTXSendStatus(int* mode, uint32_t* ssrc,
int* payloadType) const OVERRIDE; int* payloadType) const OVERRIDE;
@ -98,24 +97,24 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
virtual void SetRtxSendPayloadType(int payload_type) OVERRIDE; virtual void SetRtxSendPayloadType(int payload_type) OVERRIDE;
// Sends kRtcpByeCode when going from true to false. // Sends kRtcpByeCode when going from true to false.
virtual int32_t SetSendingStatus(const bool sending) OVERRIDE; virtual int32_t SetSendingStatus(bool sending) OVERRIDE;
virtual bool Sending() const OVERRIDE; virtual bool Sending() const OVERRIDE;
// Drops or relays media packets. // Drops or relays media packets.
virtual int32_t SetSendingMediaStatus(const bool sending) OVERRIDE; virtual void SetSendingMediaStatus(bool sending) OVERRIDE;
virtual bool SendingMedia() const OVERRIDE; virtual bool SendingMedia() const OVERRIDE;
// Used by the codec module to deliver a video or audio frame for // Used by the codec module to deliver a video or audio frame for
// packetization. // packetization.
virtual int32_t SendOutgoingData( virtual int32_t SendOutgoingData(
const FrameType frame_type, FrameType frame_type,
const int8_t payload_type, int8_t payload_type,
const uint32_t time_stamp, uint32_t time_stamp,
int64_t capture_time_ms, int64_t capture_time_ms,
const uint8_t* payload_data, const uint8_t* payload_data,
const size_t payload_size, size_t payload_size,
const RTPFragmentationHeader* fragmentation = NULL, const RTPFragmentationHeader* fragmentation = NULL,
const RTPVideoHeader* rtp_video_hdr = NULL) OVERRIDE; const RTPVideoHeader* rtp_video_hdr = NULL) OVERRIDE;
@ -136,13 +135,13 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
virtual RTCPMethod RTCP() const OVERRIDE; virtual RTCPMethod RTCP() const OVERRIDE;
// Configure RTCP status i.e on/off. // Configure RTCP status i.e on/off.
virtual int32_t SetRTCPStatus(const RTCPMethod method) OVERRIDE; virtual void SetRTCPStatus(RTCPMethod method) OVERRIDE;
// Set RTCP CName. // Set RTCP CName.
virtual int32_t SetCNAME(const char c_name[RTCP_CNAME_SIZE]) OVERRIDE; virtual int32_t SetCNAME(const char c_name[RTCP_CNAME_SIZE]) OVERRIDE;
// Get remote CName. // Get remote CName.
virtual int32_t RemoteCNAME(const uint32_t remote_ssrc, virtual int32_t RemoteCNAME(uint32_t remote_ssrc,
char c_name[RTCP_CNAME_SIZE]) const OVERRIDE; char c_name[RTCP_CNAME_SIZE]) const OVERRIDE;
// Get remote NTP. // Get remote NTP.
@ -152,13 +151,13 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
uint32_t* rtcp_arrival_time_frac, uint32_t* rtcp_arrival_time_frac,
uint32_t* rtcp_timestamp) const OVERRIDE; uint32_t* rtcp_timestamp) const OVERRIDE;
virtual int32_t AddMixedCNAME(const uint32_t ssrc, virtual int32_t AddMixedCNAME(uint32_t ssrc,
const char c_name[RTCP_CNAME_SIZE]) OVERRIDE; const char c_name[RTCP_CNAME_SIZE]) OVERRIDE;
virtual int32_t RemoveMixedCNAME(const uint32_t ssrc) OVERRIDE; virtual int32_t RemoveMixedCNAME(uint32_t ssrc) OVERRIDE;
// Get RoundTripTime. // Get RoundTripTime.
virtual int32_t RTT(const uint32_t remote_ssrc, virtual int32_t RTT(uint32_t remote_ssrc,
uint16_t* rtt, uint16_t* rtt,
uint16_t* avg_rtt, uint16_t* avg_rtt,
uint16_t* min_rtt, uint16_t* min_rtt,
@ -187,9 +186,10 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
// Set received RTCP report block. // Set received RTCP report block.
virtual int32_t AddRTCPReportBlock( virtual int32_t AddRTCPReportBlock(
const uint32_t ssrc, const RTCPReportBlock* receive_block) OVERRIDE; uint32_t ssrc,
const RTCPReportBlock* receive_block) OVERRIDE;
virtual int32_t RemoveRTCPReportBlock(const uint32_t ssrc) OVERRIDE; virtual int32_t RemoveRTCPReportBlock(uint32_t ssrc) OVERRIDE;
virtual void GetRtcpPacketTypeCounters( virtual void GetRtcpPacketTypeCounters(
RtcpPacketTypeCounter* packets_sent, RtcpPacketTypeCounter* packets_sent,
@ -198,20 +198,20 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
// (REMB) Receiver Estimated Max Bitrate. // (REMB) Receiver Estimated Max Bitrate.
virtual bool REMB() const OVERRIDE; virtual bool REMB() const OVERRIDE;
virtual int32_t SetREMBStatus(const bool enable) OVERRIDE; virtual void SetREMBStatus(bool enable) OVERRIDE;
virtual int32_t SetREMBData(const uint32_t bitrate, virtual void SetREMBData(uint32_t bitrate,
const std::vector<uint32_t>& ssrcs) OVERRIDE; const std::vector<uint32_t>& ssrcs) OVERRIDE;
// (IJ) Extended jitter report. // (IJ) Extended jitter report.
virtual bool IJ() const OVERRIDE; virtual bool IJ() const OVERRIDE;
virtual int32_t SetIJStatus(const bool enable) OVERRIDE; virtual void SetIJStatus(bool enable) OVERRIDE;
// (TMMBR) Temporary Max Media Bit Rate. // (TMMBR) Temporary Max Media Bit Rate.
virtual bool TMMBR() const OVERRIDE; virtual bool TMMBR() const OVERRIDE;
virtual int32_t SetTMMBRStatus(const bool enable) OVERRIDE; virtual void SetTMMBRStatus(bool enable) OVERRIDE;
int32_t SetTMMBN(const TMMBRSet* bounding_set); int32_t SetTMMBN(const TMMBRSet* bounding_set);
@ -219,12 +219,12 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
virtual uint16_t MaxDataPayloadLength() const OVERRIDE; virtual uint16_t MaxDataPayloadLength() const OVERRIDE;
virtual int32_t SetMaxTransferUnit(const uint16_t size) OVERRIDE; virtual int32_t SetMaxTransferUnit(uint16_t size) OVERRIDE;
virtual int32_t SetTransportOverhead( virtual int32_t SetTransportOverhead(
const bool tcp, bool tcp,
const bool ipv6, bool ipv6,
const uint8_t authentication_overhead = 0) OVERRIDE; uint8_t authentication_overhead = 0) OVERRIDE;
// (NACK) Negative acknowledgment part. // (NACK) Negative acknowledgment part.
@ -233,13 +233,12 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
virtual int SetSelectiveRetransmissions(uint8_t settings) OVERRIDE; virtual int SetSelectiveRetransmissions(uint8_t settings) OVERRIDE;
// Send a Negative acknowledgment packet. // Send a Negative acknowledgment packet.
virtual int32_t SendNACK(const uint16_t* nack_list, virtual int32_t SendNACK(const uint16_t* nack_list, uint16_t size) OVERRIDE;
const uint16_t size) OVERRIDE;
// Store the sent packets, needed to answer to a negative acknowledgment // Store the sent packets, needed to answer to a negative acknowledgment
// requests. // requests.
virtual int32_t SetStorePacketsStatus( virtual void SetStorePacketsStatus(bool enable,
const bool enable, const uint16_t number_to_store) OVERRIDE; uint16_t number_to_store) OVERRIDE;
virtual bool StorePackets() const OVERRIDE; virtual bool StorePackets() const OVERRIDE;
@ -249,11 +248,10 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
virtual RtcpStatisticsCallback* GetRtcpStatisticsCallback() OVERRIDE; virtual RtcpStatisticsCallback* GetRtcpStatisticsCallback() OVERRIDE;
// (APP) Application specific data. // (APP) Application specific data.
virtual int32_t SetRTCPApplicationSpecificData( virtual int32_t SetRTCPApplicationSpecificData(uint8_t sub_type,
const uint8_t sub_type, uint32_t name,
const uint32_t name,
const uint8_t* data, const uint8_t* data,
const uint16_t length) OVERRIDE; uint16_t length) OVERRIDE;
// (XR) VOIP metric. // (XR) VOIP metric.
virtual int32_t SetRTCPVoIPMetrics(const RTCPVoIPMetric* VoIPMetric) OVERRIDE; virtual int32_t SetRTCPVoIPMetrics(const RTCPVoIPMetric* VoIPMetric) OVERRIDE;
@ -267,47 +265,44 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
// Set audio packet size, used to determine when it's time to send a DTMF // Set audio packet size, used to determine when it's time to send a DTMF
// packet in silence (CNG). // packet in silence (CNG).
virtual int32_t SetAudioPacketSize( virtual int32_t SetAudioPacketSize(uint16_t packet_size_samples) OVERRIDE;
const uint16_t packet_size_samples) OVERRIDE;
virtual bool SendTelephoneEventActive(int8_t& telephone_event) const OVERRIDE; virtual bool SendTelephoneEventActive(int8_t& telephone_event) const OVERRIDE;
// Send a TelephoneEvent tone using RFC 2833 (4733). // Send a TelephoneEvent tone using RFC 2833 (4733).
virtual int32_t SendTelephoneEventOutband(const uint8_t key, virtual int32_t SendTelephoneEventOutband(uint8_t key,
const uint16_t time_ms, uint16_t time_ms,
const uint8_t level) OVERRIDE; uint8_t level) OVERRIDE;
// Set payload type for Redundant Audio Data RFC 2198. // Set payload type for Redundant Audio Data RFC 2198.
virtual int32_t SetSendREDPayloadType(const int8_t payload_type) OVERRIDE; virtual int32_t SetSendREDPayloadType(int8_t payload_type) OVERRIDE;
// Get payload type for Redundant Audio Data RFC 2198. // Get payload type for Redundant Audio Data RFC 2198.
virtual int32_t SendREDPayloadType(int8_t& payload_type) const OVERRIDE; virtual int32_t SendREDPayloadType(int8_t& payload_type) const OVERRIDE;
// Store the audio level in d_bov for header-extension-for-audio-level- // Store the audio level in d_bov for header-extension-for-audio-level-
// indication. // indication.
virtual int32_t SetAudioLevel(const uint8_t level_d_bov) OVERRIDE; virtual int32_t SetAudioLevel(uint8_t level_d_bov) OVERRIDE;
// Video part. // Video part.
virtual int32_t SendRTCPSliceLossIndication( virtual int32_t SendRTCPSliceLossIndication(uint8_t picture_id) OVERRIDE;
const uint8_t picture_id) OVERRIDE;
// Set method for requestion a new key frame. // Set method for requestion a new key frame.
virtual int32_t SetKeyFrameRequestMethod( virtual int32_t SetKeyFrameRequestMethod(
const KeyFrameRequestMethod method) OVERRIDE; KeyFrameRequestMethod method) OVERRIDE;
// Send a request for a keyframe. // Send a request for a keyframe.
virtual int32_t RequestKeyFrame() OVERRIDE; virtual int32_t RequestKeyFrame() OVERRIDE;
virtual int32_t SetCameraDelay(const int32_t delay_ms) OVERRIDE; virtual int32_t SetCameraDelay(int32_t delay_ms) OVERRIDE;
virtual void SetTargetSendBitrate( virtual void SetTargetSendBitrate(
const std::vector<uint32_t>& stream_bitrates) OVERRIDE; const std::vector<uint32_t>& stream_bitrates) OVERRIDE;
virtual int32_t SetGenericFECStatus( virtual int32_t SetGenericFECStatus(bool enable,
const bool enable, uint8_t payload_type_red,
const uint8_t payload_type_red, uint8_t payload_type_fec) OVERRIDE;
const uint8_t payload_type_fec) OVERRIDE;
virtual int32_t GenericFECStatus( virtual int32_t GenericFECStatus(
bool& enable, bool& enable,
@ -331,13 +326,13 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
uint32_t* fec_rate, uint32_t* fec_rate,
uint32_t* nackRate) const OVERRIDE; uint32_t* nackRate) const OVERRIDE;
uint32_t SendTimeOfSendReport(const uint32_t send_report); uint32_t SendTimeOfSendReport(uint32_t send_report);
bool SendTimeOfXrRrReport(uint32_t mid_ntp, int64_t* time_ms) const; bool SendTimeOfXrRrReport(uint32_t mid_ntp, int64_t* time_ms) const;
// Good state of RTP receiver inform sender. // Good state of RTP receiver inform sender.
virtual int32_t SendRTCPReferencePictureSelection( virtual int32_t SendRTCPReferencePictureSelection(
const uint64_t picture_id) OVERRIDE; uint64_t picture_id) OVERRIDE;
virtual void RegisterSendChannelRtpStatisticsCallback( virtual void RegisterSendChannelRtpStatisticsCallback(
StreamDataCountersCallback* callback) OVERRIDE; StreamDataCountersCallback* callback) OVERRIDE;
@ -350,11 +345,10 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
void OnRequestIntraFrame(); void OnRequestIntraFrame();
// Received a request for a new SLI. // Received a request for a new SLI.
void OnReceivedSliceLossIndication(const uint8_t picture_id); void OnReceivedSliceLossIndication(uint8_t picture_id);
// Received a new reference frame. // Received a new reference frame.
void OnReceivedReferencePictureSelectionIndication( void OnReceivedReferencePictureSelectionIndication(uint64_t picture_id);
const uint64_t picture_id);
void OnReceivedNACK(const std::list<uint16_t>& nack_sequence_numbers); void OnReceivedNACK(const std::list<uint16_t>& nack_sequence_numbers);

View File

@ -110,7 +110,7 @@ class RtpRtcpModule {
config.rtt_stats = &rtt_stats_; config.rtt_stats = &rtt_stats_;
impl_.reset(new ModuleRtpRtcpImpl(config)); impl_.reset(new ModuleRtpRtcpImpl(config));
EXPECT_EQ(0, impl_->SetRTCPStatus(kRtcpCompound)); impl_->SetRTCPStatus(kRtcpCompound);
transport_.SimulateNetworkDelay(kOneWayNetworkDelayMs, clock); transport_.SimulateNetworkDelay(kOneWayNetworkDelayMs, clock);
} }
@ -150,7 +150,7 @@ class RtpRtcpImplTest : public ::testing::Test {
receiver_(&clock_) { receiver_(&clock_) {
// Send module. // Send module.
EXPECT_EQ(0, sender_.impl_->SetSendingStatus(true)); EXPECT_EQ(0, sender_.impl_->SetSendingStatus(true));
EXPECT_EQ(0, sender_.impl_->SetSendingMediaStatus(true)); sender_.impl_->SetSendingMediaStatus(true);
sender_.impl_->SetSSRC(kSenderSsrc); sender_.impl_->SetSSRC(kSenderSsrc);
sender_.impl_->SetRemoteSSRC(kReceiverSsrc); sender_.impl_->SetRemoteSSRC(kReceiverSsrc);
sender_.impl_->SetSequenceNumber(kSequenceNumber); sender_.impl_->SetSequenceNumber(kSequenceNumber);
@ -165,7 +165,7 @@ class RtpRtcpImplTest : public ::testing::Test {
// Receive module. // Receive module.
EXPECT_EQ(0, receiver_.impl_->SetSendingStatus(false)); EXPECT_EQ(0, receiver_.impl_->SetSendingStatus(false));
EXPECT_EQ(0, receiver_.impl_->SetSendingMediaStatus(false)); receiver_.impl_->SetSendingMediaStatus(false);
receiver_.impl_->SetSSRC(kReceiverSsrc); receiver_.impl_->SetSSRC(kReceiverSsrc);
receiver_.impl_->SetRemoteSSRC(kSenderSsrc); receiver_.impl_->SetRemoteSSRC(kSenderSsrc);
// Transport settings. // Transport settings.
@ -580,7 +580,7 @@ class RtpSendingTest : public ::testing::Test {
RtpRtcp* sender = RtpRtcp::CreateRtpRtcp(config); RtpRtcp* sender = RtpRtcp::CreateRtpRtcp(config);
EXPECT_EQ(0, sender->RegisterSendPayload(codec_)); EXPECT_EQ(0, sender->RegisterSendPayload(codec_));
EXPECT_EQ(0, sender->SetSendingStatus(true)); EXPECT_EQ(0, sender->SetSendingStatus(true));
EXPECT_EQ(0, sender->SetSendingMediaStatus(true)); sender->SetSendingMediaStatus(true);
sender->SetSSRC(kSenderSsrc + i); sender->SetSSRC(kSenderSsrc + i);
sender->SetRemoteSSRC(kReceiverSsrc + i); sender->SetRemoteSSRC(kReceiverSsrc + i);
senders_.push_back(sender); senders_.push_back(sender);

View File

@ -27,7 +27,7 @@ const int kSendSideDelayWindowMs = 1000;
namespace { namespace {
const char* FrameTypeToString(const FrameType frame_type) { const char* FrameTypeToString(FrameType frame_type) {
switch (frame_type) { switch (frame_type) {
case kFrameEmpty: return "empty"; case kFrameEmpty: return "empty";
case kAudioFrameSpeech: return "audio_speech"; case kAudioFrameSpeech: return "audio_speech";
@ -91,8 +91,8 @@ class BitrateAggregator {
uint32_t ssrc_; uint32_t ssrc_;
}; };
RTPSender::RTPSender(const int32_t id, RTPSender::RTPSender(int32_t id,
const bool audio, bool audio,
Clock* clock, Clock* clock,
Transport* transport, Transport* transport,
RtpAudioFeedback* audio_feedback, RtpAudioFeedback* audio_feedback,
@ -236,8 +236,7 @@ bool RTPSender::GetSendSideDelay(int* avg_send_delay_ms,
return true; return true;
} }
int32_t RTPSender::SetTransmissionTimeOffset( int32_t RTPSender::SetTransmissionTimeOffset(int32_t transmission_time_offset) {
const int32_t transmission_time_offset) {
if (transmission_time_offset > (0x800000 - 1) || if (transmission_time_offset > (0x800000 - 1) ||
transmission_time_offset < -(0x800000 - 1)) { // Word24. transmission_time_offset < -(0x800000 - 1)) { // Word24.
return -1; return -1;
@ -247,8 +246,7 @@ int32_t RTPSender::SetTransmissionTimeOffset(
return 0; return 0;
} }
int32_t RTPSender::SetAbsoluteSendTime( int32_t RTPSender::SetAbsoluteSendTime(uint32_t absolute_send_time) {
const uint32_t absolute_send_time) {
if (absolute_send_time > 0xffffff) { // UWord24. if (absolute_send_time > 0xffffff) { // UWord24.
return -1; return -1;
} }
@ -257,14 +255,13 @@ int32_t RTPSender::SetAbsoluteSendTime(
return 0; return 0;
} }
int32_t RTPSender::RegisterRtpHeaderExtension(const RTPExtensionType type, int32_t RTPSender::RegisterRtpHeaderExtension(RTPExtensionType type,
const uint8_t id) { uint8_t id) {
CriticalSectionScoped cs(send_critsect_); CriticalSectionScoped cs(send_critsect_);
return rtp_header_extension_map_.Register(type, id); return rtp_header_extension_map_.Register(type, id);
} }
int32_t RTPSender::DeregisterRtpHeaderExtension( int32_t RTPSender::DeregisterRtpHeaderExtension(RTPExtensionType type) {
const RTPExtensionType type) {
CriticalSectionScoped cs(send_critsect_); CriticalSectionScoped cs(send_critsect_);
return rtp_header_extension_map_.Deregister(type); return rtp_header_extension_map_.Deregister(type);
} }
@ -276,8 +273,10 @@ size_t RTPSender::RtpHeaderExtensionTotalLength() const {
int32_t RTPSender::RegisterPayload( int32_t RTPSender::RegisterPayload(
const char payload_name[RTP_PAYLOAD_NAME_SIZE], const char payload_name[RTP_PAYLOAD_NAME_SIZE],
const int8_t payload_number, const uint32_t frequency, int8_t payload_number,
const uint8_t channels, const uint32_t rate) { uint32_t frequency,
uint8_t channels,
uint32_t rate) {
assert(payload_name); assert(payload_name);
CriticalSectionScoped cs(send_critsect_); CriticalSectionScoped cs(send_critsect_);
@ -321,8 +320,7 @@ int32_t RTPSender::RegisterPayload(
return ret_val; return ret_val;
} }
int32_t RTPSender::DeRegisterSendPayload( int32_t RTPSender::DeRegisterSendPayload(int8_t payload_type) {
const int8_t payload_type) {
CriticalSectionScoped lock(send_critsect_); CriticalSectionScoped lock(send_critsect_);
std::map<int8_t, RtpUtility::Payload*>::iterator it = std::map<int8_t, RtpUtility::Payload*>::iterator it =
@ -351,9 +349,8 @@ int RTPSender::SendPayloadFrequency() const {
return audio_ != NULL ? audio_->AudioFrequency() : kVideoPayloadTypeFrequency; return audio_ != NULL ? audio_->AudioFrequency() : kVideoPayloadTypeFrequency;
} }
int32_t RTPSender::SetMaxPayloadLength( int32_t RTPSender::SetMaxPayloadLength(size_t max_payload_length,
const size_t max_payload_length, uint16_t packet_over_head) {
const uint16_t packet_over_head) {
// Sanity check. // Sanity check.
if (max_payload_length < 100 || max_payload_length > IP_PACKET_SIZE) { if (max_payload_length < 100 || max_payload_length > IP_PACKET_SIZE) {
LOG(LS_ERROR) << "Invalid max payload length: " << max_payload_length; LOG(LS_ERROR) << "Invalid max payload length: " << max_payload_length;
@ -414,8 +411,8 @@ void RTPSender::SetRtxPayloadType(int payload_type) {
payload_type_rtx_ = payload_type; payload_type_rtx_ = payload_type;
} }
int32_t RTPSender::CheckPayloadType(const int8_t payload_type, int32_t RTPSender::CheckPayloadType(int8_t payload_type,
RtpVideoCodecTypes *video_type) { RtpVideoCodecTypes* video_type) {
CriticalSectionScoped cs(send_critsect_); CriticalSectionScoped cs(send_critsect_);
if (payload_type < 0) { if (payload_type < 0) {
@ -455,12 +452,15 @@ int32_t RTPSender::CheckPayloadType(const int8_t payload_type,
return 0; return 0;
} }
int32_t RTPSender::SendOutgoingData( int32_t RTPSender::SendOutgoingData(FrameType frame_type,
const FrameType frame_type, const int8_t payload_type, int8_t payload_type,
const uint32_t capture_timestamp, int64_t capture_time_ms, uint32_t capture_timestamp,
const uint8_t *payload_data, const size_t payload_size, int64_t capture_time_ms,
const RTPFragmentationHeader *fragmentation, const uint8_t* payload_data,
VideoCodecInformation *codec_info, const RTPVideoTypeHeader *rtp_type_hdr) { size_t payload_size,
const RTPFragmentationHeader* fragmentation,
VideoCodecInformation* codec_info,
const RTPVideoTypeHeader* rtp_type_hdr) {
uint32_t ssrc; uint32_t ssrc;
{ {
// Drop this packet if we're not sending media packets. // Drop this packet if we're not sending media packets.
@ -645,8 +645,7 @@ size_t RTPSender::SendPadData(uint32_t timestamp,
return bytes_sent; return bytes_sent;
} }
void RTPSender::SetStorePacketsStatus(const bool enable, void RTPSender::SetStorePacketsStatus(bool enable, uint16_t number_to_store) {
const uint16_t number_to_store) {
packet_history_.SetStorePacketsStatus(enable, number_to_store); packet_history_.SetStorePacketsStatus(enable, number_to_store);
} }
@ -720,9 +719,8 @@ int RTPSender::SetSelectiveRetransmissions(uint8_t settings) {
return video_->SetSelectiveRetransmissions(settings); return video_->SetSelectiveRetransmissions(settings);
} }
void RTPSender::OnReceivedNACK( void RTPSender::OnReceivedNACK(const std::list<uint16_t>& nack_sequence_numbers,
const std::list<uint16_t>& nack_sequence_numbers, uint16_t avg_rtt) {
const uint16_t avg_rtt) {
TRACE_EVENT2("webrtc_rtp", "RTPSender::OnReceivedNACK", TRACE_EVENT2("webrtc_rtp", "RTPSender::OnReceivedNACK",
"num_seqnum", nack_sequence_numbers.size(), "avg_rtt", avg_rtt); "num_seqnum", nack_sequence_numbers.size(), "avg_rtt", avg_rtt);
const int64_t now = clock_->TimeInMilliseconds(); const int64_t now = clock_->TimeInMilliseconds();
@ -766,7 +764,7 @@ void RTPSender::OnReceivedNACK(
} }
} }
bool RTPSender::ProcessNACKBitRate(const uint32_t now) { bool RTPSender::ProcessNACKBitRate(uint32_t now) {
uint32_t num = 0; uint32_t num = 0;
size_t byte_count = 0; size_t byte_count = 0;
const uint32_t kAvgIntervalMs = 1000; const uint32_t kAvgIntervalMs = 1000;
@ -1121,12 +1119,12 @@ size_t RTPSender::CreateRtpHeader(uint8_t* header,
} }
int32_t RTPSender::BuildRTPheader(uint8_t* data_buffer, int32_t RTPSender::BuildRTPheader(uint8_t* data_buffer,
const int8_t payload_type, int8_t payload_type,
const bool marker_bit, bool marker_bit,
const uint32_t capture_timestamp, uint32_t capture_timestamp,
int64_t capture_time_ms, int64_t capture_time_ms,
const bool timestamp_provided, bool timestamp_provided,
const bool inc_sequence_number) { bool inc_sequence_number) {
assert(payload_type >= 0); assert(payload_type >= 0);
CriticalSectionScoped cs(send_critsect_); CriticalSectionScoped cs(send_critsect_);
@ -1306,9 +1304,10 @@ uint8_t RTPSender::BuildAbsoluteSendTimeExtension(uint8_t* data_buffer) const {
return kAbsoluteSendTimeLength; return kAbsoluteSendTimeLength;
} }
void RTPSender::UpdateTransmissionTimeOffset( void RTPSender::UpdateTransmissionTimeOffset(uint8_t* rtp_packet,
uint8_t *rtp_packet, const size_t rtp_packet_length, size_t rtp_packet_length,
const RTPHeader &rtp_header, const int64_t time_diff_ms) const { const RTPHeader& rtp_header,
int64_t time_diff_ms) const {
CriticalSectionScoped cs(send_critsect_); CriticalSectionScoped cs(send_critsect_);
// Get id. // Get id.
uint8_t id = 0; uint8_t id = 0;
@ -1352,11 +1351,11 @@ void RTPSender::UpdateTransmissionTimeOffset(
time_diff_ms * 90); // RTP timestamp. time_diff_ms * 90); // RTP timestamp.
} }
bool RTPSender::UpdateAudioLevel(uint8_t *rtp_packet, bool RTPSender::UpdateAudioLevel(uint8_t* rtp_packet,
const size_t rtp_packet_length, size_t rtp_packet_length,
const RTPHeader &rtp_header, const RTPHeader& rtp_header,
const bool is_voiced, bool is_voiced,
const uint8_t dBov) const { uint8_t dBov) const {
CriticalSectionScoped cs(send_critsect_); CriticalSectionScoped cs(send_critsect_);
// Get id. // Get id.
@ -1395,9 +1394,10 @@ bool RTPSender::UpdateAudioLevel(uint8_t *rtp_packet,
return true; return true;
} }
void RTPSender::UpdateAbsoluteSendTime( void RTPSender::UpdateAbsoluteSendTime(uint8_t* rtp_packet,
uint8_t *rtp_packet, const size_t rtp_packet_length, size_t rtp_packet_length,
const RTPHeader &rtp_header, const int64_t now_ms) const { const RTPHeader& rtp_header,
int64_t now_ms) const {
CriticalSectionScoped cs(send_critsect_); CriticalSectionScoped cs(send_critsect_);
// Get id. // Get id.
@ -1464,7 +1464,7 @@ void RTPSender::SetSendingStatus(bool enabled) {
} }
} }
void RTPSender::SetSendingMediaStatus(const bool enabled) { void RTPSender::SetSendingMediaStatus(bool enabled) {
CriticalSectionScoped cs(send_critsect_); CriticalSectionScoped cs(send_critsect_);
sending_media_ = enabled; sending_media_ = enabled;
} }
@ -1549,9 +1549,9 @@ uint16_t RTPSender::SequenceNumber() const {
} }
// Audio. // Audio.
int32_t RTPSender::SendTelephoneEvent(const uint8_t key, int32_t RTPSender::SendTelephoneEvent(uint8_t key,
const uint16_t time_ms, uint16_t time_ms,
const uint8_t level) { uint8_t level) {
if (!audio_configured_) { if (!audio_configured_) {
return -1; return -1;
} }
@ -1565,19 +1565,18 @@ bool RTPSender::SendTelephoneEventActive(int8_t *telephone_event) const {
return audio_->SendTelephoneEventActive(*telephone_event); return audio_->SendTelephoneEventActive(*telephone_event);
} }
int32_t RTPSender::SetAudioPacketSize( int32_t RTPSender::SetAudioPacketSize(uint16_t packet_size_samples) {
const uint16_t packet_size_samples) {
if (!audio_configured_) { if (!audio_configured_) {
return -1; return -1;
} }
return audio_->SetAudioPacketSize(packet_size_samples); return audio_->SetAudioPacketSize(packet_size_samples);
} }
int32_t RTPSender::SetAudioLevel(const uint8_t level_d_bov) { int32_t RTPSender::SetAudioLevel(uint8_t level_d_bov) {
return audio_->SetAudioLevel(level_d_bov); return audio_->SetAudioLevel(level_d_bov);
} }
int32_t RTPSender::SetRED(const int8_t payload_type) { int32_t RTPSender::SetRED(int8_t payload_type) {
if (!audio_configured_) { if (!audio_configured_) {
return -1; return -1;
} }
@ -1618,9 +1617,9 @@ int32_t RTPSender::SendRTPIntraRequest() {
return video_->SendRTPIntraRequest(); return video_->SendRTPIntraRequest();
} }
int32_t RTPSender::SetGenericFECStatus( int32_t RTPSender::SetGenericFECStatus(bool enable,
const bool enable, const uint8_t payload_type_red, uint8_t payload_type_red,
const uint8_t payload_type_fec) { uint8_t payload_type_fec) {
if (audio_configured_) { if (audio_configured_) {
return -1; return -1;
} }

View File

@ -45,12 +45,12 @@ class RTPSenderInterface {
virtual uint32_t Timestamp() const = 0; virtual uint32_t Timestamp() const = 0;
virtual int32_t BuildRTPheader(uint8_t* data_buffer, virtual int32_t BuildRTPheader(uint8_t* data_buffer,
const int8_t payload_type, int8_t payload_type,
const bool marker_bit, bool marker_bit,
const uint32_t capture_timestamp, uint32_t capture_timestamp,
int64_t capture_time_ms, int64_t capture_time_ms,
const bool timestamp_provided = true, bool timestamp_provided = true,
const bool inc_sequence_number = true) = 0; bool inc_sequence_number = true) = 0;
virtual size_t RTPHeaderLength() const = 0; virtual size_t RTPHeaderLength() const = 0;
virtual uint16_t IncrementSequenceNumber() = 0; virtual uint16_t IncrementSequenceNumber() = 0;
@ -68,9 +68,12 @@ class RTPSenderInterface {
class RTPSender : public RTPSenderInterface { class RTPSender : public RTPSenderInterface {
public: public:
RTPSender(const int32_t id, const bool audio, Clock *clock, RTPSender(int32_t id,
Transport *transport, RtpAudioFeedback *audio_feedback, bool audio,
PacedSender *paced_sender, Clock* clock,
Transport* transport,
RtpAudioFeedback* audio_feedback,
PacedSender* paced_sender,
BitrateStatisticsObserver* bitrate_callback, BitrateStatisticsObserver* bitrate_callback,
FrameCountObserver* frame_count_observer, FrameCountObserver* frame_count_observer,
SendSideDelayObserver* send_side_delay_observer); SendSideDelayObserver* send_side_delay_observer);
@ -109,7 +112,7 @@ class RTPSender : public RTPSenderInterface {
void SetSendingStatus(bool enabled); void SetSendingStatus(bool enabled);
void SetSendingMediaStatus(const bool enabled); void SetSendingMediaStatus(bool enabled);
bool SendingMedia() const; bool SendingMedia() const;
void GetDataCounters(StreamDataCounters* rtp_stats, void GetDataCounters(StreamDataCounters* rtp_stats,
@ -121,36 +124,32 @@ class RTPSender : public RTPSenderInterface {
void SetStartTimestamp(uint32_t timestamp, bool force); void SetStartTimestamp(uint32_t timestamp, bool force);
uint32_t GenerateNewSSRC(); uint32_t GenerateNewSSRC();
void SetSSRC(const uint32_t ssrc); void SetSSRC(uint32_t ssrc);
virtual uint16_t SequenceNumber() const OVERRIDE; virtual uint16_t SequenceNumber() const OVERRIDE;
void SetSequenceNumber(uint16_t seq); void SetSequenceNumber(uint16_t seq);
void SetCsrcs(const std::vector<uint32_t>& csrcs); void SetCsrcs(const std::vector<uint32_t>& csrcs);
int32_t SetMaxPayloadLength(const size_t length, int32_t SetMaxPayloadLength(size_t length, uint16_t packet_over_head);
const uint16_t packet_over_head);
int32_t SendOutgoingData(const FrameType frame_type, int32_t SendOutgoingData(FrameType frame_type,
const int8_t payload_type, int8_t payload_type,
const uint32_t timestamp, uint32_t timestamp,
int64_t capture_time_ms, int64_t capture_time_ms,
const uint8_t* payload_data, const uint8_t* payload_data,
const size_t payload_size, size_t payload_size,
const RTPFragmentationHeader* fragmentation, const RTPFragmentationHeader* fragmentation,
VideoCodecInformation* codec_info = NULL, VideoCodecInformation* codec_info = NULL,
const RTPVideoTypeHeader* rtp_type_hdr = NULL); const RTPVideoTypeHeader* rtp_type_hdr = NULL);
// RTP header extension // RTP header extension
int32_t SetTransmissionTimeOffset( int32_t SetTransmissionTimeOffset(int32_t transmission_time_offset);
const int32_t transmission_time_offset); int32_t SetAbsoluteSendTime(uint32_t absolute_send_time);
int32_t SetAbsoluteSendTime(
const uint32_t absolute_send_time);
int32_t RegisterRtpHeaderExtension(const RTPExtensionType type, int32_t RegisterRtpHeaderExtension(RTPExtensionType type, uint8_t id);
const uint8_t id);
int32_t DeregisterRtpHeaderExtension(const RTPExtensionType type); int32_t DeregisterRtpHeaderExtension(RTPExtensionType type);
size_t RtpHeaderExtensionTotalLength() const; size_t RtpHeaderExtensionTotalLength() const;
@ -160,11 +159,11 @@ class RTPSender : public RTPSenderInterface {
uint8_t BuildAudioLevelExtension(uint8_t* data_buffer) const; uint8_t BuildAudioLevelExtension(uint8_t* data_buffer) const;
uint8_t BuildAbsoluteSendTimeExtension(uint8_t* data_buffer) const; uint8_t BuildAbsoluteSendTimeExtension(uint8_t* data_buffer) const;
bool UpdateAudioLevel(uint8_t *rtp_packet, bool UpdateAudioLevel(uint8_t* rtp_packet,
const size_t rtp_packet_length, size_t rtp_packet_length,
const RTPHeader &rtp_header, const RTPHeader& rtp_header,
const bool is_voiced, bool is_voiced,
const uint8_t dBov) const; uint8_t dBov) const;
bool TimeToSendPacket(uint16_t sequence_number, int64_t capture_time_ms, bool TimeToSendPacket(uint16_t sequence_number, int64_t capture_time_ms,
bool retransmission); bool retransmission);
@ -174,16 +173,15 @@ class RTPSender : public RTPSenderInterface {
int SelectiveRetransmissions() const; int SelectiveRetransmissions() const;
int SetSelectiveRetransmissions(uint8_t settings); int SetSelectiveRetransmissions(uint8_t settings);
void OnReceivedNACK(const std::list<uint16_t>& nack_sequence_numbers, void OnReceivedNACK(const std::list<uint16_t>& nack_sequence_numbers,
const uint16_t avg_rtt); uint16_t avg_rtt);
void SetStorePacketsStatus(const bool enable, void SetStorePacketsStatus(bool enable, uint16_t number_to_store);
const uint16_t number_to_store);
bool StorePackets() const; bool StorePackets() const;
int32_t ReSendPacket(uint16_t packet_id, uint32_t min_resend_time = 0); int32_t ReSendPacket(uint16_t packet_id, uint32_t min_resend_time = 0);
bool ProcessNACKBitRate(const uint32_t now); bool ProcessNACKBitRate(uint32_t now);
// RTX. // RTX.
void SetRTXStatus(int mode); void SetRTXStatus(int mode);
@ -198,9 +196,9 @@ class RTPSender : public RTPSenderInterface {
// Functions wrapping RTPSenderInterface. // Functions wrapping RTPSenderInterface.
virtual int32_t BuildRTPheader( virtual int32_t BuildRTPheader(
uint8_t* data_buffer, uint8_t* data_buffer,
const int8_t payload_type, int8_t payload_type,
const bool marker_bit, bool marker_bit,
const uint32_t capture_timestamp, uint32_t capture_timestamp,
int64_t capture_time_ms, int64_t capture_time_ms,
const bool timestamp_provided = true, const bool timestamp_provided = true,
const bool inc_sequence_number = true) OVERRIDE; const bool inc_sequence_number = true) OVERRIDE;
@ -222,22 +220,20 @@ class RTPSender : public RTPSenderInterface {
// Audio. // Audio.
// Send a DTMF tone using RFC 2833 (4733). // Send a DTMF tone using RFC 2833 (4733).
int32_t SendTelephoneEvent(const uint8_t key, int32_t SendTelephoneEvent(uint8_t key, uint16_t time_ms, uint8_t level);
const uint16_t time_ms,
const uint8_t level);
bool SendTelephoneEventActive(int8_t *telephone_event) const; bool SendTelephoneEventActive(int8_t *telephone_event) const;
// Set audio packet size, used to determine when it's time to send a DTMF // Set audio packet size, used to determine when it's time to send a DTMF
// packet in silence (CNG). // packet in silence (CNG).
int32_t SetAudioPacketSize(const uint16_t packet_size_samples); int32_t SetAudioPacketSize(uint16_t packet_size_samples);
// Store the audio level in d_bov for // Store the audio level in d_bov for
// header-extension-for-audio-level-indication. // header-extension-for-audio-level-indication.
int32_t SetAudioLevel(const uint8_t level_d_bov); int32_t SetAudioLevel(uint8_t level_d_bov);
// Set payload type for Redundant Audio Data RFC 2198. // Set payload type for Redundant Audio Data RFC 2198.
int32_t SetRED(const int8_t payload_type); int32_t SetRED(int8_t payload_type);
// Get payload type for Redundant Audio Data RFC 2198. // Get payload type for Redundant Audio Data RFC 2198.
int32_t RED(int8_t *payload_type) const; int32_t RED(int8_t *payload_type) const;
@ -252,9 +248,9 @@ class RTPSender : public RTPSenderInterface {
int32_t SendRTPIntraRequest(); int32_t SendRTPIntraRequest();
// FEC. // FEC.
int32_t SetGenericFECStatus(const bool enable, int32_t SetGenericFECStatus(bool enable,
const uint8_t payload_type_red, uint8_t payload_type_red,
const uint8_t payload_type_fec); uint8_t payload_type_fec);
int32_t GenericFECStatus(bool *enable, uint8_t *payload_type_red, int32_t GenericFECStatus(bool *enable, uint8_t *payload_type_red,
uint8_t *payload_type_fec) const; uint8_t *payload_type_fec) const;
@ -278,8 +274,7 @@ class RTPSender : public RTPSenderInterface {
RtpState GetRtxRtpState() const; RtpState GetRtxRtpState() const;
protected: protected:
int32_t CheckPayloadType(const int8_t payload_type, int32_t CheckPayloadType(int8_t payload_type, RtpVideoCodecTypes* video_type);
RtpVideoCodecTypes *video_type);
private: private:
// Maps capture time in milliseconds to send-side delay in milliseconds. // Maps capture time in milliseconds to send-side delay in milliseconds.
@ -317,14 +312,14 @@ class RTPSender : public RTPSenderInterface {
void UpdateDelayStatistics(int64_t capture_time_ms, int64_t now_ms); void UpdateDelayStatistics(int64_t capture_time_ms, int64_t now_ms);
void UpdateTransmissionTimeOffset(uint8_t *rtp_packet, void UpdateTransmissionTimeOffset(uint8_t* rtp_packet,
const size_t rtp_packet_length, size_t rtp_packet_length,
const RTPHeader &rtp_header, const RTPHeader& rtp_header,
const int64_t time_diff_ms) const; int64_t time_diff_ms) const;
void UpdateAbsoluteSendTime(uint8_t *rtp_packet, void UpdateAbsoluteSendTime(uint8_t* rtp_packet,
const size_t rtp_packet_length, size_t rtp_packet_length,
const RTPHeader &rtp_header, const RTPHeader& rtp_header,
const int64_t now_ms) const; int64_t now_ms) const;
void UpdateRtpStats(const uint8_t* buffer, void UpdateRtpStats(const uint8_t* buffer,
size_t packet_length, size_t packet_length,

View File

@ -55,10 +55,10 @@ class RtpRtcpAPITest : public ::testing::Test {
}; };
TEST_F(RtpRtcpAPITest, Basic) { TEST_F(RtpRtcpAPITest, Basic) {
EXPECT_EQ(0, module->SetSequenceNumber(test_sequence_number)); module->SetSequenceNumber(test_sequence_number);
EXPECT_EQ(test_sequence_number, module->SequenceNumber()); EXPECT_EQ(test_sequence_number, module->SequenceNumber());
EXPECT_EQ(0, module->SetStartTimestamp(test_timestamp)); module->SetStartTimestamp(test_timestamp);
EXPECT_EQ(test_timestamp, module->StartTimestamp()); EXPECT_EQ(test_timestamp, module->StartTimestamp());
EXPECT_FALSE(module->Sending()); EXPECT_FALSE(module->Sending());
@ -86,15 +86,15 @@ TEST_F(RtpRtcpAPITest, SSRC) {
TEST_F(RtpRtcpAPITest, RTCP) { TEST_F(RtpRtcpAPITest, RTCP) {
EXPECT_EQ(kRtcpOff, module->RTCP()); EXPECT_EQ(kRtcpOff, module->RTCP());
EXPECT_EQ(0, module->SetRTCPStatus(kRtcpCompound)); module->SetRTCPStatus(kRtcpCompound);
EXPECT_EQ(kRtcpCompound, module->RTCP()); EXPECT_EQ(kRtcpCompound, module->RTCP());
EXPECT_EQ(0, module->SetCNAME("john.doe@test.test")); EXPECT_EQ(0, module->SetCNAME("john.doe@test.test"));
EXPECT_FALSE(module->TMMBR()); EXPECT_FALSE(module->TMMBR());
EXPECT_EQ(0, module->SetTMMBRStatus(true)); module->SetTMMBRStatus(true);
EXPECT_TRUE(module->TMMBR()); EXPECT_TRUE(module->TMMBR());
EXPECT_EQ(0, module->SetTMMBRStatus(false)); module->SetTMMBRStatus(false);
EXPECT_FALSE(module->TMMBR()); EXPECT_FALSE(module->TMMBR());
EXPECT_EQ(kNackOff, rtp_receiver_->NACK()); EXPECT_EQ(kNackOff, rtp_receiver_->NACK());

View File

@ -168,7 +168,7 @@ class RtpRtcpAudioTest : public ::testing::Test {
TEST_F(RtpRtcpAudioTest, Basic) { TEST_F(RtpRtcpAudioTest, Basic) {
module1->SetSSRC(test_ssrc); module1->SetSSRC(test_ssrc);
EXPECT_EQ(0, module1->SetStartTimestamp(test_timestamp)); module1->SetStartTimestamp(test_timestamp);
// Test detection at the end of a DTMF tone. // Test detection at the end of a DTMF tone.
//EXPECT_EQ(0, module2->SetTelephoneEventForwardToDecoder(true)); //EXPECT_EQ(0, module2->SetTelephoneEventForwardToDecoder(true));
@ -239,7 +239,7 @@ TEST_F(RtpRtcpAudioTest, RED) {
(voice_codec.rate < 0) ? 0 : voice_codec.rate)); (voice_codec.rate < 0) ? 0 : voice_codec.rate));
module1->SetSSRC(test_ssrc); module1->SetSSRC(test_ssrc);
EXPECT_EQ(0, module1->SetStartTimestamp(test_timestamp)); module1->SetStartTimestamp(test_timestamp);
EXPECT_EQ(0, module1->SetSendingStatus(true)); EXPECT_EQ(0, module1->SetSendingStatus(true));
voice_codec.pltype = 127; voice_codec.pltype = 127;
@ -312,7 +312,7 @@ TEST_F(RtpRtcpAudioTest, DTMF) {
(voice_codec.rate < 0) ? 0 : voice_codec.rate)); (voice_codec.rate < 0) ? 0 : voice_codec.rate));
module1->SetSSRC(test_ssrc); module1->SetSSRC(test_ssrc);
EXPECT_EQ(0, module1->SetStartTimestamp(test_timestamp)); module1->SetStartTimestamp(test_timestamp);
EXPECT_EQ(0, module1->SetSendingStatus(true)); EXPECT_EQ(0, module1->SetSendingStatus(true));
// Prepare for DTMF. // Prepare for DTMF.

View File

@ -126,13 +126,13 @@ class RtpRtcpRtcpTest : public ::testing::Test {
myRTCPFeedback1->SetModule(module1); myRTCPFeedback1->SetModule(module1);
myRTCPFeedback2->SetModule(module2); myRTCPFeedback2->SetModule(module2);
EXPECT_EQ(0, module1->SetRTCPStatus(kRtcpCompound)); module1->SetRTCPStatus(kRtcpCompound);
EXPECT_EQ(0, module2->SetRTCPStatus(kRtcpCompound)); module2->SetRTCPStatus(kRtcpCompound);
module2->SetSSRC(test_ssrc + 1); module2->SetSSRC(test_ssrc + 1);
module1->SetSSRC(test_ssrc); module1->SetSSRC(test_ssrc);
EXPECT_EQ(0, module1->SetSequenceNumber(test_sequence_number)); module1->SetSequenceNumber(test_sequence_number);
EXPECT_EQ(0, module1->SetStartTimestamp(test_timestamp)); module1->SetStartTimestamp(test_timestamp);
module1->SetCsrcs(test_csrcs); module1->SetCsrcs(test_csrcs);
EXPECT_EQ(0, module1->SetCNAME("john.doe@test.test")); EXPECT_EQ(0, module1->SetCNAME("john.doe@test.test"));

View File

@ -50,10 +50,10 @@ class RtpRtcpVideoTest : public ::testing::Test {
rtp_receiver_.reset(RtpReceiver::CreateVideoReceiver( rtp_receiver_.reset(RtpReceiver::CreateVideoReceiver(
test_id_, &fake_clock, receiver_, NULL, &rtp_payload_registry_)); test_id_, &fake_clock, receiver_, NULL, &rtp_payload_registry_));
EXPECT_EQ(0, video_module_->SetRTCPStatus(kRtcpCompound)); video_module_->SetRTCPStatus(kRtcpCompound);
video_module_->SetSSRC(test_ssrc_); video_module_->SetSSRC(test_ssrc_);
rtp_receiver_->SetNACKStatus(kNackRtcp); rtp_receiver_->SetNACKStatus(kNackRtcp);
EXPECT_EQ(0, video_module_->SetStorePacketsStatus(true, 600)); video_module_->SetStorePacketsStatus(true, 600);
EXPECT_EQ(0, video_module_->SetSendingStatus(true)); EXPECT_EQ(0, video_module_->SetSendingStatus(true));
transport_->SetSendModule(video_module_, &rtp_payload_registry_, transport_->SetSendModule(video_module_, &rtp_payload_registry_,

View File

@ -166,9 +166,7 @@ int32_t ViEChannel::Init() {
return -1; return -1;
} }
// RTP/RTCP initialization. // RTP/RTCP initialization.
if (rtp_rtcp_->SetSendingMediaStatus(false) != 0) { rtp_rtcp_->SetSendingMediaStatus(false);
return -1;
}
if (module_process_thread_.RegisterModule(rtp_rtcp_.get()) != 0) { if (module_process_thread_.RegisterModule(rtp_rtcp_.get()) != 0) {
return -1; return -1;
} }
@ -617,7 +615,7 @@ int32_t ViEChannel::SetSignalPacketLossStatus(bool enable,
return 0; return 0;
} }
int32_t ViEChannel::SetRTCPMode(const RTCPMethod rtcp_mode) { void ViEChannel::SetRTCPMode(const RTCPMethod rtcp_mode) {
CriticalSectionScoped cs(rtp_rtcp_cs_.get()); CriticalSectionScoped cs(rtp_rtcp_cs_.get());
for (std::list<RtpRtcp*>::iterator it = simulcast_rtp_rtcp_.begin(); for (std::list<RtpRtcp*>::iterator it = simulcast_rtp_rtcp_.begin();
it != simulcast_rtp_rtcp_.end(); it != simulcast_rtp_rtcp_.end();
@ -625,12 +623,11 @@ int32_t ViEChannel::SetRTCPMode(const RTCPMethod rtcp_mode) {
RtpRtcp* rtp_rtcp = *it; RtpRtcp* rtp_rtcp = *it;
rtp_rtcp->SetRTCPStatus(rtcp_mode); rtp_rtcp->SetRTCPStatus(rtcp_mode);
} }
return rtp_rtcp_->SetRTCPStatus(rtcp_mode); rtp_rtcp_->SetRTCPStatus(rtcp_mode);
} }
int32_t ViEChannel::GetRTCPMode(RTCPMethod* rtcp_mode) { RTCPMethod ViEChannel::GetRTCPMode() const {
*rtcp_mode = rtp_rtcp_->RTCP(); return rtp_rtcp_->RTCP();
return 0;
} }
int32_t ViEChannel::SetNACKStatus(const bool enable) { int32_t ViEChannel::SetNACKStatus(const bool enable) {
@ -751,9 +748,7 @@ int ViEChannel::SetSenderBufferingMode(int target_delay_ms) {
nack_history_size_sender_ = kSendSidePacketHistorySize; nack_history_size_sender_ = kSendSidePacketHistorySize;
} }
} }
if (rtp_rtcp_->SetStorePacketsStatus(true, nack_history_size_sender_) != 0) { rtp_rtcp_->SetStorePacketsStatus(true, nack_history_size_sender_);
return -1;
}
return 0; return 0;
} }
@ -796,10 +791,8 @@ int32_t ViEChannel::SetKeyFrameRequestMethod(
return rtp_rtcp_->SetKeyFrameRequestMethod(method); return rtp_rtcp_->SetKeyFrameRequestMethod(method);
} }
bool ViEChannel::EnableRemb(bool enable) { void ViEChannel::EnableRemb(bool enable) {
if (rtp_rtcp_->SetREMBStatus(enable) != 0) rtp_rtcp_->SetREMBStatus(enable);
return false;
return true;
} }
int ViEChannel::SetSendTimestampOffsetStatus(bool enable, int id) { int ViEChannel::SetSendTimestampOffsetStatus(bool enable, int id) {
@ -882,8 +875,8 @@ void ViEChannel::SetTransmissionSmoothingStatus(bool enable) {
paced_sender_->SetStatus(enable); paced_sender_->SetStatus(enable);
} }
int32_t ViEChannel::EnableTMMBR(const bool enable) { void ViEChannel::EnableTMMBR(bool enable) {
return rtp_rtcp_->SetTMMBRStatus(enable); rtp_rtcp_->SetTMMBRStatus(enable);
} }
int32_t ViEChannel::EnableKeyFrameRequestCallback(const bool enable) { int32_t ViEChannel::EnableKeyFrameRequestCallback(const bool enable) {
@ -994,7 +987,8 @@ int32_t ViEChannel::SetStartSequenceNumber(uint16_t sequence_number) {
if (rtp_rtcp_->Sending()) { if (rtp_rtcp_->Sending()) {
return -1; return -1;
} }
return rtp_rtcp_->SetSequenceNumber(sequence_number); rtp_rtcp_->SetSequenceNumber(sequence_number);
return 0;
} }
void ViEChannel::SetRtpStateForSsrc(uint32_t ssrc, const RtpState& rtp_state) { void ViEChannel::SetRtpStateForSsrc(uint32_t ssrc, const RtpState& rtp_state) {

View File

@ -107,8 +107,8 @@ class ViEChannel
// key frames. // key frames.
int32_t SetSignalPacketLossStatus(bool enable, bool only_key_frames); int32_t SetSignalPacketLossStatus(bool enable, bool only_key_frames);
int32_t SetRTCPMode(const RTCPMethod rtcp_mode); void SetRTCPMode(const RTCPMethod rtcp_mode);
int32_t GetRTCPMode(RTCPMethod* rtcp_mode); RTCPMethod GetRTCPMode() const;
int32_t SetNACKStatus(const bool enable); int32_t SetNACKStatus(const bool enable);
int32_t SetFECStatus(const bool enable, int32_t SetFECStatus(const bool enable,
const unsigned char payload_typeRED, const unsigned char payload_typeRED,
@ -119,7 +119,7 @@ class ViEChannel
int SetSenderBufferingMode(int target_delay_ms); int SetSenderBufferingMode(int target_delay_ms);
int SetReceiverBufferingMode(int target_delay_ms); int SetReceiverBufferingMode(int target_delay_ms);
int32_t SetKeyFrameRequestMethod(const KeyFrameRequestMethod method); int32_t SetKeyFrameRequestMethod(const KeyFrameRequestMethod method);
bool EnableRemb(bool enable); void EnableRemb(bool enable);
int SetSendTimestampOffsetStatus(bool enable, int id); int SetSendTimestampOffsetStatus(bool enable, int id);
int SetReceiveTimestampOffsetStatus(bool enable, int id); int SetReceiveTimestampOffsetStatus(bool enable, int id);
int SetSendAbsoluteSendTimeStatus(bool enable, int id); int SetSendAbsoluteSendTimeStatus(bool enable, int id);
@ -127,7 +127,7 @@ class ViEChannel
bool GetReceiveAbsoluteSendTimeStatus() const; bool GetReceiveAbsoluteSendTimeStatus() const;
void SetRtcpXrRrtrStatus(bool enable); void SetRtcpXrRrtrStatus(bool enable);
void SetTransmissionSmoothingStatus(bool enable); void SetTransmissionSmoothingStatus(bool enable);
int32_t EnableTMMBR(const bool enable); void EnableTMMBR(bool enable);
int32_t EnableKeyFrameRequestCallback(const bool enable); int32_t EnableKeyFrameRequestCallback(const bool enable);
// Sets SSRC for outgoing stream. // Sets SSRC for outgoing stream.

View File

@ -226,16 +226,12 @@ EncoderStateFeedback* ChannelGroup::GetEncoderStateFeedback() {
return encoder_state_feedback_.get(); return encoder_state_feedback_.get();
} }
bool ChannelGroup::SetChannelRembStatus(int channel_id, bool sender, void ChannelGroup::SetChannelRembStatus(int channel_id,
bool receiver, ViEChannel* channel) { bool sender,
bool receiver,
ViEChannel* channel) {
// Update the channel state. // Update the channel state.
if (sender || receiver) { channel->EnableRemb(sender || receiver);
if (!channel->EnableRemb(true)) {
return false;
}
} else {
channel->EnableRemb(false);
}
// Update the REMB instance with necessary RTP modules. // Update the REMB instance with necessary RTP modules.
RtpRtcp* rtp_module = channel->rtp_rtcp(); RtpRtcp* rtp_module = channel->rtp_rtcp();
if (sender) { if (sender) {
@ -248,7 +244,6 @@ bool ChannelGroup::SetChannelRembStatus(int channel_id, bool sender,
} else { } else {
remb_->RemoveReceiveChannel(rtp_module); remb_->RemoveReceiveChannel(rtp_module);
} }
return true;
} }
void ChannelGroup::SetBandwidthEstimationConfig(const webrtc::Config& config) { void ChannelGroup::SetBandwidthEstimationConfig(const webrtc::Config& config) {

View File

@ -40,7 +40,9 @@ class ChannelGroup {
bool HasChannel(int channel_id); bool HasChannel(int channel_id);
bool Empty(); bool Empty();
bool SetChannelRembStatus(int channel_id, bool sender, bool receiver, void SetChannelRembStatus(int channel_id,
bool sender,
bool receiver,
ViEChannel* channel); ViEChannel* channel);
void SetBandwidthEstimationConfig(const webrtc::Config& config); void SetBandwidthEstimationConfig(const webrtc::Config& config);

View File

@ -348,7 +348,8 @@ bool ViEChannelManager::SetRembStatus(int channel_id, bool sender,
ViEChannel* channel = ViEChannelPtr(channel_id); ViEChannel* channel = ViEChannelPtr(channel_id);
assert(channel); assert(channel);
return group->SetChannelRembStatus(channel_id, sender, receiver, channel); group->SetChannelRembStatus(channel_id, sender, receiver, channel);
return true;
} }
bool ViEChannelManager::SetReservedTransmitBitrate( bool ViEChannelManager::SetReservedTransmitBitrate(

View File

@ -292,10 +292,7 @@ int ViERTP_RTCPImpl::SetRTCPStatus(const int video_channel,
} }
RTCPMethod module_mode = ViERTCPModeToRTCPMethod(rtcp_mode); RTCPMethod module_mode = ViERTCPModeToRTCPMethod(rtcp_mode);
if (vie_channel->SetRTCPMode(module_mode) != 0) { vie_channel->SetRTCPMode(module_mode);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
return 0; return 0;
} }
@ -307,11 +304,7 @@ int ViERTP_RTCPImpl::GetRTCPStatus(const int video_channel,
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1; return -1;
} }
RTCPMethod module_mode = kRtcpOff; RTCPMethod module_mode = vie_channel->GetRTCPMode();
if (vie_channel->GetRTCPMode(&module_mode) != 0) {
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
rtcp_mode = RTCPMethodToViERTCPMode(module_mode); rtcp_mode = RTCPMethodToViERTCPMode(module_mode);
return 0; return 0;
} }
@ -370,8 +363,8 @@ int ViERTP_RTCPImpl::SendApplicationDefinedRTCPPacket(
shared_data_->SetLastError(kViERtpRtcpNotSending); shared_data_->SetLastError(kViERtpRtcpNotSending);
return -1; return -1;
} }
RTCPMethod method; RTCPMethod method = vie_channel->GetRTCPMode();
if (vie_channel->GetRTCPMode(&method) != 0 || method == kRtcpOff) { if (method == kRtcpOff) {
shared_data_->SetLastError(kViERtpRtcpRtcpDisabled); shared_data_->SetLastError(kViERtpRtcpRtcpDisabled);
return -1; return -1;
} }
@ -545,10 +538,7 @@ int ViERTP_RTCPImpl::SetTMMBRStatus(const int video_channel,
shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
return -1; return -1;
} }
if (vie_channel->EnableTMMBR(enable) != 0) { vie_channel->EnableTMMBR(enable);
shared_data_->SetLastError(kViERtpRtcpUnknownError);
return -1;
}
return 0; return 0;
} }

View File

@ -957,14 +957,7 @@ Channel::Init()
// be transmitted since the Transport object will then be invalid. // be transmitted since the Transport object will then be invalid.
telephone_event_handler_->SetTelephoneEventForwardToDecoder(true); telephone_event_handler_->SetTelephoneEventForwardToDecoder(true);
// RTCP is enabled by default. // RTCP is enabled by default.
if (_rtpRtcpModule->SetRTCPStatus(kRtcpCompound) == -1) _rtpRtcpModule->SetRTCPStatus(kRtcpCompound);
{
_engineStatisticsPtr->SetLastError(
VE_RTP_RTCP_MODULE_ERROR, kTraceError,
"Channel::Init() RTP/RTCP module not initialized");
return -1;
}
// --- Register all permanent callbacks // --- Register all permanent callbacks
const bool fail = const bool fail =
(audio_coding_->RegisterTransportCallback(this) == -1) || (audio_coding_->RegisterTransportCallback(this) == -1) ||
@ -2908,20 +2901,10 @@ int Channel::SetReceiveAbsoluteSenderTimeStatus(bool enable, unsigned char id) {
return 0; return 0;
} }
int void Channel::SetRTCPStatus(bool enable) {
Channel::SetRTCPStatus(bool enable) WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
{
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId),
"Channel::SetRTCPStatus()"); "Channel::SetRTCPStatus()");
if (_rtpRtcpModule->SetRTCPStatus(enable ? _rtpRtcpModule->SetRTCPStatus(enable ? kRtcpCompound : kRtcpOff);
kRtcpCompound : kRtcpOff) != 0)
{
_engineStatisticsPtr->SetLastError(
VE_RTP_RTCP_MODULE_ERROR, kTraceError,
"SetRTCPStatus() failed to set RTCP status");
return -1;
}
return 0;
} }
int int
@ -3807,46 +3790,27 @@ int Channel::GetPlayoutTimestamp(unsigned int& timestamp) {
return 0; return 0;
} }
int int Channel::SetInitTimestamp(unsigned int timestamp) {
Channel::SetInitTimestamp(unsigned int timestamp) WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
{
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId),
"Channel::SetInitTimestamp()"); "Channel::SetInitTimestamp()");
if (channel_state_.Get().sending) if (channel_state_.Get().sending) {
{ _engineStatisticsPtr->SetLastError(VE_SENDING, kTraceError,
_engineStatisticsPtr->SetLastError( "SetInitTimestamp() already sending");
VE_SENDING, kTraceError, "SetInitTimestamp() already sending");
return -1;
}
if (_rtpRtcpModule->SetStartTimestamp(timestamp) != 0)
{
_engineStatisticsPtr->SetLastError(
VE_RTP_RTCP_MODULE_ERROR, kTraceError,
"SetInitTimestamp() failed to set timestamp");
return -1; return -1;
} }
_rtpRtcpModule->SetStartTimestamp(timestamp);
return 0; return 0;
} }
int int Channel::SetInitSequenceNumber(short sequenceNumber) {
Channel::SetInitSequenceNumber(short sequenceNumber) WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
{
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId),
"Channel::SetInitSequenceNumber()"); "Channel::SetInitSequenceNumber()");
if (channel_state_.Get().sending) if (channel_state_.Get().sending) {
{
_engineStatisticsPtr->SetLastError( _engineStatisticsPtr->SetLastError(
VE_SENDING, kTraceError, VE_SENDING, kTraceError, "SetInitSequenceNumber() already sending");
"SetInitSequenceNumber() already sending");
return -1;
}
if (_rtpRtcpModule->SetSequenceNumber(sequenceNumber) != 0)
{
_engineStatisticsPtr->SetLastError(
VE_RTP_RTCP_MODULE_ERROR, kTraceError,
"SetInitSequenceNumber() failed to set sequence number");
return -1; return -1;
} }
_rtpRtcpModule->SetSequenceNumber(sequenceNumber);
return 0; return 0;
} }

View File

@ -319,7 +319,7 @@ public:
int SetReceiveAudioLevelIndicationStatus(bool enable, unsigned char id); int SetReceiveAudioLevelIndicationStatus(bool enable, unsigned char id);
int SetSendAbsoluteSenderTimeStatus(bool enable, unsigned char id); int SetSendAbsoluteSenderTimeStatus(bool enable, unsigned char id);
int SetReceiveAbsoluteSenderTimeStatus(bool enable, unsigned char id); int SetReceiveAbsoluteSenderTimeStatus(bool enable, unsigned char id);
int SetRTCPStatus(bool enable); void SetRTCPStatus(bool enable);
int GetRTCPStatus(bool& enabled); int GetRTCPStatus(bool& enabled);
int SetRTCP_CNAME(const char cName[256]); int SetRTCP_CNAME(const char cName[256]);
int GetRemoteRTCP_CNAME(char cName[256]); int GetRemoteRTCP_CNAME(char cName[256]);

View File

@ -249,7 +249,8 @@ int VoERTP_RTCPImpl::SetRTCPStatus(int channel, bool enable)
"SetRTCPStatus() failed to locate channel"); "SetRTCPStatus() failed to locate channel");
return -1; return -1;
} }
return channelPtr->SetRTCPStatus(enable); channelPtr->SetRTCPStatus(enable);
return 0;
} }
int VoERTP_RTCPImpl::GetRTCPStatus(int channel, bool& enabled) int VoERTP_RTCPImpl::GetRTCPStatus(int channel, bool& enabled)