Chromium Code Reviews| Index: webrtc/common_types.h |
| diff --git a/webrtc/common_types.h b/webrtc/common_types.h |
| index 2999bc95bc82a353fd820e87506059c29d552d8c..d3fc204f55dc68a600b851cea29a8ee4c65f234b 100644 |
| --- a/webrtc/common_types.h |
| +++ b/webrtc/common_types.h |
| @@ -791,6 +791,13 @@ struct RtpPacketCounter { |
| packets += other.packets; |
| } |
| + void Subtract(const RtpPacketCounter& other) { |
| + header_bytes -= other.header_bytes; |
|
mflodman
2016/02/29 09:41:17
There's no >= 0 check, do we count on the user to
sprang_webrtc
2016/02/29 13:00:33
Yes. But I'll add a DCHECK to be sure.
|
| + payload_bytes -= other.payload_bytes; |
| + padding_bytes -= other.padding_bytes; |
| + packets -= other.packets; |
| + } |
| + |
| void AddPacket(size_t packet_length, const RTPHeader& header) { |
| ++packets; |
| header_bytes += header.headerLength; |
| @@ -825,6 +832,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); |
| } |