| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #ifndef WEBRTC_COMMON_TYPES_H_ | 11 #ifndef WEBRTC_COMMON_TYPES_H_ |
| 12 #define WEBRTC_COMMON_TYPES_H_ | 12 #define WEBRTC_COMMON_TYPES_H_ |
| 13 | 13 |
| 14 #include <assert.h> |
| 14 #include <stddef.h> | 15 #include <stddef.h> |
| 15 #include <string.h> | 16 #include <string.h> |
| 16 | 17 |
| 17 #include <string> | 18 #include <string> |
| 18 #include <vector> | 19 #include <vector> |
| 19 | 20 |
| 20 #include "webrtc/typedefs.h" | 21 #include "webrtc/typedefs.h" |
| 21 | 22 |
| 22 #if defined(_MSC_VER) | 23 #if defined(_MSC_VER) |
| 23 // Disable "new behavior: elements of array will be default initialized" | 24 // Disable "new behavior: elements of array will be default initialized" |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 padding_bytes(0), | 785 padding_bytes(0), |
| 785 packets(0) {} | 786 packets(0) {} |
| 786 | 787 |
| 787 void Add(const RtpPacketCounter& other) { | 788 void Add(const RtpPacketCounter& other) { |
| 788 header_bytes += other.header_bytes; | 789 header_bytes += other.header_bytes; |
| 789 payload_bytes += other.payload_bytes; | 790 payload_bytes += other.payload_bytes; |
| 790 padding_bytes += other.padding_bytes; | 791 padding_bytes += other.padding_bytes; |
| 791 packets += other.packets; | 792 packets += other.packets; |
| 792 } | 793 } |
| 793 | 794 |
| 795 void Subtract(const RtpPacketCounter& other) { |
| 796 assert(header_bytes >= other.header_bytes); |
| 797 header_bytes -= other.header_bytes; |
| 798 assert(payload_bytes >= other.payload_bytes); |
| 799 payload_bytes -= other.payload_bytes; |
| 800 assert(padding_bytes >= other.padding_bytes); |
| 801 padding_bytes -= other.padding_bytes; |
| 802 assert(packets >= other.packets); |
| 803 packets -= other.packets; |
| 804 } |
| 805 |
| 794 void AddPacket(size_t packet_length, const RTPHeader& header) { | 806 void AddPacket(size_t packet_length, const RTPHeader& header) { |
| 795 ++packets; | 807 ++packets; |
| 796 header_bytes += header.headerLength; | 808 header_bytes += header.headerLength; |
| 797 padding_bytes += header.paddingLength; | 809 padding_bytes += header.paddingLength; |
| 798 payload_bytes += | 810 payload_bytes += |
| 799 packet_length - (header.headerLength + header.paddingLength); | 811 packet_length - (header.headerLength + header.paddingLength); |
| 800 } | 812 } |
| 801 | 813 |
| 802 size_t TotalBytes() const { | 814 size_t TotalBytes() const { |
| 803 return header_bytes + payload_bytes + padding_bytes; | 815 return header_bytes + payload_bytes + padding_bytes; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 818 retransmitted.Add(other.retransmitted); | 830 retransmitted.Add(other.retransmitted); |
| 819 fec.Add(other.fec); | 831 fec.Add(other.fec); |
| 820 if (other.first_packet_time_ms != -1 && | 832 if (other.first_packet_time_ms != -1 && |
| 821 (other.first_packet_time_ms < first_packet_time_ms || | 833 (other.first_packet_time_ms < first_packet_time_ms || |
| 822 first_packet_time_ms == -1)) { | 834 first_packet_time_ms == -1)) { |
| 823 // Use oldest time. | 835 // Use oldest time. |
| 824 first_packet_time_ms = other.first_packet_time_ms; | 836 first_packet_time_ms = other.first_packet_time_ms; |
| 825 } | 837 } |
| 826 } | 838 } |
| 827 | 839 |
| 840 void Subtract(const StreamDataCounters& other) { |
| 841 transmitted.Subtract(other.transmitted); |
| 842 retransmitted.Subtract(other.retransmitted); |
| 843 fec.Subtract(other.fec); |
| 844 if (other.first_packet_time_ms != -1 && |
| 845 (other.first_packet_time_ms > first_packet_time_ms || |
| 846 first_packet_time_ms == -1)) { |
| 847 // Use youngest time. |
| 848 first_packet_time_ms = other.first_packet_time_ms; |
| 849 } |
| 850 } |
| 851 |
| 828 int64_t TimeSinceFirstPacketInMs(int64_t now_ms) const { | 852 int64_t TimeSinceFirstPacketInMs(int64_t now_ms) const { |
| 829 return (first_packet_time_ms == -1) ? -1 : (now_ms - first_packet_time_ms); | 853 return (first_packet_time_ms == -1) ? -1 : (now_ms - first_packet_time_ms); |
| 830 } | 854 } |
| 831 | 855 |
| 832 // Returns the number of bytes corresponding to the actual media payload (i.e. | 856 // Returns the number of bytes corresponding to the actual media payload (i.e. |
| 833 // RTP headers, padding, retransmissions and fec packets are excluded). | 857 // RTP headers, padding, retransmissions and fec packets are excluded). |
| 834 // Note this function does not have meaning for an RTX stream. | 858 // Note this function does not have meaning for an RTX stream. |
| 835 size_t MediaPayloadBytes() const { | 859 size_t MediaPayloadBytes() const { |
| 836 return transmitted.payload_bytes - retransmitted.payload_bytes - | 860 return transmitted.payload_bytes - retransmitted.payload_bytes - |
| 837 fec.payload_bytes; | 861 fec.payload_bytes; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 852 uint32_t ssrc) = 0; | 876 uint32_t ssrc) = 0; |
| 853 }; | 877 }; |
| 854 | 878 |
| 855 // RTCP mode to use. Compound mode is described by RFC 4585 and reduced-size | 879 // RTCP mode to use. Compound mode is described by RFC 4585 and reduced-size |
| 856 // RTCP mode is described by RFC 5506. | 880 // RTCP mode is described by RFC 5506. |
| 857 enum class RtcpMode { kOff, kCompound, kReducedSize }; | 881 enum class RtcpMode { kOff, kCompound, kReducedSize }; |
| 858 | 882 |
| 859 } // namespace webrtc | 883 } // namespace webrtc |
| 860 | 884 |
| 861 #endif // WEBRTC_COMMON_TYPES_H_ | 885 #endif // WEBRTC_COMMON_TYPES_H_ |
| OLD | NEW |