Index: webrtc/common_types.h |
diff --git a/webrtc/common_types.h b/webrtc/common_types.h |
index 2999bc95bc82a353fd820e87506059c29d552d8c..c59bc6240277ba5b1d773f0e4cdc295c7242c696 100644 |
--- a/webrtc/common_types.h |
+++ b/webrtc/common_types.h |
@@ -11,6 +11,7 @@ |
#ifndef WEBRTC_COMMON_TYPES_H_ |
#define WEBRTC_COMMON_TYPES_H_ |
+#include <assert.h> |
#include <stddef.h> |
#include <string.h> |
@@ -791,6 +792,17 @@ struct RtpPacketCounter { |
packets += other.packets; |
} |
+ void Subtract(const RtpPacketCounter& other) { |
+ assert(header_bytes >= other.header_bytes); |
+ header_bytes -= other.header_bytes; |
+ assert(payload_bytes >= other.payload_bytes); |
+ payload_bytes -= other.payload_bytes; |
+ assert(padding_bytes >= other.padding_bytes); |
+ padding_bytes -= other.padding_bytes; |
+ assert(packets >= other.packets); |
+ packets -= other.packets; |
+ } |
+ |
void AddPacket(size_t packet_length, const RTPHeader& header) { |
++packets; |
header_bytes += header.headerLength; |
@@ -825,6 +837,18 @@ struct StreamDataCounters { |
} |
} |
+ 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); |
} |