00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _RTCP_H
00026 #define _RTCP_H 1
00027
00028
00029 #define RTCP_SR 200
00030 #define RTCP_RR 201
00031 #define RTCP_SDES 202
00032 #define RTCP_BYE 203
00033 #define RTCP_APP 204
00034
00035
00036
00037 #define RTCP_SDES_CNAME 1
00038 #define RTCP_SDES_NAME 2
00039 #define RTCP_SDES_EMAIL 3
00040 #define RTCP_SDES_PHONE 4
00041 #define RTCP_SDES_LOC 5
00042 #define RTCP_SDES_TOOL 6
00043 #define RTCP_SDES_NOTE 7
00044 #define RTCP_SDES_PRIV 8
00045
00046
00047 #define RTCP_HEADER_LEN 3
00048
00049 typedef enum rtcp_event_enum
00050 {
00051 EVENT_BYE,
00052 EVENT_REPORT
00053
00054 } rtcp_event_t;
00055
00056 typedef struct
00057 {
00058 uint32_t ntp_timestampH;
00059 uint32_t ntp_timestampL;
00060 uint32_t rtp_timestamp;
00061 uint32_t u_pkt_count;
00062 uint32_t u_octet_count;
00063
00064 } rtcp_SR_t;
00065
00066 typedef struct
00067 {
00068
00069 } rtcp_RR_t;
00070
00071 typedef struct SDES_item_t
00072 {
00073 uint32_t i_index;
00074 uint8_t u_type;
00075 char *psz_data;
00076
00077 } rtcp_SDES_item_t;
00078
00079 typedef struct
00080 {
00081 uint32_t u_length;
00082 uint32_t u_items;
00083 rtcp_SDES_item_t **pp_items;
00084
00085 } rtcp_SDES_t;
00086
00087 typedef struct
00088 {
00089 uint32_t u_length;
00090
00091 } rtcp_BYE_t;
00092
00093 typedef struct
00094 {
00095 uint32_t u_length;
00096 uint32_t u_prefix_len;
00097 unsigned char *psz_prefix;
00098 unsigned char *psz_data;
00099
00100 } rtcp_APP_t;
00101
00102
00103
00104
00105 typedef struct
00106 {
00107 uint32_t u_RR_received;
00108 uint32_t u_SR_received;
00109 uint64_t l_dest_SSRC;
00110 uint32_t u_pkt_count;
00111 uint32_t u_octet_count;
00112 uint32_t u_pkt_lost;
00113 uint8_t u_fraction_lost;
00114 uint32_t u_highest_seq_no;
00115 uint32_t u_jitter;
00116 uint32_t u_last_SR;
00117 uint32_t u_last_RR;
00118 mtime_t u_delay_since_last_SR;
00119 mtime_t u_delay_since_last_RR;
00120
00121 uint64_t u_avg_pkt_size;
00122 uint64_t u_sent_pkt_size;
00123
00124 } rtcp_stats_t;
00125
00126 typedef struct
00127 {
00128 uint32_t u_version;
00129 bool b_padding;
00130 uint32_t u_report;
00131 uint32_t u_payload_type;
00132 uint32_t u_length;
00133 uint32_t u_ssrc;
00134
00135 union {
00136 rtcp_SR_t sr;
00137 rtcp_RR_t rr;
00138 rtcp_SDES_t sdes;
00139 rtcp_BYE_t bye;
00140 rtcp_APP_t app;
00141 } report;
00142
00143 } rtcp_pkt_t;
00144
00145 typedef struct rtcp_client_t
00146 {
00147 int fd;
00148
00149 uint32_t i_index;
00150 uint32_t u_ssrc;
00151 bool b_deleted;
00152 mtime_t i_timeout;
00153
00154
00155
00156 rtcp_stats_t *p_stats;
00157
00158 uint32_t i_items;
00159 rtcp_SDES_item_t **pp_sdes;
00160 } rtcp_client_t;
00161
00162
00163
00164
00165
00166 typedef struct rtcp_t
00167 {
00168 VLC_COMMON_MEMBERS
00169
00170 uint32_t u_clients;
00171 uint32_t u_active;
00172 uint32_t u_members;
00173
00174 mtime_t i_date;
00175 mtime_t i_last_date;
00176 mtime_t i_next_date;
00177
00178
00179 uint32_t i_clients;
00180 rtcp_client_t **pp_clients;
00181
00182
00183 bs_t *bs;
00184
00185
00186 int (*pf_add_client)( vlc_object_t *p_this, uint32_t u_ssrc, uint32_t *i_pos );
00187 int (*pf_del_client)( vlc_object_t *p_this, uint32_t u_ssrc );
00188 int (*pf_find_client)( vlc_object_t *p_this, uint32_t u_ssrc, uint32_t *i_pos );
00189 int (*pf_cleanup_clients)( vlc_object_t *p_this );
00190 int (*pf_destroy_clients)( vlc_object_t *p_this );
00191 } rtcp_t;
00192
00193 int rtcp_add_client( vlc_object_t *p_this, uint32_t u_ssrc, uint32_t *i_pos );
00194 int rtcp_del_client( vlc_object_t *p_this, uint32_t u_ssrc );
00195
00196 int rtcp_find_client( vlc_object_t *p_this, uint32_t u_ssrc, uint32_t *i_pos );
00197 int rtcp_cleanup_clients( vlc_object_t *p_this );
00198 int rtcp_destroy_clients( vlc_object_t *p_this );
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210 int rtcp_cleanup_clients( vlc_object_t *p_this );
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221 int rtcp_pkt_decode( vlc_object_t *p_this, rtcp_pkt_t *p_pkt, block_t *p_block );
00222
00223
00224
00225
00226
00227
00228
00229
00230 rtcp_pkt_t *rtcp_pkt_new( vlc_object_t *p_this, int type );
00231
00232 void rtcp_pkt_del( vlc_object_t *p_this, rtcp_pkt_t *pkt );
00233
00234 block_t *rtcp_encode_SR( vlc_object_t *p_this, rtcp_pkt_t *p_pkt );
00235 block_t *rtcp_encode_RR( vlc_object_t *p_this, rtcp_pkt_t *p_pkt );
00236 block_t *rtcp_encode_SDES( vlc_object_t *p_this, rtcp_pkt_t *p_pkt );
00237 block_t *rtcp_encode_BYE( vlc_object_t *p_this, rtcp_pkt_t *p_pkt, char *psz_reason );
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251 uint64_t rtcp_interval( vlc_object_t *p_this, uint64_t u_bandwidth, uint32_t u_ssrc,
00252 bool b_sender, bool b_first );
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267 void rtcp_expire( vlc_object_t *p_this, rtcp_event_t rtcp_event, uint64_t u_bandwidth,
00268 uint32_t u_ssrc, bool b_sender, bool *b_first );
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279 void rtcp_received( vlc_object_t *p_this, rtcp_pkt_t *pkt,
00280 rtcp_event_t rtcp_event );
00281
00282 #endif