2015-11-04 08:31:52 +01:00
|
|
|
/*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_DEFINES_H_
|
|
|
|
|
#define MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_DEFINES_H_
|
2015-11-04 08:31:52 +01:00
|
|
|
|
|
|
|
|
#include <stddef.h>
|
2019-07-05 19:08:33 +02:00
|
|
|
|
2015-11-04 08:31:52 +01:00
|
|
|
#include <list>
|
2019-10-10 12:57:28 +02:00
|
|
|
#include <memory>
|
2016-09-07 09:58:20 +02:00
|
|
|
#include <vector>
|
2015-11-04 08:31:52 +01:00
|
|
|
|
2019-03-21 15:48:49 +01:00
|
|
|
#include "absl/strings/string_view.h"
|
2019-05-07 09:29:15 -07:00
|
|
|
#include "absl/types/optional.h"
|
2018-06-26 10:44:13 +02:00
|
|
|
#include "absl/types/variant.h"
|
2019-05-07 09:29:15 -07:00
|
|
|
#include "api/array_view.h"
|
2017-10-04 12:38:53 +02:00
|
|
|
#include "api/audio_codecs/audio_format.h"
|
2017-12-15 14:40:10 +01:00
|
|
|
#include "api/rtp_headers.h"
|
2018-09-17 13:11:50 +02:00
|
|
|
#include "api/transport/network_types.h"
|
2019-07-24 11:38:03 +02:00
|
|
|
#include "modules/rtp_rtcp/source/rtcp_packet/remote_estimate.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "system_wrappers/include/clock.h"
|
2015-11-04 08:31:52 +01:00
|
|
|
|
|
|
|
|
#define RTCP_CNAME_SIZE 256 // RFC 3550 page 44, including null termination
|
|
|
|
|
#define IP_PACKET_SIZE 1500 // we assume ethernet
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
2018-11-15 08:05:16 +01:00
|
|
|
class RtpPacket;
|
2015-11-04 08:31:52 +01:00
|
|
|
namespace rtcp {
|
|
|
|
|
class TransportFeedback;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const int kVideoPayloadTypeFrequency = 90000;
|
2018-10-24 13:34:32 +02:00
|
|
|
|
|
|
|
|
// TODO(bugs.webrtc.org/6458): Remove this when all the depending projects are
|
|
|
|
|
// updated to correctly set rtp rate for RtcpSender.
|
2016-10-03 06:22:25 -07:00
|
|
|
const int kBogusRtpRateForAudioRtcp = 8000;
|
2015-11-04 08:31:52 +01:00
|
|
|
|
|
|
|
|
// Minimum RTP header size in bytes.
|
|
|
|
|
const uint8_t kRtpHeaderSize = 12;
|
|
|
|
|
|
2019-03-21 15:48:49 +01:00
|
|
|
bool IsLegalMidName(absl::string_view name);
|
|
|
|
|
bool IsLegalRsidName(absl::string_view name);
|
|
|
|
|
|
2018-09-24 14:50:48 +02:00
|
|
|
// This enum must not have any gaps, i.e., all integers between
|
|
|
|
|
// kRtpExtensionNone and kRtpExtensionNumberOfExtensions must be valid enum
|
|
|
|
|
// entries.
|
|
|
|
|
enum RTPExtensionType : int {
|
2015-11-04 08:31:52 +01:00
|
|
|
kRtpExtensionNone,
|
|
|
|
|
kRtpExtensionTransmissionTimeOffset,
|
|
|
|
|
kRtpExtensionAudioLevel,
|
|
|
|
|
kRtpExtensionAbsoluteSendTime,
|
2019-07-01 10:56:51 +02:00
|
|
|
kRtpExtensionAbsoluteCaptureTime,
|
2015-11-04 08:31:52 +01:00
|
|
|
kRtpExtensionVideoRotation,
|
|
|
|
|
kRtpExtensionTransportSequenceNumber,
|
2019-02-21 14:09:20 +00:00
|
|
|
kRtpExtensionTransportSequenceNumber02,
|
2016-06-08 00:24:21 -07:00
|
|
|
kRtpExtensionPlayoutDelay,
|
2017-04-11 10:34:31 -07:00
|
|
|
kRtpExtensionVideoContentType,
|
2017-06-19 07:18:55 -07:00
|
|
|
kRtpExtensionVideoTiming,
|
2018-09-11 16:50:49 -04:00
|
|
|
kRtpExtensionFrameMarking,
|
2017-04-19 02:59:48 -07:00
|
|
|
kRtpExtensionRtpStreamId,
|
|
|
|
|
kRtpExtensionRepairedRtpStreamId,
|
2017-07-21 09:58:31 -07:00
|
|
|
kRtpExtensionMid,
|
2019-02-19 13:01:31 +01:00
|
|
|
kRtpExtensionGenericFrameDescriptor00,
|
|
|
|
|
kRtpExtensionGenericFrameDescriptor = kRtpExtensionGenericFrameDescriptor00,
|
|
|
|
|
kRtpExtensionGenericFrameDescriptor01,
|
2019-06-27 16:45:40 +02:00
|
|
|
kRtpExtensionGenericFrameDescriptor02,
|
2018-11-27 14:36:41 +01:00
|
|
|
kRtpExtensionColorSpace,
|
2017-04-11 10:34:31 -07:00
|
|
|
kRtpExtensionNumberOfExtensions // Must be the last entity in the enum.
|
2015-11-04 08:31:52 +01:00
|
|
|
};
|
|
|
|
|
|
2015-12-10 09:51:54 -08:00
|
|
|
enum RTCPAppSubTypes { kAppSubtypeBwe = 0x00 };
|
2015-11-04 08:31:52 +01:00
|
|
|
|
|
|
|
|
// TODO(sprang): Make this an enum class once rtcp_receiver has been cleaned up.
|
|
|
|
|
enum RTCPPacketType : uint32_t {
|
|
|
|
|
kRtcpReport = 0x0001,
|
|
|
|
|
kRtcpSr = 0x0002,
|
|
|
|
|
kRtcpRr = 0x0004,
|
|
|
|
|
kRtcpSdes = 0x0008,
|
|
|
|
|
kRtcpBye = 0x0010,
|
|
|
|
|
kRtcpPli = 0x0020,
|
|
|
|
|
kRtcpNack = 0x0040,
|
|
|
|
|
kRtcpFir = 0x0080,
|
|
|
|
|
kRtcpTmmbr = 0x0100,
|
|
|
|
|
kRtcpTmmbn = 0x0200,
|
|
|
|
|
kRtcpSrReq = 0x0400,
|
|
|
|
|
kRtcpApp = 0x1000,
|
Create new RTCP feedback message - LossIndication
Create a new RTCP feedback message for reporting the loss and/or non-decodability of video frames, to be used by the upcoming injectable VideoFrameBufferController. The new feedback message should report:
1. The sequence number of the last decoded non-discardable video frame. (TBD: If a multi-packet frame, should it be the sequence number of the first, last, or any of the packets?)
2. The sequence number of the last received RTP packet in the stream.
3. A decodability flag, whose specific meaning depends on the last-received
RTP sequence number. The decodability flag is true if and only if all of
the frame's dependencies are known to be decodable, and the frame itself
is not yet known to be unassemblable.
* Clarification #1: In a multi-packet frame, the first packet's
dependencies are known, but it is not yet known whether all parts
of the current frame will be received.
* Clarification #2: In a multi-packet frame, the dependencies would be
unknown if the first packet was not received. Then, the packet will
be known-unassemblable.
Bug: webrtc:10226
Change-Id: I1563c944477e3ed40235e82ab99a439414632aff
Reviewed-on: https://webrtc-review.googlesource.com/c/118931
Commit-Queue: Elad Alon <eladalon@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26387}
2019-01-24 12:38:36 +01:00
|
|
|
kRtcpLossNotification = 0x2000,
|
2015-11-04 08:31:52 +01:00
|
|
|
kRtcpRemb = 0x10000,
|
|
|
|
|
kRtcpTransmissionTimeOffset = 0x20000,
|
|
|
|
|
kRtcpXrReceiverReferenceTime = 0x40000,
|
|
|
|
|
kRtcpXrDlrrReportBlock = 0x80000,
|
|
|
|
|
kRtcpTransportFeedback = 0x100000,
|
2016-12-01 05:18:09 -08:00
|
|
|
kRtcpXrTargetBitrate = 0x200000
|
2015-11-04 08:31:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum RtxMode {
|
|
|
|
|
kRtxOff = 0x0,
|
|
|
|
|
kRtxRetransmitted = 0x1, // Only send retransmissions over RTX.
|
|
|
|
|
kRtxRedundantPayloads = 0x2 // Preventively send redundant payloads
|
|
|
|
|
// instead of padding.
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const size_t kRtxHeaderSize = 2;
|
|
|
|
|
|
|
|
|
|
struct RTCPReportBlock {
|
|
|
|
|
RTCPReportBlock()
|
2017-08-09 06:13:45 -07:00
|
|
|
: sender_ssrc(0),
|
|
|
|
|
source_ssrc(0),
|
|
|
|
|
fraction_lost(0),
|
|
|
|
|
packets_lost(0),
|
|
|
|
|
extended_highest_sequence_number(0),
|
|
|
|
|
jitter(0),
|
|
|
|
|
last_sender_report_timestamp(0),
|
|
|
|
|
delay_since_last_sender_report(0) {}
|
|
|
|
|
|
|
|
|
|
RTCPReportBlock(uint32_t sender_ssrc,
|
2015-11-04 08:31:52 +01:00
|
|
|
uint32_t source_ssrc,
|
|
|
|
|
uint8_t fraction_lost,
|
2017-12-08 08:59:07 +01:00
|
|
|
int32_t packets_lost,
|
2017-08-09 06:13:45 -07:00
|
|
|
uint32_t extended_highest_sequence_number,
|
2015-11-04 08:31:52 +01:00
|
|
|
uint32_t jitter,
|
2017-08-09 06:13:45 -07:00
|
|
|
uint32_t last_sender_report_timestamp,
|
2015-11-04 08:31:52 +01:00
|
|
|
uint32_t delay_since_last_sender_report)
|
2017-08-09 06:13:45 -07:00
|
|
|
: sender_ssrc(sender_ssrc),
|
|
|
|
|
source_ssrc(source_ssrc),
|
|
|
|
|
fraction_lost(fraction_lost),
|
|
|
|
|
packets_lost(packets_lost),
|
|
|
|
|
extended_highest_sequence_number(extended_highest_sequence_number),
|
2015-11-04 08:31:52 +01:00
|
|
|
jitter(jitter),
|
2017-08-09 06:13:45 -07:00
|
|
|
last_sender_report_timestamp(last_sender_report_timestamp),
|
|
|
|
|
delay_since_last_sender_report(delay_since_last_sender_report) {}
|
2015-11-04 08:31:52 +01:00
|
|
|
|
|
|
|
|
// Fields as described by RFC 3550 6.4.2.
|
2017-11-15 16:28:20 +01:00
|
|
|
uint32_t sender_ssrc; // SSRC of sender of this report.
|
|
|
|
|
uint32_t source_ssrc; // SSRC of the RTP packet sender.
|
|
|
|
|
uint8_t fraction_lost;
|
2018-08-09 11:21:11 +02:00
|
|
|
int32_t packets_lost; // 24 bits valid.
|
2017-11-15 16:28:20 +01:00
|
|
|
uint32_t extended_highest_sequence_number;
|
2015-11-04 08:31:52 +01:00
|
|
|
uint32_t jitter;
|
2017-11-15 16:28:20 +01:00
|
|
|
uint32_t last_sender_report_timestamp;
|
|
|
|
|
uint32_t delay_since_last_sender_report;
|
2015-11-04 08:31:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef std::list<RTCPReportBlock> ReportBlockList;
|
|
|
|
|
|
|
|
|
|
struct RtpState {
|
|
|
|
|
RtpState()
|
|
|
|
|
: sequence_number(0),
|
|
|
|
|
start_timestamp(0),
|
|
|
|
|
timestamp(0),
|
|
|
|
|
capture_time_ms(-1),
|
|
|
|
|
last_timestamp_time_ms(-1),
|
2019-07-21 15:04:21 -04:00
|
|
|
media_has_been_sent(false),
|
|
|
|
|
ssrc_has_acked(false) {}
|
2015-11-04 08:31:52 +01:00
|
|
|
uint16_t sequence_number;
|
|
|
|
|
uint32_t start_timestamp;
|
|
|
|
|
uint32_t timestamp;
|
|
|
|
|
int64_t capture_time_ms;
|
|
|
|
|
int64_t last_timestamp_time_ms;
|
|
|
|
|
bool media_has_been_sent;
|
2019-07-21 15:04:21 -04:00
|
|
|
bool ssrc_has_acked;
|
2015-11-04 08:31:52 +01:00
|
|
|
};
|
|
|
|
|
|
2017-05-29 08:16:37 -07:00
|
|
|
// Callback interface for packets recovered by FlexFEC or ULPFEC. In
|
|
|
|
|
// the FlexFEC case, the implementation should be able to demultiplex
|
|
|
|
|
// the recovered RTP packets based on SSRC.
|
|
|
|
|
class RecoveredPacketReceiver {
|
|
|
|
|
public:
|
|
|
|
|
virtual void OnRecoveredPacket(const uint8_t* packet, size_t length) = 0;
|
2015-11-04 08:31:52 +01:00
|
|
|
|
2017-05-29 08:16:37 -07:00
|
|
|
protected:
|
|
|
|
|
virtual ~RecoveredPacketReceiver() = default;
|
2015-11-04 08:31:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class RtcpIntraFrameObserver {
|
|
|
|
|
public:
|
|
|
|
|
virtual ~RtcpIntraFrameObserver() {}
|
2018-05-28 12:53:50 +02:00
|
|
|
|
|
|
|
|
virtual void OnReceivedIntraFrameRequest(uint32_t ssrc) = 0;
|
2015-11-04 08:31:52 +01:00
|
|
|
};
|
|
|
|
|
|
2019-04-09 11:55:13 +02:00
|
|
|
// Observer for incoming LossNotification RTCP messages.
|
|
|
|
|
// See the documentation of LossNotification for details.
|
|
|
|
|
class RtcpLossNotificationObserver {
|
|
|
|
|
public:
|
|
|
|
|
virtual ~RtcpLossNotificationObserver() = default;
|
|
|
|
|
|
|
|
|
|
virtual void OnReceivedLossNotification(uint32_t ssrc,
|
|
|
|
|
uint16_t seq_num_of_last_decodable,
|
|
|
|
|
uint16_t seq_num_of_last_received,
|
|
|
|
|
bool decodability_flag) = 0;
|
|
|
|
|
};
|
|
|
|
|
|
2015-11-04 08:31:52 +01:00
|
|
|
class RtcpBandwidthObserver {
|
|
|
|
|
public:
|
|
|
|
|
// REMB or TMMBR
|
|
|
|
|
virtual void OnReceivedEstimatedBitrate(uint32_t bitrate) = 0;
|
|
|
|
|
|
|
|
|
|
virtual void OnReceivedRtcpReceiverReport(
|
|
|
|
|
const ReportBlockList& report_blocks,
|
|
|
|
|
int64_t rtt,
|
|
|
|
|
int64_t now_ms) = 0;
|
|
|
|
|
|
|
|
|
|
virtual ~RtcpBandwidthObserver() {}
|
|
|
|
|
};
|
|
|
|
|
|
2019-04-23 12:00:11 +02:00
|
|
|
struct RtpPacketSendInfo {
|
|
|
|
|
public:
|
|
|
|
|
RtpPacketSendInfo() = default;
|
|
|
|
|
|
|
|
|
|
uint16_t transport_sequence_number = 0;
|
|
|
|
|
uint32_t ssrc = 0;
|
|
|
|
|
uint16_t rtp_sequence_number = 0;
|
|
|
|
|
// Get rid of this flag when all code paths populate |rtp_sequence_number|.
|
|
|
|
|
bool has_rtp_sequence_number = false;
|
|
|
|
|
size_t length = 0;
|
|
|
|
|
PacedPacketInfo pacing_info;
|
|
|
|
|
};
|
2019-07-24 11:38:03 +02:00
|
|
|
class NetworkStateEstimateObserver {
|
|
|
|
|
public:
|
|
|
|
|
virtual void OnRemoteNetworkEstimate(NetworkStateEstimate estimate) = 0;
|
|
|
|
|
virtual ~NetworkStateEstimateObserver() = default;
|
|
|
|
|
};
|
2019-04-23 12:00:11 +02:00
|
|
|
|
2015-11-04 08:31:52 +01:00
|
|
|
class TransportFeedbackObserver {
|
|
|
|
|
public:
|
|
|
|
|
TransportFeedbackObserver() {}
|
|
|
|
|
virtual ~TransportFeedbackObserver() {}
|
|
|
|
|
|
2019-04-24 08:09:20 +02:00
|
|
|
virtual void OnAddPacket(const RtpPacketSendInfo& packet_info) = 0;
|
2015-11-04 08:31:52 +01:00
|
|
|
virtual void OnTransportFeedback(const rtcp::TransportFeedback& feedback) = 0;
|
|
|
|
|
};
|
|
|
|
|
|
2017-12-14 16:02:31 +01:00
|
|
|
// Interface for PacketRouter to send rtcp feedback on behalf of
|
|
|
|
|
// congestion controller.
|
|
|
|
|
// TODO(bugs.webrtc.org/8239): Remove and use RtcpTransceiver directly
|
|
|
|
|
// when RtcpTransceiver always present in rtp transport.
|
|
|
|
|
class RtcpFeedbackSenderInterface {
|
|
|
|
|
public:
|
|
|
|
|
virtual ~RtcpFeedbackSenderInterface() = default;
|
2019-10-10 12:57:28 +02:00
|
|
|
virtual void SendCombinedRtcpPacket(
|
|
|
|
|
std::vector<std::unique_ptr<rtcp::RtcpPacket>> rtcp_packets) = 0;
|
2017-12-14 16:02:31 +01:00
|
|
|
virtual void SetRemb(int64_t bitrate_bps, std::vector<uint32_t> ssrcs) = 0;
|
|
|
|
|
virtual void UnsetRemb() = 0;
|
|
|
|
|
};
|
|
|
|
|
|
2019-10-29 17:18:51 +01:00
|
|
|
class StreamFeedbackObserver {
|
|
|
|
|
public:
|
|
|
|
|
struct StreamPacketInfo {
|
|
|
|
|
uint32_t ssrc;
|
|
|
|
|
uint16_t rtp_sequence_number;
|
|
|
|
|
bool received;
|
|
|
|
|
};
|
|
|
|
|
virtual ~StreamFeedbackObserver() = default;
|
|
|
|
|
|
|
|
|
|
virtual void OnPacketFeedbackVector(
|
|
|
|
|
std::vector<StreamPacketInfo> packet_feedback_vector) = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class StreamFeedbackProvider {
|
|
|
|
|
public:
|
|
|
|
|
virtual void RegisterStreamFeedbackObserver(
|
|
|
|
|
std::vector<uint32_t> ssrcs,
|
|
|
|
|
StreamFeedbackObserver* observer) = 0;
|
|
|
|
|
virtual void DeRegisterStreamFeedbackObserver(
|
|
|
|
|
StreamFeedbackObserver* observer) = 0;
|
|
|
|
|
virtual ~StreamFeedbackProvider() = default;
|
|
|
|
|
};
|
|
|
|
|
|
2015-11-04 08:31:52 +01:00
|
|
|
class RtcpRttStats {
|
|
|
|
|
public:
|
|
|
|
|
virtual void OnRttUpdate(int64_t rtt) = 0;
|
|
|
|
|
|
|
|
|
|
virtual int64_t LastProcessedRtt() const = 0;
|
|
|
|
|
|
2015-12-10 09:51:54 -08:00
|
|
|
virtual ~RtcpRttStats() {}
|
2015-11-04 08:31:52 +01:00
|
|
|
};
|
|
|
|
|
|
2017-12-15 14:40:10 +01:00
|
|
|
struct RtpPacketCounter {
|
|
|
|
|
RtpPacketCounter()
|
|
|
|
|
: header_bytes(0), payload_bytes(0), padding_bytes(0), packets(0) {}
|
|
|
|
|
|
|
|
|
|
void Add(const RtpPacketCounter& other) {
|
|
|
|
|
header_bytes += other.header_bytes;
|
|
|
|
|
payload_bytes += other.payload_bytes;
|
|
|
|
|
padding_bytes += other.padding_bytes;
|
|
|
|
|
packets += other.packets;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Subtract(const RtpPacketCounter& other) {
|
|
|
|
|
RTC_DCHECK_GE(header_bytes, other.header_bytes);
|
|
|
|
|
header_bytes -= other.header_bytes;
|
|
|
|
|
RTC_DCHECK_GE(payload_bytes, other.payload_bytes);
|
|
|
|
|
payload_bytes -= other.payload_bytes;
|
|
|
|
|
RTC_DCHECK_GE(padding_bytes, other.padding_bytes);
|
|
|
|
|
padding_bytes -= other.padding_bytes;
|
|
|
|
|
RTC_DCHECK_GE(packets, other.packets);
|
|
|
|
|
packets -= other.packets;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-15 08:05:16 +01:00
|
|
|
// Not inlined, since use of RtpPacket would result in circular includes.
|
|
|
|
|
void AddPacket(const RtpPacket& packet);
|
2017-12-15 14:40:10 +01:00
|
|
|
|
|
|
|
|
size_t TotalBytes() const {
|
|
|
|
|
return header_bytes + payload_bytes + padding_bytes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t header_bytes; // Number of bytes used by RTP headers.
|
|
|
|
|
size_t payload_bytes; // Payload bytes, excluding RTP headers and padding.
|
|
|
|
|
size_t padding_bytes; // Number of padding bytes.
|
|
|
|
|
uint32_t packets; // Number of packets.
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Data usage statistics for a (rtp) stream.
|
|
|
|
|
struct StreamDataCounters {
|
|
|
|
|
StreamDataCounters();
|
|
|
|
|
|
|
|
|
|
void Add(const StreamDataCounters& other) {
|
|
|
|
|
transmitted.Add(other.transmitted);
|
|
|
|
|
retransmitted.Add(other.retransmitted);
|
|
|
|
|
fec.Add(other.fec);
|
|
|
|
|
if (other.first_packet_time_ms != -1 &&
|
|
|
|
|
(other.first_packet_time_ms < first_packet_time_ms ||
|
|
|
|
|
first_packet_time_ms == -1)) {
|
|
|
|
|
// Use oldest time.
|
|
|
|
|
first_packet_time_ms = other.first_packet_time_ms;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Subtract(const StreamDataCounters& other) {
|
|
|
|
|
transmitted.Subtract(other.transmitted);
|
|
|
|
|
retransmitted.Subtract(other.retransmitted);
|
|
|
|
|
fec.Subtract(other.fec);
|
|
|
|
|
if (other.first_packet_time_ms != -1 &&
|
|
|
|
|
(other.first_packet_time_ms > first_packet_time_ms ||
|
|
|
|
|
first_packet_time_ms == -1)) {
|
|
|
|
|
// Use youngest time.
|
|
|
|
|
first_packet_time_ms = other.first_packet_time_ms;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int64_t TimeSinceFirstPacketInMs(int64_t now_ms) const {
|
|
|
|
|
return (first_packet_time_ms == -1) ? -1 : (now_ms - first_packet_time_ms);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Returns the number of bytes corresponding to the actual media payload (i.e.
|
|
|
|
|
// RTP headers, padding, retransmissions and fec packets are excluded).
|
|
|
|
|
// Note this function does not have meaning for an RTX stream.
|
|
|
|
|
size_t MediaPayloadBytes() const {
|
|
|
|
|
return transmitted.payload_bytes - retransmitted.payload_bytes -
|
|
|
|
|
fec.payload_bytes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int64_t first_packet_time_ms; // Time when first packet is sent/received.
|
2019-04-02 15:11:48 +02:00
|
|
|
// The timestamp at which the last packet was received, i.e. the time of the
|
|
|
|
|
// local clock when it was received - not the RTP timestamp of that packet.
|
|
|
|
|
// https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-lastpacketreceivedtimestamp
|
|
|
|
|
absl::optional<int64_t> last_packet_received_timestamp_ms;
|
2017-12-15 14:40:10 +01:00
|
|
|
RtpPacketCounter transmitted; // Number of transmitted packets/bytes.
|
|
|
|
|
RtpPacketCounter retransmitted; // Number of retransmitted packets/bytes.
|
|
|
|
|
RtpPacketCounter fec; // Number of redundancy packets/bytes.
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Callback, called whenever byte/packet counts have been updated.
|
|
|
|
|
class StreamDataCountersCallback {
|
|
|
|
|
public:
|
|
|
|
|
virtual ~StreamDataCountersCallback() {}
|
|
|
|
|
|
|
|
|
|
virtual void DataCountersUpdated(const StreamDataCounters& counters,
|
|
|
|
|
uint32_t ssrc) = 0;
|
|
|
|
|
};
|
|
|
|
|
|
2019-08-22 09:40:25 +02:00
|
|
|
// Information exposed through the GetStats api.
|
|
|
|
|
struct RtpReceiveStats {
|
|
|
|
|
// |packets_lost| and |jitter| are defined by RFC 3550, and exposed in the
|
|
|
|
|
// RTCReceivedRtpStreamStats dictionary, see
|
|
|
|
|
// https://w3c.github.io/webrtc-stats/#receivedrtpstats-dict*
|
|
|
|
|
int32_t packets_lost = 0;
|
|
|
|
|
uint32_t jitter = 0;
|
|
|
|
|
|
|
|
|
|
// Timestamp and counters exposed in RTCInboundRtpStreamStats, see
|
|
|
|
|
// https://w3c.github.io/webrtc-stats/#inboundrtpstats-dict*
|
|
|
|
|
absl::optional<int64_t> last_packet_received_timestamp_ms;
|
|
|
|
|
RtpPacketCounter packet_counter;
|
|
|
|
|
};
|
|
|
|
|
|
2019-03-04 16:49:25 +01:00
|
|
|
class RtcpAckObserver {
|
|
|
|
|
public:
|
|
|
|
|
// This method is called on received report blocks matching the sender ssrc.
|
|
|
|
|
// TODO(nisse): Use of "extended" sequence number is a bit brittle, since the
|
|
|
|
|
// observer for this callback typically has its own sequence number unwrapper,
|
|
|
|
|
// and there's no guarantee that they are in sync. Change to pass raw sequence
|
|
|
|
|
// number, possibly augmented with timestamp (if available) to aid
|
|
|
|
|
// disambiguation.
|
|
|
|
|
virtual void OnReceivedAck(int64_t extended_highest_sequence_number) = 0;
|
|
|
|
|
|
|
|
|
|
virtual ~RtcpAckObserver() = default;
|
|
|
|
|
};
|
|
|
|
|
|
2019-05-07 14:39:05 +02:00
|
|
|
// Callback, used to notify an observer whenever new rates have been estimated.
|
|
|
|
|
class BitrateStatisticsObserver {
|
|
|
|
|
public:
|
|
|
|
|
virtual ~BitrateStatisticsObserver() {}
|
|
|
|
|
|
|
|
|
|
virtual void Notify(uint32_t total_bitrate_bps,
|
|
|
|
|
uint32_t retransmit_bitrate_bps,
|
|
|
|
|
uint32_t ssrc) = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Callback, used to notify an observer whenever the send-side delay is updated.
|
|
|
|
|
class SendSideDelayObserver {
|
|
|
|
|
public:
|
|
|
|
|
virtual ~SendSideDelayObserver() {}
|
|
|
|
|
virtual void SendSideDelayUpdated(int avg_delay_ms,
|
|
|
|
|
int max_delay_ms,
|
2019-05-16 18:38:20 +02:00
|
|
|
uint64_t total_delay_ms,
|
2019-05-07 14:39:05 +02:00
|
|
|
uint32_t ssrc) = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Callback, used to notify an observer whenever a packet is sent to the
|
|
|
|
|
// transport.
|
|
|
|
|
// TODO(asapersson): This class will remove the need for SendSideDelayObserver.
|
|
|
|
|
// Remove SendSideDelayObserver once possible.
|
|
|
|
|
class SendPacketObserver {
|
|
|
|
|
public:
|
|
|
|
|
virtual ~SendPacketObserver() {}
|
|
|
|
|
virtual void OnSendPacket(uint16_t packet_id,
|
|
|
|
|
int64_t capture_time_ms,
|
|
|
|
|
uint32_t ssrc) = 0;
|
|
|
|
|
};
|
2015-11-04 08:31:52 +01:00
|
|
|
} // namespace webrtc
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_RTP_RTCP_INCLUDE_RTP_RTCP_DEFINES_H_
|