Style cleanups in RtpSender.

- Renamed variables and some function to comply with style guide.
- Removed default argument values.
- Removed some dead code.
- Cleaned up comments formatting in rtp_rtcp.h

R=danilchap@webrtc.org, stefan@webrtc.org

Review URL: https://codereview.webrtc.org/2067673004 .

Cr-Commit-Position: refs/heads/master@{#13565}
This commit is contained in:
Sergey Ulanov
2016-07-28 15:19:10 -07:00
parent d762910592
commit ec4f068bcd
16 changed files with 1008 additions and 1267 deletions

View File

@ -144,13 +144,9 @@ size_t GenerateRtpPacket(uint32_t extensions_bitvector,
bool marker_bit = prng->Rand<bool>(); bool marker_bit = prng->Rand<bool>();
uint32_t capture_timestamp = prng->Rand<uint32_t>(); uint32_t capture_timestamp = prng->Rand<uint32_t>();
int64_t capture_time_ms = prng->Rand<uint32_t>(); int64_t capture_time_ms = prng->Rand<uint32_t>();
bool timestamp_provided = prng->Rand<bool>();
bool inc_sequence_number = prng->Rand<bool>();
size_t header_size = rtp_sender.BuildRTPheader(
packet, payload_type, marker_bit, capture_timestamp, capture_time_ms,
timestamp_provided, inc_sequence_number);
size_t header_size = rtp_sender.BuildRtpHeader(
packet, payload_type, marker_bit, capture_timestamp, capture_time_ms);
for (size_t i = header_size; i < packet_size; i++) { for (size_t i = header_size; i < packet_size; i++) {
packet[i] = prng->Rand<uint8_t>(); packet[i] = prng->Rand<uint8_t>();
} }

View File

@ -29,24 +29,24 @@ class RTPPayloadStrategy {
virtual bool CodecsMustBeUnique() const = 0; virtual bool CodecsMustBeUnique() const = 0;
virtual bool PayloadIsCompatible(const RtpUtility::Payload& payload, virtual bool PayloadIsCompatible(const RtpUtility::Payload& payload,
const uint32_t frequency, uint32_t frequency,
const size_t channels, size_t channels,
const uint32_t rate) const = 0; uint32_t rate) const = 0;
virtual void UpdatePayloadRate(RtpUtility::Payload* payload, virtual void UpdatePayloadRate(RtpUtility::Payload* payload,
const uint32_t rate) const = 0; uint32_t rate) const = 0;
virtual RtpUtility::Payload* CreatePayloadType( virtual RtpUtility::Payload* CreatePayloadType(
const char payloadName[RTP_PAYLOAD_NAME_SIZE], const char payload_name[RTP_PAYLOAD_NAME_SIZE],
const int8_t payloadType, int8_t payload_type,
const uint32_t frequency, uint32_t frequency,
const size_t channels, size_t channels,
const uint32_t rate) const = 0; uint32_t rate) const = 0;
virtual int GetPayloadTypeFrequency( virtual int GetPayloadTypeFrequency(
const RtpUtility::Payload& payload) const = 0; const RtpUtility::Payload& payload) const = 0;
static RTPPayloadStrategy* CreateStrategy(const bool handling_audio); static RTPPayloadStrategy* CreateStrategy(bool handling_audio);
protected: protected:
RTPPayloadStrategy() {} RTPPayloadStrategy() {}
@ -58,23 +58,20 @@ class RTPPayloadRegistry {
explicit RTPPayloadRegistry(RTPPayloadStrategy* rtp_payload_strategy); explicit RTPPayloadRegistry(RTPPayloadStrategy* rtp_payload_strategy);
~RTPPayloadRegistry(); ~RTPPayloadRegistry();
int32_t RegisterReceivePayload( int32_t RegisterReceivePayload(const char payload_name[RTP_PAYLOAD_NAME_SIZE],
const char payload_name[RTP_PAYLOAD_NAME_SIZE], int8_t payload_type,
const int8_t payload_type, uint32_t frequency,
const uint32_t frequency, size_t channels,
const size_t channels, uint32_t rate,
const uint32_t rate, bool* created_new_payload_type);
bool* created_new_payload_type);
int32_t DeRegisterReceivePayload( int32_t DeRegisterReceivePayload(int8_t payload_type);
const int8_t payload_type);
int32_t ReceivePayloadType( int32_t ReceivePayloadType(const char payload_name[RTP_PAYLOAD_NAME_SIZE],
const char payload_name[RTP_PAYLOAD_NAME_SIZE], uint32_t frequency,
const uint32_t frequency, size_t channels,
const size_t channels, uint32_t rate,
const uint32_t rate, int8_t* payload_type) const;
int8_t* payload_type) const;
bool RtxEnabled() const; bool RtxEnabled() const;
@ -154,21 +151,21 @@ class RTPPayloadRegistry {
// Prunes the payload type map of the specific payload type, if it exists. // Prunes the payload type map of the specific payload type, if it exists.
void DeregisterAudioCodecOrRedTypeRegardlessOfPayloadType( void DeregisterAudioCodecOrRedTypeRegardlessOfPayloadType(
const char payload_name[RTP_PAYLOAD_NAME_SIZE], const char payload_name[RTP_PAYLOAD_NAME_SIZE],
const size_t payload_name_length, size_t payload_name_length,
const uint32_t frequency, uint32_t frequency,
const size_t channels, size_t channels,
const uint32_t rate); uint32_t rate);
bool IsRtxInternal(const RTPHeader& header) const; bool IsRtxInternal(const RTPHeader& header) const;
rtc::CriticalSection crit_sect_; rtc::CriticalSection crit_sect_;
RtpUtility::PayloadTypeMap payload_type_map_; RtpUtility::PayloadTypeMap payload_type_map_;
std::unique_ptr<RTPPayloadStrategy> rtp_payload_strategy_; std::unique_ptr<RTPPayloadStrategy> rtp_payload_strategy_;
int8_t red_payload_type_; int8_t red_payload_type_;
int8_t ulpfec_payload_type_; int8_t ulpfec_payload_type_;
int8_t incoming_payload_type_; int8_t incoming_payload_type_;
int8_t last_received_payload_type_; int8_t last_received_payload_type_;
int8_t last_received_media_payload_type_; int8_t last_received_media_payload_type_;
bool rtx_; bool rtx_;
// TODO(changbin): Remove rtx_payload_type_ once interop with old clients that // TODO(changbin): Remove rtx_payload_type_ once interop with old clients that
// only understand one RTX PT is no longer needed. // only understand one RTX PT is no longer needed.

File diff suppressed because it is too large Load Diff

View File

@ -189,9 +189,9 @@ class RtpData {
public: public:
virtual ~RtpData() {} virtual ~RtpData() {}
virtual int32_t OnReceivedPayloadData(const uint8_t* payloadData, virtual int32_t OnReceivedPayloadData(const uint8_t* payload_data,
size_t payloadSize, size_t payload_size,
const WebRtcRTPHeader* rtpHeader) = 0; const WebRtcRTPHeader* rtp_header) = 0;
virtual bool OnRecoveredPacket(const uint8_t* packet, virtual bool OnRecoveredPacket(const uint8_t* packet,
size_t packet_length) = 0; size_t packet_length) = 0;
@ -206,15 +206,15 @@ class RtpFeedback {
* channels - number of channels in codec (1 = mono, 2 = stereo) * channels - number of channels in codec (1 = mono, 2 = stereo)
*/ */
virtual int32_t OnInitializeDecoder( virtual int32_t OnInitializeDecoder(
const int8_t payloadType, int8_t payload_type,
const char payloadName[RTP_PAYLOAD_NAME_SIZE], const char payload_name[RTP_PAYLOAD_NAME_SIZE],
const int frequency, int frequency,
const size_t channels, size_t channels,
const uint32_t rate) = 0; uint32_t rate) = 0;
virtual void OnIncomingSSRCChanged(const uint32_t ssrc) = 0; virtual void OnIncomingSSRCChanged(uint32_t ssrc) = 0;
virtual void OnIncomingCSRCChanged(const uint32_t CSRC, const bool added) = 0; virtual void OnIncomingCSRCChanged(uint32_t csrc, bool added) = 0;
}; };
class RtcpIntraFrameObserver { class RtcpIntraFrameObserver {
@ -326,16 +326,16 @@ class NullRtpFeedback : public RtpFeedback {
public: public:
virtual ~NullRtpFeedback() {} virtual ~NullRtpFeedback() {}
int32_t OnInitializeDecoder(const int8_t payloadType, int32_t OnInitializeDecoder(int8_t payload_type,
const char payloadName[RTP_PAYLOAD_NAME_SIZE], const char payloadName[RTP_PAYLOAD_NAME_SIZE],
const int frequency, int frequency,
const size_t channels, size_t channels,
const uint32_t rate) override { uint32_t rate) override {
return 0; return 0;
} }
void OnIncomingSSRCChanged(const uint32_t ssrc) override {} void OnIncomingSSRCChanged(uint32_t ssrc) override {}
void OnIncomingCSRCChanged(const uint32_t CSRC, const bool added) override {} void OnIncomingCSRCChanged(uint32_t csrc, bool added) override {}
}; };
// Null object version of RtpData. // Null object version of RtpData.
@ -343,9 +343,9 @@ class NullRtpData : public RtpData {
public: public:
virtual ~NullRtpData() {} virtual ~NullRtpData() {}
int32_t OnReceivedPayloadData(const uint8_t* payloadData, int32_t OnReceivedPayloadData(const uint8_t* payload_data,
size_t payloadSize, size_t payload_size,
const WebRtcRTPHeader* rtpHeader) override { const WebRtcRTPHeader* rtp_header) override {
return 0; return 0;
} }

View File

@ -27,9 +27,9 @@ namespace webrtc {
class MockRtpData : public RtpData { class MockRtpData : public RtpData {
public: public:
MOCK_METHOD3(OnReceivedPayloadData, MOCK_METHOD3(OnReceivedPayloadData,
int32_t(const uint8_t* payloadData, int32_t(const uint8_t* payload_data,
size_t payloadSize, size_t payload_size,
const WebRtcRTPHeader* rtpHeader)); const WebRtcRTPHeader* rtp_header));
MOCK_METHOD2(OnRecoveredPacket, MOCK_METHOD2(OnRecoveredPacket,
bool(const uint8_t* packet, size_t packet_length)); bool(const uint8_t* packet, size_t packet_length));
@ -37,100 +37,76 @@ class MockRtpData : public RtpData {
class MockRtpRtcp : public RtpRtcp { class MockRtpRtcp : public RtpRtcp {
public: public:
MOCK_METHOD1(RegisterDefaultModule, MOCK_METHOD1(RegisterDefaultModule, int32_t(RtpRtcp* module));
int32_t(RtpRtcp* module)); MOCK_METHOD0(DeRegisterDefaultModule, int32_t());
MOCK_METHOD0(DeRegisterDefaultModule, MOCK_METHOD0(DefaultModuleRegistered, bool());
int32_t()); MOCK_METHOD0(NumberChildModules, uint32_t());
MOCK_METHOD0(DefaultModuleRegistered, MOCK_METHOD1(RegisterSyncModule, int32_t(RtpRtcp* module));
bool()); MOCK_METHOD0(DeRegisterSyncModule, int32_t());
MOCK_METHOD0(NumberChildModules,
uint32_t());
MOCK_METHOD1(RegisterSyncModule,
int32_t(RtpRtcp* module));
MOCK_METHOD0(DeRegisterSyncModule,
int32_t());
MOCK_METHOD2(IncomingRtcpPacket, MOCK_METHOD2(IncomingRtcpPacket,
int32_t(const uint8_t* incomingPacket, size_t packetLength)); int32_t(const uint8_t* incoming_packet, size_t packet_length));
MOCK_METHOD1(SetRemoteSSRC, void(const uint32_t ssrc)); MOCK_METHOD1(SetRemoteSSRC, void(uint32_t ssrc));
MOCK_METHOD4(IncomingAudioNTP, MOCK_METHOD4(IncomingAudioNTP,
int32_t(const uint32_t audioReceivedNTPsecs, int32_t(uint32_t audio_received_ntp_secs,
const uint32_t audioReceivedNTPfrac, uint32_t audio_received_ntp_frac,
const uint32_t audioRTCPArrivalTimeSecs, uint32_t audio_rtcp_arrival_time_secs,
const uint32_t audioRTCPArrivalTimeFrac)); uint32_t audio_rtcp_arrival_time_frac));
MOCK_METHOD0(InitSender, MOCK_METHOD0(InitSender, int32_t());
int32_t()); MOCK_METHOD1(RegisterSendTransport, int32_t(Transport* outgoing_transport));
MOCK_METHOD1(RegisterSendTransport, MOCK_METHOD1(SetMaxTransferUnit, int32_t(uint16_t size));
int32_t(Transport* outgoingTransport));
MOCK_METHOD1(SetMaxTransferUnit,
int32_t(const uint16_t size));
MOCK_METHOD3(SetTransportOverhead, MOCK_METHOD3(SetTransportOverhead,
int32_t(const bool TCP, const bool IPV6, int32_t(bool tcp, bool ipv6, uint8_t authentication_overhead));
const uint8_t authenticationOverhead)); MOCK_CONST_METHOD0(MaxPayloadLength, uint16_t());
MOCK_CONST_METHOD0(MaxPayloadLength, MOCK_CONST_METHOD0(MaxDataPayloadLength, uint16_t());
uint16_t()); MOCK_METHOD1(RegisterSendPayload, int32_t(const CodecInst& voice_codec));
MOCK_CONST_METHOD0(MaxDataPayloadLength, MOCK_METHOD1(RegisterSendPayload, int32_t(const VideoCodec& video_codec));
uint16_t());
MOCK_METHOD1(RegisterSendPayload,
int32_t(const CodecInst& voiceCodec));
MOCK_METHOD1(RegisterSendPayload,
int32_t(const VideoCodec& videoCodec));
MOCK_METHOD2(RegisterVideoSendPayload, MOCK_METHOD2(RegisterVideoSendPayload,
void(int payload_type, const char* payload_name)); void(int payload_type, const char* payload_name));
MOCK_METHOD1(DeRegisterSendPayload, MOCK_METHOD1(DeRegisterSendPayload, int32_t(int8_t payload_type));
int32_t(const int8_t payloadType));
MOCK_METHOD2(RegisterSendRtpHeaderExtension, MOCK_METHOD2(RegisterSendRtpHeaderExtension,
int32_t(const RTPExtensionType type, const uint8_t id)); int32_t(RTPExtensionType type, uint8_t id));
MOCK_METHOD1(DeregisterSendRtpHeaderExtension, MOCK_METHOD1(DeregisterSendRtpHeaderExtension,
int32_t(const RTPExtensionType type)); int32_t(RTPExtensionType type));
MOCK_CONST_METHOD0(StartTimestamp, MOCK_CONST_METHOD0(StartTimestamp, uint32_t());
uint32_t()); MOCK_METHOD1(SetStartTimestamp, void(uint32_t timestamp));
MOCK_METHOD1(SetStartTimestamp, void(const uint32_t timestamp));
MOCK_CONST_METHOD0(SequenceNumber, uint16_t()); MOCK_CONST_METHOD0(SequenceNumber, uint16_t());
MOCK_METHOD1(SetSequenceNumber, void(const uint16_t seq)); MOCK_METHOD1(SetSequenceNumber, void(uint16_t seq));
MOCK_METHOD1(SetRtpState, void(const RtpState& rtp_state)); MOCK_METHOD1(SetRtpState, void(const RtpState& rtp_state));
MOCK_METHOD1(SetRtxState, void(const RtpState& rtp_state)); MOCK_METHOD1(SetRtxState, void(const RtpState& rtp_state));
MOCK_CONST_METHOD0(GetRtpState, RtpState()); MOCK_CONST_METHOD0(GetRtpState, RtpState());
MOCK_CONST_METHOD0(GetRtxState, RtpState()); MOCK_CONST_METHOD0(GetRtxState, RtpState());
MOCK_CONST_METHOD0(SSRC, MOCK_CONST_METHOD0(SSRC, uint32_t());
uint32_t()); MOCK_METHOD1(SetSSRC, void(uint32_t ssrc));
MOCK_METHOD1(SetSSRC, MOCK_CONST_METHOD1(CSRCs, int32_t(uint32_t csrcs[kRtpCsrcSize]));
void(const uint32_t ssrc));
MOCK_CONST_METHOD1(CSRCs,
int32_t(uint32_t arrOfCSRC[kRtpCsrcSize]));
MOCK_METHOD1(SetCsrcs, void(const std::vector<uint32_t>& csrcs)); MOCK_METHOD1(SetCsrcs, void(const std::vector<uint32_t>& csrcs));
MOCK_METHOD1(SetCSRCStatus, MOCK_METHOD1(SetCSRCStatus, int32_t(bool include));
int32_t(const bool include));
MOCK_METHOD1(SetRtxSendStatus, void(int modes)); MOCK_METHOD1(SetRtxSendStatus, void(int modes));
MOCK_CONST_METHOD0(RtxSendStatus, int()); MOCK_CONST_METHOD0(RtxSendStatus, int());
MOCK_METHOD1(SetRtxSsrc, MOCK_METHOD1(SetRtxSsrc, void(uint32_t));
void(uint32_t));
MOCK_METHOD2(SetRtxSendPayloadType, void(int, int)); MOCK_METHOD2(SetRtxSendPayloadType, void(int, int));
MOCK_CONST_METHOD0(RtxSendPayloadType, std::pair<int, int>()); MOCK_CONST_METHOD0(RtxSendPayloadType, std::pair<int, int>());
MOCK_METHOD1(SetSendingStatus, MOCK_METHOD1(SetSendingStatus, int32_t(bool sending));
int32_t(const bool sending)); MOCK_CONST_METHOD0(Sending, bool());
MOCK_CONST_METHOD0(Sending, MOCK_METHOD1(SetSendingMediaStatus, void(bool sending));
bool()); MOCK_CONST_METHOD0(SendingMedia, bool());
MOCK_METHOD1(SetSendingMediaStatus, void(const bool sending));
MOCK_CONST_METHOD0(SendingMedia,
bool());
MOCK_CONST_METHOD4(BitrateSent, MOCK_CONST_METHOD4(BitrateSent,
void(uint32_t* totalRate, void(uint32_t* total_rate,
uint32_t* videoRate, uint32_t* video_rate,
uint32_t* fecRate, uint32_t* fec_rate,
uint32_t* nackRate)); uint32_t* nack_rate));
MOCK_METHOD1(RegisterVideoBitrateObserver, void(BitrateStatisticsObserver*)); MOCK_METHOD1(RegisterVideoBitrateObserver, void(BitrateStatisticsObserver*));
MOCK_CONST_METHOD0(GetVideoBitrateObserver, BitrateStatisticsObserver*(void)); MOCK_CONST_METHOD0(GetVideoBitrateObserver, BitrateStatisticsObserver*(void));
MOCK_CONST_METHOD1(EstimatedReceiveBandwidth, MOCK_CONST_METHOD1(EstimatedReceiveBandwidth,
int(uint32_t* available_bandwidth)); int(uint32_t* available_bandwidth));
MOCK_METHOD8(SendOutgoingData, MOCK_METHOD8(SendOutgoingData,
int32_t(const FrameType frameType, int32_t(FrameType frame_type,
const int8_t payloadType, int8_t payload_type,
const uint32_t timeStamp, uint32_t timestamp,
int64_t capture_time_ms, int64_t capture_time_ms,
const uint8_t* payloadData, const uint8_t* payload_data,
const size_t payloadSize, size_t payload_size,
const RTPFragmentationHeader* fragmentation, const RTPFragmentationHeader* fragmentation,
const RTPVideoHeader* rtpVideoHdr)); const RTPVideoHeader* rtp_video_header));
MOCK_METHOD5(TimeToSendPacket, MOCK_METHOD5(TimeToSendPacket,
bool(uint32_t ssrc, bool(uint32_t ssrc,
uint16_t sequence_number, uint16_t sequence_number,
@ -139,123 +115,98 @@ class MockRtpRtcp : public RtpRtcp {
int probe_cluster_id)); int probe_cluster_id));
MOCK_METHOD2(TimeToSendPadding, size_t(size_t bytes, int probe_cluster_id)); MOCK_METHOD2(TimeToSendPadding, size_t(size_t bytes, int probe_cluster_id));
MOCK_METHOD2(RegisterRtcpObservers, MOCK_METHOD2(RegisterRtcpObservers,
void(RtcpIntraFrameObserver* intraFrameCallback, void(RtcpIntraFrameObserver* intra_frame_callback,
RtcpBandwidthObserver* bandwidthCallback)); RtcpBandwidthObserver* bandwidth_callback));
MOCK_CONST_METHOD0(RTCP, RtcpMode()); MOCK_CONST_METHOD0(RTCP, RtcpMode());
MOCK_METHOD1(SetRTCPStatus, void(const RtcpMode method)); MOCK_METHOD1(SetRTCPStatus, void(RtcpMode 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,
int32_t(const uint32_t remoteSSRC, int32_t(uint32_t remote_ssrc,
char cName[RTCP_CNAME_SIZE])); char cname[RTCP_CNAME_SIZE]));
MOCK_CONST_METHOD5(RemoteNTP, MOCK_CONST_METHOD5(RemoteNTP,
int32_t(uint32_t *ReceivedNTPsecs, int32_t(uint32_t* received_ntp_secs,
uint32_t *ReceivedNTPfrac, uint32_t* received_ntp_frac,
uint32_t *RTCPArrivalTimeSecs, uint32_t* rtcp_arrival_time_secs,
uint32_t *RTCPArrivalTimeFrac, uint32_t* rtcp_arrival_time_frac,
uint32_t *rtcp_timestamp)); uint32_t* rtcp_timestamp));
MOCK_METHOD2(AddMixedCNAME, MOCK_METHOD2(AddMixedCNAME,
int32_t(const uint32_t SSRC, int32_t(uint32_t ssrc, const char cname[RTCP_CNAME_SIZE]));
const char cName[RTCP_CNAME_SIZE])); MOCK_METHOD1(RemoveMixedCNAME, int32_t(uint32_t ssrc));
MOCK_METHOD1(RemoveMixedCNAME,
int32_t(const uint32_t SSRC));
MOCK_CONST_METHOD5(RTT, MOCK_CONST_METHOD5(RTT,
int32_t(const uint32_t remoteSSRC, int32_t(uint32_t remote_ssrc,
int64_t* RTT, int64_t* rtt,
int64_t* avgRTT, int64_t* avg_rtt,
int64_t* minRTT, int64_t* min_rtt,
int64_t* maxRTT)); int64_t* max_rtt));
MOCK_METHOD1(SendRTCP, int32_t(RTCPPacketType packetType)); MOCK_METHOD1(SendRTCP, int32_t(RTCPPacketType packet_type));
MOCK_METHOD1(SendCompoundRTCP, MOCK_METHOD1(SendCompoundRTCP,
int32_t(const std::set<RTCPPacketType>& packetTypes)); int32_t(const std::set<RTCPPacketType>& packet_types));
MOCK_METHOD1(SendRTCPReferencePictureSelection, int32_t(uint64_t pictureID)); MOCK_METHOD1(SendRTCPReferencePictureSelection, int32_t(uint64_t picture_id));
MOCK_METHOD1(SendRTCPSliceLossIndication, MOCK_METHOD1(SendRTCPSliceLossIndication, int32_t(uint8_t picture_id));
int32_t(const uint8_t pictureID));
MOCK_CONST_METHOD2(DataCountersRTP, MOCK_CONST_METHOD2(DataCountersRTP,
int32_t(size_t *bytesSent, uint32_t *packetsSent)); int32_t(size_t* bytes_sent, uint32_t* packets_sent));
MOCK_CONST_METHOD2(GetSendStreamDataCounters, MOCK_CONST_METHOD2(GetSendStreamDataCounters,
void(StreamDataCounters*, StreamDataCounters*)); void(StreamDataCounters*, StreamDataCounters*));
MOCK_CONST_METHOD3(GetRtpPacketLossStats, MOCK_CONST_METHOD3(GetRtpPacketLossStats,
void(bool, uint32_t, struct RtpPacketLossStats*)); void(bool, uint32_t, struct RtpPacketLossStats*));
MOCK_METHOD1(RemoteRTCPStat, MOCK_METHOD1(RemoteRTCPStat, int32_t(RTCPSenderInfo* sender_info));
int32_t(RTCPSenderInfo* senderInfo));
MOCK_CONST_METHOD1(RemoteRTCPStat, MOCK_CONST_METHOD1(RemoteRTCPStat,
int32_t(std::vector<RTCPReportBlock>* receiveBlocks)); int32_t(std::vector<RTCPReportBlock>* receive_blocks));
MOCK_METHOD4(SetRTCPApplicationSpecificData, MOCK_METHOD4(SetRTCPApplicationSpecificData,
int32_t(const uint8_t subType, int32_t(uint8_t sub_type,
const uint32_t name, uint32_t name,
const uint8_t* data, const uint8_t* data,
const uint16_t length)); uint16_t length));
MOCK_METHOD1(SetRTCPVoIPMetrics, MOCK_METHOD1(SetRTCPVoIPMetrics, int32_t(const RTCPVoIPMetric* voip_metric));
int32_t(const RTCPVoIPMetric* VoIPMetric)); MOCK_METHOD1(SetRtcpXrRrtrStatus, void(bool enable));
MOCK_METHOD1(SetRtcpXrRrtrStatus, MOCK_CONST_METHOD0(RtcpXrRrtrStatus, bool());
void(bool enable)); MOCK_CONST_METHOD0(REMB, bool());
MOCK_CONST_METHOD0(RtcpXrRrtrStatus, MOCK_METHOD1(SetREMBStatus, void(bool enable));
bool());
MOCK_CONST_METHOD0(REMB,
bool());
MOCK_METHOD1(SetREMBStatus, void(const bool enable));
MOCK_METHOD2(SetREMBData, MOCK_METHOD2(SetREMBData,
void(const uint32_t bitrate, void(uint32_t bitrate, const std::vector<uint32_t>& ssrcs));
const std::vector<uint32_t>& ssrcs)); MOCK_CONST_METHOD0(TMMBR, bool());
MOCK_CONST_METHOD0(TMMBR, MOCK_METHOD1(SetTMMBRStatus, void(bool enable));
bool()); MOCK_METHOD1(OnBandwidthEstimateUpdate, void(uint16_t bandwidth_kbit));
MOCK_METHOD1(SetTMMBRStatus, void(const bool enable)); MOCK_CONST_METHOD0(SelectiveRetransmissions, int());
MOCK_METHOD1(OnBandwidthEstimateUpdate, MOCK_METHOD1(SetSelectiveRetransmissions, int(uint8_t settings));
void(uint16_t bandWidthKbit)); MOCK_METHOD2(SendNACK, int32_t(const uint16_t* nack_list, uint16_t size));
MOCK_CONST_METHOD0(SelectiveRetransmissions,
int());
MOCK_METHOD1(SetSelectiveRetransmissions,
int(uint8_t settings));
MOCK_METHOD2(SendNACK,
int32_t(const uint16_t* nackList, const uint16_t size));
MOCK_METHOD1(SendNack, void(const std::vector<uint16_t>& sequence_numbers)); MOCK_METHOD1(SendNack, void(const std::vector<uint16_t>& sequence_numbers));
MOCK_METHOD2(SetStorePacketsStatus, MOCK_METHOD2(SetStorePacketsStatus,
void(const bool enable, const uint16_t numberToStore)); void(bool enable, uint16_t number_to_store));
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*());
MOCK_METHOD1(SendFeedbackPacket, bool(const rtcp::TransportFeedback& packet)); MOCK_METHOD1(SendFeedbackPacket, bool(const rtcp::TransportFeedback& packet));
MOCK_METHOD1(SetAudioPacketSize, MOCK_METHOD1(SetAudioPacketSize, int32_t(uint16_t packet_size_samples));
int32_t(const uint16_t packetSizeSamples));
MOCK_METHOD3(SendTelephoneEventOutband, MOCK_METHOD3(SendTelephoneEventOutband,
int32_t(const uint8_t key, const uint16_t time_ms, const uint8_t level)); int32_t(uint8_t key, uint16_t time_ms, uint8_t level));
MOCK_METHOD1(SetSendREDPayloadType, MOCK_METHOD1(SetSendREDPayloadType, int32_t(int8_t payload_type));
int32_t(const int8_t payloadType)); MOCK_CONST_METHOD1(SendREDPayloadType, int32_t(int8_t* payload_type));
MOCK_CONST_METHOD1(SendREDPayloadType, int32_t(int8_t* payloadType));
MOCK_METHOD2(SetRTPAudioLevelIndicationStatus, MOCK_METHOD2(SetRTPAudioLevelIndicationStatus,
int32_t(const bool enable, const uint8_t ID)); int32_t(bool enable, uint8_t id));
MOCK_METHOD1(SetAudioLevel, MOCK_METHOD1(SetAudioLevel, int32_t(uint8_t level_dbov));
int32_t(const uint8_t level_dBov)); MOCK_METHOD1(SetTargetSendBitrate, void(uint32_t bitrate_bps));
MOCK_METHOD1(SetTargetSendBitrate,
void(uint32_t bitrate_bps));
MOCK_METHOD3(SetGenericFECStatus, MOCK_METHOD3(SetGenericFECStatus,
void(const bool enable, void(bool enable,
const uint8_t payload_type_red, uint8_t payload_type_red,
const uint8_t payload_type_fec)); uint8_t payload_type_fec));
MOCK_METHOD3(GenericFECStatus, MOCK_METHOD3(GenericFECStatus,
void(bool* enable, void(bool* enable,
uint8_t* payloadTypeRED, uint8_t* payload_type_red,
uint8_t* payloadTypeFEC)); uint8_t* payload_type_fec));
MOCK_METHOD2(SetFecParameters, MOCK_METHOD2(SetFecParameters,
int32_t(const FecProtectionParams* delta_params, int32_t(const FecProtectionParams* delta_params,
const FecProtectionParams* key_params)); const FecProtectionParams* key_params));
MOCK_METHOD1(SetKeyFrameRequestMethod, MOCK_METHOD1(SetKeyFrameRequestMethod, int32_t(KeyFrameRequestMethod method));
int32_t(const KeyFrameRequestMethod method)); MOCK_METHOD0(RequestKeyFrame, int32_t());
MOCK_METHOD0(RequestKeyFrame, MOCK_METHOD0(TimeUntilNextProcess, int64_t());
int32_t()); MOCK_METHOD0(Process, void());
MOCK_METHOD0(TimeUntilNextProcess, MOCK_METHOD1(RegisterSendFrameCountObserver, void(FrameCountObserver*));
int64_t()); MOCK_CONST_METHOD0(GetSendFrameCountObserver, FrameCountObserver*(void));
MOCK_METHOD0(Process,
void());
MOCK_METHOD1(RegisterSendFrameCountObserver,
void(FrameCountObserver*));
MOCK_CONST_METHOD0(GetSendFrameCountObserver,
FrameCountObserver*(void));
MOCK_METHOD1(RegisterSendChannelRtpStatisticsCallback, MOCK_METHOD1(RegisterSendChannelRtpStatisticsCallback,
void(StreamDataCountersCallback*)); void(StreamDataCountersCallback*));
MOCK_CONST_METHOD0(GetSendChannelRtpStatisticsCallback, MOCK_CONST_METHOD0(GetSendChannelRtpStatisticsCallback,
StreamDataCountersCallback*(void)); StreamDataCountersCallback*(void));
// Members. // Members.
unsigned int remote_ssrc_; unsigned int remote_ssrc_;
}; };

View File

@ -22,20 +22,20 @@ class MockRTPPayloadStrategy : public RTPPayloadStrategy {
bool()); bool());
MOCK_CONST_METHOD4(PayloadIsCompatible, MOCK_CONST_METHOD4(PayloadIsCompatible,
bool(const RtpUtility::Payload& payload, bool(const RtpUtility::Payload& payload,
const uint32_t frequency, uint32_t frequency,
const size_t channels, size_t channels,
const uint32_t rate)); uint32_t rate));
MOCK_CONST_METHOD2(UpdatePayloadRate, MOCK_CONST_METHOD2(UpdatePayloadRate,
void(RtpUtility::Payload* payload, const uint32_t rate)); void(RtpUtility::Payload* payload, uint32_t rate));
MOCK_CONST_METHOD1(GetPayloadTypeFrequency, MOCK_CONST_METHOD1(GetPayloadTypeFrequency,
int(const RtpUtility::Payload& payload)); int(const RtpUtility::Payload& payload));
MOCK_CONST_METHOD5( MOCK_CONST_METHOD5(
CreatePayloadType, CreatePayloadType,
RtpUtility::Payload*(const char payloadName[RTP_PAYLOAD_NAME_SIZE], RtpUtility::Payload*(const char payload_name[RTP_PAYLOAD_NAME_SIZE],
const int8_t payloadType, int8_t payload_type,
const uint32_t frequency, uint32_t frequency,
const size_t channels, size_t channels,
const uint32_t rate)); uint32_t rate));
}; };
} // namespace webrtc } // namespace webrtc

View File

@ -46,25 +46,7 @@ RTPExtensionType StringToRtpExtensionType(const std::string& extension) {
} }
RtpRtcp::Configuration::Configuration() RtpRtcp::Configuration::Configuration()
: audio(false), : receive_statistics(NullObjectReceiveStatistics()) {}
receiver_only(false),
clock(nullptr),
receive_statistics(NullObjectReceiveStatistics()),
outgoing_transport(nullptr),
intra_frame_callback(nullptr),
bandwidth_callback(nullptr),
transport_feedback_callback(nullptr),
rtt_stats(nullptr),
rtcp_packet_type_counter_observer(nullptr),
remote_bitrate_estimator(nullptr),
paced_sender(nullptr),
transport_sequence_number_allocator(nullptr),
send_bitrate_observer(nullptr),
send_frame_count_observer(nullptr),
send_side_delay_observer(nullptr),
event_log(nullptr),
send_packet_observer(nullptr),
retransmission_rate_limiter(nullptr) {}
RtpRtcp* RtpRtcp::CreateRtpRtcp(const RtpRtcp::Configuration& configuration) { RtpRtcp* RtpRtcp::CreateRtpRtcp(const RtpRtcp::Configuration& configuration) {
if (configuration.clock) { if (configuration.clock) {
@ -245,8 +227,8 @@ int32_t ModuleRtpRtcpImpl::IncomingRtcpPacket(
return -1; return -1;
} }
RTCPHelp::RTCPPacketInformation rtcp_packet_information; RTCPHelp::RTCPPacketInformation rtcp_packet_information;
int32_t ret_val = rtcp_receiver_.IncomingRTCPPacket( int32_t ret_val =
rtcp_packet_information, &rtcp_parser); rtcp_receiver_.IncomingRTCPPacket(rtcp_packet_information, &rtcp_parser);
if (ret_val == 0) { if (ret_val == 0) {
rtcp_receiver_.TriggerCallbacksFromRTCPPacket(rtcp_packet_information); rtcp_receiver_.TriggerCallbacksFromRTCPPacket(rtcp_packet_information);
} }
@ -256,11 +238,8 @@ int32_t ModuleRtpRtcpImpl::IncomingRtcpPacket(
int32_t ModuleRtpRtcpImpl::RegisterSendPayload( int32_t ModuleRtpRtcpImpl::RegisterSendPayload(
const CodecInst& voice_codec) { const CodecInst& voice_codec) {
return rtp_sender_.RegisterPayload( return rtp_sender_.RegisterPayload(
voice_codec.plname, voice_codec.plname, voice_codec.pltype, voice_codec.plfreq,
voice_codec.pltype, voice_codec.channels, (voice_codec.rate < 0) ? 0 : voice_codec.rate);
voice_codec.plfreq,
voice_codec.channels,
(voice_codec.rate < 0) ? 0 : voice_codec.rate);
} }
int32_t ModuleRtpRtcpImpl::RegisterSendPayload(const VideoCodec& video_codec) { int32_t ModuleRtpRtcpImpl::RegisterSendPayload(const VideoCodec& video_codec) {
@ -413,7 +392,7 @@ int32_t ModuleRtpRtcpImpl::SendOutgoingData(
const uint8_t* payload_data, const uint8_t* payload_data,
size_t payload_size, size_t payload_size,
const RTPFragmentationHeader* fragmentation, const RTPFragmentationHeader* fragmentation,
const RTPVideoHeader* rtp_video_hdr) { const RTPVideoHeader* rtp_video_header) {
rtcp_sender_.SetLastRtpTime(time_stamp, capture_time_ms); rtcp_sender_.SetLastRtpTime(time_stamp, capture_time_ms);
// Make sure an RTCP report isn't queued behind a key frame. // Make sure an RTCP report isn't queued behind a key frame.
if (rtcp_sender_.TimeToSendRTCPReport(kVideoFrameKey == frame_type)) { if (rtcp_sender_.TimeToSendRTCPReport(kVideoFrameKey == frame_type)) {
@ -421,7 +400,7 @@ int32_t ModuleRtpRtcpImpl::SendOutgoingData(
} }
return rtp_sender_.SendOutgoingData( return rtp_sender_.SendOutgoingData(
frame_type, payload_type, time_stamp, capture_time_ms, payload_data, frame_type, payload_type, time_stamp, capture_time_ms, payload_data,
payload_size, fragmentation, rtp_video_hdr); payload_size, fragmentation, rtp_video_header);
} }
bool ModuleRtpRtcpImpl::TimeToSendPacket(uint32_t ssrc, bool ModuleRtpRtcpImpl::TimeToSendPacket(uint32_t ssrc,

View File

@ -112,14 +112,15 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
// 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.
int32_t SendOutgoingData(FrameType frame_type, int32_t SendOutgoingData(
int8_t payload_type, FrameType frame_type,
uint32_t time_stamp, int8_t payload_type,
int64_t capture_time_ms, uint32_t time_stamp,
const uint8_t* payload_data, int64_t capture_time_ms,
size_t payload_size, const uint8_t* payload_data,
const RTPFragmentationHeader* fragmentation = NULL, size_t payload_size,
const RTPVideoHeader* rtp_video_hdr = NULL) override; const RTPFragmentationHeader* fragmentation = NULL,
const RTPVideoHeader* rtp_video_header = NULL) override;
bool TimeToSendPacket(uint32_t ssrc, bool TimeToSendPacket(uint32_t ssrc,
uint16_t sequence_number, uint16_t sequence_number,

View File

@ -1128,7 +1128,7 @@ size_t RTPSender::CreateRtpHeader(uint8_t* header,
} }
uint16_t len = uint16_t len =
BuildRTPHeaderExtension(header + rtp_header_length, marker_bit); BuildRtpHeaderExtension(header + rtp_header_length, marker_bit);
if (len > 0) { if (len > 0) {
header[0] |= 0x10; // Set extension bit. header[0] |= 0x10; // Set extension bit.
rtp_header_length += len; rtp_header_length += len;
@ -1143,17 +1143,19 @@ int32_t RTPSender::BuildRTPheader(uint8_t* data_buffer,
int64_t capture_time_ms, int64_t capture_time_ms,
bool timestamp_provided, bool timestamp_provided,
bool inc_sequence_number) { bool inc_sequence_number) {
return BuildRtpHeader(data_buffer, payload_type, marker_bit,
capture_timestamp, capture_time_ms);
}
int32_t RTPSender::BuildRtpHeader(uint8_t* data_buffer,
int8_t payload_type,
bool marker_bit,
uint32_t capture_timestamp,
int64_t capture_time_ms) {
assert(payload_type >= 0); assert(payload_type >= 0);
rtc::CritScope lock(&send_critsect_); rtc::CritScope lock(&send_critsect_);
if (timestamp_provided) { timestamp_ = start_timestamp_ + capture_timestamp;
timestamp_ = start_timestamp_ + capture_timestamp;
} else {
// Make a unique time stamp.
// We can't inc by the actual time, since then we increase the risk of back
// timing.
timestamp_++;
}
last_timestamp_time_ms_ = clock_->TimeInMilliseconds(); last_timestamp_time_ms_ = clock_->TimeInMilliseconds();
uint32_t sequence_number = sequence_number_++; uint32_t sequence_number = sequence_number_++;
capture_time_ms_ = capture_time_ms; capture_time_ms_ = capture_time_ms;
@ -1162,7 +1164,7 @@ int32_t RTPSender::BuildRTPheader(uint8_t* data_buffer,
timestamp_, sequence_number, csrcs_); timestamp_, sequence_number, csrcs_);
} }
uint16_t RTPSender::BuildRTPHeaderExtension(uint8_t* data_buffer, uint16_t RTPSender::BuildRtpHeaderExtension(uint8_t* data_buffer,
bool marker_bit) const { bool marker_bit) const {
if (rtp_header_extension_map_.Size() <= 0) { if (rtp_header_extension_map_.Size() <= 0) {
return 0; return 0;
@ -1775,8 +1777,8 @@ void RTPSender::SetGenericFECStatus(bool enable,
} }
void RTPSender::GenericFECStatus(bool* enable, void RTPSender::GenericFECStatus(bool* enable,
uint8_t* payload_type_red, uint8_t* payload_type_red,
uint8_t* payload_type_fec) const { uint8_t* payload_type_fec) const {
RTC_DCHECK(!audio_configured_); RTC_DCHECK(!audio_configured_);
video_->GenericFECStatus(enable, payload_type_red, payload_type_fec); video_->GenericFECStatus(enable, payload_type_red, payload_type_fec);
} }

View File

@ -47,6 +47,9 @@ class RTPSenderInterface {
virtual uint32_t SSRC() const = 0; virtual uint32_t SSRC() const = 0;
virtual uint32_t Timestamp() const = 0; virtual uint32_t Timestamp() const = 0;
// Deprecated version of BuildRtpHeader(). |timestamp_provided| and
// |inc_sequence_number| are ignored.
// TODO(sergeyu): Remove this method.
virtual int32_t BuildRTPheader(uint8_t* data_buffer, virtual int32_t BuildRTPheader(uint8_t* data_buffer,
int8_t payload_type, int8_t payload_type,
bool marker_bit, bool marker_bit,
@ -55,6 +58,12 @@ class RTPSenderInterface {
bool timestamp_provided = true, bool timestamp_provided = true,
bool inc_sequence_number = true) = 0; bool inc_sequence_number = true) = 0;
virtual int32_t BuildRtpHeader(uint8_t* data_buffer,
int8_t payload_type,
bool marker_bit,
uint32_t capture_timestamp,
int64_t capture_time_ms) = 0;
// This returns the expected header length taking into consideration // This returns the expected header length taking into consideration
// the optional RTP header extensions that may not be currently active. // the optional RTP header extensions that may not be currently active.
virtual size_t RtpHeaderLength() const = 0; virtual size_t RtpHeaderLength() const = 0;
@ -152,7 +161,7 @@ class RTPSender : public RTPSenderInterface {
const uint8_t* payload_data, const uint8_t* payload_data,
size_t payload_size, size_t payload_size,
const RTPFragmentationHeader* fragmentation, const RTPFragmentationHeader* fragmentation,
const RTPVideoHeader* rtp_hdr = NULL); const RTPVideoHeader* rtp_header);
// RTP header extension // RTP header extension
int32_t SetTransmissionTimeOffset(int32_t transmission_time_offset); int32_t SetTransmissionTimeOffset(int32_t transmission_time_offset);
@ -166,7 +175,7 @@ class RTPSender : public RTPSenderInterface {
size_t RtpHeaderExtensionLength() const; size_t RtpHeaderExtensionLength() const;
uint16_t BuildRTPHeaderExtension(uint8_t* data_buffer, bool marker_bit) const uint16_t BuildRtpHeaderExtension(uint8_t* data_buffer, bool marker_bit) const
EXCLUSIVE_LOCKS_REQUIRED(send_critsect_); EXCLUSIVE_LOCKS_REQUIRED(send_critsect_);
uint8_t BuildTransmissionTimeOffsetExtension(uint8_t* data_buffer) const uint8_t BuildTransmissionTimeOffsetExtension(uint8_t* data_buffer) const
@ -251,8 +260,13 @@ class RTPSender : public RTPSenderInterface {
bool marker_bit, bool marker_bit,
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) override; bool inc_sequence_number = true) override;
int32_t BuildRtpHeader(uint8_t* data_buffer,
int8_t payload_type,
bool marker_bit,
uint32_t capture_timestamp,
int64_t capture_time_ms) override;
size_t RtpHeaderLength() const override; size_t RtpHeaderLength() const override;
uint16_t AllocateSequenceNumber(uint16_t packets_to_send) override; uint16_t AllocateSequenceNumber(uint16_t packets_to_send) override;
@ -308,7 +322,6 @@ class RTPSender : public RTPSenderInterface {
bool timestamp_provided, bool timestamp_provided,
uint32_t timestamp, uint32_t timestamp,
int64_t capture_time_ms); int64_t capture_time_ms);
size_t SendPadData(size_t bytes, size_t SendPadData(size_t bytes,
bool timestamp_provided, bool timestamp_provided,
uint32_t timestamp, uint32_t timestamp,

View File

@ -22,27 +22,27 @@ namespace webrtc {
static const int kDtmfFrequencyHz = 8000; static const int kDtmfFrequencyHz = 8000;
RTPSenderAudio::RTPSenderAudio(Clock* clock, RTPSender* rtpSender) RTPSenderAudio::RTPSenderAudio(Clock* clock, RTPSender* rtp_sender)
: _clock(clock), : clock_(clock),
_rtpSender(rtpSender), rtp_sender_(rtp_sender),
_packetSizeSamples(160), packet_size_samples_(160),
_dtmfEventIsOn(false), dtmf_event_is_on_(false),
_dtmfEventFirstPacketSent(false), dtmf_event_first_packet_sent_(false),
_dtmfPayloadType(-1), dtmf_payload_type_(-1),
_dtmfTimestamp(0), dtmf_timestamp_(0),
_dtmfKey(0), dtmf_key_(0),
_dtmfLengthSamples(0), dtmf_length_samples_(0),
_dtmfLevel(0), dtmf_level_(0),
_dtmfTimeLastSent(0), dtmf_time_last_sent_(0),
_dtmfTimestampLastSent(0), dtmf_timestamp_last_sent_(0),
_REDPayloadType(-1), red_payload_type_(-1),
_inbandVADactive(false), inband_vad_active_(false),
_cngNBPayloadType(-1), cngnb_payload_type_(-1),
_cngWBPayloadType(-1), cngwb_payload_type_(-1),
_cngSWBPayloadType(-1), cngswb_payload_type_(-1),
_cngFBPayloadType(-1), cngfb_payload_type_(-1),
_lastPayloadType(-1), last_payload_type_(-1),
_audioLevel_dBov(0) {} audio_level_dbov_(0) {}
RTPSenderAudio::~RTPSenderAudio() {} RTPSenderAudio::~RTPSenderAudio() {}
@ -52,44 +52,43 @@ int RTPSenderAudio::AudioFrequency() const {
// set audio packet size, used to determine when it's time to send a DTMF packet // set audio packet size, used to determine when it's time to send a DTMF packet
// in silence (CNG) // in silence (CNG)
int32_t RTPSenderAudio::SetAudioPacketSize(uint16_t packetSizeSamples) { int32_t RTPSenderAudio::SetAudioPacketSize(uint16_t packet_size_samples) {
rtc::CritScope cs(&_sendAudioCritsect); rtc::CritScope cs(&send_audio_critsect_);
packet_size_samples_ = packet_size_samples;
_packetSizeSamples = packetSizeSamples;
return 0; return 0;
} }
int32_t RTPSenderAudio::RegisterAudioPayload( int32_t RTPSenderAudio::RegisterAudioPayload(
const char payloadName[RTP_PAYLOAD_NAME_SIZE], const char payloadName[RTP_PAYLOAD_NAME_SIZE],
const int8_t payloadType, const int8_t payload_type,
const uint32_t frequency, const uint32_t frequency,
const size_t channels, const size_t channels,
const uint32_t rate, const uint32_t rate,
RtpUtility::Payload** payload) { RtpUtility::Payload** payload) {
if (RtpUtility::StringCompare(payloadName, "cn", 2)) { if (RtpUtility::StringCompare(payloadName, "cn", 2)) {
rtc::CritScope cs(&_sendAudioCritsect); rtc::CritScope cs(&send_audio_critsect_);
// we can have multiple CNG payload types // we can have multiple CNG payload types
switch (frequency) { switch (frequency) {
case 8000: case 8000:
_cngNBPayloadType = payloadType; cngnb_payload_type_ = payload_type;
break; break;
case 16000: case 16000:
_cngWBPayloadType = payloadType; cngwb_payload_type_ = payload_type;
break; break;
case 32000: case 32000:
_cngSWBPayloadType = payloadType; cngswb_payload_type_ = payload_type;
break; break;
case 48000: case 48000:
_cngFBPayloadType = payloadType; cngfb_payload_type_ = payload_type;
break; break;
default: default:
return -1; return -1;
} }
} else if (RtpUtility::StringCompare(payloadName, "telephone-event", 15)) { } else if (RtpUtility::StringCompare(payloadName, "telephone-event", 15)) {
rtc::CritScope cs(&_sendAudioCritsect); rtc::CritScope cs(&send_audio_critsect_);
// Don't add it to the list // Don't add it to the list
// we dont want to allow send with a DTMF payloadtype // we dont want to allow send with a DTMF payloadtype
_dtmfPayloadType = payloadType; dtmf_payload_type_ = payload_type;
return 0; return 0;
// The default timestamp rate is 8000 Hz, but other rates may be defined. // The default timestamp rate is 8000 Hz, but other rates may be defined.
} }
@ -103,27 +102,27 @@ int32_t RTPSenderAudio::RegisterAudioPayload(
return 0; return 0;
} }
bool RTPSenderAudio::MarkerBit(FrameType frameType, int8_t payload_type) { bool RTPSenderAudio::MarkerBit(FrameType frame_type, int8_t payload_type) {
rtc::CritScope cs(&_sendAudioCritsect); rtc::CritScope cs(&send_audio_critsect_);
// for audio true for first packet in a speech burst // for audio true for first packet in a speech burst
bool markerBit = false; bool marker_bit = false;
if (_lastPayloadType != payload_type) { if (last_payload_type_ != payload_type) {
if (payload_type != -1 && (_cngNBPayloadType == payload_type || if (payload_type != -1 && (cngnb_payload_type_ == payload_type ||
_cngWBPayloadType == payload_type || cngwb_payload_type_ == payload_type ||
_cngSWBPayloadType == payload_type || cngswb_payload_type_ == payload_type ||
_cngFBPayloadType == payload_type)) { cngfb_payload_type_ == payload_type)) {
// Only set a marker bit when we change payload type to a non CNG // Only set a marker bit when we change payload type to a non CNG
return false; return false;
} }
// payload_type differ // payload_type differ
if (_lastPayloadType == -1) { if (last_payload_type_ == -1) {
if (frameType != kAudioFrameCN) { if (frame_type != kAudioFrameCN) {
// first packet and NOT CNG // first packet and NOT CNG
return true; return true;
} else { } else {
// first packet and CNG // first packet and CNG
_inbandVADactive = true; inband_vad_active_ = true;
return false; return false;
} }
} }
@ -133,158 +132,159 @@ bool RTPSenderAudio::MarkerBit(FrameType frameType, int8_t payload_type) {
// payload_type changed // payload_type changed
// set a marker bit when we change payload type // set a marker bit when we change payload type
markerBit = true; marker_bit = true;
} }
// For G.723 G.729, AMR etc we can have inband VAD // For G.723 G.729, AMR etc we can have inband VAD
if (frameType == kAudioFrameCN) { if (frame_type == kAudioFrameCN) {
_inbandVADactive = true; inband_vad_active_ = true;
} else if (_inbandVADactive) { } else if (inband_vad_active_) {
_inbandVADactive = false; inband_vad_active_ = false;
markerBit = true; marker_bit = true;
} }
return markerBit; return marker_bit;
} }
int32_t RTPSenderAudio::SendAudio(FrameType frameType, int32_t RTPSenderAudio::SendAudio(FrameType frame_type,
int8_t payloadType, int8_t payload_type,
uint32_t captureTimeStamp, uint32_t capture_timestamp,
const uint8_t* payloadData, const uint8_t* payload_data,
size_t dataSize, size_t data_size,
const RTPFragmentationHeader* fragmentation) { const RTPFragmentationHeader* fragmentation) {
// TODO(pwestin) Breakup function in smaller functions. // TODO(pwestin) Breakup function in smaller functions.
size_t payloadSize = dataSize; size_t payload_size = data_size;
size_t maxPayloadLength = _rtpSender->MaxPayloadLength(); size_t max_payload_length = rtp_sender_->MaxPayloadLength();
uint16_t dtmfLengthMS = 0; uint16_t dtmf_length_ms = 0;
uint8_t key = 0; uint8_t key = 0;
int red_payload_type; int red_payload_type;
uint8_t audio_level_dbov; uint8_t audio_level_dbov;
int8_t dtmf_payload_type; int8_t dtmf_payload_type;
uint16_t packet_size_samples; uint16_t packet_size_samples;
{ {
rtc::CritScope cs(&_sendAudioCritsect); rtc::CritScope cs(&send_audio_critsect_);
red_payload_type = _REDPayloadType; red_payload_type = red_payload_type_;
audio_level_dbov = _audioLevel_dBov; audio_level_dbov = audio_level_dbov_;
dtmf_payload_type = _dtmfPayloadType; dtmf_payload_type = dtmf_payload_type_;
packet_size_samples = _packetSizeSamples; packet_size_samples = packet_size_samples_;
} }
// Check if we have pending DTMFs to send // Check if we have pending DTMFs to send
if (!_dtmfEventIsOn && PendingDTMF()) { if (!dtmf_event_is_on_ && PendingDTMF()) {
int64_t delaySinceLastDTMF = int64_t delaySinceLastDTMF =
_clock->TimeInMilliseconds() - _dtmfTimeLastSent; clock_->TimeInMilliseconds() - dtmf_time_last_sent_;
if (delaySinceLastDTMF > 100) { if (delaySinceLastDTMF > 100) {
// New tone to play // New tone to play
_dtmfTimestamp = captureTimeStamp; dtmf_timestamp_ = capture_timestamp;
if (NextDTMF(&key, &dtmfLengthMS, &_dtmfLevel) >= 0) { if (NextDTMF(&key, &dtmf_length_ms, &dtmf_level_) >= 0) {
_dtmfEventFirstPacketSent = false; dtmf_event_first_packet_sent_ = false;
_dtmfKey = key; dtmf_key_ = key;
_dtmfLengthSamples = (kDtmfFrequencyHz / 1000) * dtmfLengthMS; dtmf_length_samples_ = (kDtmfFrequencyHz / 1000) * dtmf_length_ms;
_dtmfEventIsOn = true; dtmf_event_is_on_ = true;
} }
} }
} }
// A source MAY send events and coded audio packets for the same time // A source MAY send events and coded audio packets for the same time
// but we don't support it // but we don't support it
if (_dtmfEventIsOn) { if (dtmf_event_is_on_) {
if (frameType == kEmptyFrame) { if (frame_type == kEmptyFrame) {
// kEmptyFrame is used to drive the DTMF when in CN mode // kEmptyFrame is used to drive the DTMF when in CN mode
// it can be triggered more frequently than we want to send the // it can be triggered more frequently than we want to send the
// DTMF packets. // DTMF packets.
if (packet_size_samples > (captureTimeStamp - _dtmfTimestampLastSent)) { if (packet_size_samples >
(capture_timestamp - dtmf_timestamp_last_sent_)) {
// not time to send yet // not time to send yet
return 0; return 0;
} }
} }
_dtmfTimestampLastSent = captureTimeStamp; dtmf_timestamp_last_sent_ = capture_timestamp;
uint32_t dtmfDurationSamples = captureTimeStamp - _dtmfTimestamp; uint32_t dtmf_duration_samples = capture_timestamp - dtmf_timestamp_;
bool ended = false; bool ended = false;
bool send = true; bool send = true;
if (_dtmfLengthSamples > dtmfDurationSamples) { if (dtmf_length_samples_ > dtmf_duration_samples) {
if (dtmfDurationSamples <= 0) { if (dtmf_duration_samples <= 0) {
// Skip send packet at start, since we shouldn't use duration 0 // Skip send packet at start, since we shouldn't use duration 0
send = false; send = false;
} }
} else { } else {
ended = true; ended = true;
_dtmfEventIsOn = false; dtmf_event_is_on_ = false;
_dtmfTimeLastSent = _clock->TimeInMilliseconds(); dtmf_time_last_sent_ = clock_->TimeInMilliseconds();
} }
if (send) { if (send) {
if (dtmfDurationSamples > 0xffff) { if (dtmf_duration_samples > 0xffff) {
// RFC 4733 2.5.2.3 Long-Duration Events // RFC 4733 2.5.2.3 Long-Duration Events
SendTelephoneEventPacket(ended, dtmf_payload_type, _dtmfTimestamp, SendTelephoneEventPacket(ended, dtmf_payload_type, dtmf_timestamp_,
static_cast<uint16_t>(0xffff), false); static_cast<uint16_t>(0xffff), false);
// set new timestap for this segment // set new timestap for this segment
_dtmfTimestamp = captureTimeStamp; dtmf_timestamp_ = capture_timestamp;
dtmfDurationSamples -= 0xffff; dtmf_duration_samples -= 0xffff;
_dtmfLengthSamples -= 0xffff; dtmf_length_samples_ -= 0xffff;
return SendTelephoneEventPacket( return SendTelephoneEventPacket(
ended, dtmf_payload_type, _dtmfTimestamp, ended, dtmf_payload_type, dtmf_timestamp_,
static_cast<uint16_t>(dtmfDurationSamples), false); static_cast<uint16_t>(dtmf_duration_samples), false);
} else { } else {
if (SendTelephoneEventPacket(ended, dtmf_payload_type, _dtmfTimestamp, if (SendTelephoneEventPacket(ended, dtmf_payload_type, dtmf_timestamp_,
static_cast<uint16_t>(dtmfDurationSamples), dtmf_duration_samples,
!_dtmfEventFirstPacketSent) != 0) { !dtmf_event_first_packet_sent_) != 0) {
return -1; return -1;
} }
_dtmfEventFirstPacketSent = true; dtmf_event_first_packet_sent_ = true;
return 0; return 0;
} }
} }
return 0; return 0;
} }
if (payloadSize == 0 || payloadData == NULL) { if (payload_size == 0 || payload_data == NULL) {
if (frameType == kEmptyFrame) { if (frame_type == kEmptyFrame) {
// we don't send empty audio RTP packets // we don't send empty audio RTP packets
// no error since we use it to drive DTMF when we use VAD // no error since we use it to drive DTMF when we use VAD
return 0; return 0;
} }
return -1; return -1;
} }
uint8_t dataBuffer[IP_PACKET_SIZE]; uint8_t data_buffer[IP_PACKET_SIZE];
bool markerBit = MarkerBit(frameType, payloadType); bool marker_bit = MarkerBit(frame_type, payload_type);
int32_t rtpHeaderLength = 0; int32_t rtpHeaderLength = 0;
uint16_t timestampOffset = 0; uint16_t timestampOffset = 0;
if (red_payload_type >= 0 && fragmentation && !markerBit && if (red_payload_type >= 0 && fragmentation && !marker_bit &&
fragmentation->fragmentationVectorSize > 1) { fragmentation->fragmentationVectorSize > 1) {
// have we configured RED? use its payload type // have we configured RED? use its payload type
// we need to get the current timestamp to calc the diff // we need to get the current timestamp to calc the diff
uint32_t oldTimeStamp = _rtpSender->Timestamp(); uint32_t old_timestamp = rtp_sender_->Timestamp();
rtpHeaderLength = _rtpSender->BuildRTPheader(dataBuffer, red_payload_type, rtpHeaderLength = rtp_sender_->BuildRtpHeader(data_buffer, red_payload_type,
markerBit, captureTimeStamp, marker_bit, capture_timestamp,
_clock->TimeInMilliseconds()); clock_->TimeInMilliseconds());
timestampOffset = uint16_t(_rtpSender->Timestamp() - oldTimeStamp); timestampOffset = uint16_t(rtp_sender_->Timestamp() - old_timestamp);
} else { } else {
rtpHeaderLength = _rtpSender->BuildRTPheader(dataBuffer, payloadType, rtpHeaderLength = rtp_sender_->BuildRtpHeader(data_buffer, payload_type,
markerBit, captureTimeStamp, marker_bit, capture_timestamp,
_clock->TimeInMilliseconds()); clock_->TimeInMilliseconds());
} }
if (rtpHeaderLength <= 0) { if (rtpHeaderLength <= 0) {
return -1; return -1;
} }
if (maxPayloadLength < (rtpHeaderLength + payloadSize)) { if (max_payload_length < (rtpHeaderLength + payload_size)) {
// Too large payload buffer. // Too large payload buffer.
return -1; return -1;
} }
if (red_payload_type >= 0 && // Have we configured RED? if (red_payload_type >= 0 && // Have we configured RED?
fragmentation && fragmentation->fragmentationVectorSize > 1 && fragmentation && fragmentation->fragmentationVectorSize > 1 &&
!markerBit) { !marker_bit) {
if (timestampOffset <= 0x3fff) { if (timestampOffset <= 0x3fff) {
if (fragmentation->fragmentationVectorSize != 2) { if (fragmentation->fragmentationVectorSize != 2) {
// we only support 2 codecs when using RED // we only support 2 codecs when using RED
return -1; return -1;
} }
// only 0x80 if we have multiple blocks // only 0x80 if we have multiple blocks
dataBuffer[rtpHeaderLength++] = data_buffer[rtpHeaderLength++] =
0x80 + fragmentation->fragmentationPlType[1]; 0x80 + fragmentation->fragmentationPlType[1];
size_t blockLength = fragmentation->fragmentationLength[1]; size_t blockLength = fragmentation->fragmentationLength[1];
@ -293,66 +293,65 @@ int32_t RTPSenderAudio::SendAudio(FrameType frameType,
return -1; return -1;
} }
uint32_t REDheader = (timestampOffset << 10) + blockLength; uint32_t REDheader = (timestampOffset << 10) + blockLength;
ByteWriter<uint32_t>::WriteBigEndian(dataBuffer + rtpHeaderLength, ByteWriter<uint32_t>::WriteBigEndian(data_buffer + rtpHeaderLength,
REDheader); REDheader);
rtpHeaderLength += 3; rtpHeaderLength += 3;
dataBuffer[rtpHeaderLength++] = fragmentation->fragmentationPlType[0]; data_buffer[rtpHeaderLength++] = fragmentation->fragmentationPlType[0];
// copy the RED data // copy the RED data
memcpy(dataBuffer + rtpHeaderLength, memcpy(data_buffer + rtpHeaderLength,
payloadData + fragmentation->fragmentationOffset[1], payload_data + fragmentation->fragmentationOffset[1],
fragmentation->fragmentationLength[1]); fragmentation->fragmentationLength[1]);
// copy the normal data // copy the normal data
memcpy( memcpy(
dataBuffer + rtpHeaderLength + fragmentation->fragmentationLength[1], data_buffer + rtpHeaderLength + fragmentation->fragmentationLength[1],
payloadData + fragmentation->fragmentationOffset[0], payload_data + fragmentation->fragmentationOffset[0],
fragmentation->fragmentationLength[0]); fragmentation->fragmentationLength[0]);
payloadSize = fragmentation->fragmentationLength[0] + payload_size = fragmentation->fragmentationLength[0] +
fragmentation->fragmentationLength[1]; fragmentation->fragmentationLength[1];
} else { } else {
// silence for too long send only new data // silence for too long send only new data
dataBuffer[rtpHeaderLength++] = fragmentation->fragmentationPlType[0]; data_buffer[rtpHeaderLength++] = fragmentation->fragmentationPlType[0];
memcpy(dataBuffer + rtpHeaderLength, memcpy(data_buffer + rtpHeaderLength,
payloadData + fragmentation->fragmentationOffset[0], payload_data + fragmentation->fragmentationOffset[0],
fragmentation->fragmentationLength[0]); fragmentation->fragmentationLength[0]);
payloadSize = fragmentation->fragmentationLength[0]; payload_size = fragmentation->fragmentationLength[0];
} }
} else { } else {
if (fragmentation && fragmentation->fragmentationVectorSize > 0) { if (fragmentation && fragmentation->fragmentationVectorSize > 0) {
// use the fragment info if we have one // use the fragment info if we have one
dataBuffer[rtpHeaderLength++] = fragmentation->fragmentationPlType[0]; data_buffer[rtpHeaderLength++] = fragmentation->fragmentationPlType[0];
memcpy(dataBuffer + rtpHeaderLength, memcpy(data_buffer + rtpHeaderLength,
payloadData + fragmentation->fragmentationOffset[0], payload_data + fragmentation->fragmentationOffset[0],
fragmentation->fragmentationLength[0]); fragmentation->fragmentationLength[0]);
payloadSize = fragmentation->fragmentationLength[0]; payload_size = fragmentation->fragmentationLength[0];
} else { } else {
memcpy(dataBuffer + rtpHeaderLength, payloadData, payloadSize); memcpy(data_buffer + rtpHeaderLength, payload_data, payload_size);
} }
} }
{ {
rtc::CritScope cs(&_sendAudioCritsect); rtc::CritScope cs(&send_audio_critsect_);
_lastPayloadType = payloadType; last_payload_type_ = payload_type;
} }
// Update audio level extension, if included. // Update audio level extension, if included.
size_t packetSize = payloadSize + rtpHeaderLength; size_t packetSize = payload_size + rtpHeaderLength;
RtpUtility::RtpHeaderParser rtp_parser(dataBuffer, packetSize); RtpUtility::RtpHeaderParser rtp_parser(data_buffer, packetSize);
RTPHeader rtp_header; RTPHeader rtp_header;
rtp_parser.Parse(&rtp_header); rtp_parser.Parse(&rtp_header);
_rtpSender->UpdateAudioLevel(dataBuffer, packetSize, rtp_header, rtp_sender_->UpdateAudioLevel(data_buffer, packetSize, rtp_header,
(frameType == kAudioFrameSpeech), (frame_type == kAudioFrameSpeech),
audio_level_dbov); audio_level_dbov);
TRACE_EVENT_ASYNC_END2("webrtc", "Audio", captureTimeStamp, "timestamp", TRACE_EVENT_ASYNC_END2("webrtc", "Audio", capture_timestamp, "timestamp",
_rtpSender->Timestamp(), "seqnum", rtp_sender_->Timestamp(), "seqnum",
_rtpSender->SequenceNumber()); rtp_sender_->SequenceNumber());
int32_t send_result = _rtpSender->SendToNetwork( int32_t send_result = rtp_sender_->SendToNetwork(
dataBuffer, payloadSize, rtpHeaderLength, data_buffer, payload_size, rtpHeaderLength, rtc::TimeMillis(),
rtc::TimeMillis(), kAllowRetransmission, kAllowRetransmission, RtpPacketSender::kHighPriority);
RtpPacketSender::kHighPriority);
if (first_packet_sent_()) { if (first_packet_sent_()) {
LOG(LS_INFO) << "First audio RTP packet sent to pacer"; LOG(LS_INFO) << "First audio RTP packet sent to pacer";
} }
@ -360,33 +359,33 @@ int32_t RTPSenderAudio::SendAudio(FrameType frameType,
} }
// Audio level magnitude and voice activity flag are set for each RTP packet // Audio level magnitude and voice activity flag are set for each RTP packet
int32_t RTPSenderAudio::SetAudioLevel(uint8_t level_dBov) { int32_t RTPSenderAudio::SetAudioLevel(uint8_t level_dbov) {
if (level_dBov > 127) { if (level_dbov > 127) {
return -1; return -1;
} }
rtc::CritScope cs(&_sendAudioCritsect); rtc::CritScope cs(&send_audio_critsect_);
_audioLevel_dBov = level_dBov; audio_level_dbov_ = level_dbov;
return 0; return 0;
} }
// Set payload type for Redundant Audio Data RFC 2198 // Set payload type for Redundant Audio Data RFC 2198
int32_t RTPSenderAudio::SetRED(int8_t payloadType) { int32_t RTPSenderAudio::SetRED(int8_t payload_type) {
if (payloadType < -1) { if (payload_type < -1) {
return -1; return -1;
} }
rtc::CritScope cs(&_sendAudioCritsect); rtc::CritScope cs(&send_audio_critsect_);
_REDPayloadType = payloadType; red_payload_type_ = payload_type;
return 0; return 0;
} }
// Get payload type for Redundant Audio Data RFC 2198 // Get payload type for Redundant Audio Data RFC 2198
int32_t RTPSenderAudio::RED(int8_t* payloadType) const { int32_t RTPSenderAudio::RED(int8_t* payload_type) const {
rtc::CritScope cs(&_sendAudioCritsect); rtc::CritScope cs(&send_audio_critsect_);
if (_REDPayloadType == -1) { if (red_payload_type_ == -1) {
// not configured // not configured
return -1; return -1;
} }
*payloadType = _REDPayloadType; *payload_type = red_payload_type_;
return 0; return 0;
} }
@ -395,8 +394,8 @@ int32_t RTPSenderAudio::SendTelephoneEvent(uint8_t key,
uint16_t time_ms, uint16_t time_ms,
uint8_t level) { uint8_t level) {
{ {
rtc::CritScope lock(&_sendAudioCritsect); rtc::CritScope lock(&send_audio_critsect_);
if (_dtmfPayloadType < 0) { if (dtmf_payload_type_ < 0) {
// TelephoneEvent payloadtype not configured // TelephoneEvent payloadtype not configured
return -1; return -1;
} }
@ -406,9 +405,9 @@ int32_t RTPSenderAudio::SendTelephoneEvent(uint8_t key,
int32_t RTPSenderAudio::SendTelephoneEventPacket(bool ended, int32_t RTPSenderAudio::SendTelephoneEventPacket(bool ended,
int8_t dtmf_payload_type, int8_t dtmf_payload_type,
uint32_t dtmfTimeStamp, uint32_t dtmf_timestamp,
uint16_t duration, uint16_t duration,
bool markerBit) { bool marker_bit) {
uint8_t dtmfbuffer[IP_PACKET_SIZE]; uint8_t dtmfbuffer[IP_PACKET_SIZE];
uint8_t sendCount = 1; uint8_t sendCount = 1;
int32_t retVal = 0; int32_t retVal = 0;
@ -419,8 +418,8 @@ int32_t RTPSenderAudio::SendTelephoneEventPacket(bool ended,
} }
do { do {
// Send DTMF data // Send DTMF data
_rtpSender->BuildRTPheader(dtmfbuffer, dtmf_payload_type, markerBit, rtp_sender_->BuildRtpHeader(dtmfbuffer, dtmf_payload_type, marker_bit,
dtmfTimeStamp, _clock->TimeInMilliseconds()); dtmf_timestamp, clock_->TimeInMilliseconds());
// reset CSRC and X bit // reset CSRC and X bit
dtmfbuffer[0] &= 0xe0; dtmfbuffer[0] &= 0xe0;
@ -436,22 +435,22 @@ int32_t RTPSenderAudio::SendTelephoneEventPacket(bool ended,
*/ */
// R bit always cleared // R bit always cleared
uint8_t R = 0x00; uint8_t R = 0x00;
uint8_t volume = _dtmfLevel; uint8_t volume = dtmf_level_;
// First packet un-ended // First packet un-ended
uint8_t E = ended ? 0x80 : 0x00; uint8_t E = ended ? 0x80 : 0x00;
// First byte is Event number, equals key number // First byte is Event number, equals key number
dtmfbuffer[12] = _dtmfKey; dtmfbuffer[12] = dtmf_key_;
dtmfbuffer[13] = E | R | volume; dtmfbuffer[13] = E | R | volume;
ByteWriter<uint16_t>::WriteBigEndian(dtmfbuffer + 14, duration); ByteWriter<uint16_t>::WriteBigEndian(dtmfbuffer + 14, duration);
TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), TRACE_EVENT_INSTANT2(
"Audio::SendTelephoneEvent", "timestamp", TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "Audio::SendTelephoneEvent",
dtmfTimeStamp, "seqnum", _rtpSender->SequenceNumber()); "timestamp", dtmf_timestamp, "seqnum", rtp_sender_->SequenceNumber());
retVal = _rtpSender->SendToNetwork( retVal = rtp_sender_->SendToNetwork(dtmfbuffer, 4, 12, rtc::TimeMillis(),
dtmfbuffer, 4, 12, rtc::TimeMillis(), kAllowRetransmission,
kAllowRetransmission, RtpPacketSender::kHighPriority); RtpPacketSender::kHighPriority);
sendCount--; sendCount--;
} while (sendCount > 0 && retVal == 0); } while (sendCount > 0 && retVal == 0);

View File

@ -21,33 +21,34 @@
#include "webrtc/typedefs.h" #include "webrtc/typedefs.h"
namespace webrtc { namespace webrtc {
class RTPSenderAudio : public DTMFqueue { class RTPSenderAudio : public DTMFqueue {
public: public:
RTPSenderAudio(Clock* clock, RTPSender* rtpSender); RTPSenderAudio(Clock* clock, RTPSender* rtp_sender);
virtual ~RTPSenderAudio(); virtual ~RTPSenderAudio();
int32_t RegisterAudioPayload(const char payloadName[RTP_PAYLOAD_NAME_SIZE], int32_t RegisterAudioPayload(const char payloadName[RTP_PAYLOAD_NAME_SIZE],
int8_t payloadType, int8_t payload_type,
uint32_t frequency, uint32_t frequency,
size_t channels, size_t channels,
uint32_t rate, uint32_t rate,
RtpUtility::Payload** payload); RtpUtility::Payload** payload);
int32_t SendAudio(FrameType frameType, int32_t SendAudio(FrameType frame_type,
int8_t payloadType, int8_t payload_type,
uint32_t captureTimeStamp, uint32_t capture_timestamp,
const uint8_t* payloadData, const uint8_t* payload_data,
size_t payloadSize, size_t payload_size,
const RTPFragmentationHeader* fragmentation); const RTPFragmentationHeader* fragmentation);
// 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(uint16_t packetSizeSamples); int32_t SetAudioPacketSize(uint16_t packet_size_samples);
// Store the audio level in dBov for // Store the audio level in dBov for
// header-extension-for-audio-level-indication. // header-extension-for-audio-level-indication.
// Valid range is [0,100]. Actual value is negative. // Valid range is [0,100]. Actual value is negative.
int32_t SetAudioLevel(uint8_t level_dBov); int32_t SetAudioLevel(uint8_t level_dbov);
// Send a DTMF tone using RFC 2833 (4733) // Send a DTMF tone using RFC 2833 (4733)
int32_t SendTelephoneEvent(uint8_t key, uint16_t time_ms, uint8_t level); int32_t SendTelephoneEvent(uint8_t key, uint16_t time_ms, uint8_t level);
@ -55,55 +56,56 @@ class RTPSenderAudio : public DTMFqueue {
int AudioFrequency() const; int AudioFrequency() const;
// Set payload type for Redundant Audio Data RFC 2198 // Set payload type for Redundant Audio Data RFC 2198
int32_t SetRED(int8_t payloadType); 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* payloadType) const; int32_t RED(int8_t* payload_type) const;
protected: protected:
int32_t SendTelephoneEventPacket( int32_t SendTelephoneEventPacket(
bool ended, bool ended,
int8_t dtmf_payload_type, int8_t dtmf_payload_type,
uint32_t dtmfTimeStamp, uint32_t dtmf_timestamp,
uint16_t duration, uint16_t duration,
bool markerBit); // set on first packet in talk burst bool marker_bit); // set on first packet in talk burst
bool MarkerBit(const FrameType frameType, const int8_t payloadType); bool MarkerBit(FrameType frame_type, int8_t payload_type);
private: private:
Clock* const _clock; Clock* const clock_;
RTPSender* const _rtpSender; RTPSender* const rtp_sender_;
rtc::CriticalSection _sendAudioCritsect; rtc::CriticalSection send_audio_critsect_;
uint16_t _packetSizeSamples GUARDED_BY(_sendAudioCritsect); uint16_t packet_size_samples_ GUARDED_BY(send_audio_critsect_);
// DTMF // DTMF.
bool _dtmfEventIsOn; bool dtmf_event_is_on_;
bool _dtmfEventFirstPacketSent; bool dtmf_event_first_packet_sent_;
int8_t _dtmfPayloadType GUARDED_BY(_sendAudioCritsect); int8_t dtmf_payload_type_ GUARDED_BY(send_audio_critsect_);
uint32_t _dtmfTimestamp; uint32_t dtmf_timestamp_;
uint8_t _dtmfKey; uint8_t dtmf_key_;
uint32_t _dtmfLengthSamples; uint32_t dtmf_length_samples_;
uint8_t _dtmfLevel; uint8_t dtmf_level_;
int64_t _dtmfTimeLastSent; int64_t dtmf_time_last_sent_;
uint32_t _dtmfTimestampLastSent; uint32_t dtmf_timestamp_last_sent_;
int8_t _REDPayloadType GUARDED_BY(_sendAudioCritsect); int8_t red_payload_type_ GUARDED_BY(send_audio_critsect_);
// VAD detection, used for markerbit // VAD detection, used for marker bit.
bool _inbandVADactive GUARDED_BY(_sendAudioCritsect); bool inband_vad_active_ GUARDED_BY(send_audio_critsect_);
int8_t _cngNBPayloadType GUARDED_BY(_sendAudioCritsect); int8_t cngnb_payload_type_ GUARDED_BY(send_audio_critsect_);
int8_t _cngWBPayloadType GUARDED_BY(_sendAudioCritsect); int8_t cngwb_payload_type_ GUARDED_BY(send_audio_critsect_);
int8_t _cngSWBPayloadType GUARDED_BY(_sendAudioCritsect); int8_t cngswb_payload_type_ GUARDED_BY(send_audio_critsect_);
int8_t _cngFBPayloadType GUARDED_BY(_sendAudioCritsect); int8_t cngfb_payload_type_ GUARDED_BY(send_audio_critsect_);
int8_t _lastPayloadType GUARDED_BY(_sendAudioCritsect); int8_t last_payload_type_ GUARDED_BY(send_audio_critsect_);
// Audio level indication // Audio level indication.
// (https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/) // (https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/)
uint8_t _audioLevel_dBov GUARDED_BY(_sendAudioCritsect); uint8_t audio_level_dbov_ GUARDED_BY(send_audio_critsect_);
OneTimeEvent first_packet_sent_; OneTimeEvent first_packet_sent_;
}; };
} // namespace webrtc } // namespace webrtc
#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_AUDIO_H_ #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_AUDIO_H_

View File

@ -185,7 +185,7 @@ class RtpSenderTest : public ::testing::Test {
void SendPacket(int64_t capture_time_ms, int payload_length) { void SendPacket(int64_t capture_time_ms, int payload_length) {
uint32_t timestamp = capture_time_ms * 90; uint32_t timestamp = capture_time_ms * 90;
int32_t rtp_length = rtp_sender_->BuildRTPheader( int32_t rtp_length = rtp_sender_->BuildRtpHeader(
packet_, kPayload, kMarkerBit, timestamp, capture_time_ms); packet_, kPayload, kMarkerBit, timestamp, capture_time_ms);
ASSERT_GE(rtp_length, 0); ASSERT_GE(rtp_length, 0);
@ -206,7 +206,7 @@ class RtpSenderTest : public ::testing::Test {
EXPECT_EQ(0, rtp_sender_->SendOutgoingData( EXPECT_EQ(0, rtp_sender_->SendOutgoingData(
kVideoFrameKey, kPayloadType, kTimestamp, kCaptureTimeMs, kVideoFrameKey, kPayloadType, kTimestamp, kCaptureTimeMs,
kPayload, sizeof(kPayload), nullptr)); kPayload, sizeof(kPayload), nullptr, nullptr));
} }
}; };
@ -236,7 +236,7 @@ class RtpSenderVideoTest : public RtpSenderTest {
webrtc::RtpUtility::RtpHeaderParser rtp_parser(data, len); webrtc::RtpUtility::RtpHeaderParser rtp_parser(data, len);
webrtc::RTPHeader rtp_header; webrtc::RTPHeader rtp_header;
size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader( size_t length = static_cast<size_t>(rtp_sender_->BuildRtpHeader(
packet_, kPayload, expect_cvo /* marker_bit */, kTimestamp, 0)); packet_, kPayload, expect_cvo /* marker_bit */, kTimestamp, 0));
if (expect_cvo) { if (expect_cvo) {
ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionLength(), ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionLength(),
@ -363,7 +363,7 @@ TEST_F(RtpSenderTestWithoutPacer, RegisterRtpVideoRotationHeaderExtension) {
} }
TEST_F(RtpSenderTestWithoutPacer, BuildRTPPacket) { TEST_F(RtpSenderTestWithoutPacer, BuildRTPPacket) {
size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader( size_t length = static_cast<size_t>(rtp_sender_->BuildRtpHeader(
packet_, kPayload, kMarkerBit, kTimestamp, 0)); packet_, kPayload, kMarkerBit, kTimestamp, 0));
ASSERT_EQ(kRtpHeaderSize, length); ASSERT_EQ(kRtpHeaderSize, length);
@ -394,7 +394,7 @@ TEST_F(RtpSenderTestWithoutPacer,
kRtpExtensionTransmissionTimeOffset, kRtpExtensionTransmissionTimeOffset,
kTransmissionTimeOffsetExtensionId)); kTransmissionTimeOffsetExtensionId));
size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader( size_t length = static_cast<size_t>(rtp_sender_->BuildRtpHeader(
packet_, kPayload, kMarkerBit, kTimestamp, 0)); packet_, kPayload, kMarkerBit, kTimestamp, 0));
ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionLength(), length); ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionLength(), length);
@ -433,7 +433,7 @@ TEST_F(RtpSenderTestWithoutPacer,
kRtpExtensionTransmissionTimeOffset, kRtpExtensionTransmissionTimeOffset,
kTransmissionTimeOffsetExtensionId)); kTransmissionTimeOffsetExtensionId));
size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader( size_t length = static_cast<size_t>(rtp_sender_->BuildRtpHeader(
packet_, kPayload, kMarkerBit, kTimestamp, 0)); packet_, kPayload, kMarkerBit, kTimestamp, 0));
ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionLength(), length); ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionLength(), length);
@ -460,7 +460,7 @@ TEST_F(RtpSenderTestWithoutPacer, BuildRTPPacketWithAbsoluteSendTimeExtension) {
0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime, 0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime,
kAbsoluteSendTimeExtensionId)); kAbsoluteSendTimeExtensionId));
size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader( size_t length = static_cast<size_t>(rtp_sender_->BuildRtpHeader(
packet_, kPayload, kMarkerBit, kTimestamp, 0)); packet_, kPayload, kMarkerBit, kTimestamp, 0));
ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionLength(), length); ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionLength(), length);
@ -545,7 +545,7 @@ TEST_F(RtpSenderTestWithoutPacer, BuildRTPPacketWithVideoRotation_MarkerBit) {
map.Register(kRtpExtensionVideoRotation, kVideoRotationExtensionId); map.Register(kRtpExtensionVideoRotation, kVideoRotationExtensionId);
size_t length = static_cast<size_t>( size_t length = static_cast<size_t>(
rtp_sender_->BuildRTPheader(packet_, kPayload, true, kTimestamp, 0)); rtp_sender_->BuildRtpHeader(packet_, kPayload, true, kTimestamp, 0));
ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionLength(), length); ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionLength(), length);
// Verify // Verify
@ -573,7 +573,7 @@ TEST_F(RtpSenderTestWithoutPacer,
map.Register(kRtpExtensionVideoRotation, kVideoRotationExtensionId); map.Register(kRtpExtensionVideoRotation, kVideoRotationExtensionId);
size_t length = static_cast<size_t>( size_t length = static_cast<size_t>(
rtp_sender_->BuildRTPheader(packet_, kPayload, false, kTimestamp, 0)); rtp_sender_->BuildRtpHeader(packet_, kPayload, false, kTimestamp, 0));
ASSERT_EQ(kRtpHeaderSize, length); ASSERT_EQ(kRtpHeaderSize, length);
// Verify // Verify
@ -591,7 +591,7 @@ TEST_F(RtpSenderTestWithoutPacer, BuildRTPPacketWithAudioLevelExtension) {
EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAudioLevel, EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAudioLevel,
kAudioLevelExtensionId)); kAudioLevelExtensionId));
size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader( size_t length = static_cast<size_t>(rtp_sender_->BuildRtpHeader(
packet_, kPayload, kMarkerBit, kTimestamp, 0)); packet_, kPayload, kMarkerBit, kTimestamp, 0));
ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionLength(), length); ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionLength(), length);
@ -634,7 +634,7 @@ TEST_F(RtpSenderTestWithoutPacer,
std::vector<uint32_t> csrcs; std::vector<uint32_t> csrcs;
csrcs.push_back(0x23456789); csrcs.push_back(0x23456789);
rtp_sender_->SetCsrcs(csrcs); rtp_sender_->SetCsrcs(csrcs);
size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader( size_t length = static_cast<size_t>(rtp_sender_->BuildRtpHeader(
packet_, kPayload, kMarkerBit, kTimestamp, 0)); packet_, kPayload, kMarkerBit, kTimestamp, 0));
// Verify // Verify
@ -678,7 +678,7 @@ TEST_F(RtpSenderTestWithoutPacer, BuildRTPPacketWithHeaderExtensions) {
kRtpExtensionTransportSequenceNumber, kRtpExtensionTransportSequenceNumber,
kTransportSequenceNumberExtensionId)); kTransportSequenceNumberExtensionId));
size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader( size_t length = static_cast<size_t>(rtp_sender_->BuildRtpHeader(
packet_, kPayload, kMarkerBit, kTimestamp, 0)); packet_, kPayload, kMarkerBit, kTimestamp, 0));
ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionLength(), length); ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionLength(), length);
@ -747,7 +747,7 @@ TEST_F(RtpSenderTest, TrafficSmoothingWithExtensions) {
0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime, 0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime,
kAbsoluteSendTimeExtensionId)); kAbsoluteSendTimeExtensionId));
int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); int64_t capture_time_ms = fake_clock_.TimeInMilliseconds();
int rtp_length_int = rtp_sender_->BuildRTPheader( int rtp_length_int = rtp_sender_->BuildRtpHeader(
packet_, kPayload, kMarkerBit, kTimestamp, capture_time_ms); packet_, kPayload, kMarkerBit, kTimestamp, capture_time_ms);
ASSERT_NE(-1, rtp_length_int); ASSERT_NE(-1, rtp_length_int);
size_t rtp_length = static_cast<size_t>(rtp_length_int); size_t rtp_length = static_cast<size_t>(rtp_length_int);
@ -800,7 +800,7 @@ TEST_F(RtpSenderTest, TrafficSmoothingRetransmits) {
0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime, 0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime,
kAbsoluteSendTimeExtensionId)); kAbsoluteSendTimeExtensionId));
int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); int64_t capture_time_ms = fake_clock_.TimeInMilliseconds();
int rtp_length_int = rtp_sender_->BuildRTPheader( int rtp_length_int = rtp_sender_->BuildRtpHeader(
packet_, kPayload, kMarkerBit, kTimestamp, capture_time_ms); packet_, kPayload, kMarkerBit, kTimestamp, capture_time_ms);
ASSERT_NE(-1, rtp_length_int); ASSERT_NE(-1, rtp_length_int);
size_t rtp_length = static_cast<size_t>(rtp_length_int); size_t rtp_length = static_cast<size_t>(rtp_length_int);
@ -881,7 +881,7 @@ TEST_F(RtpSenderTest, SendPadding) {
webrtc::RTPHeader rtp_header; webrtc::RTPHeader rtp_header;
int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); int64_t capture_time_ms = fake_clock_.TimeInMilliseconds();
int rtp_length_int = rtp_sender_->BuildRTPheader( int rtp_length_int = rtp_sender_->BuildRtpHeader(
packet_, kPayload, kMarkerBit, timestamp, capture_time_ms); packet_, kPayload, kMarkerBit, timestamp, capture_time_ms);
const uint32_t media_packet_timestamp = timestamp; const uint32_t media_packet_timestamp = timestamp;
ASSERT_NE(-1, rtp_length_int); ASSERT_NE(-1, rtp_length_int);
@ -939,7 +939,7 @@ TEST_F(RtpSenderTest, SendPadding) {
// Send a regular video packet again. // Send a regular video packet again.
capture_time_ms = fake_clock_.TimeInMilliseconds(); capture_time_ms = fake_clock_.TimeInMilliseconds();
rtp_length_int = rtp_sender_->BuildRTPheader(packet_, kPayload, kMarkerBit, rtp_length_int = rtp_sender_->BuildRtpHeader(packet_, kPayload, kMarkerBit,
timestamp, capture_time_ms); timestamp, capture_time_ms);
ASSERT_NE(-1, rtp_length_int); ASSERT_NE(-1, rtp_length_int);
rtp_length = static_cast<size_t>(rtp_length_int); rtp_length = static_cast<size_t>(rtp_length_int);
@ -1114,9 +1114,9 @@ TEST_F(RtpSenderTestWithoutPacer, SendGenericVideo) {
uint8_t payload[] = {47, 11, 32, 93, 89}; uint8_t payload[] = {47, 11, 32, 93, 89};
// Send keyframe // Send keyframe
ASSERT_EQ( ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kVideoFrameKey, payload_type, 1234,
0, rtp_sender_->SendOutgoingData(kVideoFrameKey, payload_type, 1234, 4321, 4321, payload, sizeof(payload),
payload, sizeof(payload), nullptr)); nullptr, nullptr));
RtpUtility::RtpHeaderParser rtp_parser(transport_.last_sent_packet_, RtpUtility::RtpHeaderParser rtp_parser(transport_.last_sent_packet_,
transport_.last_sent_packet_len_); transport_.last_sent_packet_len_);
@ -1140,9 +1140,9 @@ TEST_F(RtpSenderTestWithoutPacer, SendGenericVideo) {
payload[1] = 42; payload[1] = 42;
payload[4] = 13; payload[4] = 13;
ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kVideoFrameDelta, payload_type, ASSERT_EQ(0, rtp_sender_->SendOutgoingData(
1234, 4321, payload, kVideoFrameDelta, payload_type, 1234, 4321, payload,
sizeof(payload), nullptr)); sizeof(payload), nullptr, nullptr));
RtpUtility::RtpHeaderParser rtp_parser2(transport_.last_sent_packet_, RtpUtility::RtpHeaderParser rtp_parser2(transport_.last_sent_packet_,
transport_.last_sent_packet_len_); transport_.last_sent_packet_len_);
@ -1193,18 +1193,18 @@ TEST_F(RtpSenderTest, FrameCountCallbacks) {
EXPECT_CALL(mock_paced_sender_, InsertPacket(_, _, _, _, _, _)) EXPECT_CALL(mock_paced_sender_, InsertPacket(_, _, _, _, _, _))
.Times(::testing::AtLeast(2)); .Times(::testing::AtLeast(2));
ASSERT_EQ( ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kVideoFrameKey, payload_type, 1234,
0, rtp_sender_->SendOutgoingData(kVideoFrameKey, payload_type, 1234, 4321, 4321, payload, sizeof(payload),
payload, sizeof(payload), nullptr)); nullptr, nullptr));
EXPECT_EQ(1U, callback.num_calls_); EXPECT_EQ(1U, callback.num_calls_);
EXPECT_EQ(ssrc, callback.ssrc_); EXPECT_EQ(ssrc, callback.ssrc_);
EXPECT_EQ(1, callback.frame_counts_.key_frames); EXPECT_EQ(1, callback.frame_counts_.key_frames);
EXPECT_EQ(0, callback.frame_counts_.delta_frames); EXPECT_EQ(0, callback.frame_counts_.delta_frames);
ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kVideoFrameDelta, payload_type, ASSERT_EQ(0, rtp_sender_->SendOutgoingData(
1234, 4321, payload, kVideoFrameDelta, payload_type, 1234, 4321, payload,
sizeof(payload), nullptr)); sizeof(payload), nullptr, nullptr));
EXPECT_EQ(2U, callback.num_calls_); EXPECT_EQ(2U, callback.num_calls_);
EXPECT_EQ(ssrc, callback.ssrc_); EXPECT_EQ(ssrc, callback.ssrc_);
@ -1266,9 +1266,9 @@ TEST_F(RtpSenderTest, BitrateCallbacks) {
// Send a few frames. // Send a few frames.
for (uint32_t i = 0; i < kNumPackets; ++i) { for (uint32_t i = 0; i < kNumPackets; ++i) {
ASSERT_EQ(0, ASSERT_EQ(0, rtp_sender_->SendOutgoingData(
rtp_sender_->SendOutgoingData(kVideoFrameKey, payload_type, 1234, kVideoFrameKey, payload_type, 1234, 4321, payload,
4321, payload, sizeof(payload), 0)); sizeof(payload), nullptr, nullptr));
fake_clock_.AdvanceTimeMilliseconds(kPacketInterval); fake_clock_.AdvanceTimeMilliseconds(kPacketInterval);
} }
@ -1347,9 +1347,9 @@ TEST_F(RtpSenderTestWithoutPacer, StreamDataCountersCallbacks) {
rtp_sender_->RegisterRtpStatisticsCallback(&callback); rtp_sender_->RegisterRtpStatisticsCallback(&callback);
// Send a frame. // Send a frame.
ASSERT_EQ( ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kVideoFrameKey, payload_type, 1234,
0, rtp_sender_->SendOutgoingData(kVideoFrameKey, payload_type, 1234, 4321, 4321, payload, sizeof(payload),
payload, sizeof(payload), nullptr)); nullptr, nullptr));
StreamDataCounters expected; StreamDataCounters expected;
expected.transmitted.payload_bytes = 6; expected.transmitted.payload_bytes = 6;
expected.transmitted.header_bytes = 12; expected.transmitted.header_bytes = 12;
@ -1389,9 +1389,9 @@ TEST_F(RtpSenderTestWithoutPacer, StreamDataCountersCallbacks) {
fec_params.fec_rate = 1; fec_params.fec_rate = 1;
fec_params.max_fec_frames = 1; fec_params.max_fec_frames = 1;
rtp_sender_->SetFecParameters(&fec_params, &fec_params); rtp_sender_->SetFecParameters(&fec_params, &fec_params);
ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kVideoFrameDelta, payload_type, ASSERT_EQ(0, rtp_sender_->SendOutgoingData(
1234, 4321, payload, kVideoFrameDelta, payload_type, 1234, 4321, payload,
sizeof(payload), nullptr)); sizeof(payload), nullptr, nullptr));
expected.transmitted.payload_bytes = 40; expected.transmitted.payload_bytes = 40;
expected.transmitted.header_bytes = 60; expected.transmitted.header_bytes = 60;
expected.transmitted.packets = 5; expected.transmitted.packets = 5;
@ -1408,9 +1408,9 @@ TEST_F(RtpSenderAudioTest, SendAudio) {
0, 1500)); 0, 1500));
uint8_t payload[] = {47, 11, 32, 93, 89}; uint8_t payload[] = {47, 11, 32, 93, 89};
ASSERT_EQ( ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kAudioFrameCN, payload_type, 1234,
0, rtp_sender_->SendOutgoingData(kAudioFrameCN, payload_type, 1234, 4321, 4321, payload, sizeof(payload),
payload, sizeof(payload), nullptr)); nullptr, nullptr));
RtpUtility::RtpHeaderParser rtp_parser(transport_.last_sent_packet_, RtpUtility::RtpHeaderParser rtp_parser(transport_.last_sent_packet_,
transport_.last_sent_packet_len_); transport_.last_sent_packet_len_);
@ -1437,9 +1437,9 @@ TEST_F(RtpSenderAudioTest, SendAudioWithAudioLevelExtension) {
0, 1500)); 0, 1500));
uint8_t payload[] = {47, 11, 32, 93, 89}; uint8_t payload[] = {47, 11, 32, 93, 89};
ASSERT_EQ( ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kAudioFrameCN, payload_type, 1234,
0, rtp_sender_->SendOutgoingData(kAudioFrameCN, payload_type, 1234, 4321, 4321, payload, sizeof(payload),
payload, sizeof(payload), nullptr)); nullptr, nullptr));
RtpUtility::RtpHeaderParser rtp_parser(transport_.last_sent_packet_, RtpUtility::RtpHeaderParser rtp_parser(transport_.last_sent_packet_,
transport_.last_sent_packet_len_); transport_.last_sent_packet_len_);
@ -1490,13 +1490,13 @@ TEST_F(RtpSenderAudioTest, CheckMarkerBitForTelephoneEvents) {
// timestamp. So for first call it will skip since the duration is zero. // timestamp. So for first call it will skip since the duration is zero.
ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kEmptyFrame, payload_type, ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kEmptyFrame, payload_type,
capture_time_ms, 0, nullptr, 0, capture_time_ms, 0, nullptr, 0,
nullptr)); nullptr, nullptr));
// DTMF Sample Length is (Frequency/1000) * Duration. // DTMF Sample Length is (Frequency/1000) * Duration.
// So in this case, it is (8000/1000) * 500 = 4000. // So in this case, it is (8000/1000) * 500 = 4000.
// Sending it as two packets. // Sending it as two packets.
ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kEmptyFrame, payload_type, ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kEmptyFrame, payload_type,
capture_time_ms + 2000, 0, nullptr, capture_time_ms + 2000, 0, nullptr,
0, nullptr)); 0, nullptr, nullptr));
std::unique_ptr<webrtc::RtpHeaderParser> rtp_parser( std::unique_ptr<webrtc::RtpHeaderParser> rtp_parser(
webrtc::RtpHeaderParser::Create()); webrtc::RtpHeaderParser::Create());
ASSERT_TRUE(rtp_parser.get() != nullptr); ASSERT_TRUE(rtp_parser.get() != nullptr);
@ -1508,7 +1508,7 @@ TEST_F(RtpSenderAudioTest, CheckMarkerBitForTelephoneEvents) {
ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kEmptyFrame, payload_type, ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kEmptyFrame, payload_type,
capture_time_ms + 4000, 0, nullptr, capture_time_ms + 4000, 0, nullptr,
0, nullptr)); 0, nullptr, nullptr));
ASSERT_TRUE(rtp_parser->Parse(transport_.last_sent_packet_, ASSERT_TRUE(rtp_parser->Parse(transport_.last_sent_packet_,
transport_.last_sent_packet_len_, &rtp_header)); transport_.last_sent_packet_len_, &rtp_header));
// Marker Bit should be set to 0 for rest of the packets. // Marker Bit should be set to 0 for rest of the packets.
@ -1527,9 +1527,9 @@ TEST_F(RtpSenderTestWithoutPacer, BytesReportedCorrectly) {
0, 1500)); 0, 1500));
uint8_t payload[] = {47, 11, 32, 93, 89}; uint8_t payload[] = {47, 11, 32, 93, 89};
ASSERT_EQ( ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kVideoFrameKey, kPayloadType, 1234,
0, rtp_sender_->SendOutgoingData(kVideoFrameKey, kPayloadType, 1234, 4321, 4321, payload, sizeof(payload),
payload, sizeof(payload), 0)); nullptr, nullptr));
// Will send 2 full-size padding packets. // Will send 2 full-size padding packets.
rtp_sender_->TimeToSendPadding(1, PacketInfo::kNotAProbe); rtp_sender_->TimeToSendPadding(1, PacketInfo::kNotAProbe);

