24 #include <ortp/port.h> 
   26 #define RTCP_MAX_RECV_BUFSIZE 1500 
   28 #define RTCP_SENDER_INFO_SIZE 20 
   29 #define RTCP_REPORT_BLOCK_SIZE 24 
   30 #define RTCP_COMMON_HEADER_SIZE 4 
   31 #define RTCP_SSRC_FIELD_SIZE 4 
   57         uint16_t packet_type:8;
 
   62         uint16_t packet_type:8;
 
   67 #define rtcp_common_header_set_version(ch,v) (ch)->version=v 
   68 #define rtcp_common_header_set_padbit(ch,p) (ch)->padbit=p 
   69 #define rtcp_common_header_set_rc(ch,rc) (ch)->rc=rc 
   70 #define rtcp_common_header_set_packet_type(ch,pt) (ch)->packet_type=pt 
   71 #define rtcp_common_header_set_length(ch,l)     (ch)->length=htons(l) 
   73 #define rtcp_common_header_get_version(ch) ((ch)->version) 
   74 #define rtcp_common_header_get padbit(ch) ((ch)->padbit) 
   75 #define rtcp_common_header_get_rc(ch) ((ch)->rc) 
   76 #define rtcp_common_header_get_packet_type(ch) ((ch)->packet_type) 
   77 #define rtcp_common_header_get_length(ch)       ntohs((ch)->length) 
   84         uint32_t ntp_timestamp_msw;
 
   85         uint32_t ntp_timestamp_lsw;
 
   86         uint32_t rtp_timestamp;
 
   87         uint32_t senders_packet_count;
 
   88         uint32_t senders_octet_count;
 
   91 uint64_t sender_info_get_ntp_timestamp(
const sender_info_t *si);
 
   92 #define sender_info_get_rtp_timestamp(si)       ((si)->rtp_timestamp) 
   93 #define sender_info_get_packet_count(si) \ 
   94         ntohl((si)->senders_packet_count) 
   95 #define sender_info_get_octet_count(si) \ 
   96         ntohl((si)->senders_octet_count) 
  103         uint32_t ext_high_seq_num_rec; 
 
  104         uint32_t interarrival_jitter;
 
  106         uint32_t delay_snc_last_sr; 
 
  109 static ORTP_INLINE uint32_t report_block_get_ssrc(
const report_block_t * rb) {
 
  110         return ntohl(rb->ssrc);
 
  112 static ORTP_INLINE uint32_t report_block_get_high_ext_seq(
const report_block_t * rb) {
 
  113         return ntohl(rb->ext_high_seq_num_rec);
 
  115 static ORTP_INLINE uint32_t report_block_get_interarrival_jitter(
const report_block_t * rb) {
 
  116         return ntohl(rb->interarrival_jitter);
 
  119 static ORTP_INLINE uint32_t report_block_get_last_SR_time(
const report_block_t * rb) {
 
  120         return ntohl(rb->lsr);
 
  122 static ORTP_INLINE uint32_t report_block_get_last_SR_delay(
const report_block_t * rb) {
 
  123         return ntohl(rb->delay_snc_last_sr);
 
  125 static ORTP_INLINE uint32_t report_block_get_fraction_lost(
const report_block_t * rb) {
 
  126         return (ntohl(rb->fl_cnpl)>>24);
 
  128 static ORTP_INLINE int32_t report_block_get_cum_packet_lost(
const report_block_t * rb){
 
  129         int cum_loss = ntohl(rb->fl_cnpl);
 
  130         if (((cum_loss>>23)&1)==0)
 
  131                 return 0x00FFFFFF & cum_loss;
 
  133                 return 0xFF000000 | (cum_loss-0xFFFFFF-1);
 
  136 static ORTP_INLINE 
void report_block_set_fraction_lost(
report_block_t * rb, 
int fl){
 
  137         rb->fl_cnpl = htonl( (ntohl(rb->fl_cnpl) & 0xFFFFFF) | (fl&0xFF)<<24);
 
  140 static ORTP_INLINE 
void report_block_set_cum_packet_lost(
report_block_t * rb, int64_t cpl) {
 
  141         uint32_t clamp = (uint32_t)((1<<24) + ((cpl>=0) ? (cpl>0x7FFFFF?0x7FFFFF:cpl) : (-cpl>0x800000?-0x800000:cpl)));
 
  144                         (ntohl(rb->fl_cnpl) & 0xFF000000) |
 
  145                         (cpl >= 0 ? clamp&0x7FFFFF : clamp|0x800000)
 
  170 #define sdes_chunk_get_csrc(c)  ntohl((c)->csrc) 
  179 #define RTCP_SDES_MAX_STRING_SIZE 255 
  180 #define RTCP_SDES_ITEM_HEADER_SIZE 2 
  181 #define RTCP_SDES_CHUNK_DEFAULT_SIZE 1024 
  182 #define RTCP_SDES_CHUNK_HEADER_SIZE (sizeof(sdes_chunk_t)) 
  197 #define RTCP_BYE_HEADER_SIZE sizeof(rtcp_bye_t) 
  198 #define RTCP_BYE_REASON_MAX_STRING_SIZE 255 
  203 #define RTCP_XR_VOIP_METRICS_CONFIG_PLC_STD ((1 << 7) | (1 << 6)) 
  204 #define RTCP_XR_VOIP_METRICS_CONFIG_PLC_ENH (1 << 7) 
  205 #define RTCP_XR_VOIP_METRICS_CONFIG_PLC_DIS (1 << 6) 
  206 #define RTCP_XR_VOIP_METRICS_CONFIG_PLC_UNS 0 
  207 #define RTCP_XR_VOIP_METRICS_CONFIG_JBA_ADA ((1 << 5) | (1 << 4)) 
  208 #define RTCP_XR_VOIP_METRICS_CONFIG_JBA_NON (1 << 5) 
  209 #define RTCP_XR_VOIP_METRICS_CONFIG_JBA_UNK 0 
  212         RTCP_XR_LOSS_RLE = 1,
 
  213         RTCP_XR_DUPLICATE_RLE = 2,
 
  214         RTCP_XR_PACKET_RECEIPT_TIMES = 3,
 
  215         RTCP_XR_RCVR_RTT = 4,
 
  217         RTCP_XR_STAT_SUMMARY = 6,
 
  218         RTCP_XR_VOIP_METRICS = 7
 
  219 } rtcp_xr_block_type_t;
 
  234         uint32_t ntp_timestamp_msw;
 
  235         uint32_t ntp_timestamp_lsw;
 
  254         uint32_t lost_packets;
 
  255         uint32_t dup_packets;
 
  258         uint32_t mean_jitter;
 
  260         uint8_t min_ttl_or_hl;
 
  261         uint8_t max_ttl_or_hl;
 
  262         uint8_t mean_ttl_or_hl;
 
  263         uint8_t dev_ttl_or_hl;
 
  270         uint8_t discard_rate;
 
  271         uint8_t burst_density;
 
  273         uint16_t burst_duration;
 
  274         uint16_t gap_duration;
 
  275         uint16_t round_trip_delay;
 
  276         uint16_t end_system_delay;
 
  277         uint8_t signal_level;
 
  282         uint8_t ext_r_factor;
 
  292 #define MIN_RTCP_XR_PACKET_SIZE (sizeof(rtcp_xr_header_t) + 4) 
  296         RTCP_RTPFB_TMMBR = 3,
 
  309         uint32_t packet_sender_ssrc;
 
  310         uint32_t media_source_ssrc;
 
  318 #define rtcp_fb_tmmbr_fci_get_ssrc(tmmbr) ntohl((tmmbr)->ssrc) 
  319 #define rtcp_fb_tmmbr_fci_get_mxtbr_exp(tmmbr) \ 
  320         ((uint8_t)((ntohl((tmmbr)->value) >> 26) & 0x0000003F)) 
  321 #define rtcp_fb_tmmbr_fci_set_mxtbr_exp(tmmbr, mxtbr_exp) \ 
  322         ((tmmbr)->value) = htonl((ntohl((tmmbr)->value) & 0x03FFFFFF) | (((mxtbr_exp) & 0x0000003F) << 26)) 
  323 #define rtcp_fb_tmmbr_fci_get_mxtbr_mantissa(tmmbr) \ 
  324         ((uint32_t)((ntohl((tmmbr)->value) >> 9) & 0x0001FFFF)) 
  325 #define rtcp_fb_tmmbr_fci_set_mxtbr_mantissa(tmmbr, mxtbr_mantissa) \ 
  326         ((tmmbr)->value) = htonl((ntohl((tmmbr)->value) & 0xFC0001FF) | (((mxtbr_mantissa) & 0x0001FFFF) << 9)) 
  327 #define rtcp_fb_tmmbr_fci_get_measured_overhead(tmmbr) \ 
  328         ((uint16_t)(ntohl((tmmbr)->value) & 0x000001FF)) 
  329 #define rtcp_fb_tmmbr_fci_set_measured_overhead(tmmbr, measured_overhead) \ 
  330         ((tmmbr)->value) = htonl((ntohl((tmmbr)->value) & 0xFFFFFE00) | ((measured_overhead) & 0x000001FF)) 
  339 #define rtcp_fb_fir_fci_get_ssrc(fci) ntohl((fci)->ssrc) 
  340 #define rtcp_fb_fir_fci_get_seq_nr(fci) (fci)->seq_nr 
  346 #define rtcp_fb_sli_fci_get_first(fci) \ 
  347         ((uint16_t)((ntohl((fci)->value) >> 19) & 0x00001FFF)) 
  348 #define rtcp_fb_sli_fci_set_first(fci, first) \ 
  349         ((fci)->value) = htonl((ntohl((fci)->value) & 0x0007FFFF) | (((first) & 0x00001FFF) << 19)) 
  350 #define rtcp_fb_sli_fci_get_number(fci) \ 
  351         ((uint16_t)((ntohl((fci)->value) >> 6) & 0x00001FFF)) 
  352 #define rtcp_fb_sli_fci_set_number(fci, number) \ 
  353         ((fci)->value) = htonl((ntohl((fci)->value) & 0xFFF8003F) | (((number) & 0x00001FFF) << 6)) 
  354 #define rtcp_fb_sli_fci_get_picture_id(fci) \ 
  355         ((uint8_t)(ntohl((fci)->value) & 0x0000003F)) 
  356 #define rtcp_fb_sli_fci_set_picture_id(fci, picture_id) \ 
  357         ((fci)->value) = htonl((ntohl((fci)->value) & 0xFFFFFFC0) | ((picture_id) & 0x0000003F)) 
  361         uint8_t payload_type;
 
  362         uint16_t bit_string[1];
 
  365 #define rtcp_fb_rpsi_fci_get_payload_type(fci) (fci)->payload_type 
  366 #define rtcp_fb_rpsi_fci_get_bit_string(fci) ((uint8_t *)(fci)->bit_string) 
  368 #define MIN_RTCP_PSFB_PACKET_SIZE (sizeof(rtcp_common_header_t) + sizeof(rtcp_fb_header_t)) 
  369 #define MIN_RTCP_RTPFB_PACKET_SIZE (sizeof(rtcp_common_header_t) + sizeof(rtcp_fb_header_t)) 
  394 ORTP_PUBLIC 
void rtp_session_rtcp_process_send(
struct _RtpSession *s);
 
  395 ORTP_PUBLIC 
void rtp_session_rtcp_process_recv(
struct _RtpSession *s);
 
  398 #define RTCP_DEFAULT_REPORT_INTERVAL 5000  
  405 ORTP_PUBLIC bool_t rtcp_next_packet(
mblk_t *m);
 
  407 ORTP_PUBLIC 
void rtcp_rewind(
mblk_t *m);
 
  413 ORTP_PUBLIC bool_t rtcp_is_SR(
const mblk_t *m);
 
  414 ORTP_PUBLIC uint32_t rtcp_SR_get_ssrc(
const mblk_t *m);
 
  419 ORTP_PUBLIC bool_t rtcp_is_RR(
const mblk_t *m);
 
  420 ORTP_PUBLIC uint32_t rtcp_RR_get_ssrc(
const mblk_t *m);
 
  424 ORTP_PUBLIC bool_t rtcp_is_SDES(
const mblk_t *m);
 
  425 typedef void (*SdesItemFoundCallback)(
void *user_data, uint32_t csrc, rtcp_sdes_type_t t, 
const char *content, uint8_t content_len);
 
  426 ORTP_PUBLIC 
void rtcp_sdes_parse(
const mblk_t *m, SdesItemFoundCallback cb, 
void *user_data);
 
  429 ORTP_PUBLIC bool_t rtcp_is_BYE(
const mblk_t *m);
 
  430 ORTP_PUBLIC bool_t rtcp_BYE_get_ssrc(
const mblk_t *m, 
int idx, uint32_t *ssrc);
 
  431 ORTP_PUBLIC bool_t rtcp_BYE_get_reason(
const mblk_t *m, 
const char **reason, 
int *reason_len);
 
  434 ORTP_PUBLIC bool_t rtcp_is_APP(
const mblk_t *m);
 
  435 ORTP_PUBLIC 
int rtcp_APP_get_subtype(
const mblk_t *m);
 
  436 ORTP_PUBLIC uint32_t rtcp_APP_get_ssrc(
const mblk_t *m);
 
  438 ORTP_PUBLIC 
void rtcp_APP_get_name(
const mblk_t *m, 
char *name);
 
  440 ORTP_PUBLIC 
void rtcp_APP_get_data(
const mblk_t *m, uint8_t **data, 
int *len);
 
  443 ORTP_PUBLIC bool_t rtcp_is_XR(
const mblk_t *m);
 
  444 ORTP_PUBLIC rtcp_xr_block_type_t rtcp_XR_get_block_type(
const mblk_t *m);
 
  445 ORTP_PUBLIC uint32_t rtcp_XR_get_ssrc(
const mblk_t *m);
 
  446 ORTP_PUBLIC uint64_t rtcp_XR_rcvr_rtt_get_ntp_timestamp(
const mblk_t *m);
 
  447 ORTP_PUBLIC uint32_t rtcp_XR_dlrr_get_ssrc(
const mblk_t *m);
 
  448 ORTP_PUBLIC uint32_t rtcp_XR_dlrr_get_lrr(
const mblk_t *m);
 
  449 ORTP_PUBLIC uint32_t rtcp_XR_dlrr_get_dlrr(
const mblk_t *m);
 
  450 ORTP_PUBLIC uint8_t rtcp_XR_stat_summary_get_flags(
const mblk_t *m);
 
  451 ORTP_PUBLIC uint32_t rtcp_XR_stat_summary_get_ssrc(
const mblk_t *m);
 
  452 ORTP_PUBLIC uint16_t rtcp_XR_stat_summary_get_begin_seq(
const mblk_t *m);
 
  453 ORTP_PUBLIC uint16_t rtcp_XR_stat_summary_get_end_seq(
const mblk_t *m);
 
  454 ORTP_PUBLIC uint32_t rtcp_XR_stat_summary_get_lost_packets(
const mblk_t *m);
 
  455 ORTP_PUBLIC uint32_t rtcp_XR_stat_summary_get_dup_packets(
const mblk_t *m);
 
  456 ORTP_PUBLIC uint32_t rtcp_XR_stat_summary_get_min_jitter(
const mblk_t *m);
 
  457 ORTP_PUBLIC uint32_t rtcp_XR_stat_summary_get_max_jitter(
const mblk_t *m);
 
  458 ORTP_PUBLIC uint32_t rtcp_XR_stat_summary_get_mean_jitter(
const mblk_t *m);
 
  459 ORTP_PUBLIC uint32_t rtcp_XR_stat_summary_get_dev_jitter(
const mblk_t *m);
 
  460 ORTP_PUBLIC uint8_t rtcp_XR_stat_summary_get_min_ttl_or_hl(
const mblk_t *m);
 
  461 ORTP_PUBLIC uint8_t rtcp_XR_stat_summary_get_max_ttl_or_hl(
const mblk_t *m);
 
  462 ORTP_PUBLIC uint8_t rtcp_XR_stat_summary_get_mean_ttl_or_hl(
const mblk_t *m);
 
  463 ORTP_PUBLIC uint8_t rtcp_XR_stat_summary_get_dev_ttl_or_hl(
const mblk_t *m);
 
  464 ORTP_PUBLIC uint32_t rtcp_XR_voip_metrics_get_ssrc(
const mblk_t *m);
 
  465 ORTP_PUBLIC uint8_t rtcp_XR_voip_metrics_get_loss_rate(
const mblk_t *m);
 
  466 ORTP_PUBLIC uint8_t rtcp_XR_voip_metrics_get_discard_rate(
const mblk_t *m);
 
  467 ORTP_PUBLIC uint8_t rtcp_XR_voip_metrics_get_burst_density(
const mblk_t *m);
 
  468 ORTP_PUBLIC uint8_t rtcp_XR_voip_metrics_get_gap_density(
const mblk_t *m);
 
  469 ORTP_PUBLIC uint16_t rtcp_XR_voip_metrics_get_burst_duration(
const mblk_t *m);
 
  470 ORTP_PUBLIC uint16_t rtcp_XR_voip_metrics_get_gap_duration(
const mblk_t *m);
 
  471 ORTP_PUBLIC uint16_t rtcp_XR_voip_metrics_get_round_trip_delay(
const mblk_t *m);
 
  472 ORTP_PUBLIC uint16_t rtcp_XR_voip_metrics_get_end_system_delay(
const mblk_t *m);
 
  473 ORTP_PUBLIC uint8_t rtcp_XR_voip_metrics_get_signal_level(
const mblk_t *m);
 
  474 ORTP_PUBLIC uint8_t rtcp_XR_voip_metrics_get_noise_level(
const mblk_t *m);
 
  475 ORTP_PUBLIC uint8_t rtcp_XR_voip_metrics_get_rerl(
const mblk_t *m);
 
  476 ORTP_PUBLIC uint8_t rtcp_XR_voip_metrics_get_gmin(
const mblk_t *m);
 
  477 ORTP_PUBLIC uint8_t rtcp_XR_voip_metrics_get_r_factor(
const mblk_t *m);
 
  478 ORTP_PUBLIC uint8_t rtcp_XR_voip_metrics_get_ext_r_factor(
const mblk_t *m);
 
  479 ORTP_PUBLIC uint8_t rtcp_XR_voip_metrics_get_mos_lq(
const mblk_t *m);
 
  480 ORTP_PUBLIC uint8_t rtcp_XR_voip_metrics_get_mos_cq(
const mblk_t *m);
 
  481 ORTP_PUBLIC uint8_t rtcp_XR_voip_metrics_get_rx_config(
const mblk_t *m);
 
  482 ORTP_PUBLIC uint16_t rtcp_XR_voip_metrics_get_jb_nominal(
const mblk_t *m);
 
  483 ORTP_PUBLIC uint16_t rtcp_XR_voip_metrics_get_jb_maximum(
const mblk_t *m);
 
  484 ORTP_PUBLIC uint16_t rtcp_XR_voip_metrics_get_jb_abs_max(
const mblk_t *m);
 
  487 ORTP_PUBLIC bool_t rtcp_is_RTPFB(
const mblk_t *m);
 
  488 ORTP_PUBLIC rtcp_rtpfb_type_t rtcp_RTPFB_get_type(
const mblk_t *m);
 
  492 ORTP_PUBLIC bool_t rtcp_is_PSFB(
const mblk_t *m);
 
  493 ORTP_PUBLIC rtcp_psfb_type_t rtcp_PSFB_get_type(
const mblk_t *m);
 
  494 ORTP_PUBLIC uint32_t rtcp_PSFB_get_packet_sender_ssrc(
const mblk_t *m);
 
  495 ORTP_PUBLIC uint32_t rtcp_PSFB_get_media_source_ssrc(
const mblk_t *m);
 
  499 ORTP_PUBLIC uint16_t rtcp_PSFB_rpsi_get_fci_bit_string_len(
const mblk_t *m);
 
  503         int min_packet_count_interval;
 
  504         uint64_t min_time_ms_interval;
 
  505         uint64_t last_estimate_time_ms;
 
  506         int32_t last_cum_loss;
 
  507         int32_t last_ext_seq;
 
  522 ORTP_PUBLIC 
OrtpLossRateEstimator * ortp_loss_rate_estimator_new(
int min_packet_count_interval, uint64_t min_time_ms_interval, 
struct _RtpSession *session);
 
  524 ORTP_PUBLIC 
void ortp_loss_rate_estimator_init(
OrtpLossRateEstimator *obj, 
int min_packet_count_interval, uint64_t min_time_ms_interval, 
struct _RtpSession *session);
 
int32_t last_packet_sent_count
Definition: rtcp.h:518
Definition: rtpsession.h:348
Definition: str_utils.h:49
Definition: rtpsession.h:284
int32_t last_dup_packet_sent_count
Definition: rtcp.h:513