mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 13:50:40 +01:00

This reverts commit fb0dca6c05
.
Reason for revert: Speculative revert due to failing stats test in chromium. Possibly because the chromium test expected the metrics to not be supported, and now they are. Reverting just to unblock the webrtc roll into chromium.
Original change's description:
> Wire up non-sender RTT for audio, and implement related standardized stats.
>
> The implemented stats are:
> - https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-roundtriptime
> - https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-totalroundtriptime
> - https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-roundtriptimemeasurements
>
> Bug: webrtc:12951, webrtc:12714
> Change-Id: Ia362d5c4b0456140e32da79d40edc06ab9ce2a2c
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226956
> Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
> Reviewed-by: Henrik Boström <hbos@webrtc.org>
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#34861}
# Not skipping CQ checks because original CL landed > 1 day ago.
TBR=hta,hbos,minyue
Bug: webrtc:12951, webrtc:12714
Change-Id: If07ad63286eea9cdde88271e61cc28f4b268b290
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231001
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Reviewed-by: Olga Sharonova <olka@webrtc.org>
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#34897}
329 lines
11 KiB
C++
329 lines
11 KiB
C++
/*
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#ifndef MODULES_RTP_RTCP_SOURCE_RTP_RTCP_IMPL_H_
|
|
#define MODULES_RTP_RTCP_SOURCE_RTP_RTCP_IMPL_H_
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
#include <memory>
|
|
#include <set>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "absl/types/optional.h"
|
|
#include "api/rtp_headers.h"
|
|
#include "api/video/video_bitrate_allocation.h"
|
|
#include "modules/include/module_fec_types.h"
|
|
#include "modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
|
|
#include "modules/rtp_rtcp/include/rtp_rtcp.h"
|
|
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" // RTCPPacketType
|
|
#include "modules/rtp_rtcp/source/deprecated/deprecated_rtp_sender_egress.h"
|
|
#include "modules/rtp_rtcp/source/packet_sequencer.h"
|
|
#include "modules/rtp_rtcp/source/rtcp_packet/tmmb_item.h"
|
|
#include "modules/rtp_rtcp/source/rtcp_receiver.h"
|
|
#include "modules/rtp_rtcp/source/rtcp_sender.h"
|
|
#include "modules/rtp_rtcp/source/rtp_packet_history.h"
|
|
#include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
|
|
#include "modules/rtp_rtcp/source/rtp_sender.h"
|
|
#include "rtc_base/gtest_prod_util.h"
|
|
#include "rtc_base/synchronization/mutex.h"
|
|
|
|
namespace webrtc {
|
|
|
|
class Clock;
|
|
struct PacedPacketInfo;
|
|
struct RTPVideoHeader;
|
|
|
|
// DEPRECATED.
|
|
class ModuleRtpRtcpImpl : public RtpRtcp, public RTCPReceiver::ModuleRtpRtcp {
|
|
public:
|
|
explicit ModuleRtpRtcpImpl(
|
|
const RtpRtcpInterface::Configuration& configuration);
|
|
~ModuleRtpRtcpImpl() override;
|
|
|
|
// Returns the number of milliseconds until the module want a worker thread to
|
|
// call Process.
|
|
int64_t TimeUntilNextProcess() override;
|
|
|
|
// Process any pending tasks such as timeouts.
|
|
void Process() override;
|
|
|
|
// Receiver part.
|
|
|
|
// Called when we receive an RTCP packet.
|
|
void IncomingRtcpPacket(const uint8_t* incoming_packet,
|
|
size_t incoming_packet_length) override;
|
|
|
|
void SetRemoteSSRC(uint32_t ssrc) override;
|
|
void SetLocalSsrc(uint32_t ssrc) override;
|
|
|
|
// Sender part.
|
|
void RegisterSendPayloadFrequency(int payload_type,
|
|
int payload_frequency) override;
|
|
|
|
int32_t DeRegisterSendPayload(int8_t payload_type) override;
|
|
|
|
void SetExtmapAllowMixed(bool extmap_allow_mixed) override;
|
|
|
|
// Register RTP header extension.
|
|
void RegisterRtpHeaderExtension(absl::string_view uri, int id) override;
|
|
int32_t DeregisterSendRtpHeaderExtension(RTPExtensionType type) override;
|
|
void DeregisterSendRtpHeaderExtension(absl::string_view uri) override;
|
|
|
|
bool SupportsPadding() const override;
|
|
bool SupportsRtxPayloadPadding() const override;
|
|
|
|
// Get start timestamp.
|
|
uint32_t StartTimestamp() const override;
|
|
|
|
// Configure start timestamp, default is a random number.
|
|
void SetStartTimestamp(uint32_t timestamp) override;
|
|
|
|
uint16_t SequenceNumber() const override;
|
|
|
|
// Set SequenceNumber, default is a random number.
|
|
void SetSequenceNumber(uint16_t seq) override;
|
|
|
|
void SetRtpState(const RtpState& rtp_state) override;
|
|
void SetRtxState(const RtpState& rtp_state) override;
|
|
RtpState GetRtpState() const override;
|
|
RtpState GetRtxState() const override;
|
|
|
|
void SetNonSenderRttMeasurement(bool enabled) override {}
|
|
|
|
uint32_t SSRC() const override { return rtcp_sender_.SSRC(); }
|
|
|
|
void SetRid(const std::string& rid) override;
|
|
|
|
void SetMid(const std::string& mid) override;
|
|
|
|
void SetCsrcs(const std::vector<uint32_t>& csrcs) override;
|
|
|
|
RTCPSender::FeedbackState GetFeedbackState();
|
|
|
|
void SetRtxSendStatus(int mode) override;
|
|
int RtxSendStatus() const override;
|
|
absl::optional<uint32_t> RtxSsrc() const override;
|
|
|
|
void SetRtxSendPayloadType(int payload_type,
|
|
int associated_payload_type) override;
|
|
|
|
absl::optional<uint32_t> FlexfecSsrc() const override;
|
|
|
|
// Sends kRtcpByeCode when going from true to false.
|
|
int32_t SetSendingStatus(bool sending) override;
|
|
|
|
bool Sending() const override;
|
|
|
|
// Drops or relays media packets.
|
|
void SetSendingMediaStatus(bool sending) override;
|
|
|
|
bool SendingMedia() const override;
|
|
|
|
bool IsAudioConfigured() const override;
|
|
|
|
void SetAsPartOfAllocation(bool part_of_allocation) override;
|
|
|
|
bool OnSendingRtpFrame(uint32_t timestamp,
|
|
int64_t capture_time_ms,
|
|
int payload_type,
|
|
bool force_sender_report) override;
|
|
|
|
bool TrySendPacket(RtpPacketToSend* packet,
|
|
const PacedPacketInfo& pacing_info) override;
|
|
|
|
void SetFecProtectionParams(const FecProtectionParams& delta_params,
|
|
const FecProtectionParams& key_params) override;
|
|
|
|
std::vector<std::unique_ptr<RtpPacketToSend>> FetchFecPackets() override;
|
|
|
|
void OnPacketsAcknowledged(
|
|
rtc::ArrayView<const uint16_t> sequence_numbers) override;
|
|
|
|
std::vector<std::unique_ptr<RtpPacketToSend>> GeneratePadding(
|
|
size_t target_size_bytes) override;
|
|
|
|
std::vector<RtpSequenceNumberMap::Info> GetSentRtpPacketInfos(
|
|
rtc::ArrayView<const uint16_t> sequence_numbers) const override;
|
|
|
|
size_t ExpectedPerPacketOverhead() const override;
|
|
|
|
void OnPacketSendingThreadSwitched() override;
|
|
|
|
// RTCP part.
|
|
|
|
// Get RTCP status.
|
|
RtcpMode RTCP() const override;
|
|
|
|
// Configure RTCP status i.e on/off.
|
|
void SetRTCPStatus(RtcpMode method) override;
|
|
|
|
// Set RTCP CName.
|
|
int32_t SetCNAME(const char* c_name) override;
|
|
|
|
// Get remote NTP.
|
|
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 override;
|
|
|
|
// Get RoundTripTime.
|
|
int32_t RTT(uint32_t remote_ssrc,
|
|
int64_t* rtt,
|
|
int64_t* avg_rtt,
|
|
int64_t* min_rtt,
|
|
int64_t* max_rtt) const override;
|
|
|
|
int64_t ExpectedRetransmissionTimeMs() const override;
|
|
|
|
// Force a send of an RTCP packet.
|
|
// Normal SR and RR are triggered via the process function.
|
|
int32_t SendRTCP(RTCPPacketType rtcpPacketType) override;
|
|
|
|
void GetSendStreamDataCounters(
|
|
StreamDataCounters* rtp_counters,
|
|
StreamDataCounters* rtx_counters) const override;
|
|
|
|
// A snapshot of the most recent Report Block with additional data of
|
|
// interest to statistics. Used to implement RTCRemoteInboundRtpStreamStats.
|
|
// Within this list, the ReportBlockData::RTCPReportBlock::source_ssrc(),
|
|
// which is the SSRC of the corresponding outbound RTP stream, is unique.
|
|
std::vector<ReportBlockData> GetLatestReportBlockData() const override;
|
|
absl::optional<SenderReportStats> GetSenderReportStats() const override;
|
|
|
|
// (REMB) Receiver Estimated Max Bitrate.
|
|
void SetRemb(int64_t bitrate_bps, std::vector<uint32_t> ssrcs) override;
|
|
void UnsetRemb() override;
|
|
|
|
void SetTmmbn(std::vector<rtcp::TmmbItem> bounding_set) override;
|
|
|
|
size_t MaxRtpPacketSize() const override;
|
|
|
|
void SetMaxRtpPacketSize(size_t max_packet_size) override;
|
|
|
|
// (NACK) Negative acknowledgment part.
|
|
|
|
// Send a Negative acknowledgment packet.
|
|
// TODO(philipel): Deprecate SendNACK and use SendNack instead.
|
|
int32_t SendNACK(const uint16_t* nack_list, uint16_t size) override;
|
|
|
|
void SendNack(const std::vector<uint16_t>& sequence_numbers) override;
|
|
|
|
// Store the sent packets, needed to answer to a negative acknowledgment
|
|
// requests.
|
|
void SetStorePacketsStatus(bool enable, uint16_t number_to_store) override;
|
|
|
|
void SendCombinedRtcpPacket(
|
|
std::vector<std::unique_ptr<rtcp::RtcpPacket>> rtcp_packets) override;
|
|
|
|
// Video part.
|
|
int32_t SendLossNotification(uint16_t last_decoded_seq_num,
|
|
uint16_t last_received_seq_num,
|
|
bool decodability_flag,
|
|
bool buffering_allowed) override;
|
|
|
|
RtpSendRates GetSendRates() const override;
|
|
|
|
void OnReceivedNack(
|
|
const std::vector<uint16_t>& nack_sequence_numbers) override;
|
|
void OnReceivedRtcpReportBlocks(
|
|
const ReportBlockList& report_blocks) override;
|
|
void OnRequestSendReport() override;
|
|
|
|
void SetVideoBitrateAllocation(
|
|
const VideoBitrateAllocation& bitrate) override;
|
|
|
|
RTPSender* RtpSender() override;
|
|
const RTPSender* RtpSender() const override;
|
|
|
|
protected:
|
|
bool UpdateRTCPReceiveInformationTimers();
|
|
|
|
RTPSender* rtp_sender() {
|
|
return rtp_sender_ ? &rtp_sender_->packet_generator : nullptr;
|
|
}
|
|
const RTPSender* rtp_sender() const {
|
|
return rtp_sender_ ? &rtp_sender_->packet_generator : nullptr;
|
|
}
|
|
|
|
RTCPSender* rtcp_sender() { return &rtcp_sender_; }
|
|
const RTCPSender* rtcp_sender() const { return &rtcp_sender_; }
|
|
|
|
RTCPReceiver* rtcp_receiver() { return &rtcp_receiver_; }
|
|
const RTCPReceiver* rtcp_receiver() const { return &rtcp_receiver_; }
|
|
|
|
void SetMediaHasBeenSent(bool media_has_been_sent) {
|
|
rtp_sender_->packet_sender.SetMediaHasBeenSent(media_has_been_sent);
|
|
}
|
|
|
|
Clock* clock() const { return clock_; }
|
|
|
|
private:
|
|
FRIEND_TEST_ALL_PREFIXES(RtpRtcpImplTest, Rtt);
|
|
FRIEND_TEST_ALL_PREFIXES(RtpRtcpImplTest, RttForReceiverOnly);
|
|
|
|
struct RtpSenderContext {
|
|
explicit RtpSenderContext(const RtpRtcpInterface::Configuration& config);
|
|
// Storage of packets, for retransmissions and padding, if applicable.
|
|
RtpPacketHistory packet_history;
|
|
// Handles sequence number assignment and padding timestamp generation.
|
|
mutable Mutex sequencer_mutex;
|
|
PacketSequencer sequencer_ RTC_GUARDED_BY(sequencer_mutex);
|
|
// Handles final time timestamping/stats/etc and handover to Transport.
|
|
DEPRECATED_RtpSenderEgress packet_sender;
|
|
// If no paced sender configured, this class will be used to pass packets
|
|
// from `packet_generator_` to `packet_sender_`.
|
|
DEPRECATED_RtpSenderEgress::NonPacedPacketSender non_paced_sender;
|
|
// Handles creation of RTP packets to be sent.
|
|
RTPSender packet_generator;
|
|
};
|
|
|
|
void set_rtt_ms(int64_t rtt_ms);
|
|
int64_t rtt_ms() const;
|
|
|
|
bool TimeToSendFullNackList(int64_t now) const;
|
|
|
|
// Returns true if the module is configured to store packets.
|
|
bool StorePackets() const;
|
|
|
|
// Returns current Receiver Reference Time Report (RTTR) status.
|
|
bool RtcpXrRrtrStatus() const;
|
|
|
|
std::unique_ptr<RtpSenderContext> rtp_sender_;
|
|
|
|
RTCPSender rtcp_sender_;
|
|
RTCPReceiver rtcp_receiver_;
|
|
|
|
Clock* const clock_;
|
|
|
|
int64_t last_bitrate_process_time_;
|
|
int64_t last_rtt_process_time_;
|
|
int64_t next_process_time_;
|
|
uint16_t packet_overhead_;
|
|
|
|
// Send side
|
|
int64_t nack_last_time_sent_full_ms_;
|
|
uint16_t nack_last_seq_number_sent_;
|
|
|
|
RemoteBitrateEstimator* const remote_bitrate_;
|
|
|
|
RtcpRttStats* const rtt_stats_;
|
|
|
|
// The processed RTT from RtcpRttStats.
|
|
mutable Mutex mutex_rtt_;
|
|
int64_t rtt_ms_ RTC_GUARDED_BY(mutex_rtt_);
|
|
};
|
|
|
|
} // namespace webrtc
|
|
|
|
#endif // MODULES_RTP_RTCP_SOURCE_RTP_RTCP_IMPL_H_
|