View File

@ -27,75 +27,61 @@
#include "webrtc/modules/rtp_rtcp/source/rtp_format_vp9.h" #include "webrtc/modules/rtp_rtcp/source/rtp_format_vp9.h"
namespace webrtc { namespace webrtc {
enum { REDForFECHeaderLength = 1 }; enum { REDForFECHeaderLength = 1 };
RTPSenderVideo::RTPSenderVideo(Clock* clock, RTPSenderInterface* rtpSender) RTPSenderVideo::RTPSenderVideo(Clock* clock, RTPSenderInterface* rtp_sender)
: _rtpSender(*rtpSender), : rtp_sender_(rtp_sender),
clock_(clock), clock_(clock),
_videoType(kRtpVideoGeneric),
_retransmissionSettings(kRetransmitBaseLayer),
// Generic FEC // Generic FEC
fec_(),
fec_enabled_(false),
red_payload_type_(0),
fec_payload_type_(0),
delta_fec_params_(),
key_fec_params_(),
producer_fec_(&fec_), producer_fec_(&fec_),
fec_bitrate_(1000, RateStatistics::kBpsScale), fec_bitrate_(1000, RateStatistics::kBpsScale),
video_bitrate_(1000, RateStatistics::kBpsScale) { video_bitrate_(1000, RateStatistics::kBpsScale) {}
memset(&delta_fec_params_, 0, sizeof(delta_fec_params_));
memset(&key_fec_params_, 0, sizeof(key_fec_params_));
delta_fec_params_.max_fec_frames = key_fec_params_.max_fec_frames = 1;
delta_fec_params_.fec_mask_type = key_fec_params_.fec_mask_type =
kFecMaskRandom;
}
RTPSenderVideo::~RTPSenderVideo() { RTPSenderVideo::~RTPSenderVideo() {}
}
void RTPSenderVideo::SetVideoCodecType(RtpVideoCodecTypes videoType) { void RTPSenderVideo::SetVideoCodecType(RtpVideoCodecTypes video_type) {
_videoType = videoType; video_type_ = video_type;
} }
RtpVideoCodecTypes RTPSenderVideo::VideoCodecType() const { RtpVideoCodecTypes RTPSenderVideo::VideoCodecType() const {
return _videoType; return video_type_;
} }
// Static. // Static.
RtpUtility::Payload* RTPSenderVideo::CreateVideoPayload( RtpUtility::Payload* RTPSenderVideo::CreateVideoPayload(
const char payloadName[RTP_PAYLOAD_NAME_SIZE], const char payload_name[RTP_PAYLOAD_NAME_SIZE],
const int8_t payloadType) { int8_t payload_type) {
RtpVideoCodecTypes videoType = kRtpVideoGeneric; RtpVideoCodecTypes video_type = kRtpVideoGeneric;
if (RtpUtility::StringCompare(payloadName, "VP8", 3)) { if (RtpUtility::StringCompare(payload_name, "VP8", 3)) {
videoType = kRtpVideoVp8; video_type = kRtpVideoVp8;
} else if (RtpUtility::StringCompare(payloadName, "VP9", 3)) { } else if (RtpUtility::StringCompare(payload_name, "VP9", 3)) {
videoType = kRtpVideoVp9; video_type = kRtpVideoVp9;
} else if (RtpUtility::StringCompare(payloadName, "H264", 4)) { } else if (RtpUtility::StringCompare(payload_name, "H264", 4)) {
videoType = kRtpVideoH264; video_type = kRtpVideoH264;
} else if (RtpUtility::StringCompare(payloadName, "I420", 4)) { } else if (RtpUtility::StringCompare(payload_name, "I420", 4)) {
videoType = kRtpVideoGeneric; video_type = kRtpVideoGeneric;
} else { } else {
videoType = kRtpVideoGeneric; video_type = kRtpVideoGeneric;
} }
RtpUtility::Payload* payload = new RtpUtility::Payload(); RtpUtility::Payload* payload = new RtpUtility::Payload();
payload->name[RTP_PAYLOAD_NAME_SIZE - 1] = 0; payload->name[RTP_PAYLOAD_NAME_SIZE - 1] = 0;
strncpy(payload->name, payloadName, RTP_PAYLOAD_NAME_SIZE - 1); strncpy(payload->name, payload_name, RTP_PAYLOAD_NAME_SIZE - 1);
payload->typeSpecific.Video.videoCodecType = videoType; payload->typeSpecific.Video.videoCodecType = video_type;
payload->audio = false; payload->audio = false;
return payload; return payload;
} }
void RTPSenderVideo::SendVideoPacket(uint8_t* data_buffer, void RTPSenderVideo::SendVideoPacket(uint8_t* data_buffer,
const size_t payload_length, size_t payload_length,
const size_t rtp_header_length, size_t rtp_header_length,
uint16_t seq_num, uint16_t seq_num,
const uint32_t capture_timestamp, uint32_t capture_timestamp,
int64_t capture_time_ms, int64_t capture_time_ms,
StorageType storage) { StorageType storage) {
if (_rtpSender.SendToNetwork(data_buffer, payload_length, rtp_header_length, if (rtp_sender_->SendToNetwork(data_buffer, payload_length, rtp_header_length,
capture_time_ms, storage, capture_time_ms, storage,
RtpPacketSender::kLowPriority) == 0) { RtpPacketSender::kLowPriority) == 0) {
rtc::CritScope cs(&stats_crit_); rtc::CritScope cs(&stats_crit_);
video_bitrate_.Update(payload_length + rtp_header_length, video_bitrate_.Update(payload_length + rtp_header_length,
clock_->TimeInMilliseconds()); clock_->TimeInMilliseconds());
@ -108,10 +94,10 @@ void RTPSenderVideo::SendVideoPacket(uint8_t* data_buffer,
} }
void RTPSenderVideo::SendVideoPacketAsRed(uint8_t* data_buffer, void RTPSenderVideo::SendVideoPacketAsRed(uint8_t* data_buffer,
const size_t payload_length, size_t payload_length,
const size_t rtp_header_length, size_t rtp_header_length,
uint16_t media_seq_num, uint16_t media_seq_num,
const uint32_t capture_timestamp, uint32_t capture_timestamp,
int64_t capture_time_ms, int64_t capture_time_ms,
StorageType media_packet_storage, StorageType media_packet_storage,
bool protect) { bool protect) {
@ -131,16 +117,16 @@ void RTPSenderVideo::SendVideoPacketAsRed(uint8_t* data_buffer,
uint16_t num_fec_packets = producer_fec_.NumAvailableFecPackets(); uint16_t num_fec_packets = producer_fec_.NumAvailableFecPackets();
if (num_fec_packets > 0) { if (num_fec_packets > 0) {
next_fec_sequence_number = next_fec_sequence_number =
_rtpSender.AllocateSequenceNumber(num_fec_packets); rtp_sender_->AllocateSequenceNumber(num_fec_packets);
fec_packets = producer_fec_.GetFecPackets( fec_packets = producer_fec_.GetFecPackets(
red_payload_type_, fec_payload_type_, next_fec_sequence_number, red_payload_type_, fec_payload_type_, next_fec_sequence_number,
rtp_header_length); rtp_header_length);
RTC_DCHECK_EQ(num_fec_packets, fec_packets.size()); RTC_DCHECK_EQ(num_fec_packets, fec_packets.size());
if (_retransmissionSettings & kRetransmitFECPackets) if (retransmission_settings_ & kRetransmitFECPackets)
fec_storage = kAllowRetransmission; fec_storage = kAllowRetransmission;
} }
} }
if (_rtpSender.SendToNetwork( if (rtp_sender_->SendToNetwork(
red_packet->data(), red_packet->length() - rtp_header_length, red_packet->data(), red_packet->length() - rtp_header_length,
rtp_header_length, capture_time_ms, media_packet_storage, rtp_header_length, capture_time_ms, media_packet_storage,
RtpPacketSender::kLowPriority) == 0) { RtpPacketSender::kLowPriority) == 0) {
@ -153,7 +139,7 @@ void RTPSenderVideo::SendVideoPacketAsRed(uint8_t* data_buffer,
LOG(LS_WARNING) << "Failed to send RED packet " << media_seq_num; LOG(LS_WARNING) << "Failed to send RED packet " << media_seq_num;
} }
for (RedPacket* fec_packet : fec_packets) { for (RedPacket* fec_packet : fec_packets) {
if (_rtpSender.SendToNetwork( if (rtp_sender_->SendToNetwork(
fec_packet->data(), fec_packet->length() - rtp_header_length, fec_packet->data(), fec_packet->length() - rtp_header_length,
rtp_header_length, capture_time_ms, fec_storage, rtp_header_length, capture_time_ms, fec_storage,
RtpPacketSender::kLowPriority) == 0) { RtpPacketSender::kLowPriority) == 0) {
@ -171,28 +157,25 @@ void RTPSenderVideo::SendVideoPacketAsRed(uint8_t* data_buffer,
} }
} }
void RTPSenderVideo::SetGenericFECStatus(const bool enable, void RTPSenderVideo::SetGenericFECStatus(bool enable,
const uint8_t payloadTypeRED, uint8_t payload_type_red,
const uint8_t payloadTypeFEC) { uint8_t payload_type_fec) {
RTC_DCHECK(!enable || payloadTypeRED > 0); RTC_DCHECK(!enable || payload_type_red > 0);
rtc::CritScope cs(&crit_); rtc::CritScope cs(&crit_);
fec_enabled_ = enable; fec_enabled_ = enable;
red_payload_type_ = payloadTypeRED; red_payload_type_ = payload_type_red;
fec_payload_type_ = payloadTypeFEC; fec_payload_type_ = payload_type_fec;
memset(&delta_fec_params_, 0, sizeof(delta_fec_params_)); delta_fec_params_ = FecProtectionParams{0, 1, kFecMaskRandom};
memset(&key_fec_params_, 0, sizeof(key_fec_params_)); key_fec_params_ = FecProtectionParams{0, 1, kFecMaskRandom};
delta_fec_params_.max_fec_frames = key_fec_params_.max_fec_frames = 1;
delta_fec_params_.fec_mask_type = key_fec_params_.fec_mask_type =
kFecMaskRandom;
} }
void RTPSenderVideo::GenericFECStatus(bool* enable, void RTPSenderVideo::GenericFECStatus(bool* enable,
uint8_t* payloadTypeRED, uint8_t* payload_type_red,
uint8_t* payloadTypeFEC) const { uint8_t* payload_type_fec) const {
rtc::CritScope cs(&crit_); rtc::CritScope cs(&crit_);
*enable = fec_enabled_; *enable = fec_enabled_;
*payloadTypeRED = red_payload_type_; *payload_type_red = red_payload_type_;
*payloadTypeFEC = fec_payload_type_; *payload_type_fec = fec_payload_type_;
} }
size_t RTPSenderVideo::FECPacketOverhead() const { size_t RTPSenderVideo::FECPacketOverhead() const {
@ -205,7 +188,7 @@ size_t RTPSenderVideo::FECPacketOverhead() const {
// from an FEC viewpoint, they are part of the payload to be protected. // from an FEC viewpoint, they are part of the payload to be protected.
// (The base RTP header is already protected by the FEC header.) // (The base RTP header is already protected by the FEC header.)
return ForwardErrorCorrection::PacketOverhead() + REDForFECHeaderLength + return ForwardErrorCorrection::PacketOverhead() + REDForFECHeaderLength +
(_rtpSender.RtpHeaderLength() - kRtpHeaderSize); (rtp_sender_->RtpHeaderLength() - kRtpHeaderSize);
} }
if (fec_enabled_) if (fec_enabled_)
overhead += ForwardErrorCorrection::PacketOverhead(); overhead += ForwardErrorCorrection::PacketOverhead();
@ -223,22 +206,22 @@ void RTPSenderVideo::SetFecParameters(const FecProtectionParams* delta_params,
} }
} }
int32_t RTPSenderVideo::SendVideo(const RtpVideoCodecTypes videoType, int32_t RTPSenderVideo::SendVideo(RtpVideoCodecTypes video_type,
const FrameType frameType, FrameType frame_type,
const int8_t payloadType, int8_t payload_type,
const uint32_t captureTimeStamp, uint32_t capture_timestamp,
int64_t capture_time_ms, int64_t capture_time_ms,
const uint8_t* payloadData, const uint8_t* payload_data,
const size_t payloadSize, size_t payload_size,
const RTPFragmentationHeader* fragmentation, const RTPFragmentationHeader* fragmentation,
const RTPVideoHeader* video_header) { const RTPVideoHeader* video_header) {
if (payloadSize == 0) { if (payload_size == 0) {
return -1; return -1;
} }
std::unique_ptr<RtpPacketizer> packetizer(RtpPacketizer::Create( std::unique_ptr<RtpPacketizer> packetizer(RtpPacketizer::Create(
videoType, _rtpSender.MaxDataPayloadLength(), video_type, rtp_sender_->MaxDataPayloadLength(),
video_header ? &(video_header->codecHeader) : nullptr, frameType)); video_header ? &(video_header->codecHeader) : nullptr, frame_type));
StorageType storage; StorageType storage;
int red_payload_type; int red_payload_type;
@ -246,9 +229,9 @@ int32_t RTPSenderVideo::SendVideo(const RtpVideoCodecTypes videoType,
{ {
rtc::CritScope cs(&crit_); rtc::CritScope cs(&crit_);
FecProtectionParams* fec_params = FecProtectionParams* fec_params =
frameType == kVideoFrameKey ? &key_fec_params_ : &delta_fec_params_; frame_type == kVideoFrameKey ? &key_fec_params_ : &delta_fec_params_;
producer_fec_.SetFecParameters(fec_params, 0); producer_fec_.SetFecParameters(fec_params, 0);
storage = packetizer->GetStorageType(_retransmissionSettings); storage = packetizer->GetStorageType(retransmission_settings_);
red_payload_type = red_payload_type_; red_payload_type = red_payload_type_;
} }
@ -256,18 +239,18 @@ int32_t RTPSenderVideo::SendVideo(const RtpVideoCodecTypes videoType,
// with pending rotation. // with pending rotation.
bool video_rotation_active = false; bool video_rotation_active = false;
if (video_header && video_header->rotation != kVideoRotation_0) { if (video_header && video_header->rotation != kVideoRotation_0) {
video_rotation_active = _rtpSender.ActivateCVORtpHeaderExtension(); video_rotation_active = rtp_sender_->ActivateCVORtpHeaderExtension();
} }
int rtp_header_length = _rtpSender.RtpHeaderLength(); int rtp_header_length = rtp_sender_->RtpHeaderLength();
size_t payload_bytes_to_send = payloadSize; size_t payload_bytes_to_send = payload_size;
const uint8_t* data = payloadData; const uint8_t* data = payload_data;
// TODO(changbin): we currently don't support to configure the codec to // TODO(changbin): we currently don't support to configure the codec to
// output multiple partitions for VP8. Should remove below check after the // output multiple partitions for VP8. Should remove below check after the
// issue is fixed. // issue is fixed.
const RTPFragmentationHeader* frag = const RTPFragmentationHeader* frag =
(videoType == kRtpVideoVp8) ? NULL : fragmentation; (video_type == kRtpVideoVp8) ? NULL : fragmentation;
packetizer->SetPayloadData(data, payload_bytes_to_send, frag); packetizer->SetPayloadData(data, payload_bytes_to_send, frag);
@ -283,8 +266,8 @@ int32_t RTPSenderVideo::SendVideo(const RtpVideoCodecTypes videoType,
} }
// Write RTP header. // Write RTP header.
_rtpSender.BuildRTPheader( rtp_sender_->BuildRtpHeader(dataBuffer, payload_type, last,
dataBuffer, payloadType, last, captureTimeStamp, capture_time_ms); capture_timestamp, capture_time_ms);
// According to // According to
// http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/
@ -298,7 +281,7 @@ int32_t RTPSenderVideo::SendVideo(const RtpVideoCodecTypes videoType,
// value sent. // value sent.
// Here we are adding it to every packet of every frame at this point. // Here we are adding it to every packet of every frame at this point.
if (!video_header) { if (!video_header) {
RTC_DCHECK(!_rtpSender.IsRtpHeaderExtensionRegistered( RTC_DCHECK(!rtp_sender_->IsRtpHeaderExtensionRegistered(
kRtpExtensionVideoRotation)); kRtpExtensionVideoRotation));
} else if (video_rotation_active) { } else if (video_rotation_active) {
// Checking whether CVO header extension is registered will require taking // Checking whether CVO header extension is registered will require taking
@ -306,21 +289,21 @@ int32_t RTPSenderVideo::SendVideo(const RtpVideoCodecTypes videoType,
// TODO(guoweis): For now, all packets sent will carry the CVO such that // TODO(guoweis): For now, all packets sent will carry the CVO such that
// the RTP header length is consistent, although the receiver side will // the RTP header length is consistent, although the receiver side will
// only exam the packets with marker bit set. // only exam the packets with marker bit set.
size_t packetSize = payloadSize + rtp_header_length; size_t packetSize = payload_size + rtp_header_length;
RtpUtility::RtpHeaderParser rtp_parser(dataBuffer, packetSize); RtpUtility::RtpHeaderParser rtp_parser(dataBuffer, packetSize);
RTPHeader rtp_header; RTPHeader rtp_header;
rtp_parser.Parse(&rtp_header); rtp_parser.Parse(&rtp_header);
_rtpSender.UpdateVideoRotation(dataBuffer, packetSize, rtp_header, rtp_sender_->UpdateVideoRotation(dataBuffer, packetSize, rtp_header,
video_header->rotation); video_header->rotation);
} }
if (red_payload_type != 0) { if (red_payload_type != 0) {
SendVideoPacketAsRed(dataBuffer, payload_bytes_in_packet, SendVideoPacketAsRed(dataBuffer, payload_bytes_in_packet,
rtp_header_length, _rtpSender.SequenceNumber(), rtp_header_length, rtp_sender_->SequenceNumber(),
captureTimeStamp, capture_time_ms, storage, capture_timestamp, capture_time_ms, storage,
packetizer->GetProtectionType() == kProtectedPacket); packetizer->GetProtectionType() == kProtectedPacket);
} else { } else {
SendVideoPacket(dataBuffer, payload_bytes_in_packet, rtp_header_length, SendVideoPacket(dataBuffer, payload_bytes_in_packet, rtp_header_length,
_rtpSender.SequenceNumber(), captureTimeStamp, rtp_sender_->SequenceNumber(), capture_timestamp,
capture_time_ms, storage); capture_time_ms, storage);
} }
@ -337,8 +320,8 @@ int32_t RTPSenderVideo::SendVideo(const RtpVideoCodecTypes videoType,
first = false; first = false;
} }
TRACE_EVENT_ASYNC_END1( TRACE_EVENT_ASYNC_END1("webrtc", "Video", capture_time_ms, "timestamp",
"webrtc", "Video", capture_time_ms, "timestamp", _rtpSender.Timestamp()); rtp_sender_->Timestamp());
return 0; return 0;
} }
@ -354,12 +337,12 @@ uint32_t RTPSenderVideo::FecOverheadRate() const {
int RTPSenderVideo::SelectiveRetransmissions() const { int RTPSenderVideo::SelectiveRetransmissions() const {
rtc::CritScope cs(&crit_); rtc::CritScope cs(&crit_);
return _retransmissionSettings; return retransmission_settings_;
} }
void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) { void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) {
rtc::CritScope cs(&crit_); rtc::CritScope cs(&crit_);
_retransmissionSettings = settings; retransmission_settings_ = settings;
} }
} // namespace webrtc } // namespace webrtc

View File

@ -31,7 +31,7 @@ namespace webrtc {
class RTPSenderVideo { class RTPSenderVideo {
public: public:
RTPSenderVideo(Clock* clock, RTPSenderInterface* rtpSender); RTPSenderVideo(Clock* clock, RTPSenderInterface* rtp_sender);
virtual ~RTPSenderVideo(); virtual ~RTPSenderVideo();
virtual RtpVideoCodecTypes VideoCodecType() const; virtual RtpVideoCodecTypes VideoCodecType() const;
@ -39,16 +39,16 @@ class RTPSenderVideo {
size_t FECPacketOverhead() const; size_t FECPacketOverhead() const;
static RtpUtility::Payload* CreateVideoPayload( static RtpUtility::Payload* CreateVideoPayload(
const char payloadName[RTP_PAYLOAD_NAME_SIZE], const char payload_name[RTP_PAYLOAD_NAME_SIZE],
const int8_t payloadType); int8_t payload_type);
int32_t SendVideo(const RtpVideoCodecTypes videoType, int32_t SendVideo(RtpVideoCodecTypes video_type,
const FrameType frameType, FrameType frame_type,
const int8_t payloadType, int8_t payload_type,
const uint32_t captureTimeStamp, uint32_t capture_timestamp,
int64_t capture_time_ms, int64_t capture_time_ms,
const uint8_t* payloadData, const uint8_t* payload_data,
const size_t payloadSize, size_t payload_size,
const RTPFragmentationHeader* fragmentation, const RTPFragmentationHeader* fragmentation,
const RTPVideoHeader* video_header); const RTPVideoHeader* video_header);
@ -57,13 +57,13 @@ class RTPSenderVideo {
void SetVideoCodecType(RtpVideoCodecTypes type); void SetVideoCodecType(RtpVideoCodecTypes type);
// FEC // FEC
void SetGenericFECStatus(const bool enable, void SetGenericFECStatus(bool enable,
const uint8_t payloadTypeRED, uint8_t payload_type_red,
const uint8_t payloadTypeFEC); uint8_t payload_type_fec);
void GenericFECStatus(bool* enable, void GenericFECStatus(bool* enable,
uint8_t* payloadTypeRED, uint8_t* payload_type_red,
uint8_t* payloadTypeFEC) const; uint8_t* payload_type_fec) const;
void SetFecParameters(const FecProtectionParams* delta_params, void SetFecParameters(const FecProtectionParams* delta_params,
const FecProtectionParams* key_params); const FecProtectionParams* key_params);
@ -75,39 +75,41 @@ class RTPSenderVideo {
void SetSelectiveRetransmissions(uint8_t settings); void SetSelectiveRetransmissions(uint8_t settings);
private: private:
void SendVideoPacket(uint8_t* dataBuffer, void SendVideoPacket(uint8_t* data_buffer,
const size_t payloadLength, size_t payload_length,
const size_t rtpHeaderLength, size_t rtp_header_length,
uint16_t seq_num, uint16_t seq_num,
const uint32_t capture_timestamp, uint32_t capture_timestamp,
int64_t capture_time_ms, int64_t capture_time_ms,
StorageType storage); StorageType storage);
void SendVideoPacketAsRed(uint8_t* dataBuffer, void SendVideoPacketAsRed(uint8_t* data_buffer,
const size_t payloadLength, size_t payload_length,
const size_t rtpHeaderLength, size_t rtp_header_length,
uint16_t video_seq_num, uint16_t video_seq_num,
const uint32_t capture_timestamp, uint32_t capture_timestamp,
int64_t capture_time_ms, int64_t capture_time_ms,
StorageType media_packet_storage, StorageType media_packet_storage,
bool protect); bool protect);
RTPSenderInterface& _rtpSender; RTPSenderInterface* const rtp_sender_;
Clock* const clock_; Clock* const clock_;
// Should never be held when calling out of this class. // Should never be held when calling out of this class.
rtc::CriticalSection crit_; rtc::CriticalSection crit_;
RtpVideoCodecTypes _videoType; RtpVideoCodecTypes video_type_ = kRtpVideoGeneric;
int32_t _retransmissionSettings GUARDED_BY(crit_); int32_t retransmission_settings_ GUARDED_BY(crit_) = kRetransmitBaseLayer;
// FEC // FEC
ForwardErrorCorrection fec_; ForwardErrorCorrection fec_;
bool fec_enabled_ GUARDED_BY(crit_); bool fec_enabled_ GUARDED_BY(crit_) = false;
int8_t red_payload_type_ GUARDED_BY(crit_); int8_t red_payload_type_ GUARDED_BY(crit_) = 0;
int8_t fec_payload_type_ GUARDED_BY(crit_); int8_t fec_payload_type_ GUARDED_BY(crit_) = 0;
FecProtectionParams delta_fec_params_ GUARDED_BY(crit_); FecProtectionParams delta_fec_params_ GUARDED_BY(crit_) = FecProtectionParams{
FecProtectionParams key_fec_params_ GUARDED_BY(crit_); 0, 1, kFecMaskRandom};
FecProtectionParams key_fec_params_ GUARDED_BY(crit_) = FecProtectionParams{
0, 1, kFecMaskRandom};
ProducerFec producer_fec_ GUARDED_BY(crit_); ProducerFec producer_fec_ GUARDED_BY(crit_);
rtc::CriticalSection stats_crit_; rtc::CriticalSection stats_crit_;
@ -118,6 +120,7 @@ class RTPSenderVideo {
RateStatistics video_bitrate_ GUARDED_BY(stats_crit_); RateStatistics video_bitrate_ GUARDED_BY(stats_crit_);
OneTimeEvent first_frame_sent_; OneTimeEvent first_frame_sent_;
}; };
} // namespace webrtc } // namespace webrtc
#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_VIDEO_H_ #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_VIDEO_H_

View File

@ -90,13 +90,13 @@ class RtpStreamReceiver : public RtpData, public RtpFeedback,
bool OnRecoveredPacket(const uint8_t* packet, size_t packet_length) override; bool OnRecoveredPacket(const uint8_t* packet, size_t packet_length) override;
// Implements RtpFeedback. // Implements RtpFeedback.
int32_t OnInitializeDecoder(const int8_t payload_type, int32_t OnInitializeDecoder(int8_t payload_type,
const char payload_name[RTP_PAYLOAD_NAME_SIZE], const char payload_name[RTP_PAYLOAD_NAME_SIZE],
const int frequency, int frequency,
const size_t channels, size_t channels,
const uint32_t rate) override; uint32_t rate) override;
void OnIncomingSSRCChanged(const uint32_t ssrc) override; void OnIncomingSSRCChanged(uint32_t ssrc) override;
void OnIncomingCSRCChanged(const uint32_t CSRC, const bool added) override {} void OnIncomingCSRCChanged(uint32_t CSRC, bool added) override {}
// Implements VCMFrameTypeCallback. // Implements VCMFrameTypeCallback.
int32_t RequestKeyFrame() override; int32_t RequestKeyFrame() override;