niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | /* |
| 12 | * RTCP statistics reporting. |
| 13 | */ |
| 14 | |
| 15 | #ifndef RTCP_H |
| 16 | #define RTCP_H |
| 17 | |
| 18 | #include "typedefs.h" |
| 19 | |
| 20 | typedef struct |
| 21 | { |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 22 | uint16_t cycles; /* The number of wrap-arounds for the sequence number */ |
| 23 | uint16_t max_seq; /* The maximum sequence number received |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 24 | (starts from 0 again after wrap around) */ |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 25 | uint16_t base_seq; /* The sequence number of the first packet that arrived */ |
| 26 | uint32_t received; /* The number of packets that has been received */ |
| 27 | uint32_t rec_prior; /* Number of packets received when last report was generated */ |
| 28 | uint32_t exp_prior; /* Number of packets that should have been received if no |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 29 | packets were lost. Stored value from last report. */ |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 30 | uint32_t jitter; /* Jitter statistics at this instance (calculated according to RFC) */ |
| 31 | int32_t transit; /* Clock difference for previous packet (RTPtimestamp - LOCALtime_rec) */ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 32 | } WebRtcNetEQ_RTCP_t; |
| 33 | |
| 34 | /**************************************************************************** |
| 35 | * WebRtcNetEQ_RTCPInit(...) |
| 36 | * |
| 37 | * This function calculates the parameters that are needed for the RTCP |
| 38 | * report. |
| 39 | * |
| 40 | * Input: |
| 41 | * - RTCP_inst : RTCP instance, that contains information about the |
| 42 | * packets that have been received etc. |
| 43 | * - seqNo : Packet number of the first received frame. |
| 44 | * |
| 45 | * Return value : 0 - Ok |
| 46 | * -1 - Error |
| 47 | */ |
| 48 | |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 49 | int WebRtcNetEQ_RTCPInit(WebRtcNetEQ_RTCP_t *RTCP_inst, uint16_t uw16_seqNo); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 50 | |
| 51 | /**************************************************************************** |
| 52 | * WebRtcNetEQ_RTCPUpdate(...) |
| 53 | * |
| 54 | * This function calculates the parameters that are needed for the RTCP |
| 55 | * report. |
| 56 | * |
| 57 | * Input: |
| 58 | * - RTCP_inst : RTCP instance, that contains information about the |
| 59 | * packets that have been received etc. |
| 60 | * - seqNo : Packet number of the first received frame. |
| 61 | * - timeStamp : Time stamp from the RTP header. |
| 62 | * - recTime : Time (in RTP timestamps) when this packet was received. |
| 63 | * |
| 64 | * Return value : 0 - Ok |
| 65 | * -1 - Error |
| 66 | */ |
| 67 | |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 68 | int WebRtcNetEQ_RTCPUpdate(WebRtcNetEQ_RTCP_t *RTCP_inst, uint16_t uw16_seqNo, |
| 69 | uint32_t uw32_timeStamp, uint32_t uw32_recTime); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 70 | |
| 71 | /**************************************************************************** |
| 72 | * WebRtcNetEQ_RTCPGetStats(...) |
| 73 | * |
| 74 | * This function calculates the parameters that are needed for the RTCP |
| 75 | * report. |
| 76 | * |
| 77 | * Input: |
| 78 | * - RTCP_inst : RTCP instance, that contains information about the |
| 79 | * packets that have been received etc. |
| 80 | * - doNotReset : If non-zero, the fraction lost statistics will not |
| 81 | * be reset. |
| 82 | * |
| 83 | * Output: |
| 84 | * - RTCP_inst : Updated RTCP information (some statistics are |
| 85 | * reset when generating this report) |
| 86 | * - fraction_lost : Number of lost RTP packets divided by the number of |
| 87 | * expected packets, since the last RTCP Report. |
| 88 | * - cum_lost : Cumulative number of lost packets during this |
| 89 | * session. |
| 90 | * - ext_max : Extended highest sequence number received. |
| 91 | * - jitter : Inter-arrival jitter. |
| 92 | * |
| 93 | * Return value : 0 - Ok |
| 94 | * -1 - Error |
| 95 | */ |
| 96 | |
| 97 | int WebRtcNetEQ_RTCPGetStats(WebRtcNetEQ_RTCP_t *RTCP_inst, |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 98 | uint16_t *puw16_fraction_lost, |
| 99 | uint32_t *puw32_cum_lost, uint32_t *puw32_ext_max, |
| 100 | uint32_t *puw32_jitter, int16_t doNotReset); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 101 | |
| 102 | #endif |