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:
@ -144,13 +144,9 @@ size_t GenerateRtpPacket(uint32_t extensions_bitvector,
|
||||
bool marker_bit = prng->Rand<bool>();
|
||||
uint32_t capture_timestamp = 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++) {
|
||||
packet[i] = prng->Rand<uint8_t>();
|
||||
}
|
||||
|
||||
@ -29,24 +29,24 @@ class RTPPayloadStrategy {
|
||||
virtual bool CodecsMustBeUnique() const = 0;
|
||||
|
||||
virtual bool PayloadIsCompatible(const RtpUtility::Payload& payload,
|
||||
const uint32_t frequency,
|
||||
const size_t channels,
|
||||
const uint32_t rate) const = 0;
|
||||
uint32_t frequency,
|
||||
size_t channels,
|
||||
uint32_t rate) const = 0;
|
||||
|
||||
virtual void UpdatePayloadRate(RtpUtility::Payload* payload,
|
||||
const uint32_t rate) const = 0;
|
||||
uint32_t rate) const = 0;
|
||||
|
||||
virtual RtpUtility::Payload* CreatePayloadType(
|
||||
const char payloadName[RTP_PAYLOAD_NAME_SIZE],
|
||||
const int8_t payloadType,
|
||||
const uint32_t frequency,
|
||||
const size_t channels,
|
||||
const uint32_t rate) const = 0;
|
||||
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
|
||||
int8_t payload_type,
|
||||
uint32_t frequency,
|
||||
size_t channels,
|
||||
uint32_t rate) const = 0;
|
||||
|
||||
virtual int GetPayloadTypeFrequency(
|
||||
const RtpUtility::Payload& payload) const = 0;
|
||||
|
||||
static RTPPayloadStrategy* CreateStrategy(const bool handling_audio);
|
||||
static RTPPayloadStrategy* CreateStrategy(bool handling_audio);
|
||||
|
||||
protected:
|
||||
RTPPayloadStrategy() {}
|
||||
@ -58,22 +58,19 @@ class RTPPayloadRegistry {
|
||||
explicit RTPPayloadRegistry(RTPPayloadStrategy* rtp_payload_strategy);
|
||||
~RTPPayloadRegistry();
|
||||
|
||||
int32_t RegisterReceivePayload(
|
||||
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
|
||||
const int8_t payload_type,
|
||||
const uint32_t frequency,
|
||||
const size_t channels,
|
||||
const uint32_t rate,
|
||||
int32_t RegisterReceivePayload(const char payload_name[RTP_PAYLOAD_NAME_SIZE],
|
||||
int8_t payload_type,
|
||||
uint32_t frequency,
|
||||
size_t channels,
|
||||
uint32_t rate,
|
||||
bool* created_new_payload_type);
|
||||
|
||||
int32_t DeRegisterReceivePayload(
|
||||
const int8_t payload_type);
|
||||
int32_t DeRegisterReceivePayload(int8_t payload_type);
|
||||
|
||||
int32_t ReceivePayloadType(
|
||||
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
|
||||
const uint32_t frequency,
|
||||
const size_t channels,
|
||||
const uint32_t rate,
|
||||
int32_t ReceivePayloadType(const char payload_name[RTP_PAYLOAD_NAME_SIZE],
|
||||
uint32_t frequency,
|
||||
size_t channels,
|
||||
uint32_t rate,
|
||||
int8_t* payload_type) const;
|
||||
|
||||
bool RtxEnabled() const;
|
||||
@ -154,10 +151,10 @@ class RTPPayloadRegistry {
|
||||
// Prunes the payload type map of the specific payload type, if it exists.
|
||||
void DeregisterAudioCodecOrRedTypeRegardlessOfPayloadType(
|
||||
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
|
||||
const size_t payload_name_length,
|
||||
const uint32_t frequency,
|
||||
const size_t channels,
|
||||
const uint32_t rate);
|
||||
size_t payload_name_length,
|
||||
uint32_t frequency,
|
||||
size_t channels,
|
||||
uint32_t rate);
|
||||
|
||||
bool IsRtxInternal(const RTPHeader& header) const;
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
#include "webrtc/modules/video_coding/include/video_coding_defines.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// Forward declarations.
|
||||
class RateLimiter;
|
||||
class ReceiveStatistics;
|
||||
@ -41,176 +42,127 @@ class RtpRtcp : public Module {
|
||||
struct Configuration {
|
||||
Configuration();
|
||||
|
||||
/* id - Unique identifier of this RTP/RTCP module object
|
||||
* audio - True for a audio version of the RTP/RTCP module
|
||||
* object false will create a video version
|
||||
* clock - The clock to use to read time. If NULL object
|
||||
* will be using the system clock.
|
||||
* incoming_data - Callback object that will receive the incoming
|
||||
* data. May not be NULL; default callback will do
|
||||
* nothing.
|
||||
* incoming_messages - Callback object that will receive the incoming
|
||||
* RTP messages. May not be NULL; default callback
|
||||
* will do nothing.
|
||||
* outgoing_transport - Transport object that will be called when packets
|
||||
* are ready to be sent out on the network
|
||||
* intra_frame_callback - Called when the receiver request a intra frame.
|
||||
* bandwidth_callback - Called when we receive a changed estimate from
|
||||
* the receiver of out stream.
|
||||
* remote_bitrate_estimator - Estimates the bandwidth available for a set of
|
||||
* streams from the same client.
|
||||
* paced_sender - Spread any bursts of packets into smaller
|
||||
* bursts to minimize packet loss.
|
||||
*/
|
||||
bool audio;
|
||||
bool receiver_only;
|
||||
Clock* clock;
|
||||
// True for a audio version of the RTP/RTCP module object false will create
|
||||
// a video version.
|
||||
bool audio = false;
|
||||
bool receiver_only = false;
|
||||
|
||||
// The clock to use to read time. If nullptr then system clock will be used.
|
||||
Clock* clock = nullptr;
|
||||
|
||||
ReceiveStatistics* receive_statistics;
|
||||
Transport* outgoing_transport;
|
||||
RtcpIntraFrameObserver* intra_frame_callback;
|
||||
RtcpBandwidthObserver* bandwidth_callback;
|
||||
TransportFeedbackObserver* transport_feedback_callback;
|
||||
RtcpRttStats* rtt_stats;
|
||||
RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer;
|
||||
RemoteBitrateEstimator* remote_bitrate_estimator;
|
||||
RtpPacketSender* paced_sender;
|
||||
TransportSequenceNumberAllocator* transport_sequence_number_allocator;
|
||||
BitrateStatisticsObserver* send_bitrate_observer;
|
||||
FrameCountObserver* send_frame_count_observer;
|
||||
SendSideDelayObserver* send_side_delay_observer;
|
||||
RtcEventLog* event_log;
|
||||
SendPacketObserver* send_packet_observer;
|
||||
RateLimiter* retransmission_rate_limiter;
|
||||
|
||||
// Transport object that will be called when packets are ready to be sent
|
||||
// out on the network.
|
||||
Transport* outgoing_transport = nullptr;
|
||||
|
||||
// Called when the receiver request a intra frame.
|
||||
RtcpIntraFrameObserver* intra_frame_callback = nullptr;
|
||||
|
||||
// Called when we receive a changed estimate from the receiver of out
|
||||
// stream.
|
||||
RtcpBandwidthObserver* bandwidth_callback = nullptr;
|
||||
|
||||
TransportFeedbackObserver* transport_feedback_callback = nullptr;
|
||||
RtcpRttStats* rtt_stats = nullptr;
|
||||
RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer = nullptr;
|
||||
|
||||
// Estimates the bandwidth available for a set of streams from the same
|
||||
// client.
|
||||
RemoteBitrateEstimator* remote_bitrate_estimator = nullptr;
|
||||
|
||||
// Spread any bursts of packets into smaller bursts to minimize packet loss.
|
||||
RtpPacketSender* paced_sender = nullptr;
|
||||
|
||||
TransportSequenceNumberAllocator* transport_sequence_number_allocator =
|
||||
nullptr;
|
||||
BitrateStatisticsObserver* send_bitrate_observer = nullptr;
|
||||
FrameCountObserver* send_frame_count_observer = nullptr;
|
||||
SendSideDelayObserver* send_side_delay_observer = nullptr;
|
||||
RtcEventLog* event_log = nullptr;
|
||||
SendPacketObserver* send_packet_observer = nullptr;
|
||||
RateLimiter* retransmission_rate_limiter = nullptr;
|
||||
|
||||
private:
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(Configuration);
|
||||
};
|
||||
|
||||
/*
|
||||
* Create a RTP/RTCP module object using the system clock.
|
||||
*
|
||||
* configuration - Configuration of the RTP/RTCP module.
|
||||
*/
|
||||
// Create a RTP/RTCP module object using the system clock.
|
||||
// |configuration| - Configuration of the RTP/RTCP module.
|
||||
static RtpRtcp* CreateRtpRtcp(const RtpRtcp::Configuration& configuration);
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Receiver functions
|
||||
*
|
||||
***************************************************************************/
|
||||
// **************************************************************************
|
||||
// Receiver functions
|
||||
// **************************************************************************
|
||||
|
||||
virtual int32_t IncomingRtcpPacket(const uint8_t* incoming_packet,
|
||||
size_t incoming_packet_length) = 0;
|
||||
|
||||
virtual void SetRemoteSSRC(uint32_t ssrc) = 0;
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Sender
|
||||
*
|
||||
***************************************************************************/
|
||||
// **************************************************************************
|
||||
// Sender
|
||||
// **************************************************************************
|
||||
|
||||
/*
|
||||
* set MTU
|
||||
*
|
||||
* size - Max transfer unit in bytes, default is 1500
|
||||
*
|
||||
* return -1 on failure else 0
|
||||
*/
|
||||
// Sets MTU.
|
||||
// |size| - Max transfer unit in bytes, default is 1500.
|
||||
// Returns -1 on failure else 0.
|
||||
virtual int32_t SetMaxTransferUnit(uint16_t size) = 0;
|
||||
|
||||
/*
|
||||
* set transtport overhead
|
||||
* default is IPv4 and UDP with no encryption
|
||||
*
|
||||
* TCP - true for TCP false UDP
|
||||
* IPv6 - true for IP version 6 false for version 4
|
||||
* authenticationOverhead - number of bytes to leave for an
|
||||
* authentication header
|
||||
*
|
||||
* return -1 on failure else 0
|
||||
*/
|
||||
virtual int32_t SetTransportOverhead(
|
||||
bool TCP,
|
||||
bool IPV6,
|
||||
uint8_t authenticationOverhead = 0) = 0;
|
||||
// Sets transtport overhead. Default is IPv4 and UDP with no encryption.
|
||||
// |tcp| - true for TCP false UDP.
|
||||
// |ipv6| - true for IP version 6 false for version 4.
|
||||
// |authentication_overhead| - number of bytes to leave for an authentication
|
||||
// header.
|
||||
// Returns -1 on failure else 0
|
||||
virtual int32_t SetTransportOverhead(bool tcp,
|
||||
bool ipv6,
|
||||
uint8_t authentication_overhead = 0) = 0;
|
||||
|
||||
/*
|
||||
* Get max payload length
|
||||
*
|
||||
* A combination of the configuration MaxTransferUnit and
|
||||
* TransportOverhead.
|
||||
* Does not account FEC/ULP/RED overhead if FEC is enabled.
|
||||
* Does not account for RTP headers
|
||||
*/
|
||||
// Returns max payload length, which is a combination of the configuration
|
||||
// MaxTransferUnit and TransportOverhead.
|
||||
// Does not account for RTP headers and FEC/ULP/RED overhead (when FEC is
|
||||
// enabled).
|
||||
virtual uint16_t MaxPayloadLength() const = 0;
|
||||
|
||||
/*
|
||||
* Get max data payload length
|
||||
*
|
||||
* A combination of the configuration MaxTransferUnit, headers and
|
||||
* TransportOverhead.
|
||||
* Takes into account FEC/ULP/RED overhead if FEC is enabled.
|
||||
* Takes into account RTP headers
|
||||
*/
|
||||
// Returns max data payload length, which is a combination of the
|
||||
// configuration MaxTransferUnit, headers and TransportOverhead.
|
||||
// Takes into account RTP headers and FEC/ULP/RED overhead (when FEC is
|
||||
// enabled).
|
||||
virtual uint16_t MaxDataPayloadLength() const = 0;
|
||||
|
||||
/*
|
||||
* set codec name and payload type
|
||||
*
|
||||
* return -1 on failure else 0
|
||||
*/
|
||||
virtual int32_t RegisterSendPayload(
|
||||
const CodecInst& voiceCodec) = 0;
|
||||
// Sets codec name and payload type. Returns -1 on failure else 0.
|
||||
virtual int32_t RegisterSendPayload(const CodecInst& voice_codec) = 0;
|
||||
|
||||
/*
|
||||
* set codec name and payload type
|
||||
*
|
||||
* return -1 on failure else 0
|
||||
*/
|
||||
virtual int32_t RegisterSendPayload(
|
||||
const VideoCodec& videoCodec) = 0;
|
||||
// Sets codec name and payload type. Return -1 on failure else 0.
|
||||
virtual int32_t RegisterSendPayload(const VideoCodec& video_codec) = 0;
|
||||
|
||||
virtual void RegisterVideoSendPayload(int payload_type,
|
||||
const char* payload_name) = 0;
|
||||
|
||||
/*
|
||||
* Unregister a send payload
|
||||
*
|
||||
* payloadType - payload type of codec
|
||||
*
|
||||
* return -1 on failure else 0
|
||||
*/
|
||||
virtual int32_t DeRegisterSendPayload(int8_t payloadType) = 0;
|
||||
// Unregisters a send payload.
|
||||
// |payload_type| - payload type of codec
|
||||
// Returns -1 on failure else 0.
|
||||
virtual int32_t DeRegisterSendPayload(int8_t payload_type) = 0;
|
||||
|
||||
/*
|
||||
* (De)register RTP header extension type and id.
|
||||
*
|
||||
* return -1 on failure else 0
|
||||
*/
|
||||
// (De)registers RTP header extension type and id.
|
||||
// Returns -1 on failure else 0.
|
||||
virtual int32_t RegisterSendRtpHeaderExtension(RTPExtensionType type,
|
||||
uint8_t id) = 0;
|
||||
|
||||
virtual int32_t DeregisterSendRtpHeaderExtension(RTPExtensionType type) = 0;
|
||||
|
||||
/*
|
||||
* get start timestamp
|
||||
*/
|
||||
// Returns start timestamp.
|
||||
virtual uint32_t StartTimestamp() const = 0;
|
||||
|
||||
/*
|
||||
* configure start timestamp, default is a random number
|
||||
*
|
||||
* timestamp - start timestamp
|
||||
*/
|
||||
// Sets start timestamp. Start timestamp is set to a random value if this
|
||||
// function is never called.
|
||||
virtual void SetStartTimestamp(uint32_t timestamp) = 0;
|
||||
|
||||
/*
|
||||
* Get SequenceNumber
|
||||
*/
|
||||
// Returns SequenceNumber.
|
||||
virtual uint16_t SequenceNumber() const = 0;
|
||||
|
||||
/*
|
||||
* Set SequenceNumber, default is a random number
|
||||
*/
|
||||
// Sets SequenceNumber, default is a random number.
|
||||
virtual void SetSequenceNumber(uint16_t seq) = 0;
|
||||
|
||||
virtual void SetRtpState(const RtpState& rtp_state) = 0;
|
||||
@ -218,33 +170,22 @@ class RtpRtcp : public Module {
|
||||
virtual RtpState GetRtpState() const = 0;
|
||||
virtual RtpState GetRtxState() const = 0;
|
||||
|
||||
/*
|
||||
* Get SSRC
|
||||
*/
|
||||
// Returns SSRC.
|
||||
virtual uint32_t SSRC() const = 0;
|
||||
|
||||
/*
|
||||
* configure SSRC, default is a random number
|
||||
*/
|
||||
// Sets SSRC, default is a random number.
|
||||
virtual void SetSSRC(uint32_t ssrc) = 0;
|
||||
|
||||
/*
|
||||
* Set CSRC
|
||||
*
|
||||
* csrcs - vector of CSRCs
|
||||
*/
|
||||
// Sets CSRC.
|
||||
// |csrcs| - vector of CSRCs
|
||||
virtual void SetCsrcs(const std::vector<uint32_t>& csrcs) = 0;
|
||||
|
||||
/*
|
||||
* Turn on/off sending RTX (RFC 4588). The modes can be set as a combination
|
||||
* of values of the enumerator RtxMode.
|
||||
*/
|
||||
// Turns on/off sending RTX (RFC 4588). The modes can be set as a combination
|
||||
// of values of the enumerator RtxMode.
|
||||
virtual void SetRtxSendStatus(int modes) = 0;
|
||||
|
||||
/*
|
||||
* Get status of sending RTX (RFC 4588). The returned value can be
|
||||
* a combination of values of the enumerator RtxMode.
|
||||
*/
|
||||
// Returns status of sending RTX (RFC 4588). The returned value can be
|
||||
// a combination of values of the enumerator RtxMode.
|
||||
virtual int RtxSendStatus() const = 0;
|
||||
|
||||
// Sets the SSRC to use when sending RTX packets. This doesn't enable RTX,
|
||||
@ -256,63 +197,44 @@ class RtpRtcp : public Module {
|
||||
virtual void SetRtxSendPayloadType(int payload_type,
|
||||
int associated_payload_type) = 0;
|
||||
|
||||
/*
|
||||
* sends kRtcpByeCode when going from true to false
|
||||
*
|
||||
* sending - on/off
|
||||
*
|
||||
* return -1 on failure else 0
|
||||
*/
|
||||
// Sets sending status. Sends kRtcpByeCode when going from true to false.
|
||||
// Returns -1 on failure else 0.
|
||||
virtual int32_t SetSendingStatus(bool sending) = 0;
|
||||
|
||||
/*
|
||||
* get send status
|
||||
*/
|
||||
// Returns current sending status.
|
||||
virtual bool Sending() const = 0;
|
||||
|
||||
/*
|
||||
* Starts/Stops media packets, on by default
|
||||
*
|
||||
* sending - on/off
|
||||
*/
|
||||
// Starts/Stops media packets. On by default.
|
||||
virtual void SetSendingMediaStatus(bool sending) = 0;
|
||||
|
||||
/*
|
||||
* get send status
|
||||
*/
|
||||
// Returns current media sending status.
|
||||
virtual bool SendingMedia() const = 0;
|
||||
|
||||
/*
|
||||
* get sent bitrate in Kbit/s
|
||||
*/
|
||||
virtual void BitrateSent(uint32_t* totalRate,
|
||||
uint32_t* videoRate,
|
||||
uint32_t* fecRate,
|
||||
uint32_t* nackRate) const = 0;
|
||||
// Returns current bitrate in Kbit/s.
|
||||
virtual void BitrateSent(uint32_t* total_rate,
|
||||
uint32_t* video_rate,
|
||||
uint32_t* fec_rate,
|
||||
uint32_t* nack_rate) const = 0;
|
||||
|
||||
/*
|
||||
* Used by the codec module to deliver a video or audio frame for
|
||||
* packetization.
|
||||
*
|
||||
* frameType - type of frame to send
|
||||
* payloadType - payload type of frame to send
|
||||
* timestamp - timestamp of frame to send
|
||||
* payloadData - payload buffer of frame to send
|
||||
* payloadSize - size of payload buffer to send
|
||||
* fragmentation - fragmentation offset data for fragmented frames such
|
||||
* as layers or RED
|
||||
*
|
||||
* return -1 on failure else 0
|
||||
*/
|
||||
// Used by the codec module to deliver a video or audio frame for
|
||||
// packetization.
|
||||
// |frame_type| - type of frame to send
|
||||
// |payload_type| - payload type of frame to send
|
||||
// |timestamp| - timestamp of frame to send
|
||||
// |payload_data| - payload buffer of frame to send
|
||||
// |payload_size| - size of payload buffer to send
|
||||
// |fragmentation| - fragmentation offset data for fragmented frames such
|
||||
// as layers or RED
|
||||
// Returns -1 on failure else 0.
|
||||
virtual int32_t SendOutgoingData(
|
||||
FrameType frameType,
|
||||
int8_t payloadType,
|
||||
uint32_t timeStamp,
|
||||
FrameType frame_type,
|
||||
int8_t payload_type,
|
||||
uint32_t timestamp,
|
||||
int64_t capture_time_ms,
|
||||
const uint8_t* payloadData,
|
||||
size_t payloadSize,
|
||||
const RTPFragmentationHeader* fragmentation = NULL,
|
||||
const RTPVideoHeader* rtpVideoHdr = NULL) = 0;
|
||||
const uint8_t* payload_data,
|
||||
size_t payload_size,
|
||||
const RTPFragmentationHeader* fragmentation = nullptr,
|
||||
const RTPVideoHeader* rtp_video_header = nullptr) = 0;
|
||||
|
||||
virtual bool TimeToSendPacket(uint32_t ssrc,
|
||||
uint16_t sequence_number,
|
||||
@ -325,173 +247,111 @@ class RtpRtcp : public Module {
|
||||
// Called on generation of new statistics after an RTP send.
|
||||
virtual void RegisterSendChannelRtpStatisticsCallback(
|
||||
StreamDataCountersCallback* callback) = 0;
|
||||
virtual StreamDataCountersCallback*
|
||||
GetSendChannelRtpStatisticsCallback() const = 0;
|
||||
virtual StreamDataCountersCallback* GetSendChannelRtpStatisticsCallback()
|
||||
const = 0;
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* RTCP
|
||||
*
|
||||
***************************************************************************/
|
||||
// **************************************************************************
|
||||
// RTCP
|
||||
// **************************************************************************
|
||||
|
||||
/*
|
||||
* Get RTCP status
|
||||
*/
|
||||
// Returns RTCP status.
|
||||
virtual RtcpMode RTCP() const = 0;
|
||||
|
||||
/*
|
||||
* configure RTCP status i.e on(compound or non- compound)/off
|
||||
*
|
||||
* method - RTCP method to use
|
||||
*/
|
||||
// Sets RTCP status i.e on(compound or non-compound)/off.
|
||||
// |method| - RTCP method to use.
|
||||
virtual void SetRTCPStatus(RtcpMode method) = 0;
|
||||
|
||||
/*
|
||||
* Set RTCP CName (i.e unique identifier)
|
||||
*
|
||||
* return -1 on failure else 0
|
||||
*/
|
||||
virtual int32_t SetCNAME(const char* c_name) = 0;
|
||||
// Sets RTCP CName (i.e unique identifier).
|
||||
// Returns -1 on failure else 0.
|
||||
virtual int32_t SetCNAME(const char* cname) = 0;
|
||||
|
||||
/*
|
||||
* Get remote CName
|
||||
*
|
||||
* return -1 on failure else 0
|
||||
*/
|
||||
virtual int32_t RemoteCNAME(uint32_t remoteSSRC,
|
||||
char cName[RTCP_CNAME_SIZE]) const = 0;
|
||||
// Returns remote CName.
|
||||
// Returns -1 on failure else 0.
|
||||
virtual int32_t RemoteCNAME(uint32_t remote_ssrc,
|
||||
char cname[RTCP_CNAME_SIZE]) const = 0;
|
||||
|
||||
/*
|
||||
* Get remote NTP
|
||||
*
|
||||
* return -1 on failure else 0
|
||||
*/
|
||||
virtual int32_t RemoteNTP(
|
||||
uint32_t *ReceivedNTPsecs,
|
||||
uint32_t *ReceivedNTPfrac,
|
||||
uint32_t *RTCPArrivalTimeSecs,
|
||||
uint32_t *RTCPArrivalTimeFrac,
|
||||
// Returns remote NTP.
|
||||
// Returns -1 on failure else 0.
|
||||
virtual int32_t RemoteNTP(uint32_t* received_ntp_secs,
|
||||
uint32_t* received_ntp_frac,
|
||||
uint32_t* rtcp_arrival_time_secs,
|
||||
uint32_t* rtcp_arrival_time_frac,
|
||||
uint32_t* rtcp_timestamp) const = 0;
|
||||
|
||||
/*
|
||||
* AddMixedCNAME
|
||||
*
|
||||
* return -1 on failure else 0
|
||||
*/
|
||||
virtual int32_t AddMixedCNAME(uint32_t SSRC, const char* c_name) = 0;
|
||||
// Returns -1 on failure else 0.
|
||||
virtual int32_t AddMixedCNAME(uint32_t ssrc, const char* cname) = 0;
|
||||
|
||||
/*
|
||||
* RemoveMixedCNAME
|
||||
*
|
||||
* return -1 on failure else 0
|
||||
*/
|
||||
virtual int32_t RemoveMixedCNAME(uint32_t SSRC) = 0;
|
||||
// Returns -1 on failure else 0.
|
||||
virtual int32_t RemoveMixedCNAME(uint32_t ssrc) = 0;
|
||||
|
||||
/*
|
||||
* Get RoundTripTime
|
||||
*
|
||||
* return -1 on failure else 0
|
||||
*/
|
||||
virtual int32_t RTT(uint32_t remoteSSRC,
|
||||
int64_t* RTT,
|
||||
int64_t* avgRTT,
|
||||
int64_t* minRTT,
|
||||
int64_t* maxRTT) const = 0;
|
||||
// Returns current RTT (round-trip time) estimate.
|
||||
// Returns -1 on failure else 0.
|
||||
virtual int32_t RTT(uint32_t remote_ssrc,
|
||||
int64_t* rtt,
|
||||
int64_t* avg_rtt,
|
||||
int64_t* min_rtt,
|
||||
int64_t* max_rtt) const = 0;
|
||||
|
||||
/*
|
||||
* Force a send of a RTCP packet
|
||||
* periodic SR and RR are triggered via the process function
|
||||
*
|
||||
* return -1 on failure else 0
|
||||
*/
|
||||
virtual int32_t SendRTCP(RTCPPacketType rtcpPacketType) = 0;
|
||||
// Forces a send of a RTCP packet. Periodic SR and RR are triggered via the
|
||||
// process function.
|
||||
// Returns -1 on failure else 0.
|
||||
virtual int32_t SendRTCP(RTCPPacketType rtcp_packet_type) = 0;
|
||||
|
||||
/*
|
||||
* Force a send of a RTCP packet with more than one packet type.
|
||||
* periodic SR and RR are triggered via the process function
|
||||
*
|
||||
* return -1 on failure else 0
|
||||
*/
|
||||
// Forces a send of a RTCP packet with more than one packet type.
|
||||
// periodic SR and RR are triggered via the process function
|
||||
// Returns -1 on failure else 0.
|
||||
virtual int32_t SendCompoundRTCP(
|
||||
const std::set<RTCPPacketType>& rtcpPacketTypes) = 0;
|
||||
const std::set<RTCPPacketType>& rtcp_packet_types) = 0;
|
||||
|
||||
/*
|
||||
* Good state of RTP receiver inform sender
|
||||
*/
|
||||
virtual int32_t SendRTCPReferencePictureSelection(uint64_t pictureID) = 0;
|
||||
// Notifies the sender about good state of the RTP receiver.
|
||||
virtual int32_t SendRTCPReferencePictureSelection(uint64_t picture_id) = 0;
|
||||
|
||||
/*
|
||||
* Send a RTCP Slice Loss Indication (SLI)
|
||||
* 6 least significant bits of pictureID
|
||||
*/
|
||||
virtual int32_t SendRTCPSliceLossIndication(uint8_t pictureID) = 0;
|
||||
// Send a RTCP Slice Loss Indication (SLI).
|
||||
// |picture_id| - 6 least significant bits of picture_id.
|
||||
virtual int32_t SendRTCPSliceLossIndication(uint8_t picture_id) = 0;
|
||||
|
||||
/*
|
||||
* Statistics of the amount of data sent
|
||||
*
|
||||
* return -1 on failure else 0
|
||||
*/
|
||||
virtual int32_t DataCountersRTP(
|
||||
size_t* bytesSent,
|
||||
uint32_t* packetsSent) const = 0;
|
||||
// Returns statistics of the amount of data sent.
|
||||
// Returns -1 on failure else 0.
|
||||
virtual int32_t DataCountersRTP(size_t* bytes_sent,
|
||||
uint32_t* packets_sent) const = 0;
|
||||
|
||||
/*
|
||||
* Get send statistics for the RTP and RTX stream.
|
||||
*/
|
||||
// Returns send statistics for the RTP and RTX stream.
|
||||
virtual void GetSendStreamDataCounters(
|
||||
StreamDataCounters* rtp_counters,
|
||||
StreamDataCounters* rtx_counters) const = 0;
|
||||
|
||||
/*
|
||||
* Get packet loss statistics for the RTP stream.
|
||||
*/
|
||||
// Returns packet loss statistics for the RTP stream.
|
||||
virtual void GetRtpPacketLossStats(
|
||||
bool outgoing,
|
||||
uint32_t ssrc,
|
||||
struct RtpPacketLossStats* loss_stats) const = 0;
|
||||
|
||||
/*
|
||||
* Get received RTCP sender info
|
||||
*
|
||||
* return -1 on failure else 0
|
||||
*/
|
||||
virtual int32_t RemoteRTCPStat(RTCPSenderInfo* senderInfo) = 0;
|
||||
// Returns received RTCP sender info.
|
||||
// Returns -1 on failure else 0.
|
||||
virtual int32_t RemoteRTCPStat(RTCPSenderInfo* sender_info) = 0;
|
||||
|
||||
/*
|
||||
* Get received RTCP report block
|
||||
*
|
||||
* return -1 on failure else 0
|
||||
*/
|
||||
// Returns received RTCP report block.
|
||||
// Returns -1 on failure else 0.
|
||||
virtual int32_t RemoteRTCPStat(
|
||||
std::vector<RTCPReportBlock>* receiveBlocks) const = 0;
|
||||
std::vector<RTCPReportBlock>* receive_blocks) const = 0;
|
||||
|
||||
/*
|
||||
* (APP) Application specific data
|
||||
*
|
||||
* return -1 on failure else 0
|
||||
*/
|
||||
virtual int32_t SetRTCPApplicationSpecificData(uint8_t subType,
|
||||
// (APP) Sets application specific data.
|
||||
// Returns -1 on failure else 0.
|
||||
virtual int32_t SetRTCPApplicationSpecificData(uint8_t sub_type,
|
||||
uint32_t name,
|
||||
const uint8_t* data,
|
||||
uint16_t length) = 0;
|
||||
/*
|
||||
* (XR) VOIP metric
|
||||
*
|
||||
* return -1 on failure else 0
|
||||
*/
|
||||
virtual int32_t SetRTCPVoIPMetrics(
|
||||
const RTCPVoIPMetric* VoIPMetric) = 0;
|
||||
// (XR) Sets VOIP metric.
|
||||
// Returns -1 on failure else 0.
|
||||
virtual int32_t SetRTCPVoIPMetrics(const RTCPVoIPMetric* VoIPMetric) = 0;
|
||||
|
||||
/*
|
||||
* (XR) Receiver Reference Time Report
|
||||
*/
|
||||
// (XR) Sets Receiver Reference Time Report (RTTR) status.
|
||||
virtual void SetRtcpXrRrtrStatus(bool enable) = 0;
|
||||
|
||||
// Returns current Receiver Reference Time Report (RTTR) status.
|
||||
virtual bool RtcpXrRrtrStatus() const = 0;
|
||||
|
||||
/*
|
||||
* (REMB) Receiver Estimated Max Bitrate
|
||||
*/
|
||||
// (REMB) Receiver Estimated Max Bitrate.
|
||||
virtual bool REMB() const = 0;
|
||||
|
||||
virtual void SetREMBStatus(bool enable) = 0;
|
||||
@ -499,59 +359,42 @@ class RtpRtcp : public Module {
|
||||
virtual void SetREMBData(uint32_t bitrate,
|
||||
const std::vector<uint32_t>& ssrcs) = 0;
|
||||
|
||||
/*
|
||||
* (TMMBR) Temporary Max Media Bit Rate
|
||||
*/
|
||||
// (TMMBR) Temporary Max Media Bit Rate
|
||||
virtual bool TMMBR() const = 0;
|
||||
|
||||
virtual void SetTMMBRStatus(bool enable) = 0;
|
||||
|
||||
/*
|
||||
* (NACK)
|
||||
*/
|
||||
// (NACK)
|
||||
|
||||
/*
|
||||
* TODO(holmer): Propagate this API to VideoEngine.
|
||||
* Returns the currently configured selective retransmission settings.
|
||||
*/
|
||||
// TODO(holmer): Propagate this API to VideoEngine.
|
||||
// Returns the currently configured selective retransmission settings.
|
||||
virtual int SelectiveRetransmissions() const = 0;
|
||||
|
||||
/*
|
||||
* TODO(holmer): Propagate this API to VideoEngine.
|
||||
* Sets the selective retransmission settings, which will decide which
|
||||
* packets will be retransmitted if NACKed. Settings are constructed by
|
||||
* combining the constants in enum RetransmissionMode with bitwise OR.
|
||||
* All packets are retransmitted if kRetransmitAllPackets is set, while no
|
||||
* packets are retransmitted if kRetransmitOff is set.
|
||||
* By default all packets except FEC packets are retransmitted. For VP8
|
||||
* with temporal scalability only base layer packets are retransmitted.
|
||||
*
|
||||
* Returns -1 on failure, otherwise 0.
|
||||
*/
|
||||
// TODO(holmer): Propagate this API to VideoEngine.
|
||||
// Sets the selective retransmission settings, which will decide which
|
||||
// packets will be retransmitted if NACKed. Settings are constructed by
|
||||
// combining the constants in enum RetransmissionMode with bitwise OR.
|
||||
// All packets are retransmitted if kRetransmitAllPackets is set, while no
|
||||
// packets are retransmitted if kRetransmitOff is set.
|
||||
// By default all packets except FEC packets are retransmitted. For VP8
|
||||
// with temporal scalability only base layer packets are retransmitted.
|
||||
// Returns -1 on failure, otherwise 0.
|
||||
virtual int SetSelectiveRetransmissions(uint8_t settings) = 0;
|
||||
|
||||
/*
|
||||
* Send a Negative acknowledgement packet
|
||||
*
|
||||
* return -1 on failure else 0
|
||||
*/
|
||||
// TODO(philipel): Deprecate this and start using SendNack instead,
|
||||
// mostly because we want a function that actually send
|
||||
// NACK for the specified packets.
|
||||
virtual int32_t SendNACK(const uint16_t* nackList, uint16_t size) = 0;
|
||||
// Sends a Negative acknowledgement packet.
|
||||
// Returns -1 on failure else 0.
|
||||
// TODO(philipel): Deprecate this and start using SendNack instead, mostly
|
||||
// because we want a function that actually send NACK for the specified
|
||||
// packets.
|
||||
virtual int32_t SendNACK(const uint16_t* nack_list, uint16_t size) = 0;
|
||||
|
||||
/*
|
||||
* Send NACK for the packets specified.
|
||||
*
|
||||
* Note: This assumes the caller keeps track of timing and doesn't rely on
|
||||
* the RTP module to do this.
|
||||
*/
|
||||
// Sends NACK for the packets specified.
|
||||
// Note: This assumes the caller keeps track of timing and doesn't rely on
|
||||
// the RTP module to do this.
|
||||
virtual void SendNack(const std::vector<uint16_t>& sequence_numbers) = 0;
|
||||
|
||||
/*
|
||||
* Store the sent packets, needed to answer to a Negative acknowledgement
|
||||
* requests
|
||||
*/
|
||||
// Store the sent packets, needed to answer to a Negative acknowledgment
|
||||
// requests.
|
||||
virtual void SetStorePacketsStatus(bool enable, uint16_t numberToStore) = 0;
|
||||
|
||||
// Returns true if the module is configured to store packets.
|
||||
@ -560,94 +403,66 @@ class RtpRtcp : public Module {
|
||||
// Called on receipt of RTCP report block from remote side.
|
||||
virtual void RegisterRtcpStatisticsCallback(
|
||||
RtcpStatisticsCallback* callback) = 0;
|
||||
virtual RtcpStatisticsCallback*
|
||||
GetRtcpStatisticsCallback() = 0;
|
||||
virtual RtcpStatisticsCallback* GetRtcpStatisticsCallback() = 0;
|
||||
// BWE feedback packets.
|
||||
virtual bool SendFeedbackPacket(const rtcp::TransportFeedback& packet) = 0;
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Audio
|
||||
*
|
||||
***************************************************************************/
|
||||
// **************************************************************************
|
||||
// Audio
|
||||
// **************************************************************************
|
||||
|
||||
/*
|
||||
* set audio packet size, used to determine when it's time to send a DTMF
|
||||
* packet in silence (CNG)
|
||||
*
|
||||
* return -1 on failure else 0
|
||||
*/
|
||||
virtual int32_t SetAudioPacketSize(uint16_t packetSizeSamples) = 0;
|
||||
// Sets audio packet size, used to determine when it's time to send a DTMF
|
||||
// packet in silence (CNG).
|
||||
// Returns -1 on failure else 0.
|
||||
virtual int32_t SetAudioPacketSize(uint16_t packet_size_samples) = 0;
|
||||
|
||||
/*
|
||||
* Send a TelephoneEvent tone using RFC 2833 (4733)
|
||||
*
|
||||
* return -1 on failure else 0
|
||||
*/
|
||||
// Sends a TelephoneEvent tone using RFC 2833 (4733).
|
||||
// Returns -1 on failure else 0.
|
||||
virtual int32_t SendTelephoneEventOutband(uint8_t key,
|
||||
uint16_t time_ms,
|
||||
uint8_t level) = 0;
|
||||
|
||||
/*
|
||||
* Set payload type for Redundant Audio Data RFC 2198
|
||||
*
|
||||
* return -1 on failure else 0
|
||||
*/
|
||||
virtual int32_t SetSendREDPayloadType(int8_t payloadType) = 0;
|
||||
// Sets payload type for Redundant Audio Data RFC 2198.
|
||||
// Returns -1 on failure else 0.
|
||||
virtual int32_t SetSendREDPayloadType(int8_t payload_type) = 0;
|
||||
|
||||
/*
|
||||
* Get payload type for Redundant Audio Data RFC 2198
|
||||
*
|
||||
* return -1 on failure else 0
|
||||
*/
|
||||
// Get payload type for Redundant Audio Data RFC 2198.
|
||||
// Returns -1 on failure else 0.
|
||||
virtual int32_t SendREDPayloadType(int8_t* payload_type) const = 0;
|
||||
/*
|
||||
* Store the audio level in dBov for header-extension-for-audio-level-
|
||||
* indication.
|
||||
* This API shall be called before transmision of an RTP packet to ensure
|
||||
* that the |level| part of the extended RTP header is updated.
|
||||
*
|
||||
* return -1 on failure else 0.
|
||||
*/
|
||||
virtual int32_t SetAudioLevel(uint8_t level_dBov) = 0;
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Video
|
||||
*
|
||||
***************************************************************************/
|
||||
// Store the audio level in dBov for header-extension-for-audio-level-
|
||||
// indication.
|
||||
// This API shall be called before transmision of an RTP packet to ensure
|
||||
// that the |level| part of the extended RTP header is updated.
|
||||
// return -1 on failure else 0.
|
||||
virtual int32_t SetAudioLevel(uint8_t level_dbov) = 0;
|
||||
|
||||
/*
|
||||
* Turn on/off generic FEC
|
||||
*/
|
||||
// **************************************************************************
|
||||
// Video
|
||||
// **************************************************************************
|
||||
|
||||
// Turn on/off generic FEC.
|
||||
virtual void SetGenericFECStatus(bool enable,
|
||||
uint8_t payload_type_red,
|
||||
uint8_t payload_type_fec) = 0;
|
||||
|
||||
/*
|
||||
* Get generic FEC setting
|
||||
*/
|
||||
// Get generic FEC setting.
|
||||
virtual void GenericFECStatus(bool* enable,
|
||||
uint8_t* payload_type_red,
|
||||
uint8_t* payload_type_fec) = 0;
|
||||
|
||||
virtual int32_t SetFecParameters(
|
||||
const FecProtectionParams* delta_params,
|
||||
virtual int32_t SetFecParameters(const FecProtectionParams* delta_params,
|
||||
const FecProtectionParams* key_params) = 0;
|
||||
|
||||
/*
|
||||
* Set method for requestion a new key frame
|
||||
*
|
||||
* return -1 on failure else 0
|
||||
*/
|
||||
// Set method for requestion a new key frame.
|
||||
// Returns -1 on failure else 0.
|
||||
virtual int32_t SetKeyFrameRequestMethod(KeyFrameRequestMethod method) = 0;
|
||||
|
||||
/*
|
||||
* send a request for a keyframe
|
||||
*
|
||||
* return -1 on failure else 0
|
||||
*/
|
||||
// Sends a request for a keyframe.
|
||||
// Returns -1 on failure else 0.
|
||||
virtual int32_t RequestKeyFrame() = 0;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_H_
|
||||
|
||||
@ -189,9 +189,9 @@ class RtpData {
|
||||
public:
|
||||
virtual ~RtpData() {}
|
||||
|
||||
virtual int32_t OnReceivedPayloadData(const uint8_t* payloadData,
|
||||
size_t payloadSize,
|
||||
const WebRtcRTPHeader* rtpHeader) = 0;
|
||||
virtual int32_t OnReceivedPayloadData(const uint8_t* payload_data,
|
||||
size_t payload_size,
|
||||
const WebRtcRTPHeader* rtp_header) = 0;
|
||||
|
||||
virtual bool OnRecoveredPacket(const uint8_t* packet,
|
||||
size_t packet_length) = 0;
|
||||
@ -206,15 +206,15 @@ class RtpFeedback {
|
||||
* channels - number of channels in codec (1 = mono, 2 = stereo)
|
||||
*/
|
||||
virtual int32_t OnInitializeDecoder(
|
||||
const int8_t payloadType,
|
||||
const char payloadName[RTP_PAYLOAD_NAME_SIZE],
|
||||
const int frequency,
|
||||
const size_t channels,
|
||||
const uint32_t rate) = 0;
|
||||
int8_t payload_type,
|
||||
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
|
||||
int frequency,
|
||||
size_t channels,
|
||||
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 {
|
||||
@ -326,16 +326,16 @@ class NullRtpFeedback : public RtpFeedback {
|
||||
public:
|
||||
virtual ~NullRtpFeedback() {}
|
||||
|
||||
int32_t OnInitializeDecoder(const int8_t payloadType,
|
||||
int32_t OnInitializeDecoder(int8_t payload_type,
|
||||
const char payloadName[RTP_PAYLOAD_NAME_SIZE],
|
||||
const int frequency,
|
||||
const size_t channels,
|
||||
const uint32_t rate) override {
|
||||
int frequency,
|
||||
size_t channels,
|
||||
uint32_t rate) override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void OnIncomingSSRCChanged(const uint32_t ssrc) override {}
|
||||
void OnIncomingCSRCChanged(const uint32_t CSRC, const bool added) override {}
|
||||
void OnIncomingSSRCChanged(uint32_t ssrc) override {}
|
||||
void OnIncomingCSRCChanged(uint32_t csrc, bool added) override {}
|
||||
};
|
||||
|
||||
// Null object version of RtpData.
|
||||
@ -343,9 +343,9 @@ class NullRtpData : public RtpData {
|
||||
public:
|
||||
virtual ~NullRtpData() {}
|
||||
|
||||
int32_t OnReceivedPayloadData(const uint8_t* payloadData,
|
||||
size_t payloadSize,
|
||||
const WebRtcRTPHeader* rtpHeader) override {
|
||||
int32_t OnReceivedPayloadData(const uint8_t* payload_data,
|
||||
size_t payload_size,
|
||||
const WebRtcRTPHeader* rtp_header) override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -27,9 +27,9 @@ namespace webrtc {
|
||||
class MockRtpData : public RtpData {
|
||||
public:
|
||||
MOCK_METHOD3(OnReceivedPayloadData,
|
||||
int32_t(const uint8_t* payloadData,
|
||||
size_t payloadSize,
|
||||
const WebRtcRTPHeader* rtpHeader));
|
||||
int32_t(const uint8_t* payload_data,
|
||||
size_t payload_size,
|
||||
const WebRtcRTPHeader* rtp_header));
|
||||
|
||||
MOCK_METHOD2(OnRecoveredPacket,
|
||||
bool(const uint8_t* packet, size_t packet_length));
|
||||
@ -37,100 +37,76 @@ class MockRtpData : public RtpData {
|
||||
|
||||
class MockRtpRtcp : public RtpRtcp {
|
||||
public:
|
||||
MOCK_METHOD1(RegisterDefaultModule,
|
||||
int32_t(RtpRtcp* module));
|
||||
MOCK_METHOD0(DeRegisterDefaultModule,
|
||||
int32_t());
|
||||
MOCK_METHOD0(DefaultModuleRegistered,
|
||||
bool());
|
||||
MOCK_METHOD0(NumberChildModules,
|
||||
uint32_t());
|
||||
MOCK_METHOD1(RegisterSyncModule,
|
||||
int32_t(RtpRtcp* module));
|
||||
MOCK_METHOD0(DeRegisterSyncModule,
|
||||
int32_t());
|
||||
MOCK_METHOD1(RegisterDefaultModule, int32_t(RtpRtcp* module));
|
||||
MOCK_METHOD0(DeRegisterDefaultModule, int32_t());
|
||||
MOCK_METHOD0(DefaultModuleRegistered, bool());
|
||||
MOCK_METHOD0(NumberChildModules, uint32_t());
|
||||
MOCK_METHOD1(RegisterSyncModule, int32_t(RtpRtcp* module));
|
||||
MOCK_METHOD0(DeRegisterSyncModule, int32_t());
|
||||
MOCK_METHOD2(IncomingRtcpPacket,
|
||||
int32_t(const uint8_t* incomingPacket, size_t packetLength));
|
||||
MOCK_METHOD1(SetRemoteSSRC, void(const uint32_t ssrc));
|
||||
int32_t(const uint8_t* incoming_packet, size_t packet_length));
|
||||
MOCK_METHOD1(SetRemoteSSRC, void(uint32_t ssrc));
|
||||
MOCK_METHOD4(IncomingAudioNTP,
|
||||
int32_t(const uint32_t audioReceivedNTPsecs,
|
||||
const uint32_t audioReceivedNTPfrac,
|
||||
const uint32_t audioRTCPArrivalTimeSecs,
|
||||
const uint32_t audioRTCPArrivalTimeFrac));
|
||||
MOCK_METHOD0(InitSender,
|
||||
int32_t());
|
||||
MOCK_METHOD1(RegisterSendTransport,
|
||||
int32_t(Transport* outgoingTransport));
|
||||
MOCK_METHOD1(SetMaxTransferUnit,
|
||||
int32_t(const uint16_t size));
|
||||
int32_t(uint32_t audio_received_ntp_secs,
|
||||
uint32_t audio_received_ntp_frac,
|
||||
uint32_t audio_rtcp_arrival_time_secs,
|
||||
uint32_t audio_rtcp_arrival_time_frac));
|
||||
MOCK_METHOD0(InitSender, int32_t());
|
||||
MOCK_METHOD1(RegisterSendTransport, int32_t(Transport* outgoing_transport));
|
||||
MOCK_METHOD1(SetMaxTransferUnit, int32_t(uint16_t size));
|
||||
MOCK_METHOD3(SetTransportOverhead,
|
||||
int32_t(const bool TCP, const bool IPV6,
|
||||
const uint8_t authenticationOverhead));
|
||||
MOCK_CONST_METHOD0(MaxPayloadLength,
|
||||
uint16_t());
|
||||
MOCK_CONST_METHOD0(MaxDataPayloadLength,
|
||||
uint16_t());
|
||||
MOCK_METHOD1(RegisterSendPayload,
|
||||
int32_t(const CodecInst& voiceCodec));
|
||||
MOCK_METHOD1(RegisterSendPayload,
|
||||
int32_t(const VideoCodec& videoCodec));
|
||||
int32_t(bool tcp, bool ipv6, uint8_t authentication_overhead));
|
||||
MOCK_CONST_METHOD0(MaxPayloadLength, uint16_t());
|
||||
MOCK_CONST_METHOD0(MaxDataPayloadLength, uint16_t());
|
||||
MOCK_METHOD1(RegisterSendPayload, int32_t(const CodecInst& voice_codec));
|
||||
MOCK_METHOD1(RegisterSendPayload, int32_t(const VideoCodec& video_codec));
|
||||
MOCK_METHOD2(RegisterVideoSendPayload,
|
||||
void(int payload_type, const char* payload_name));
|
||||
MOCK_METHOD1(DeRegisterSendPayload,
|
||||
int32_t(const int8_t payloadType));
|
||||
MOCK_METHOD1(DeRegisterSendPayload, int32_t(int8_t payload_type));
|
||||
MOCK_METHOD2(RegisterSendRtpHeaderExtension,
|
||||
int32_t(const RTPExtensionType type, const uint8_t id));
|
||||
int32_t(RTPExtensionType type, uint8_t id));
|
||||
MOCK_METHOD1(DeregisterSendRtpHeaderExtension,
|
||||
int32_t(const RTPExtensionType type));
|
||||
MOCK_CONST_METHOD0(StartTimestamp,
|
||||
uint32_t());
|
||||
MOCK_METHOD1(SetStartTimestamp, void(const uint32_t timestamp));
|
||||
int32_t(RTPExtensionType type));
|
||||
MOCK_CONST_METHOD0(StartTimestamp, uint32_t());
|
||||
MOCK_METHOD1(SetStartTimestamp, void(uint32_t timestamp));
|
||||
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(SetRtxState, void(const RtpState& rtp_state));
|
||||
MOCK_CONST_METHOD0(GetRtpState, RtpState());
|
||||
MOCK_CONST_METHOD0(GetRtxState, RtpState());
|
||||
MOCK_CONST_METHOD0(SSRC,
|
||||
uint32_t());
|
||||
MOCK_METHOD1(SetSSRC,
|
||||
void(const uint32_t ssrc));
|
||||
MOCK_CONST_METHOD1(CSRCs,
|
||||
int32_t(uint32_t arrOfCSRC[kRtpCsrcSize]));
|
||||
MOCK_CONST_METHOD0(SSRC, uint32_t());
|
||||
MOCK_METHOD1(SetSSRC, void(uint32_t ssrc));
|
||||
MOCK_CONST_METHOD1(CSRCs, int32_t(uint32_t csrcs[kRtpCsrcSize]));
|
||||
MOCK_METHOD1(SetCsrcs, void(const std::vector<uint32_t>& csrcs));
|
||||
MOCK_METHOD1(SetCSRCStatus,
|
||||
int32_t(const bool include));
|
||||
MOCK_METHOD1(SetCSRCStatus, int32_t(bool include));
|
||||
MOCK_METHOD1(SetRtxSendStatus, void(int modes));
|
||||
MOCK_CONST_METHOD0(RtxSendStatus, int());
|
||||
MOCK_METHOD1(SetRtxSsrc,
|
||||
void(uint32_t));
|
||||
MOCK_METHOD1(SetRtxSsrc, void(uint32_t));
|
||||
MOCK_METHOD2(SetRtxSendPayloadType, void(int, int));
|
||||
MOCK_CONST_METHOD0(RtxSendPayloadType, std::pair<int, int>());
|
||||
MOCK_METHOD1(SetSendingStatus,
|
||||
int32_t(const bool sending));
|
||||
MOCK_CONST_METHOD0(Sending,
|
||||
bool());
|
||||
MOCK_METHOD1(SetSendingMediaStatus, void(const bool sending));
|
||||
MOCK_CONST_METHOD0(SendingMedia,
|
||||
bool());
|
||||
MOCK_METHOD1(SetSendingStatus, int32_t(bool sending));
|
||||
MOCK_CONST_METHOD0(Sending, bool());
|
||||
MOCK_METHOD1(SetSendingMediaStatus, void(bool sending));
|
||||
MOCK_CONST_METHOD0(SendingMedia, bool());
|
||||
MOCK_CONST_METHOD4(BitrateSent,
|
||||
void(uint32_t* totalRate,
|
||||
uint32_t* videoRate,
|
||||
uint32_t* fecRate,
|
||||
uint32_t* nackRate));
|
||||
void(uint32_t* total_rate,
|
||||
uint32_t* video_rate,
|
||||
uint32_t* fec_rate,
|
||||
uint32_t* nack_rate));
|
||||
MOCK_METHOD1(RegisterVideoBitrateObserver, void(BitrateStatisticsObserver*));
|
||||
MOCK_CONST_METHOD0(GetVideoBitrateObserver, BitrateStatisticsObserver*(void));
|
||||
MOCK_CONST_METHOD1(EstimatedReceiveBandwidth,
|
||||
int(uint32_t* available_bandwidth));
|
||||
MOCK_METHOD8(SendOutgoingData,
|
||||
int32_t(const FrameType frameType,
|
||||
const int8_t payloadType,
|
||||
const uint32_t timeStamp,
|
||||
int32_t(FrameType frame_type,
|
||||
int8_t payload_type,
|
||||
uint32_t timestamp,
|
||||
int64_t capture_time_ms,
|
||||
const uint8_t* payloadData,
|
||||
const size_t payloadSize,
|
||||
const uint8_t* payload_data,
|
||||
size_t payload_size,
|
||||
const RTPFragmentationHeader* fragmentation,
|
||||
const RTPVideoHeader* rtpVideoHdr));
|
||||
const RTPVideoHeader* rtp_video_header));
|
||||
MOCK_METHOD5(TimeToSendPacket,
|
||||
bool(uint32_t ssrc,
|
||||
uint16_t sequence_number,
|
||||
@ -139,119 +115,94 @@ class MockRtpRtcp : public RtpRtcp {
|
||||
int probe_cluster_id));
|
||||
MOCK_METHOD2(TimeToSendPadding, size_t(size_t bytes, int probe_cluster_id));
|
||||
MOCK_METHOD2(RegisterRtcpObservers,
|
||||
void(RtcpIntraFrameObserver* intraFrameCallback,
|
||||
RtcpBandwidthObserver* bandwidthCallback));
|
||||
void(RtcpIntraFrameObserver* intra_frame_callback,
|
||||
RtcpBandwidthObserver* bandwidth_callback));
|
||||
MOCK_CONST_METHOD0(RTCP, RtcpMode());
|
||||
MOCK_METHOD1(SetRTCPStatus, void(const RtcpMode method));
|
||||
MOCK_METHOD1(SetCNAME,
|
||||
int32_t(const char cName[RTCP_CNAME_SIZE]));
|
||||
MOCK_METHOD1(SetRTCPStatus, void(RtcpMode method));
|
||||
MOCK_METHOD1(SetCNAME, int32_t(const char cname[RTCP_CNAME_SIZE]));
|
||||
MOCK_CONST_METHOD2(RemoteCNAME,
|
||||
int32_t(const uint32_t remoteSSRC,
|
||||
char cName[RTCP_CNAME_SIZE]));
|
||||
int32_t(uint32_t remote_ssrc,
|
||||
char cname[RTCP_CNAME_SIZE]));
|
||||
MOCK_CONST_METHOD5(RemoteNTP,
|
||||
int32_t(uint32_t *ReceivedNTPsecs,
|
||||
uint32_t *ReceivedNTPfrac,
|
||||
uint32_t *RTCPArrivalTimeSecs,
|
||||
uint32_t *RTCPArrivalTimeFrac,
|
||||
int32_t(uint32_t* received_ntp_secs,
|
||||
uint32_t* received_ntp_frac,
|
||||
uint32_t* rtcp_arrival_time_secs,
|
||||
uint32_t* rtcp_arrival_time_frac,
|
||||
uint32_t* rtcp_timestamp));
|
||||
MOCK_METHOD2(AddMixedCNAME,
|
||||
int32_t(const uint32_t SSRC,
|
||||
const char cName[RTCP_CNAME_SIZE]));
|
||||
MOCK_METHOD1(RemoveMixedCNAME,
|
||||
int32_t(const uint32_t SSRC));
|
||||
int32_t(uint32_t ssrc, const char cname[RTCP_CNAME_SIZE]));
|
||||
MOCK_METHOD1(RemoveMixedCNAME, int32_t(uint32_t ssrc));
|
||||
MOCK_CONST_METHOD5(RTT,
|
||||
int32_t(const uint32_t remoteSSRC,
|
||||
int64_t* RTT,
|
||||
int64_t* avgRTT,
|
||||
int64_t* minRTT,
|
||||
int64_t* maxRTT));
|
||||
MOCK_METHOD1(SendRTCP, int32_t(RTCPPacketType packetType));
|
||||
int32_t(uint32_t remote_ssrc,
|
||||
int64_t* rtt,
|
||||
int64_t* avg_rtt,
|
||||
int64_t* min_rtt,
|
||||
int64_t* max_rtt));
|
||||
MOCK_METHOD1(SendRTCP, int32_t(RTCPPacketType packet_type));
|
||||
MOCK_METHOD1(SendCompoundRTCP,
|
||||
int32_t(const std::set<RTCPPacketType>& packetTypes));
|
||||
MOCK_METHOD1(SendRTCPReferencePictureSelection, int32_t(uint64_t pictureID));
|
||||
MOCK_METHOD1(SendRTCPSliceLossIndication,
|
||||
int32_t(const uint8_t pictureID));
|
||||
int32_t(const std::set<RTCPPacketType>& packet_types));
|
||||
MOCK_METHOD1(SendRTCPReferencePictureSelection, int32_t(uint64_t picture_id));
|
||||
MOCK_METHOD1(SendRTCPSliceLossIndication, int32_t(uint8_t picture_id));
|
||||
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,
|
||||
void(StreamDataCounters*, StreamDataCounters*));
|
||||
MOCK_CONST_METHOD3(GetRtpPacketLossStats,
|
||||
void(bool, uint32_t, struct RtpPacketLossStats*));
|
||||
MOCK_METHOD1(RemoteRTCPStat,
|
||||
int32_t(RTCPSenderInfo* senderInfo));
|
||||
MOCK_METHOD1(RemoteRTCPStat, int32_t(RTCPSenderInfo* sender_info));
|
||||
MOCK_CONST_METHOD1(RemoteRTCPStat,
|
||||
int32_t(std::vector<RTCPReportBlock>* receiveBlocks));
|
||||
int32_t(std::vector<RTCPReportBlock>* receive_blocks));
|
||||
MOCK_METHOD4(SetRTCPApplicationSpecificData,
|
||||
int32_t(const uint8_t subType,
|
||||
const uint32_t name,
|
||||
int32_t(uint8_t sub_type,
|
||||
uint32_t name,
|
||||
const uint8_t* data,
|
||||
const uint16_t length));
|
||||
MOCK_METHOD1(SetRTCPVoIPMetrics,
|
||||
int32_t(const RTCPVoIPMetric* VoIPMetric));
|
||||
MOCK_METHOD1(SetRtcpXrRrtrStatus,
|
||||
void(bool enable));
|
||||
MOCK_CONST_METHOD0(RtcpXrRrtrStatus,
|
||||
bool());
|
||||
MOCK_CONST_METHOD0(REMB,
|
||||
bool());
|
||||
MOCK_METHOD1(SetREMBStatus, void(const bool enable));
|
||||
uint16_t length));
|
||||
MOCK_METHOD1(SetRTCPVoIPMetrics, int32_t(const RTCPVoIPMetric* voip_metric));
|
||||
MOCK_METHOD1(SetRtcpXrRrtrStatus, void(bool enable));
|
||||
MOCK_CONST_METHOD0(RtcpXrRrtrStatus, bool());
|
||||
MOCK_CONST_METHOD0(REMB, bool());
|
||||
MOCK_METHOD1(SetREMBStatus, void(bool enable));
|
||||
MOCK_METHOD2(SetREMBData,
|
||||
void(const uint32_t bitrate,
|
||||
const std::vector<uint32_t>& ssrcs));
|
||||
MOCK_CONST_METHOD0(TMMBR,
|
||||
bool());
|
||||
MOCK_METHOD1(SetTMMBRStatus, void(const bool enable));
|
||||
MOCK_METHOD1(OnBandwidthEstimateUpdate,
|
||||
void(uint16_t bandWidthKbit));
|
||||
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));
|
||||
void(uint32_t bitrate, const std::vector<uint32_t>& ssrcs));
|
||||
MOCK_CONST_METHOD0(TMMBR, bool());
|
||||
MOCK_METHOD1(SetTMMBRStatus, void(bool enable));
|
||||
MOCK_METHOD1(OnBandwidthEstimateUpdate, void(uint16_t bandwidth_kbit));
|
||||
MOCK_CONST_METHOD0(SelectiveRetransmissions, int());
|
||||
MOCK_METHOD1(SetSelectiveRetransmissions, int(uint8_t settings));
|
||||
MOCK_METHOD2(SendNACK, int32_t(const uint16_t* nack_list, uint16_t size));
|
||||
MOCK_METHOD1(SendNack, void(const std::vector<uint16_t>& sequence_numbers));
|
||||
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_METHOD1(RegisterRtcpStatisticsCallback, void(RtcpStatisticsCallback*));
|
||||
MOCK_METHOD0(GetRtcpStatisticsCallback, RtcpStatisticsCallback*());
|
||||
MOCK_METHOD1(SendFeedbackPacket, bool(const rtcp::TransportFeedback& packet));
|
||||
MOCK_METHOD1(SetAudioPacketSize,
|
||||
int32_t(const uint16_t packetSizeSamples));
|
||||
MOCK_METHOD1(SetAudioPacketSize, int32_t(uint16_t packet_size_samples));
|
||||
MOCK_METHOD3(SendTelephoneEventOutband,
|
||||
int32_t(const uint8_t key, const uint16_t time_ms, const uint8_t level));
|
||||
MOCK_METHOD1(SetSendREDPayloadType,
|
||||
int32_t(const int8_t payloadType));
|
||||
MOCK_CONST_METHOD1(SendREDPayloadType, int32_t(int8_t* payloadType));
|
||||
int32_t(uint8_t key, uint16_t time_ms, uint8_t level));
|
||||
MOCK_METHOD1(SetSendREDPayloadType, int32_t(int8_t payload_type));
|
||||
MOCK_CONST_METHOD1(SendREDPayloadType, int32_t(int8_t* payload_type));
|
||||
MOCK_METHOD2(SetRTPAudioLevelIndicationStatus,
|
||||
int32_t(const bool enable, const uint8_t ID));
|
||||
MOCK_METHOD1(SetAudioLevel,
|
||||
int32_t(const uint8_t level_dBov));
|
||||
MOCK_METHOD1(SetTargetSendBitrate,
|
||||
void(uint32_t bitrate_bps));
|
||||
int32_t(bool enable, uint8_t id));
|
||||
MOCK_METHOD1(SetAudioLevel, int32_t(uint8_t level_dbov));
|
||||
MOCK_METHOD1(SetTargetSendBitrate, void(uint32_t bitrate_bps));
|
||||
MOCK_METHOD3(SetGenericFECStatus,
|
||||
void(const bool enable,
|
||||
const uint8_t payload_type_red,
|
||||
const uint8_t payload_type_fec));
|
||||
void(bool enable,
|
||||
uint8_t payload_type_red,
|
||||
uint8_t payload_type_fec));
|
||||
MOCK_METHOD3(GenericFECStatus,
|
||||
void(bool* enable,
|
||||
uint8_t* payloadTypeRED,
|
||||
uint8_t* payloadTypeFEC));
|
||||
uint8_t* payload_type_red,
|
||||
uint8_t* payload_type_fec));
|
||||
MOCK_METHOD2(SetFecParameters,
|
||||
int32_t(const FecProtectionParams* delta_params,
|
||||
const FecProtectionParams* key_params));
|
||||
MOCK_METHOD1(SetKeyFrameRequestMethod,
|
||||
int32_t(const KeyFrameRequestMethod method));
|
||||
MOCK_METHOD0(RequestKeyFrame,
|
||||
int32_t());
|
||||
MOCK_METHOD0(TimeUntilNextProcess,
|
||||
int64_t());
|
||||
MOCK_METHOD0(Process,
|
||||
void());
|
||||
MOCK_METHOD1(RegisterSendFrameCountObserver,
|
||||
void(FrameCountObserver*));
|
||||
MOCK_CONST_METHOD0(GetSendFrameCountObserver,
|
||||
FrameCountObserver*(void));
|
||||
MOCK_METHOD1(SetKeyFrameRequestMethod, int32_t(KeyFrameRequestMethod method));
|
||||
MOCK_METHOD0(RequestKeyFrame, int32_t());
|
||||
MOCK_METHOD0(TimeUntilNextProcess, int64_t());
|
||||
MOCK_METHOD0(Process, void());
|
||||
MOCK_METHOD1(RegisterSendFrameCountObserver, void(FrameCountObserver*));
|
||||
MOCK_CONST_METHOD0(GetSendFrameCountObserver, FrameCountObserver*(void));
|
||||
MOCK_METHOD1(RegisterSendChannelRtpStatisticsCallback,
|
||||
void(StreamDataCountersCallback*));
|
||||
MOCK_CONST_METHOD0(GetSendChannelRtpStatisticsCallback,
|
||||
|
||||
@ -22,20 +22,20 @@ class MockRTPPayloadStrategy : public RTPPayloadStrategy {
|
||||
bool());
|
||||
MOCK_CONST_METHOD4(PayloadIsCompatible,
|
||||
bool(const RtpUtility::Payload& payload,
|
||||
const uint32_t frequency,
|
||||
const size_t channels,
|
||||
const uint32_t rate));
|
||||
uint32_t frequency,
|
||||
size_t channels,
|
||||
uint32_t rate));
|
||||
MOCK_CONST_METHOD2(UpdatePayloadRate,
|
||||
void(RtpUtility::Payload* payload, const uint32_t rate));
|
||||
void(RtpUtility::Payload* payload, uint32_t rate));
|
||||
MOCK_CONST_METHOD1(GetPayloadTypeFrequency,
|
||||
int(const RtpUtility::Payload& payload));
|
||||
MOCK_CONST_METHOD5(
|
||||
CreatePayloadType,
|
||||
RtpUtility::Payload*(const char payloadName[RTP_PAYLOAD_NAME_SIZE],
|
||||
const int8_t payloadType,
|
||||
const uint32_t frequency,
|
||||
const size_t channels,
|
||||
const uint32_t rate));
|
||||
RtpUtility::Payload*(const char payload_name[RTP_PAYLOAD_NAME_SIZE],
|
||||
int8_t payload_type,
|
||||
uint32_t frequency,
|
||||
size_t channels,
|
||||
uint32_t rate));
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -46,25 +46,7 @@ RTPExtensionType StringToRtpExtensionType(const std::string& extension) {
|
||||
}
|
||||
|
||||
RtpRtcp::Configuration::Configuration()
|
||||
: audio(false),
|
||||
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) {}
|
||||
: receive_statistics(NullObjectReceiveStatistics()) {}
|
||||
|
||||
RtpRtcp* RtpRtcp::CreateRtpRtcp(const RtpRtcp::Configuration& configuration) {
|
||||
if (configuration.clock) {
|
||||
@ -245,8 +227,8 @@ int32_t ModuleRtpRtcpImpl::IncomingRtcpPacket(
|
||||
return -1;
|
||||
}
|
||||
RTCPHelp::RTCPPacketInformation rtcp_packet_information;
|
||||
int32_t ret_val = rtcp_receiver_.IncomingRTCPPacket(
|
||||
rtcp_packet_information, &rtcp_parser);
|
||||
int32_t ret_val =
|
||||
rtcp_receiver_.IncomingRTCPPacket(rtcp_packet_information, &rtcp_parser);
|
||||
if (ret_val == 0) {
|
||||
rtcp_receiver_.TriggerCallbacksFromRTCPPacket(rtcp_packet_information);
|
||||
}
|
||||
@ -256,11 +238,8 @@ int32_t ModuleRtpRtcpImpl::IncomingRtcpPacket(
|
||||
int32_t ModuleRtpRtcpImpl::RegisterSendPayload(
|
||||
const CodecInst& voice_codec) {
|
||||
return rtp_sender_.RegisterPayload(
|
||||
voice_codec.plname,
|
||||
voice_codec.pltype,
|
||||
voice_codec.plfreq,
|
||||
voice_codec.channels,
|
||||
(voice_codec.rate < 0) ? 0 : voice_codec.rate);
|
||||
voice_codec.plname, voice_codec.pltype, voice_codec.plfreq,
|
||||
voice_codec.channels, (voice_codec.rate < 0) ? 0 : voice_codec.rate);
|
||||
}
|
||||
|
||||
int32_t ModuleRtpRtcpImpl::RegisterSendPayload(const VideoCodec& video_codec) {
|
||||
@ -413,7 +392,7 @@ int32_t ModuleRtpRtcpImpl::SendOutgoingData(
|
||||
const uint8_t* payload_data,
|
||||
size_t payload_size,
|
||||
const RTPFragmentationHeader* fragmentation,
|
||||
const RTPVideoHeader* rtp_video_hdr) {
|
||||
const RTPVideoHeader* rtp_video_header) {
|
||||
rtcp_sender_.SetLastRtpTime(time_stamp, capture_time_ms);
|
||||
// Make sure an RTCP report isn't queued behind a key frame.
|
||||
if (rtcp_sender_.TimeToSendRTCPReport(kVideoFrameKey == frame_type)) {
|
||||
@ -421,7 +400,7 @@ int32_t ModuleRtpRtcpImpl::SendOutgoingData(
|
||||
}
|
||||
return rtp_sender_.SendOutgoingData(
|
||||
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,
|
||||
|
||||
@ -112,14 +112,15 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
|
||||
|
||||
// Used by the codec module to deliver a video or audio frame for
|
||||
// packetization.
|
||||
int32_t SendOutgoingData(FrameType frame_type,
|
||||
int32_t SendOutgoingData(
|
||||
FrameType frame_type,
|
||||
int8_t payload_type,
|
||||
uint32_t time_stamp,
|
||||
int64_t capture_time_ms,
|
||||
const uint8_t* payload_data,
|
||||
size_t payload_size,
|
||||
const RTPFragmentationHeader* fragmentation = NULL,
|
||||
const RTPVideoHeader* rtp_video_hdr = NULL) override;
|
||||
const RTPVideoHeader* rtp_video_header = NULL) override;
|
||||
|
||||
bool TimeToSendPacket(uint32_t ssrc,
|
||||
uint16_t sequence_number,
|
||||
|
||||
@ -1128,7 +1128,7 @@ size_t RTPSender::CreateRtpHeader(uint8_t* header,
|
||||
}
|
||||
|
||||
uint16_t len =
|
||||
BuildRTPHeaderExtension(header + rtp_header_length, marker_bit);
|
||||
BuildRtpHeaderExtension(header + rtp_header_length, marker_bit);
|
||||
if (len > 0) {
|
||||
header[0] |= 0x10; // Set extension bit.
|
||||
rtp_header_length += len;
|
||||
@ -1143,17 +1143,19 @@ int32_t RTPSender::BuildRTPheader(uint8_t* data_buffer,
|
||||
int64_t capture_time_ms,
|
||||
bool timestamp_provided,
|
||||
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);
|
||||
rtc::CritScope lock(&send_critsect_);
|
||||
|
||||
if (timestamp_provided) {
|
||||
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();
|
||||
uint32_t sequence_number = sequence_number_++;
|
||||
capture_time_ms_ = capture_time_ms;
|
||||
@ -1162,7 +1164,7 @@ int32_t RTPSender::BuildRTPheader(uint8_t* data_buffer,
|
||||
timestamp_, sequence_number, csrcs_);
|
||||
}
|
||||
|
||||
uint16_t RTPSender::BuildRTPHeaderExtension(uint8_t* data_buffer,
|
||||
uint16_t RTPSender::BuildRtpHeaderExtension(uint8_t* data_buffer,
|
||||
bool marker_bit) const {
|
||||
if (rtp_header_extension_map_.Size() <= 0) {
|
||||
return 0;
|
||||
|
||||
@ -47,6 +47,9 @@ class RTPSenderInterface {
|
||||
virtual uint32_t SSRC() 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,
|
||||
int8_t payload_type,
|
||||
bool marker_bit,
|
||||
@ -55,6 +58,12 @@ class RTPSenderInterface {
|
||||
bool timestamp_provided = true,
|
||||
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
|
||||
// the optional RTP header extensions that may not be currently active.
|
||||
virtual size_t RtpHeaderLength() const = 0;
|
||||
@ -152,7 +161,7 @@ class RTPSender : public RTPSenderInterface {
|
||||
const uint8_t* payload_data,
|
||||
size_t payload_size,
|
||||
const RTPFragmentationHeader* fragmentation,
|
||||
const RTPVideoHeader* rtp_hdr = NULL);
|
||||
const RTPVideoHeader* rtp_header);
|
||||
|
||||
// RTP header extension
|
||||
int32_t SetTransmissionTimeOffset(int32_t transmission_time_offset);
|
||||
@ -166,7 +175,7 @@ class RTPSender : public RTPSenderInterface {
|
||||
|
||||
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_);
|
||||
|
||||
uint8_t BuildTransmissionTimeOffsetExtension(uint8_t* data_buffer) const
|
||||
@ -251,8 +260,13 @@ class RTPSender : public RTPSenderInterface {
|
||||
bool marker_bit,
|
||||
uint32_t capture_timestamp,
|
||||
int64_t capture_time_ms,
|
||||
const bool timestamp_provided = true,
|
||||
const bool inc_sequence_number = true) override;
|
||||
bool timestamp_provided = true,
|
||||
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;
|
||||
uint16_t AllocateSequenceNumber(uint16_t packets_to_send) override;
|
||||
@ -308,7 +322,6 @@ class RTPSender : public RTPSenderInterface {
|
||||
bool timestamp_provided,
|
||||
uint32_t timestamp,
|
||||
int64_t capture_time_ms);
|
||||
|
||||
size_t SendPadData(size_t bytes,
|
||||
bool timestamp_provided,
|
||||
uint32_t timestamp,
|
||||
|
||||
@ -22,27 +22,27 @@ namespace webrtc {
|
||||
|
||||
static const int kDtmfFrequencyHz = 8000;
|
||||
|
||||
RTPSenderAudio::RTPSenderAudio(Clock* clock, RTPSender* rtpSender)
|
||||
: _clock(clock),
|
||||
_rtpSender(rtpSender),
|
||||
_packetSizeSamples(160),
|
||||
_dtmfEventIsOn(false),
|
||||
_dtmfEventFirstPacketSent(false),
|
||||
_dtmfPayloadType(-1),
|
||||
_dtmfTimestamp(0),
|
||||
_dtmfKey(0),
|
||||
_dtmfLengthSamples(0),
|
||||
_dtmfLevel(0),
|
||||
_dtmfTimeLastSent(0),
|
||||
_dtmfTimestampLastSent(0),
|
||||
_REDPayloadType(-1),
|
||||
_inbandVADactive(false),
|
||||
_cngNBPayloadType(-1),
|
||||
_cngWBPayloadType(-1),
|
||||
_cngSWBPayloadType(-1),
|
||||
_cngFBPayloadType(-1),
|
||||
_lastPayloadType(-1),
|
||||
_audioLevel_dBov(0) {}
|
||||
RTPSenderAudio::RTPSenderAudio(Clock* clock, RTPSender* rtp_sender)
|
||||
: clock_(clock),
|
||||
rtp_sender_(rtp_sender),
|
||||
packet_size_samples_(160),
|
||||
dtmf_event_is_on_(false),
|
||||
dtmf_event_first_packet_sent_(false),
|
||||
dtmf_payload_type_(-1),
|
||||
dtmf_timestamp_(0),
|
||||
dtmf_key_(0),
|
||||
dtmf_length_samples_(0),
|
||||
dtmf_level_(0),
|
||||
dtmf_time_last_sent_(0),
|
||||
dtmf_timestamp_last_sent_(0),
|
||||
red_payload_type_(-1),
|
||||
inband_vad_active_(false),
|
||||
cngnb_payload_type_(-1),
|
||||
cngwb_payload_type_(-1),
|
||||
cngswb_payload_type_(-1),
|
||||
cngfb_payload_type_(-1),
|
||||
last_payload_type_(-1),
|
||||
audio_level_dbov_(0) {}
|
||||
|
||||
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
|
||||
// in silence (CNG)
|
||||
int32_t RTPSenderAudio::SetAudioPacketSize(uint16_t packetSizeSamples) {
|
||||
rtc::CritScope cs(&_sendAudioCritsect);
|
||||
|
||||
_packetSizeSamples = packetSizeSamples;
|
||||
int32_t RTPSenderAudio::SetAudioPacketSize(uint16_t packet_size_samples) {
|
||||
rtc::CritScope cs(&send_audio_critsect_);
|
||||
packet_size_samples_ = packet_size_samples;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t RTPSenderAudio::RegisterAudioPayload(
|
||||
const char payloadName[RTP_PAYLOAD_NAME_SIZE],
|
||||
const int8_t payloadType,
|
||||
const int8_t payload_type,
|
||||
const uint32_t frequency,
|
||||
const size_t channels,
|
||||
const uint32_t rate,
|
||||
RtpUtility::Payload** payload) {
|
||||
if (RtpUtility::StringCompare(payloadName, "cn", 2)) {
|
||||
rtc::CritScope cs(&_sendAudioCritsect);
|
||||
rtc::CritScope cs(&send_audio_critsect_);
|
||||
// we can have multiple CNG payload types
|
||||
switch (frequency) {
|
||||
case 8000:
|
||||
_cngNBPayloadType = payloadType;
|
||||
cngnb_payload_type_ = payload_type;
|
||||
break;
|
||||
case 16000:
|
||||
_cngWBPayloadType = payloadType;
|
||||
cngwb_payload_type_ = payload_type;
|
||||
break;
|
||||
case 32000:
|
||||
_cngSWBPayloadType = payloadType;
|
||||
cngswb_payload_type_ = payload_type;
|
||||
break;
|
||||
case 48000:
|
||||
_cngFBPayloadType = payloadType;
|
||||
cngfb_payload_type_ = payload_type;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
} 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
|
||||
// we dont want to allow send with a DTMF payloadtype
|
||||
_dtmfPayloadType = payloadType;
|
||||
dtmf_payload_type_ = payload_type;
|
||||
return 0;
|
||||
// The default timestamp rate is 8000 Hz, but other rates may be defined.
|
||||
}
|
||||
@ -103,27 +102,27 @@ int32_t RTPSenderAudio::RegisterAudioPayload(
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool RTPSenderAudio::MarkerBit(FrameType frameType, int8_t payload_type) {
|
||||
rtc::CritScope cs(&_sendAudioCritsect);
|
||||
bool RTPSenderAudio::MarkerBit(FrameType frame_type, int8_t payload_type) {
|
||||
rtc::CritScope cs(&send_audio_critsect_);
|
||||
// for audio true for first packet in a speech burst
|
||||
bool markerBit = false;
|
||||
if (_lastPayloadType != payload_type) {
|
||||
if (payload_type != -1 && (_cngNBPayloadType == payload_type ||
|
||||
_cngWBPayloadType == payload_type ||
|
||||
_cngSWBPayloadType == payload_type ||
|
||||
_cngFBPayloadType == payload_type)) {
|
||||
bool marker_bit = false;
|
||||
if (last_payload_type_ != payload_type) {
|
||||
if (payload_type != -1 && (cngnb_payload_type_ == payload_type ||
|
||||
cngwb_payload_type_ == payload_type ||
|
||||
cngswb_payload_type_ == payload_type ||
|
||||
cngfb_payload_type_ == payload_type)) {
|
||||
// Only set a marker bit when we change payload type to a non CNG
|
||||
return false;
|
||||
}
|
||||
|
||||
// payload_type differ
|
||||
if (_lastPayloadType == -1) {
|
||||
if (frameType != kAudioFrameCN) {
|
||||
if (last_payload_type_ == -1) {
|
||||
if (frame_type != kAudioFrameCN) {
|
||||
// first packet and NOT CNG
|
||||
return true;
|
||||
} else {
|
||||
// first packet and CNG
|
||||
_inbandVADactive = true;
|
||||
inband_vad_active_ = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -133,158 +132,159 @@ bool RTPSenderAudio::MarkerBit(FrameType frameType, int8_t payload_type) {
|
||||
// payload_type changed
|
||||
|
||||
// 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
|
||||
if (frameType == kAudioFrameCN) {
|
||||
_inbandVADactive = true;
|
||||
} else if (_inbandVADactive) {
|
||||
_inbandVADactive = false;
|
||||
markerBit = true;
|
||||
if (frame_type == kAudioFrameCN) {
|
||||
inband_vad_active_ = true;
|
||||
} else if (inband_vad_active_) {
|
||||
inband_vad_active_ = false;
|
||||
marker_bit = true;
|
||||
}
|
||||
return markerBit;
|
||||
return marker_bit;
|
||||
}
|
||||
|
||||
int32_t RTPSenderAudio::SendAudio(FrameType frameType,
|
||||
int8_t payloadType,
|
||||
uint32_t captureTimeStamp,
|
||||
const uint8_t* payloadData,
|
||||
size_t dataSize,
|
||||
int32_t RTPSenderAudio::SendAudio(FrameType frame_type,
|
||||
int8_t payload_type,
|
||||
uint32_t capture_timestamp,
|
||||
const uint8_t* payload_data,
|
||||
size_t data_size,
|
||||
const RTPFragmentationHeader* fragmentation) {
|
||||
// TODO(pwestin) Breakup function in smaller functions.
|
||||
size_t payloadSize = dataSize;
|
||||
size_t maxPayloadLength = _rtpSender->MaxPayloadLength();
|
||||
uint16_t dtmfLengthMS = 0;
|
||||
size_t payload_size = data_size;
|
||||
size_t max_payload_length = rtp_sender_->MaxPayloadLength();
|
||||
uint16_t dtmf_length_ms = 0;
|
||||
uint8_t key = 0;
|
||||
int red_payload_type;
|
||||
uint8_t audio_level_dbov;
|
||||
int8_t dtmf_payload_type;
|
||||
uint16_t packet_size_samples;
|
||||
{
|
||||
rtc::CritScope cs(&_sendAudioCritsect);
|
||||
red_payload_type = _REDPayloadType;
|
||||
audio_level_dbov = _audioLevel_dBov;
|
||||
dtmf_payload_type = _dtmfPayloadType;
|
||||
packet_size_samples = _packetSizeSamples;
|
||||
rtc::CritScope cs(&send_audio_critsect_);
|
||||
red_payload_type = red_payload_type_;
|
||||
audio_level_dbov = audio_level_dbov_;
|
||||
dtmf_payload_type = dtmf_payload_type_;
|
||||
packet_size_samples = packet_size_samples_;
|
||||
}
|
||||
|
||||
// Check if we have pending DTMFs to send
|
||||
if (!_dtmfEventIsOn && PendingDTMF()) {
|
||||
if (!dtmf_event_is_on_ && PendingDTMF()) {
|
||||
int64_t delaySinceLastDTMF =
|
||||
_clock->TimeInMilliseconds() - _dtmfTimeLastSent;
|
||||
clock_->TimeInMilliseconds() - dtmf_time_last_sent_;
|
||||
|
||||
if (delaySinceLastDTMF > 100) {
|
||||
// New tone to play
|
||||
_dtmfTimestamp = captureTimeStamp;
|
||||
if (NextDTMF(&key, &dtmfLengthMS, &_dtmfLevel) >= 0) {
|
||||
_dtmfEventFirstPacketSent = false;
|
||||
_dtmfKey = key;
|
||||
_dtmfLengthSamples = (kDtmfFrequencyHz / 1000) * dtmfLengthMS;
|
||||
_dtmfEventIsOn = true;
|
||||
dtmf_timestamp_ = capture_timestamp;
|
||||
if (NextDTMF(&key, &dtmf_length_ms, &dtmf_level_) >= 0) {
|
||||
dtmf_event_first_packet_sent_ = false;
|
||||
dtmf_key_ = key;
|
||||
dtmf_length_samples_ = (kDtmfFrequencyHz / 1000) * dtmf_length_ms;
|
||||
dtmf_event_is_on_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A source MAY send events and coded audio packets for the same time
|
||||
// but we don't support it
|
||||
if (_dtmfEventIsOn) {
|
||||
if (frameType == kEmptyFrame) {
|
||||
if (dtmf_event_is_on_) {
|
||||
if (frame_type == kEmptyFrame) {
|
||||
// kEmptyFrame is used to drive the DTMF when in CN mode
|
||||
// it can be triggered more frequently than we want to send the
|
||||
// DTMF packets.
|
||||
if (packet_size_samples > (captureTimeStamp - _dtmfTimestampLastSent)) {
|
||||
if (packet_size_samples >
|
||||
(capture_timestamp - dtmf_timestamp_last_sent_)) {
|
||||
// not time to send yet
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
_dtmfTimestampLastSent = captureTimeStamp;
|
||||
uint32_t dtmfDurationSamples = captureTimeStamp - _dtmfTimestamp;
|
||||
dtmf_timestamp_last_sent_ = capture_timestamp;
|
||||
uint32_t dtmf_duration_samples = capture_timestamp - dtmf_timestamp_;
|
||||
bool ended = false;
|
||||
bool send = true;
|
||||
|
||||
if (_dtmfLengthSamples > dtmfDurationSamples) {
|
||||
if (dtmfDurationSamples <= 0) {
|
||||
if (dtmf_length_samples_ > dtmf_duration_samples) {
|
||||
if (dtmf_duration_samples <= 0) {
|
||||
// Skip send packet at start, since we shouldn't use duration 0
|
||||
send = false;
|
||||
}
|
||||
} else {
|
||||
ended = true;
|
||||
_dtmfEventIsOn = false;
|
||||
_dtmfTimeLastSent = _clock->TimeInMilliseconds();
|
||||
dtmf_event_is_on_ = false;
|
||||
dtmf_time_last_sent_ = clock_->TimeInMilliseconds();
|
||||
}
|
||||
if (send) {
|
||||
if (dtmfDurationSamples > 0xffff) {
|
||||
if (dtmf_duration_samples > 0xffff) {
|
||||
// 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);
|
||||
|
||||
// set new timestap for this segment
|
||||
_dtmfTimestamp = captureTimeStamp;
|
||||
dtmfDurationSamples -= 0xffff;
|
||||
_dtmfLengthSamples -= 0xffff;
|
||||
dtmf_timestamp_ = capture_timestamp;
|
||||
dtmf_duration_samples -= 0xffff;
|
||||
dtmf_length_samples_ -= 0xffff;
|
||||
|
||||
return SendTelephoneEventPacket(
|
||||
ended, dtmf_payload_type, _dtmfTimestamp,
|
||||
static_cast<uint16_t>(dtmfDurationSamples), false);
|
||||
ended, dtmf_payload_type, dtmf_timestamp_,
|
||||
static_cast<uint16_t>(dtmf_duration_samples), false);
|
||||
} else {
|
||||
if (SendTelephoneEventPacket(ended, dtmf_payload_type, _dtmfTimestamp,
|
||||
static_cast<uint16_t>(dtmfDurationSamples),
|
||||
!_dtmfEventFirstPacketSent) != 0) {
|
||||
if (SendTelephoneEventPacket(ended, dtmf_payload_type, dtmf_timestamp_,
|
||||
dtmf_duration_samples,
|
||||
!dtmf_event_first_packet_sent_) != 0) {
|
||||
return -1;
|
||||
}
|
||||
_dtmfEventFirstPacketSent = true;
|
||||
dtmf_event_first_packet_sent_ = true;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (payloadSize == 0 || payloadData == NULL) {
|
||||
if (frameType == kEmptyFrame) {
|
||||
if (payload_size == 0 || payload_data == NULL) {
|
||||
if (frame_type == kEmptyFrame) {
|
||||
// we don't send empty audio RTP packets
|
||||
// no error since we use it to drive DTMF when we use VAD
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
uint8_t dataBuffer[IP_PACKET_SIZE];
|
||||
bool markerBit = MarkerBit(frameType, payloadType);
|
||||
uint8_t data_buffer[IP_PACKET_SIZE];
|
||||
bool marker_bit = MarkerBit(frame_type, payload_type);
|
||||
|
||||
int32_t rtpHeaderLength = 0;
|
||||
uint16_t timestampOffset = 0;
|
||||
|
||||
if (red_payload_type >= 0 && fragmentation && !markerBit &&
|
||||
if (red_payload_type >= 0 && fragmentation && !marker_bit &&
|
||||
fragmentation->fragmentationVectorSize > 1) {
|
||||
// have we configured RED? use its payload type
|
||||
// we need to get the current timestamp to calc the diff
|
||||
uint32_t oldTimeStamp = _rtpSender->Timestamp();
|
||||
rtpHeaderLength = _rtpSender->BuildRTPheader(dataBuffer, red_payload_type,
|
||||
markerBit, captureTimeStamp,
|
||||
_clock->TimeInMilliseconds());
|
||||
uint32_t old_timestamp = rtp_sender_->Timestamp();
|
||||
rtpHeaderLength = rtp_sender_->BuildRtpHeader(data_buffer, red_payload_type,
|
||||
marker_bit, capture_timestamp,
|
||||
clock_->TimeInMilliseconds());
|
||||
|
||||
timestampOffset = uint16_t(_rtpSender->Timestamp() - oldTimeStamp);
|
||||
timestampOffset = uint16_t(rtp_sender_->Timestamp() - old_timestamp);
|
||||
} else {
|
||||
rtpHeaderLength = _rtpSender->BuildRTPheader(dataBuffer, payloadType,
|
||||
markerBit, captureTimeStamp,
|
||||
_clock->TimeInMilliseconds());
|
||||
rtpHeaderLength = rtp_sender_->BuildRtpHeader(data_buffer, payload_type,
|
||||
marker_bit, capture_timestamp,
|
||||
clock_->TimeInMilliseconds());
|
||||
}
|
||||
if (rtpHeaderLength <= 0) {
|
||||
return -1;
|
||||
}
|
||||
if (maxPayloadLength < (rtpHeaderLength + payloadSize)) {
|
||||
if (max_payload_length < (rtpHeaderLength + payload_size)) {
|
||||
// Too large payload buffer.
|
||||
return -1;
|
||||
}
|
||||
if (red_payload_type >= 0 && // Have we configured RED?
|
||||
fragmentation && fragmentation->fragmentationVectorSize > 1 &&
|
||||
!markerBit) {
|
||||
!marker_bit) {
|
||||
if (timestampOffset <= 0x3fff) {
|
||||
if (fragmentation->fragmentationVectorSize != 2) {
|
||||
// we only support 2 codecs when using RED
|
||||
return -1;
|
||||
}
|
||||
// only 0x80 if we have multiple blocks
|
||||
dataBuffer[rtpHeaderLength++] =
|
||||
data_buffer[rtpHeaderLength++] =
|
||||
0x80 + fragmentation->fragmentationPlType[1];
|
||||
size_t blockLength = fragmentation->fragmentationLength[1];
|
||||
|
||||
@ -293,66 +293,65 @@ int32_t RTPSenderAudio::SendAudio(FrameType frameType,
|
||||
return -1;
|
||||
}
|
||||
uint32_t REDheader = (timestampOffset << 10) + blockLength;
|
||||
ByteWriter<uint32_t>::WriteBigEndian(dataBuffer + rtpHeaderLength,
|
||||
ByteWriter<uint32_t>::WriteBigEndian(data_buffer + rtpHeaderLength,
|
||||
REDheader);
|
||||
rtpHeaderLength += 3;
|
||||
|
||||
dataBuffer[rtpHeaderLength++] = fragmentation->fragmentationPlType[0];
|
||||
data_buffer[rtpHeaderLength++] = fragmentation->fragmentationPlType[0];
|
||||
// copy the RED data
|
||||
memcpy(dataBuffer + rtpHeaderLength,
|
||||
payloadData + fragmentation->fragmentationOffset[1],
|
||||
memcpy(data_buffer + rtpHeaderLength,
|
||||
payload_data + fragmentation->fragmentationOffset[1],
|
||||
fragmentation->fragmentationLength[1]);
|
||||
|
||||
// copy the normal data
|
||||
memcpy(
|
||||
dataBuffer + rtpHeaderLength + fragmentation->fragmentationLength[1],
|
||||
payloadData + fragmentation->fragmentationOffset[0],
|
||||
data_buffer + rtpHeaderLength + fragmentation->fragmentationLength[1],
|
||||
payload_data + fragmentation->fragmentationOffset[0],
|
||||
fragmentation->fragmentationLength[0]);
|
||||
|
||||
payloadSize = fragmentation->fragmentationLength[0] +
|
||||
payload_size = fragmentation->fragmentationLength[0] +
|
||||
fragmentation->fragmentationLength[1];
|
||||
} else {
|
||||
// silence for too long send only new data
|
||||
dataBuffer[rtpHeaderLength++] = fragmentation->fragmentationPlType[0];
|
||||
memcpy(dataBuffer + rtpHeaderLength,
|
||||
payloadData + fragmentation->fragmentationOffset[0],
|
||||
data_buffer[rtpHeaderLength++] = fragmentation->fragmentationPlType[0];
|
||||
memcpy(data_buffer + rtpHeaderLength,
|
||||
payload_data + fragmentation->fragmentationOffset[0],
|
||||
fragmentation->fragmentationLength[0]);
|
||||
|
||||
payloadSize = fragmentation->fragmentationLength[0];
|
||||
payload_size = fragmentation->fragmentationLength[0];
|
||||
}
|
||||
} else {
|
||||
if (fragmentation && fragmentation->fragmentationVectorSize > 0) {
|
||||
// use the fragment info if we have one
|
||||
dataBuffer[rtpHeaderLength++] = fragmentation->fragmentationPlType[0];
|
||||
memcpy(dataBuffer + rtpHeaderLength,
|
||||
payloadData + fragmentation->fragmentationOffset[0],
|
||||
data_buffer[rtpHeaderLength++] = fragmentation->fragmentationPlType[0];
|
||||
memcpy(data_buffer + rtpHeaderLength,
|
||||
payload_data + fragmentation->fragmentationOffset[0],
|
||||
fragmentation->fragmentationLength[0]);
|
||||
|
||||
payloadSize = fragmentation->fragmentationLength[0];
|
||||
payload_size = fragmentation->fragmentationLength[0];
|
||||
} else {
|
||||
memcpy(dataBuffer + rtpHeaderLength, payloadData, payloadSize);
|
||||
memcpy(data_buffer + rtpHeaderLength, payload_data, payload_size);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
rtc::CritScope cs(&_sendAudioCritsect);
|
||||
_lastPayloadType = payloadType;
|
||||
rtc::CritScope cs(&send_audio_critsect_);
|
||||
last_payload_type_ = payload_type;
|
||||
}
|
||||
// Update audio level extension, if included.
|
||||
size_t packetSize = payloadSize + rtpHeaderLength;
|
||||
RtpUtility::RtpHeaderParser rtp_parser(dataBuffer, packetSize);
|
||||
size_t packetSize = payload_size + rtpHeaderLength;
|
||||
RtpUtility::RtpHeaderParser rtp_parser(data_buffer, packetSize);
|
||||
RTPHeader rtp_header;
|
||||
rtp_parser.Parse(&rtp_header);
|
||||
_rtpSender->UpdateAudioLevel(dataBuffer, packetSize, rtp_header,
|
||||
(frameType == kAudioFrameSpeech),
|
||||
rtp_sender_->UpdateAudioLevel(data_buffer, packetSize, rtp_header,
|
||||
(frame_type == kAudioFrameSpeech),
|
||||
audio_level_dbov);
|
||||
TRACE_EVENT_ASYNC_END2("webrtc", "Audio", captureTimeStamp, "timestamp",
|
||||
_rtpSender->Timestamp(), "seqnum",
|
||||
_rtpSender->SequenceNumber());
|
||||
int32_t send_result = _rtpSender->SendToNetwork(
|
||||
dataBuffer, payloadSize, rtpHeaderLength,
|
||||
rtc::TimeMillis(), kAllowRetransmission,
|
||||
RtpPacketSender::kHighPriority);
|
||||
TRACE_EVENT_ASYNC_END2("webrtc", "Audio", capture_timestamp, "timestamp",
|
||||
rtp_sender_->Timestamp(), "seqnum",
|
||||
rtp_sender_->SequenceNumber());
|
||||
int32_t send_result = rtp_sender_->SendToNetwork(
|
||||
data_buffer, payload_size, rtpHeaderLength, rtc::TimeMillis(),
|
||||
kAllowRetransmission, RtpPacketSender::kHighPriority);
|
||||
if (first_packet_sent_()) {
|
||||
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
|
||||
int32_t RTPSenderAudio::SetAudioLevel(uint8_t level_dBov) {
|
||||
if (level_dBov > 127) {
|
||||
int32_t RTPSenderAudio::SetAudioLevel(uint8_t level_dbov) {
|
||||
if (level_dbov > 127) {
|
||||
return -1;
|
||||
}
|
||||
rtc::CritScope cs(&_sendAudioCritsect);
|
||||
_audioLevel_dBov = level_dBov;
|
||||
rtc::CritScope cs(&send_audio_critsect_);
|
||||
audio_level_dbov_ = level_dbov;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Set payload type for Redundant Audio Data RFC 2198
|
||||
int32_t RTPSenderAudio::SetRED(int8_t payloadType) {
|
||||
if (payloadType < -1) {
|
||||
int32_t RTPSenderAudio::SetRED(int8_t payload_type) {
|
||||
if (payload_type < -1) {
|
||||
return -1;
|
||||
}
|
||||
rtc::CritScope cs(&_sendAudioCritsect);
|
||||
_REDPayloadType = payloadType;
|
||||
rtc::CritScope cs(&send_audio_critsect_);
|
||||
red_payload_type_ = payload_type;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get payload type for Redundant Audio Data RFC 2198
|
||||
int32_t RTPSenderAudio::RED(int8_t* payloadType) const {
|
||||
rtc::CritScope cs(&_sendAudioCritsect);
|
||||
if (_REDPayloadType == -1) {
|
||||
int32_t RTPSenderAudio::RED(int8_t* payload_type) const {
|
||||
rtc::CritScope cs(&send_audio_critsect_);
|
||||
if (red_payload_type_ == -1) {
|
||||
// not configured
|
||||
return -1;
|
||||
}
|
||||
*payloadType = _REDPayloadType;
|
||||
*payload_type = red_payload_type_;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -395,8 +394,8 @@ int32_t RTPSenderAudio::SendTelephoneEvent(uint8_t key,
|
||||
uint16_t time_ms,
|
||||
uint8_t level) {
|
||||
{
|
||||
rtc::CritScope lock(&_sendAudioCritsect);
|
||||
if (_dtmfPayloadType < 0) {
|
||||
rtc::CritScope lock(&send_audio_critsect_);
|
||||
if (dtmf_payload_type_ < 0) {
|
||||
// TelephoneEvent payloadtype not configured
|
||||
return -1;
|
||||
}
|
||||
@ -406,9 +405,9 @@ int32_t RTPSenderAudio::SendTelephoneEvent(uint8_t key,
|
||||
|
||||
int32_t RTPSenderAudio::SendTelephoneEventPacket(bool ended,
|
||||
int8_t dtmf_payload_type,
|
||||
uint32_t dtmfTimeStamp,
|
||||
uint32_t dtmf_timestamp,
|
||||
uint16_t duration,
|
||||
bool markerBit) {
|
||||
bool marker_bit) {
|
||||
uint8_t dtmfbuffer[IP_PACKET_SIZE];
|
||||
uint8_t sendCount = 1;
|
||||
int32_t retVal = 0;
|
||||
@ -419,8 +418,8 @@ int32_t RTPSenderAudio::SendTelephoneEventPacket(bool ended,
|
||||
}
|
||||
do {
|
||||
// Send DTMF data
|
||||
_rtpSender->BuildRTPheader(dtmfbuffer, dtmf_payload_type, markerBit,
|
||||
dtmfTimeStamp, _clock->TimeInMilliseconds());
|
||||
rtp_sender_->BuildRtpHeader(dtmfbuffer, dtmf_payload_type, marker_bit,
|
||||
dtmf_timestamp, clock_->TimeInMilliseconds());
|
||||
|
||||
// reset CSRC and X bit
|
||||
dtmfbuffer[0] &= 0xe0;
|
||||
@ -436,22 +435,22 @@ int32_t RTPSenderAudio::SendTelephoneEventPacket(bool ended,
|
||||
*/
|
||||
// R bit always cleared
|
||||
uint8_t R = 0x00;
|
||||
uint8_t volume = _dtmfLevel;
|
||||
uint8_t volume = dtmf_level_;
|
||||
|
||||
// First packet un-ended
|
||||
uint8_t E = ended ? 0x80 : 0x00;
|
||||
|
||||
// First byte is Event number, equals key number
|
||||
dtmfbuffer[12] = _dtmfKey;
|
||||
dtmfbuffer[12] = dtmf_key_;
|
||||
dtmfbuffer[13] = E | R | volume;
|
||||
ByteWriter<uint16_t>::WriteBigEndian(dtmfbuffer + 14, duration);
|
||||
|
||||
TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"),
|
||||
"Audio::SendTelephoneEvent", "timestamp",
|
||||
dtmfTimeStamp, "seqnum", _rtpSender->SequenceNumber());
|
||||
retVal = _rtpSender->SendToNetwork(
|
||||
dtmfbuffer, 4, 12, rtc::TimeMillis(),
|
||||
kAllowRetransmission, RtpPacketSender::kHighPriority);
|
||||
TRACE_EVENT_INSTANT2(
|
||||
TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "Audio::SendTelephoneEvent",
|
||||
"timestamp", dtmf_timestamp, "seqnum", rtp_sender_->SequenceNumber());
|
||||
retVal = rtp_sender_->SendToNetwork(dtmfbuffer, 4, 12, rtc::TimeMillis(),
|
||||
kAllowRetransmission,
|
||||
RtpPacketSender::kHighPriority);
|
||||
sendCount--;
|
||||
} while (sendCount > 0 && retVal == 0);
|
||||
|
||||
|
||||
@ -21,33 +21,34 @@
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class RTPSenderAudio : public DTMFqueue {
|
||||
public:
|
||||
RTPSenderAudio(Clock* clock, RTPSender* rtpSender);
|
||||
RTPSenderAudio(Clock* clock, RTPSender* rtp_sender);
|
||||
virtual ~RTPSenderAudio();
|
||||
|
||||
int32_t RegisterAudioPayload(const char payloadName[RTP_PAYLOAD_NAME_SIZE],
|
||||
int8_t payloadType,
|
||||
int8_t payload_type,
|
||||
uint32_t frequency,
|
||||
size_t channels,
|
||||
uint32_t rate,
|
||||
RtpUtility::Payload** payload);
|
||||
|
||||
int32_t SendAudio(FrameType frameType,
|
||||
int8_t payloadType,
|
||||
uint32_t captureTimeStamp,
|
||||
const uint8_t* payloadData,
|
||||
size_t payloadSize,
|
||||
int32_t SendAudio(FrameType frame_type,
|
||||
int8_t payload_type,
|
||||
uint32_t capture_timestamp,
|
||||
const uint8_t* payload_data,
|
||||
size_t payload_size,
|
||||
const RTPFragmentationHeader* fragmentation);
|
||||
|
||||
// set audio packet size, used to determine when it's time to send a DTMF
|
||||
// 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
|
||||
// header-extension-for-audio-level-indication.
|
||||
// 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)
|
||||
int32_t SendTelephoneEvent(uint8_t key, uint16_t time_ms, uint8_t level);
|
||||
@ -55,55 +56,56 @@ class RTPSenderAudio : public DTMFqueue {
|
||||
int AudioFrequency() const;
|
||||
|
||||
// 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
|
||||
int32_t RED(int8_t* payloadType) const;
|
||||
int32_t RED(int8_t* payload_type) const;
|
||||
|
||||
protected:
|
||||
int32_t SendTelephoneEventPacket(
|
||||
bool ended,
|
||||
int8_t dtmf_payload_type,
|
||||
uint32_t dtmfTimeStamp,
|
||||
uint32_t dtmf_timestamp,
|
||||
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:
|
||||
Clock* const _clock;
|
||||
RTPSender* const _rtpSender;
|
||||
Clock* const clock_;
|
||||
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
|
||||
bool _dtmfEventIsOn;
|
||||
bool _dtmfEventFirstPacketSent;
|
||||
int8_t _dtmfPayloadType GUARDED_BY(_sendAudioCritsect);
|
||||
uint32_t _dtmfTimestamp;
|
||||
uint8_t _dtmfKey;
|
||||
uint32_t _dtmfLengthSamples;
|
||||
uint8_t _dtmfLevel;
|
||||
int64_t _dtmfTimeLastSent;
|
||||
uint32_t _dtmfTimestampLastSent;
|
||||
// DTMF.
|
||||
bool dtmf_event_is_on_;
|
||||
bool dtmf_event_first_packet_sent_;
|
||||
int8_t dtmf_payload_type_ GUARDED_BY(send_audio_critsect_);
|
||||
uint32_t dtmf_timestamp_;
|
||||
uint8_t dtmf_key_;
|
||||
uint32_t dtmf_length_samples_;
|
||||
uint8_t dtmf_level_;
|
||||
int64_t dtmf_time_last_sent_;
|
||||
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
|
||||
bool _inbandVADactive GUARDED_BY(_sendAudioCritsect);
|
||||
int8_t _cngNBPayloadType GUARDED_BY(_sendAudioCritsect);
|
||||
int8_t _cngWBPayloadType GUARDED_BY(_sendAudioCritsect);
|
||||
int8_t _cngSWBPayloadType GUARDED_BY(_sendAudioCritsect);
|
||||
int8_t _cngFBPayloadType GUARDED_BY(_sendAudioCritsect);
|
||||
int8_t _lastPayloadType GUARDED_BY(_sendAudioCritsect);
|
||||
// VAD detection, used for marker bit.
|
||||
bool inband_vad_active_ GUARDED_BY(send_audio_critsect_);
|
||||
int8_t cngnb_payload_type_ GUARDED_BY(send_audio_critsect_);
|
||||
int8_t cngwb_payload_type_ GUARDED_BY(send_audio_critsect_);
|
||||
int8_t cngswb_payload_type_ GUARDED_BY(send_audio_critsect_);
|
||||
int8_t cngfb_payload_type_ GUARDED_BY(send_audio_critsect_);
|
||||
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/)
|
||||
uint8_t _audioLevel_dBov GUARDED_BY(_sendAudioCritsect);
|
||||
uint8_t audio_level_dbov_ GUARDED_BY(send_audio_critsect_);
|
||||
OneTimeEvent first_packet_sent_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_AUDIO_H_
|
||||
|
||||
@ -185,7 +185,7 @@ class RtpSenderTest : public ::testing::Test {
|
||||
|
||||
void SendPacket(int64_t capture_time_ms, int payload_length) {
|
||||
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);
|
||||
ASSERT_GE(rtp_length, 0);
|
||||
|
||||
@ -206,7 +206,7 @@ class RtpSenderTest : public ::testing::Test {
|
||||
|
||||
EXPECT_EQ(0, rtp_sender_->SendOutgoingData(
|
||||
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::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));
|
||||
if (expect_cvo) {
|
||||
ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionLength(),
|
||||
@ -363,7 +363,7 @@ TEST_F(RtpSenderTestWithoutPacer, RegisterRtpVideoRotationHeaderExtension) {
|
||||
}
|
||||
|
||||
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));
|
||||
ASSERT_EQ(kRtpHeaderSize, length);
|
||||
|
||||
@ -394,7 +394,7 @@ TEST_F(RtpSenderTestWithoutPacer,
|
||||
kRtpExtensionTransmissionTimeOffset,
|
||||
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));
|
||||
ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionLength(), length);
|
||||
|
||||
@ -433,7 +433,7 @@ TEST_F(RtpSenderTestWithoutPacer,
|
||||
kRtpExtensionTransmissionTimeOffset,
|
||||
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));
|
||||
ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionLength(), length);
|
||||
|
||||
@ -460,7 +460,7 @@ TEST_F(RtpSenderTestWithoutPacer, BuildRTPPacketWithAbsoluteSendTimeExtension) {
|
||||
0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime,
|
||||
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));
|
||||
ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionLength(), length);
|
||||
|
||||
@ -545,7 +545,7 @@ TEST_F(RtpSenderTestWithoutPacer, BuildRTPPacketWithVideoRotation_MarkerBit) {
|
||||
map.Register(kRtpExtensionVideoRotation, kVideoRotationExtensionId);
|
||||
|
||||
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);
|
||||
|
||||
// Verify
|
||||
@ -573,7 +573,7 @@ TEST_F(RtpSenderTestWithoutPacer,
|
||||
map.Register(kRtpExtensionVideoRotation, kVideoRotationExtensionId);
|
||||
|
||||
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);
|
||||
|
||||
// Verify
|
||||
@ -591,7 +591,7 @@ TEST_F(RtpSenderTestWithoutPacer, BuildRTPPacketWithAudioLevelExtension) {
|
||||
EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAudioLevel,
|
||||
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));
|
||||
ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionLength(), length);
|
||||
|
||||
@ -634,7 +634,7 @@ TEST_F(RtpSenderTestWithoutPacer,
|
||||
std::vector<uint32_t> csrcs;
|
||||
csrcs.push_back(0x23456789);
|
||||
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));
|
||||
|
||||
// Verify
|
||||
@ -678,7 +678,7 @@ TEST_F(RtpSenderTestWithoutPacer, BuildRTPPacketWithHeaderExtensions) {
|
||||
kRtpExtensionTransportSequenceNumber,
|
||||
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));
|
||||
ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionLength(), length);
|
||||
|
||||
@ -747,7 +747,7 @@ TEST_F(RtpSenderTest, TrafficSmoothingWithExtensions) {
|
||||
0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime,
|
||||
kAbsoluteSendTimeExtensionId));
|
||||
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);
|
||||
ASSERT_NE(-1, 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,
|
||||
kAbsoluteSendTimeExtensionId));
|
||||
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);
|
||||
ASSERT_NE(-1, 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;
|
||||
|
||||
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);
|
||||
const uint32_t media_packet_timestamp = timestamp;
|
||||
ASSERT_NE(-1, rtp_length_int);
|
||||
@ -939,7 +939,7 @@ TEST_F(RtpSenderTest, SendPadding) {
|
||||
|
||||
// Send a regular video packet again.
|
||||
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);
|
||||
ASSERT_NE(-1, 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};
|
||||
|
||||
// Send keyframe
|
||||
ASSERT_EQ(
|
||||
0, rtp_sender_->SendOutgoingData(kVideoFrameKey, payload_type, 1234, 4321,
|
||||
payload, sizeof(payload), nullptr));
|
||||
ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kVideoFrameKey, payload_type, 1234,
|
||||
4321, payload, sizeof(payload),
|
||||
nullptr, nullptr));
|
||||
|
||||
RtpUtility::RtpHeaderParser rtp_parser(transport_.last_sent_packet_,
|
||||
transport_.last_sent_packet_len_);
|
||||
@ -1140,9 +1140,9 @@ TEST_F(RtpSenderTestWithoutPacer, SendGenericVideo) {
|
||||
payload[1] = 42;
|
||||
payload[4] = 13;
|
||||
|
||||
ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kVideoFrameDelta, payload_type,
|
||||
1234, 4321, payload,
|
||||
sizeof(payload), nullptr));
|
||||
ASSERT_EQ(0, rtp_sender_->SendOutgoingData(
|
||||
kVideoFrameDelta, payload_type, 1234, 4321, payload,
|
||||
sizeof(payload), nullptr, nullptr));
|
||||
|
||||
RtpUtility::RtpHeaderParser rtp_parser2(transport_.last_sent_packet_,
|
||||
transport_.last_sent_packet_len_);
|
||||
@ -1193,18 +1193,18 @@ TEST_F(RtpSenderTest, FrameCountCallbacks) {
|
||||
EXPECT_CALL(mock_paced_sender_, InsertPacket(_, _, _, _, _, _))
|
||||
.Times(::testing::AtLeast(2));
|
||||
|
||||
ASSERT_EQ(
|
||||
0, rtp_sender_->SendOutgoingData(kVideoFrameKey, payload_type, 1234, 4321,
|
||||
payload, sizeof(payload), nullptr));
|
||||
ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kVideoFrameKey, payload_type, 1234,
|
||||
4321, payload, sizeof(payload),
|
||||
nullptr, nullptr));
|
||||
|
||||
EXPECT_EQ(1U, callback.num_calls_);
|
||||
EXPECT_EQ(ssrc, callback.ssrc_);
|
||||
EXPECT_EQ(1, callback.frame_counts_.key_frames);
|
||||
EXPECT_EQ(0, callback.frame_counts_.delta_frames);
|
||||
|
||||
ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kVideoFrameDelta, payload_type,
|
||||
1234, 4321, payload,
|
||||
sizeof(payload), nullptr));
|
||||
ASSERT_EQ(0, rtp_sender_->SendOutgoingData(
|
||||
kVideoFrameDelta, payload_type, 1234, 4321, payload,
|
||||
sizeof(payload), nullptr, nullptr));
|
||||
|
||||
EXPECT_EQ(2U, callback.num_calls_);
|
||||
EXPECT_EQ(ssrc, callback.ssrc_);
|
||||
@ -1266,9 +1266,9 @@ TEST_F(RtpSenderTest, BitrateCallbacks) {
|
||||
|
||||
// Send a few frames.
|
||||
for (uint32_t i = 0; i < kNumPackets; ++i) {
|
||||
ASSERT_EQ(0,
|
||||
rtp_sender_->SendOutgoingData(kVideoFrameKey, payload_type, 1234,
|
||||
4321, payload, sizeof(payload), 0));
|
||||
ASSERT_EQ(0, rtp_sender_->SendOutgoingData(
|
||||
kVideoFrameKey, payload_type, 1234, 4321, payload,
|
||||
sizeof(payload), nullptr, nullptr));
|
||||
fake_clock_.AdvanceTimeMilliseconds(kPacketInterval);
|
||||
}
|
||||
|
||||
@ -1347,9 +1347,9 @@ TEST_F(RtpSenderTestWithoutPacer, StreamDataCountersCallbacks) {
|
||||
rtp_sender_->RegisterRtpStatisticsCallback(&callback);
|
||||
|
||||
// Send a frame.
|
||||
ASSERT_EQ(
|
||||
0, rtp_sender_->SendOutgoingData(kVideoFrameKey, payload_type, 1234, 4321,
|
||||
payload, sizeof(payload), nullptr));
|
||||
ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kVideoFrameKey, payload_type, 1234,
|
||||
4321, payload, sizeof(payload),
|
||||
nullptr, nullptr));
|
||||
StreamDataCounters expected;
|
||||
expected.transmitted.payload_bytes = 6;
|
||||
expected.transmitted.header_bytes = 12;
|
||||
@ -1389,9 +1389,9 @@ TEST_F(RtpSenderTestWithoutPacer, StreamDataCountersCallbacks) {
|
||||
fec_params.fec_rate = 1;
|
||||
fec_params.max_fec_frames = 1;
|
||||
rtp_sender_->SetFecParameters(&fec_params, &fec_params);
|
||||
ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kVideoFrameDelta, payload_type,
|
||||
1234, 4321, payload,
|
||||
sizeof(payload), nullptr));
|
||||
ASSERT_EQ(0, rtp_sender_->SendOutgoingData(
|
||||
kVideoFrameDelta, payload_type, 1234, 4321, payload,
|
||||
sizeof(payload), nullptr, nullptr));
|
||||
expected.transmitted.payload_bytes = 40;
|
||||
expected.transmitted.header_bytes = 60;
|
||||
expected.transmitted.packets = 5;
|
||||
@ -1408,9 +1408,9 @@ TEST_F(RtpSenderAudioTest, SendAudio) {
|
||||
0, 1500));
|
||||
uint8_t payload[] = {47, 11, 32, 93, 89};
|
||||
|
||||
ASSERT_EQ(
|
||||
0, rtp_sender_->SendOutgoingData(kAudioFrameCN, payload_type, 1234, 4321,
|
||||
payload, sizeof(payload), nullptr));
|
||||
ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kAudioFrameCN, payload_type, 1234,
|
||||
4321, payload, sizeof(payload),
|
||||
nullptr, nullptr));
|
||||
|
||||
RtpUtility::RtpHeaderParser rtp_parser(transport_.last_sent_packet_,
|
||||
transport_.last_sent_packet_len_);
|
||||
@ -1437,9 +1437,9 @@ TEST_F(RtpSenderAudioTest, SendAudioWithAudioLevelExtension) {
|
||||
0, 1500));
|
||||
uint8_t payload[] = {47, 11, 32, 93, 89};
|
||||
|
||||
ASSERT_EQ(
|
||||
0, rtp_sender_->SendOutgoingData(kAudioFrameCN, payload_type, 1234, 4321,
|
||||
payload, sizeof(payload), nullptr));
|
||||
ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kAudioFrameCN, payload_type, 1234,
|
||||
4321, payload, sizeof(payload),
|
||||
nullptr, nullptr));
|
||||
|
||||
RtpUtility::RtpHeaderParser rtp_parser(transport_.last_sent_packet_,
|
||||
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.
|
||||
ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kEmptyFrame, payload_type,
|
||||
capture_time_ms, 0, nullptr, 0,
|
||||
nullptr));
|
||||
nullptr, nullptr));
|
||||
// DTMF Sample Length is (Frequency/1000) * Duration.
|
||||
// So in this case, it is (8000/1000) * 500 = 4000.
|
||||
// Sending it as two packets.
|
||||
ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kEmptyFrame, payload_type,
|
||||
capture_time_ms + 2000, 0, nullptr,
|
||||
0, nullptr));
|
||||
0, nullptr, nullptr));
|
||||
std::unique_ptr<webrtc::RtpHeaderParser> rtp_parser(
|
||||
webrtc::RtpHeaderParser::Create());
|
||||
ASSERT_TRUE(rtp_parser.get() != nullptr);
|
||||
@ -1508,7 +1508,7 @@ TEST_F(RtpSenderAudioTest, CheckMarkerBitForTelephoneEvents) {
|
||||
|
||||
ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kEmptyFrame, payload_type,
|
||||
capture_time_ms + 4000, 0, nullptr,
|
||||
0, nullptr));
|
||||
0, nullptr, nullptr));
|
||||
ASSERT_TRUE(rtp_parser->Parse(transport_.last_sent_packet_,
|
||||
transport_.last_sent_packet_len_, &rtp_header));
|
||||
// Marker Bit should be set to 0 for rest of the packets.
|
||||
@ -1527,9 +1527,9 @@ TEST_F(RtpSenderTestWithoutPacer, BytesReportedCorrectly) {
|
||||
0, 1500));
|
||||
uint8_t payload[] = {47, 11, 32, 93, 89};
|
||||
|
||||
ASSERT_EQ(
|
||||
0, rtp_sender_->SendOutgoingData(kVideoFrameKey, kPayloadType, 1234, 4321,
|
||||
payload, sizeof(payload), 0));
|
||||
ASSERT_EQ(0, rtp_sender_->SendOutgoingData(kVideoFrameKey, kPayloadType, 1234,
|
||||
4321, payload, sizeof(payload),
|
||||
nullptr, nullptr));
|
||||
|
||||
// Will send 2 full-size padding packets.
|
||||
rtp_sender_->TimeToSendPadding(1, PacketInfo::kNotAProbe);
|
||||
|
||||
@ -27,73 +27,59 @@
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtp_format_vp9.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
enum { REDForFECHeaderLength = 1 };
|
||||
|
||||
RTPSenderVideo::RTPSenderVideo(Clock* clock, RTPSenderInterface* rtpSender)
|
||||
: _rtpSender(*rtpSender),
|
||||
RTPSenderVideo::RTPSenderVideo(Clock* clock, RTPSenderInterface* rtp_sender)
|
||||
: rtp_sender_(rtp_sender),
|
||||
clock_(clock),
|
||||
_videoType(kRtpVideoGeneric),
|
||||
_retransmissionSettings(kRetransmitBaseLayer),
|
||||
// Generic FEC
|
||||
fec_(),
|
||||
fec_enabled_(false),
|
||||
red_payload_type_(0),
|
||||
fec_payload_type_(0),
|
||||
delta_fec_params_(),
|
||||
key_fec_params_(),
|
||||
producer_fec_(&fec_),
|
||||
fec_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;
|
||||
}
|
||||
video_bitrate_(1000, RateStatistics::kBpsScale) {}
|
||||
|
||||
RTPSenderVideo::~RTPSenderVideo() {
|
||||
}
|
||||
RTPSenderVideo::~RTPSenderVideo() {}
|
||||
|
||||
void RTPSenderVideo::SetVideoCodecType(RtpVideoCodecTypes videoType) {
|
||||
_videoType = videoType;
|
||||
void RTPSenderVideo::SetVideoCodecType(RtpVideoCodecTypes video_type) {
|
||||
video_type_ = video_type;
|
||||
}
|
||||
|
||||
RtpVideoCodecTypes RTPSenderVideo::VideoCodecType() const {
|
||||
return _videoType;
|
||||
return video_type_;
|
||||
}
|
||||
|
||||
// Static.
|
||||
RtpUtility::Payload* RTPSenderVideo::CreateVideoPayload(
|
||||
const char payloadName[RTP_PAYLOAD_NAME_SIZE],
|
||||
const int8_t payloadType) {
|
||||
RtpVideoCodecTypes videoType = kRtpVideoGeneric;
|
||||
if (RtpUtility::StringCompare(payloadName, "VP8", 3)) {
|
||||
videoType = kRtpVideoVp8;
|
||||
} else if (RtpUtility::StringCompare(payloadName, "VP9", 3)) {
|
||||
videoType = kRtpVideoVp9;
|
||||
} else if (RtpUtility::StringCompare(payloadName, "H264", 4)) {
|
||||
videoType = kRtpVideoH264;
|
||||
} else if (RtpUtility::StringCompare(payloadName, "I420", 4)) {
|
||||
videoType = kRtpVideoGeneric;
|
||||
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
|
||||
int8_t payload_type) {
|
||||
RtpVideoCodecTypes video_type = kRtpVideoGeneric;
|
||||
if (RtpUtility::StringCompare(payload_name, "VP8", 3)) {
|
||||
video_type = kRtpVideoVp8;
|
||||
} else if (RtpUtility::StringCompare(payload_name, "VP9", 3)) {
|
||||
video_type = kRtpVideoVp9;
|
||||
} else if (RtpUtility::StringCompare(payload_name, "H264", 4)) {
|
||||
video_type = kRtpVideoH264;
|
||||
} else if (RtpUtility::StringCompare(payload_name, "I420", 4)) {
|
||||
video_type = kRtpVideoGeneric;
|
||||
} else {
|
||||
videoType = kRtpVideoGeneric;
|
||||
video_type = kRtpVideoGeneric;
|
||||
}
|
||||
RtpUtility::Payload* payload = new RtpUtility::Payload();
|
||||
payload->name[RTP_PAYLOAD_NAME_SIZE - 1] = 0;
|
||||
strncpy(payload->name, payloadName, RTP_PAYLOAD_NAME_SIZE - 1);
|
||||
payload->typeSpecific.Video.videoCodecType = videoType;
|
||||
strncpy(payload->name, payload_name, RTP_PAYLOAD_NAME_SIZE - 1);
|
||||
payload->typeSpecific.Video.videoCodecType = video_type;
|
||||
payload->audio = false;
|
||||
return payload;
|
||||
}
|
||||
|
||||
void RTPSenderVideo::SendVideoPacket(uint8_t* data_buffer,
|
||||
const size_t payload_length,
|
||||
const size_t rtp_header_length,
|
||||
size_t payload_length,
|
||||
size_t rtp_header_length,
|
||||
uint16_t seq_num,
|
||||
const uint32_t capture_timestamp,
|
||||
uint32_t capture_timestamp,
|
||||
int64_t capture_time_ms,
|
||||
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,
|
||||
RtpPacketSender::kLowPriority) == 0) {
|
||||
rtc::CritScope cs(&stats_crit_);
|
||||
@ -108,10 +94,10 @@ void RTPSenderVideo::SendVideoPacket(uint8_t* data_buffer,
|
||||
}
|
||||
|
||||
void RTPSenderVideo::SendVideoPacketAsRed(uint8_t* data_buffer,
|
||||
const size_t payload_length,
|
||||
const size_t rtp_header_length,
|
||||
size_t payload_length,
|
||||
size_t rtp_header_length,
|
||||
uint16_t media_seq_num,
|
||||
const uint32_t capture_timestamp,
|
||||
uint32_t capture_timestamp,
|
||||
int64_t capture_time_ms,
|
||||
StorageType media_packet_storage,
|
||||
bool protect) {
|
||||
@ -131,16 +117,16 @@ void RTPSenderVideo::SendVideoPacketAsRed(uint8_t* data_buffer,
|
||||
uint16_t num_fec_packets = producer_fec_.NumAvailableFecPackets();
|
||||
if (num_fec_packets > 0) {
|
||||
next_fec_sequence_number =
|
||||
_rtpSender.AllocateSequenceNumber(num_fec_packets);
|
||||
rtp_sender_->AllocateSequenceNumber(num_fec_packets);
|
||||
fec_packets = producer_fec_.GetFecPackets(
|
||||
red_payload_type_, fec_payload_type_, next_fec_sequence_number,
|
||||
rtp_header_length);
|
||||
RTC_DCHECK_EQ(num_fec_packets, fec_packets.size());
|
||||
if (_retransmissionSettings & kRetransmitFECPackets)
|
||||
if (retransmission_settings_ & kRetransmitFECPackets)
|
||||
fec_storage = kAllowRetransmission;
|
||||
}
|
||||
}
|
||||
if (_rtpSender.SendToNetwork(
|
||||
if (rtp_sender_->SendToNetwork(
|
||||
red_packet->data(), red_packet->length() - rtp_header_length,
|
||||
rtp_header_length, capture_time_ms, media_packet_storage,
|
||||
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;
|
||||
}
|
||||
for (RedPacket* fec_packet : fec_packets) {
|
||||
if (_rtpSender.SendToNetwork(
|
||||
if (rtp_sender_->SendToNetwork(
|
||||
fec_packet->data(), fec_packet->length() - rtp_header_length,
|
||||
rtp_header_length, capture_time_ms, fec_storage,
|
||||
RtpPacketSender::kLowPriority) == 0) {
|
||||
@ -171,28 +157,25 @@ void RTPSenderVideo::SendVideoPacketAsRed(uint8_t* data_buffer,
|
||||
}
|
||||
}
|
||||
|
||||
void RTPSenderVideo::SetGenericFECStatus(const bool enable,
|
||||
const uint8_t payloadTypeRED,
|
||||
const uint8_t payloadTypeFEC) {
|
||||
RTC_DCHECK(!enable || payloadTypeRED > 0);
|
||||
void RTPSenderVideo::SetGenericFECStatus(bool enable,
|
||||
uint8_t payload_type_red,
|
||||
uint8_t payload_type_fec) {
|
||||
RTC_DCHECK(!enable || payload_type_red > 0);
|
||||
rtc::CritScope cs(&crit_);
|
||||
fec_enabled_ = enable;
|
||||
red_payload_type_ = payloadTypeRED;
|
||||
fec_payload_type_ = payloadTypeFEC;
|
||||
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;
|
||||
red_payload_type_ = payload_type_red;
|
||||
fec_payload_type_ = payload_type_fec;
|
||||
delta_fec_params_ = FecProtectionParams{0, 1, kFecMaskRandom};
|
||||
key_fec_params_ = FecProtectionParams{0, 1, kFecMaskRandom};
|
||||
}
|
||||
|
||||
void RTPSenderVideo::GenericFECStatus(bool* enable,
|
||||
uint8_t* payloadTypeRED,
|
||||
uint8_t* payloadTypeFEC) const {
|
||||
uint8_t* payload_type_red,
|
||||
uint8_t* payload_type_fec) const {
|
||||
rtc::CritScope cs(&crit_);
|
||||
*enable = fec_enabled_;
|
||||
*payloadTypeRED = red_payload_type_;
|
||||
*payloadTypeFEC = fec_payload_type_;
|
||||
*payload_type_red = red_payload_type_;
|
||||
*payload_type_fec = fec_payload_type_;
|
||||
}
|
||||
|
||||
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.
|
||||
// (The base RTP header is already protected by the FEC header.)
|
||||
return ForwardErrorCorrection::PacketOverhead() + REDForFECHeaderLength +
|
||||
(_rtpSender.RtpHeaderLength() - kRtpHeaderSize);
|
||||
(rtp_sender_->RtpHeaderLength() - kRtpHeaderSize);
|
||||
}
|
||||
if (fec_enabled_)
|
||||
overhead += ForwardErrorCorrection::PacketOverhead();
|
||||
@ -223,22 +206,22 @@ void RTPSenderVideo::SetFecParameters(const FecProtectionParams* delta_params,
|
||||
}
|
||||
}
|
||||
|
||||
int32_t RTPSenderVideo::SendVideo(const RtpVideoCodecTypes videoType,
|
||||
const FrameType frameType,
|
||||
const int8_t payloadType,
|
||||
const uint32_t captureTimeStamp,
|
||||
int32_t RTPSenderVideo::SendVideo(RtpVideoCodecTypes video_type,
|
||||
FrameType frame_type,
|
||||
int8_t payload_type,
|
||||
uint32_t capture_timestamp,
|
||||
int64_t capture_time_ms,
|
||||
const uint8_t* payloadData,
|
||||
const size_t payloadSize,
|
||||
const uint8_t* payload_data,
|
||||
size_t payload_size,
|
||||
const RTPFragmentationHeader* fragmentation,
|
||||
const RTPVideoHeader* video_header) {
|
||||
if (payloadSize == 0) {
|
||||
if (payload_size == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::unique_ptr<RtpPacketizer> packetizer(RtpPacketizer::Create(
|
||||
videoType, _rtpSender.MaxDataPayloadLength(),
|
||||
video_header ? &(video_header->codecHeader) : nullptr, frameType));
|
||||
video_type, rtp_sender_->MaxDataPayloadLength(),
|
||||
video_header ? &(video_header->codecHeader) : nullptr, frame_type));
|
||||
|
||||
StorageType storage;
|
||||
int red_payload_type;
|
||||
@ -246,9 +229,9 @@ int32_t RTPSenderVideo::SendVideo(const RtpVideoCodecTypes videoType,
|
||||
{
|
||||
rtc::CritScope cs(&crit_);
|
||||
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);
|
||||
storage = packetizer->GetStorageType(_retransmissionSettings);
|
||||
storage = packetizer->GetStorageType(retransmission_settings_);
|
||||
red_payload_type = red_payload_type_;
|
||||
}
|
||||
|
||||
@ -256,18 +239,18 @@ int32_t RTPSenderVideo::SendVideo(const RtpVideoCodecTypes videoType,
|
||||
// with pending rotation.
|
||||
bool video_rotation_active = false;
|
||||
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();
|
||||
size_t payload_bytes_to_send = payloadSize;
|
||||
const uint8_t* data = payloadData;
|
||||
int rtp_header_length = rtp_sender_->RtpHeaderLength();
|
||||
size_t payload_bytes_to_send = payload_size;
|
||||
const uint8_t* data = payload_data;
|
||||
|
||||
// TODO(changbin): we currently don't support to configure the codec to
|
||||
// output multiple partitions for VP8. Should remove below check after the
|
||||
// issue is fixed.
|
||||
const RTPFragmentationHeader* frag =
|
||||
(videoType == kRtpVideoVp8) ? NULL : fragmentation;
|
||||
(video_type == kRtpVideoVp8) ? NULL : fragmentation;
|
||||
|
||||
packetizer->SetPayloadData(data, payload_bytes_to_send, frag);
|
||||
|
||||
@ -283,8 +266,8 @@ int32_t RTPSenderVideo::SendVideo(const RtpVideoCodecTypes videoType,
|
||||
}
|
||||
|
||||
// Write RTP header.
|
||||
_rtpSender.BuildRTPheader(
|
||||
dataBuffer, payloadType, last, captureTimeStamp, capture_time_ms);
|
||||
rtp_sender_->BuildRtpHeader(dataBuffer, payload_type, last,
|
||||
capture_timestamp, capture_time_ms);
|
||||
|
||||
// According to
|
||||
// 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.
|
||||
// Here we are adding it to every packet of every frame at this point.
|
||||
if (!video_header) {
|
||||
RTC_DCHECK(!_rtpSender.IsRtpHeaderExtensionRegistered(
|
||||
RTC_DCHECK(!rtp_sender_->IsRtpHeaderExtensionRegistered(
|
||||
kRtpExtensionVideoRotation));
|
||||
} else if (video_rotation_active) {
|
||||
// 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
|
||||
// the RTP header length is consistent, although the receiver side will
|
||||
// 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);
|
||||
RTPHeader rtp_header;
|
||||
rtp_parser.Parse(&rtp_header);
|
||||
_rtpSender.UpdateVideoRotation(dataBuffer, packetSize, rtp_header,
|
||||
rtp_sender_->UpdateVideoRotation(dataBuffer, packetSize, rtp_header,
|
||||
video_header->rotation);
|
||||
}
|
||||
if (red_payload_type != 0) {
|
||||
SendVideoPacketAsRed(dataBuffer, payload_bytes_in_packet,
|
||||
rtp_header_length, _rtpSender.SequenceNumber(),
|
||||
captureTimeStamp, capture_time_ms, storage,
|
||||
rtp_header_length, rtp_sender_->SequenceNumber(),
|
||||
capture_timestamp, capture_time_ms, storage,
|
||||
packetizer->GetProtectionType() == kProtectedPacket);
|
||||
} else {
|
||||
SendVideoPacket(dataBuffer, payload_bytes_in_packet, rtp_header_length,
|
||||
_rtpSender.SequenceNumber(), captureTimeStamp,
|
||||
rtp_sender_->SequenceNumber(), capture_timestamp,
|
||||
capture_time_ms, storage);
|
||||
}
|
||||
|
||||
@ -337,8 +320,8 @@ int32_t RTPSenderVideo::SendVideo(const RtpVideoCodecTypes videoType,
|
||||
first = false;
|
||||
}
|
||||
|
||||
TRACE_EVENT_ASYNC_END1(
|
||||
"webrtc", "Video", capture_time_ms, "timestamp", _rtpSender.Timestamp());
|
||||
TRACE_EVENT_ASYNC_END1("webrtc", "Video", capture_time_ms, "timestamp",
|
||||
rtp_sender_->Timestamp());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -354,12 +337,12 @@ uint32_t RTPSenderVideo::FecOverheadRate() const {
|
||||
|
||||
int RTPSenderVideo::SelectiveRetransmissions() const {
|
||||
rtc::CritScope cs(&crit_);
|
||||
return _retransmissionSettings;
|
||||
return retransmission_settings_;
|
||||
}
|
||||
|
||||
void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) {
|
||||
rtc::CritScope cs(&crit_);
|
||||
_retransmissionSettings = settings;
|
||||
retransmission_settings_ = settings;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -31,7 +31,7 @@ namespace webrtc {
|
||||
|
||||
class RTPSenderVideo {
|
||||
public:
|
||||
RTPSenderVideo(Clock* clock, RTPSenderInterface* rtpSender);
|
||||
RTPSenderVideo(Clock* clock, RTPSenderInterface* rtp_sender);
|
||||
virtual ~RTPSenderVideo();
|
||||
|
||||
virtual RtpVideoCodecTypes VideoCodecType() const;
|
||||
@ -39,16 +39,16 @@ class RTPSenderVideo {
|
||||
size_t FECPacketOverhead() const;
|
||||
|
||||
static RtpUtility::Payload* CreateVideoPayload(
|
||||
const char payloadName[RTP_PAYLOAD_NAME_SIZE],
|
||||
const int8_t payloadType);
|
||||
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
|
||||
int8_t payload_type);
|
||||
|
||||
int32_t SendVideo(const RtpVideoCodecTypes videoType,
|
||||
const FrameType frameType,
|
||||
const int8_t payloadType,
|
||||
const uint32_t captureTimeStamp,
|
||||
int32_t SendVideo(RtpVideoCodecTypes video_type,
|
||||
FrameType frame_type,
|
||||
int8_t payload_type,
|
||||
uint32_t capture_timestamp,
|
||||
int64_t capture_time_ms,
|
||||
const uint8_t* payloadData,
|
||||
const size_t payloadSize,
|
||||
const uint8_t* payload_data,
|
||||
size_t payload_size,
|
||||
const RTPFragmentationHeader* fragmentation,
|
||||
const RTPVideoHeader* video_header);
|
||||
|
||||
@ -57,13 +57,13 @@ class RTPSenderVideo {
|
||||
void SetVideoCodecType(RtpVideoCodecTypes type);
|
||||
|
||||
// FEC
|
||||
void SetGenericFECStatus(const bool enable,
|
||||
const uint8_t payloadTypeRED,
|
||||
const uint8_t payloadTypeFEC);
|
||||
void SetGenericFECStatus(bool enable,
|
||||
uint8_t payload_type_red,
|
||||
uint8_t payload_type_fec);
|
||||
|
||||
void GenericFECStatus(bool* enable,
|
||||
uint8_t* payloadTypeRED,
|
||||
uint8_t* payloadTypeFEC) const;
|
||||
uint8_t* payload_type_red,
|
||||
uint8_t* payload_type_fec) const;
|
||||
|
||||
void SetFecParameters(const FecProtectionParams* delta_params,
|
||||
const FecProtectionParams* key_params);
|
||||
@ -75,39 +75,41 @@ class RTPSenderVideo {
|
||||
void SetSelectiveRetransmissions(uint8_t settings);
|
||||
|
||||
private:
|
||||
void SendVideoPacket(uint8_t* dataBuffer,
|
||||
const size_t payloadLength,
|
||||
const size_t rtpHeaderLength,
|
||||
void SendVideoPacket(uint8_t* data_buffer,
|
||||
size_t payload_length,
|
||||
size_t rtp_header_length,
|
||||
uint16_t seq_num,
|
||||
const uint32_t capture_timestamp,
|
||||
uint32_t capture_timestamp,
|
||||
int64_t capture_time_ms,
|
||||
StorageType storage);
|
||||
|
||||
void SendVideoPacketAsRed(uint8_t* dataBuffer,
|
||||
const size_t payloadLength,
|
||||
const size_t rtpHeaderLength,
|
||||
void SendVideoPacketAsRed(uint8_t* data_buffer,
|
||||
size_t payload_length,
|
||||
size_t rtp_header_length,
|
||||
uint16_t video_seq_num,
|
||||
const uint32_t capture_timestamp,
|
||||
uint32_t capture_timestamp,
|
||||
int64_t capture_time_ms,
|
||||
StorageType media_packet_storage,
|
||||
bool protect);
|
||||
|
||||
RTPSenderInterface& _rtpSender;
|
||||
RTPSenderInterface* const rtp_sender_;
|
||||
Clock* const clock_;
|
||||
|
||||
// Should never be held when calling out of this class.
|
||||
rtc::CriticalSection crit_;
|
||||
|
||||
RtpVideoCodecTypes _videoType;
|
||||
int32_t _retransmissionSettings GUARDED_BY(crit_);
|
||||
RtpVideoCodecTypes video_type_ = kRtpVideoGeneric;
|
||||
int32_t retransmission_settings_ GUARDED_BY(crit_) = kRetransmitBaseLayer;
|
||||
|
||||
// FEC
|
||||
ForwardErrorCorrection fec_;
|
||||
bool fec_enabled_ GUARDED_BY(crit_);
|
||||
int8_t red_payload_type_ GUARDED_BY(crit_);
|
||||
int8_t fec_payload_type_ GUARDED_BY(crit_);
|
||||
FecProtectionParams delta_fec_params_ GUARDED_BY(crit_);
|
||||
FecProtectionParams key_fec_params_ GUARDED_BY(crit_);
|
||||
bool fec_enabled_ GUARDED_BY(crit_) = false;
|
||||
int8_t red_payload_type_ GUARDED_BY(crit_) = 0;
|
||||
int8_t fec_payload_type_ GUARDED_BY(crit_) = 0;
|
||||
FecProtectionParams delta_fec_params_ GUARDED_BY(crit_) = FecProtectionParams{
|
||||
0, 1, kFecMaskRandom};
|
||||
FecProtectionParams key_fec_params_ GUARDED_BY(crit_) = FecProtectionParams{
|
||||
0, 1, kFecMaskRandom};
|
||||
ProducerFec producer_fec_ GUARDED_BY(crit_);
|
||||
|
||||
rtc::CriticalSection stats_crit_;
|
||||
@ -118,6 +120,7 @@ class RTPSenderVideo {
|
||||
RateStatistics video_bitrate_ GUARDED_BY(stats_crit_);
|
||||
OneTimeEvent first_frame_sent_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_VIDEO_H_
|
||||
|
||||
@ -90,13 +90,13 @@ class RtpStreamReceiver : public RtpData, public RtpFeedback,
|
||||
bool OnRecoveredPacket(const uint8_t* packet, size_t packet_length) override;
|
||||
|
||||
// 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 int frequency,
|
||||
const size_t channels,
|
||||
const uint32_t rate) override;
|
||||
void OnIncomingSSRCChanged(const uint32_t ssrc) override;
|
||||
void OnIncomingCSRCChanged(const uint32_t CSRC, const bool added) override {}
|
||||
int frequency,
|
||||
size_t channels,
|
||||
uint32_t rate) override;
|
||||
void OnIncomingSSRCChanged(uint32_t ssrc) override;
|
||||
void OnIncomingCSRCChanged(uint32_t CSRC, bool added) override {}
|
||||
|
||||
// Implements VCMFrameTypeCallback.
|
||||
int32_t RequestKeyFrame() override;
|
||||
|
||||
Reference in New Issue
Block a user